babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. /**
  409. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  410. * @param num the number to convert and pad
  411. * @param length the expected length of the string
  412. * @returns the padded string
  413. */
  414. static PadNumber(num: number, length: number): string;
  415. }
  416. }
  417. declare module "babylonjs/Misc/deepCopier" {
  418. /**
  419. * Class containing a set of static utilities functions for deep copy.
  420. */
  421. export class DeepCopier {
  422. /**
  423. * Tries to copy an object by duplicating every property
  424. * @param source defines the source object
  425. * @param destination defines the target object
  426. * @param doNotCopyList defines a list of properties to avoid
  427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  428. */
  429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  430. }
  431. }
  432. declare module "babylonjs/Misc/precisionDate" {
  433. /**
  434. * Class containing a set of static utilities functions for precision date
  435. */
  436. export class PrecisionDate {
  437. /**
  438. * Gets either window.performance.now() if supported or Date.now() else
  439. */
  440. static get Now(): number;
  441. }
  442. }
  443. declare module "babylonjs/Misc/devTools" {
  444. /** @hidden */
  445. export class _DevTools {
  446. static WarnImport(name: string): string;
  447. }
  448. }
  449. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  450. /**
  451. * Interface used to define the mechanism to get data from the network
  452. */
  453. export interface IWebRequest {
  454. /**
  455. * Returns client's response url
  456. */
  457. responseURL: string;
  458. /**
  459. * Returns client's status
  460. */
  461. status: number;
  462. /**
  463. * Returns client's status as a text
  464. */
  465. statusText: string;
  466. }
  467. }
  468. declare module "babylonjs/Misc/webRequest" {
  469. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  470. import { Nullable } from "babylonjs/types";
  471. /**
  472. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  473. */
  474. export class WebRequest implements IWebRequest {
  475. private _xhr;
  476. /**
  477. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  478. * i.e. when loading files, where the server/service expects an Authorization header
  479. */
  480. static CustomRequestHeaders: {
  481. [key: string]: string;
  482. };
  483. /**
  484. * Add callback functions in this array to update all the requests before they get sent to the network
  485. */
  486. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  487. private _injectCustomRequestHeaders;
  488. /**
  489. * Gets or sets a function to be called when loading progress changes
  490. */
  491. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  492. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  493. /**
  494. * Returns client's state
  495. */
  496. get readyState(): number;
  497. /**
  498. * Returns client's status
  499. */
  500. get status(): number;
  501. /**
  502. * Returns client's status as a text
  503. */
  504. get statusText(): string;
  505. /**
  506. * Returns client's response
  507. */
  508. get response(): any;
  509. /**
  510. * Returns client's response url
  511. */
  512. get responseURL(): string;
  513. /**
  514. * Returns client's response as text
  515. */
  516. get responseText(): string;
  517. /**
  518. * Gets or sets the expected response type
  519. */
  520. get responseType(): XMLHttpRequestResponseType;
  521. set responseType(value: XMLHttpRequestResponseType);
  522. /** @hidden */
  523. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  524. /** @hidden */
  525. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  526. /**
  527. * Cancels any network activity
  528. */
  529. abort(): void;
  530. /**
  531. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  532. * @param body defines an optional request body
  533. */
  534. send(body?: Document | BodyInit | null): void;
  535. /**
  536. * Sets the request method, request URL
  537. * @param method defines the method to use (GET, POST, etc..)
  538. * @param url defines the url to connect with
  539. */
  540. open(method: string, url: string): void;
  541. /**
  542. * Sets the value of a request header.
  543. * @param name The name of the header whose value is to be set
  544. * @param value The value to set as the body of the header
  545. */
  546. setRequestHeader(name: string, value: string): void;
  547. /**
  548. * Get the string containing the text of a particular header's value.
  549. * @param name The name of the header
  550. * @returns The string containing the text of the given header name
  551. */
  552. getResponseHeader(name: string): Nullable<string>;
  553. }
  554. }
  555. declare module "babylonjs/Misc/fileRequest" {
  556. import { Observable } from "babylonjs/Misc/observable";
  557. /**
  558. * File request interface
  559. */
  560. export interface IFileRequest {
  561. /**
  562. * Raised when the request is complete (success or error).
  563. */
  564. onCompleteObservable: Observable<IFileRequest>;
  565. /**
  566. * Aborts the request for a file.
  567. */
  568. abort: () => void;
  569. }
  570. }
  571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  572. /**
  573. * Define options used to create a render target texture
  574. */
  575. export class RenderTargetCreationOptions {
  576. /**
  577. * Specifies is mipmaps must be generated
  578. */
  579. generateMipMaps?: boolean;
  580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  581. generateDepthBuffer?: boolean;
  582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  583. generateStencilBuffer?: boolean;
  584. /** Defines texture type (int by default) */
  585. type?: number;
  586. /** Defines sampling mode (trilinear by default) */
  587. samplingMode?: number;
  588. /** Defines format (RGBA by default) */
  589. format?: number;
  590. }
  591. }
  592. declare module "babylonjs/Engines/constants" {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  688. static readonly GEQUAL: number;
  689. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1046. import { Nullable } from "babylonjs/types";
  1047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1048. /**
  1049. * This represents the required contract to create a new type of texture loader.
  1050. */
  1051. export interface IInternalTextureLoader {
  1052. /**
  1053. * Defines wether the loader supports cascade loading the different faces.
  1054. */
  1055. supportCascades: boolean;
  1056. /**
  1057. * This returns if the loader support the current file information.
  1058. * @param extension defines the file extension of the file being loaded
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string): boolean;
  1062. /**
  1063. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1064. * @param data contains the texture data
  1065. * @param texture defines the BabylonJS internal texture
  1066. * @param createPolynomials will be true if polynomials have been requested
  1067. * @param onLoad defines the callback to trigger once the texture is ready
  1068. * @param onError defines the callback to trigger in case of error
  1069. */
  1070. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1071. /**
  1072. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param callback defines the method to call once ready to upload
  1076. */
  1077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Engines/IPipelineContext" {
  1081. /**
  1082. * Class used to store and describe the pipeline context associated with an effect
  1083. */
  1084. export interface IPipelineContext {
  1085. /**
  1086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1087. */
  1088. isAsync: boolean;
  1089. /**
  1090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1091. */
  1092. isReady: boolean;
  1093. /** @hidden */
  1094. _getVertexShaderCode(): string | null;
  1095. /** @hidden */
  1096. _getFragmentShaderCode(): string | null;
  1097. /** @hidden */
  1098. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Meshes/dataBuffer" {
  1102. /**
  1103. * Class used to store gfx data (like WebGLBuffer)
  1104. */
  1105. export class DataBuffer {
  1106. /**
  1107. * Gets or sets the number of objects referencing this buffer
  1108. */
  1109. references: number;
  1110. /** Gets or sets the size of the underlying buffer */
  1111. capacity: number;
  1112. /**
  1113. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1114. */
  1115. is32Bits: boolean;
  1116. /**
  1117. * Gets the underlying buffer
  1118. */
  1119. get underlyingResource(): any;
  1120. }
  1121. }
  1122. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1123. /** @hidden */
  1124. export interface IShaderProcessor {
  1125. attributeProcessor?: (attribute: string) => string;
  1126. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1127. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1128. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1129. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1130. lineProcessor?: (line: string, isFragment: boolean) => string;
  1131. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1136. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1155. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1156. /** @hidden */
  1157. export class ShaderCodeNode {
  1158. line: string;
  1159. children: ShaderCodeNode[];
  1160. additionalDefineKey?: string;
  1161. additionalDefineValue?: string;
  1162. isValid(preprocessors: {
  1163. [key: string]: string;
  1164. }): boolean;
  1165. process(preprocessors: {
  1166. [key: string]: string;
  1167. }, options: ProcessingOptions): string;
  1168. }
  1169. }
  1170. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1171. /** @hidden */
  1172. export class ShaderCodeCursor {
  1173. private _lines;
  1174. lineIndex: number;
  1175. get currentLine(): string;
  1176. get canRead(): boolean;
  1177. set lines(value: string[]);
  1178. }
  1179. }
  1180. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1181. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1182. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1183. /** @hidden */
  1184. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1185. process(preprocessors: {
  1186. [key: string]: string;
  1187. }, options: ProcessingOptions): string;
  1188. }
  1189. }
  1190. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1191. /** @hidden */
  1192. export class ShaderDefineExpression {
  1193. isTrue(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1199. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1200. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1201. /** @hidden */
  1202. export class ShaderCodeTestNode extends ShaderCodeNode {
  1203. testExpression: ShaderDefineExpression;
  1204. isValid(preprocessors: {
  1205. [key: string]: string;
  1206. }): boolean;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1210. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1211. /** @hidden */
  1212. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1213. define: string;
  1214. not: boolean;
  1215. constructor(define: string, not?: boolean);
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1236. leftOperand: ShaderDefineExpression;
  1237. rightOperand: ShaderDefineExpression;
  1238. isTrue(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module "babylonjs/Offline/IOfflineProvider" {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module "babylonjs/Misc/filesInputStore" {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module "babylonjs/Misc/retryStrategy" {
  1308. import { WebRequest } from "babylonjs/Misc/webRequest";
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module "babylonjs/Misc/baseError" {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/fileTools" {
  1332. import { WebRequest } from "babylonjs/Misc/webRequest";
  1333. import { Nullable } from "babylonjs/types";
  1334. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1335. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1336. import { BaseError } from "babylonjs/Misc/baseError";
  1337. /** @ignore */
  1338. export class LoadFileError extends BaseError {
  1339. request?: WebRequest;
  1340. file?: File;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. * @param file defines the optional file
  1346. */
  1347. constructor(message: string, object?: WebRequest | File);
  1348. }
  1349. /** @ignore */
  1350. export class RequestFileError extends BaseError {
  1351. request: WebRequest;
  1352. /**
  1353. * Creates a new LoadFileError
  1354. * @param message defines the message of the error
  1355. * @param request defines the optional web request
  1356. */
  1357. constructor(message: string, request: WebRequest);
  1358. }
  1359. /** @ignore */
  1360. export class ReadFileError extends BaseError {
  1361. file: File;
  1362. /**
  1363. * Creates a new ReadFileError
  1364. * @param message defines the message of the error
  1365. * @param file defines the optional file
  1366. */
  1367. constructor(message: string, file: File);
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export class FileTools {
  1373. /**
  1374. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1375. */
  1376. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1377. /**
  1378. * Gets or sets the base URL to use to load assets
  1379. */
  1380. static BaseUrl: string;
  1381. /**
  1382. * Default behaviour for cors in the application.
  1383. * It can be a string if the expected behavior is identical in the entire app.
  1384. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1385. */
  1386. static CorsBehavior: string | ((url: string | string[]) => string);
  1387. /**
  1388. * Gets or sets a function used to pre-process url before using them to load assets
  1389. */
  1390. static PreprocessUrl: (url: string) => string;
  1391. /**
  1392. * Removes unwanted characters from an url
  1393. * @param url defines the url to clean
  1394. * @returns the cleaned url
  1395. */
  1396. private static _CleanUrl;
  1397. /**
  1398. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1399. * @param url define the url we are trying
  1400. * @param element define the dom element where to configure the cors policy
  1401. */
  1402. static SetCorsBehavior(url: string | string[], element: {
  1403. crossOrigin: string | null;
  1404. }): void;
  1405. /**
  1406. * Loads an image as an HTMLImageElement.
  1407. * @param input url string, ArrayBuffer, or Blob to load
  1408. * @param onLoad callback called when the image successfully loads
  1409. * @param onError callback called when the image fails to load
  1410. * @param offlineProvider offline provider for caching
  1411. * @param mimeType optional mime type
  1412. * @returns the HTMLImageElement of the loaded image
  1413. */
  1414. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1415. /**
  1416. * Reads a file from a File object
  1417. * @param file defines the file to load
  1418. * @param onSuccess defines the callback to call when data is loaded
  1419. * @param onProgress defines the callback to call during loading process
  1420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1421. * @param onError defines the callback to call when an error occurs
  1422. * @returns a file request object
  1423. */
  1424. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file from a url
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param offlineProvider defines the offline provider for caching
  1431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1432. * @param onError callback called when the file fails to load
  1433. * @returns a file request object
  1434. */
  1435. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1436. /**
  1437. * Loads a file
  1438. * @param url url to load
  1439. * @param onSuccess callback called when the file successfully loads
  1440. * @param onProgress callback called while file is loading (if the server supports this mode)
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @param onOpened callback called when the web request is opened
  1444. * @returns a file request object
  1445. */
  1446. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1447. /**
  1448. * Checks if the loaded document was accessed via `file:`-Protocol.
  1449. * @returns boolean
  1450. */
  1451. static IsFileURL(): boolean;
  1452. }
  1453. }
  1454. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1455. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1456. import { WebRequest } from "babylonjs/Misc/webRequest";
  1457. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1458. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1459. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1460. /** @hidden */
  1461. export class ShaderProcessor {
  1462. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1463. private static _ProcessPrecision;
  1464. private static _ExtractOperation;
  1465. private static _BuildSubExpression;
  1466. private static _BuildExpression;
  1467. private static _MoveCursorWithinIf;
  1468. private static _MoveCursor;
  1469. private static _EvaluatePreProcessors;
  1470. private static _PreparePreProcessors;
  1471. private static _ProcessShaderConversion;
  1472. private static _ProcessIncludes;
  1473. /**
  1474. * Loads a file from a url
  1475. * @param url url to load
  1476. * @param onSuccess callback called when the file successfully loads
  1477. * @param onProgress callback called while file is loading (if the server supports this mode)
  1478. * @param offlineProvider defines the offline provider for caching
  1479. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1480. * @param onError callback called when the file fails to load
  1481. * @returns a file request object
  1482. * @hidden
  1483. */
  1484. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1485. }
  1486. }
  1487. declare module "babylonjs/Maths/math.like" {
  1488. import { float, int, DeepImmutable } from "babylonjs/types";
  1489. /**
  1490. * @hidden
  1491. */
  1492. export interface IColor4Like {
  1493. r: float;
  1494. g: float;
  1495. b: float;
  1496. a: float;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor3Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IVector4Like {
  1510. x: float;
  1511. y: float;
  1512. z: float;
  1513. w: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector3Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector2Like {
  1527. x: float;
  1528. y: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IMatrixLike {
  1534. toArray(): DeepImmutable<Float32Array>;
  1535. updateFlag: int;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IViewportLike {
  1541. x: float;
  1542. y: float;
  1543. width: float;
  1544. height: float;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IPlaneLike {
  1550. normal: IVector3Like;
  1551. d: float;
  1552. normalize(): void;
  1553. }
  1554. }
  1555. declare module "babylonjs/Materials/iEffectFallbacks" {
  1556. import { Effect } from "babylonjs/Materials/effect";
  1557. /**
  1558. * Interface used to define common properties for effect fallbacks
  1559. */
  1560. export interface IEffectFallbacks {
  1561. /**
  1562. * Removes the defines that should be removed when falling back.
  1563. * @param currentDefines defines the current define statements for the shader.
  1564. * @param effect defines the current effect we try to compile
  1565. * @returns The resulting defines with defines of the current rank removed.
  1566. */
  1567. reduce(currentDefines: string, effect: Effect): string;
  1568. /**
  1569. * Removes the fallback from the bound mesh.
  1570. */
  1571. unBindMesh(): void;
  1572. /**
  1573. * Checks to see if more fallbacks are still availible.
  1574. */
  1575. hasMoreFallbacks: boolean;
  1576. }
  1577. }
  1578. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1579. /**
  1580. * Class used to evalaute queries containing `and` and `or` operators
  1581. */
  1582. export class AndOrNotEvaluator {
  1583. /**
  1584. * Evaluate a query
  1585. * @param query defines the query to evaluate
  1586. * @param evaluateCallback defines the callback used to filter result
  1587. * @returns true if the query matches
  1588. */
  1589. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1590. private static _HandleParenthesisContent;
  1591. private static _SimplifyNegation;
  1592. }
  1593. }
  1594. declare module "babylonjs/Misc/tags" {
  1595. /**
  1596. * Class used to store custom tags
  1597. */
  1598. export class Tags {
  1599. /**
  1600. * Adds support for tags on the given object
  1601. * @param obj defines the object to use
  1602. */
  1603. static EnableFor(obj: any): void;
  1604. /**
  1605. * Removes tags support
  1606. * @param obj defines the object to use
  1607. */
  1608. static DisableFor(obj: any): void;
  1609. /**
  1610. * Gets a boolean indicating if the given object has tags
  1611. * @param obj defines the object to use
  1612. * @returns a boolean
  1613. */
  1614. static HasTags(obj: any): boolean;
  1615. /**
  1616. * Gets the tags available on a given object
  1617. * @param obj defines the object to use
  1618. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1619. * @returns the tags
  1620. */
  1621. static GetTags(obj: any, asString?: boolean): any;
  1622. /**
  1623. * Adds tags to an object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1626. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1627. */
  1628. static AddTagsTo(obj: any, tagsString: string): void;
  1629. /**
  1630. * @hidden
  1631. */
  1632. static _AddTagTo(obj: any, tag: string): void;
  1633. /**
  1634. * Removes specific tags from a specific object
  1635. * @param obj defines the object to use
  1636. * @param tagsString defines the tags to remove
  1637. */
  1638. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1639. /**
  1640. * @hidden
  1641. */
  1642. static _RemoveTagFrom(obj: any, tag: string): void;
  1643. /**
  1644. * Defines if tags hosted on an object match a given query
  1645. * @param obj defines the object to use
  1646. * @param tagsQuery defines the tag query
  1647. * @returns a boolean
  1648. */
  1649. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1650. }
  1651. }
  1652. declare module "babylonjs/Maths/math.scalar" {
  1653. /**
  1654. * Scalar computation library
  1655. */
  1656. export class Scalar {
  1657. /**
  1658. * Two pi constants convenient for computation.
  1659. */
  1660. static TwoPi: number;
  1661. /**
  1662. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. * @param a number
  1664. * @param b number
  1665. * @param epsilon (default = 1.401298E-45)
  1666. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1667. */
  1668. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1669. /**
  1670. * Returns a string : the upper case translation of the number i to hexadecimal.
  1671. * @param i number
  1672. * @returns the upper case translation of the number i to hexadecimal.
  1673. */
  1674. static ToHex(i: number): string;
  1675. /**
  1676. * Returns -1 if value is negative and +1 is value is positive.
  1677. * @param value the value
  1678. * @returns the value itself if it's equal to zero.
  1679. */
  1680. static Sign(value: number): number;
  1681. /**
  1682. * Returns the value itself if it's between min and max.
  1683. * Returns min if the value is lower than min.
  1684. * Returns max if the value is greater than max.
  1685. * @param value the value to clmap
  1686. * @param min the min value to clamp to (default: 0)
  1687. * @param max the max value to clamp to (default: 1)
  1688. * @returns the clamped value
  1689. */
  1690. static Clamp(value: number, min?: number, max?: number): number;
  1691. /**
  1692. * the log2 of value.
  1693. * @param value the value to compute log2 of
  1694. * @returns the log2 of value.
  1695. */
  1696. static Log2(value: number): number;
  1697. /**
  1698. * Loops the value, so that it is never larger than length and never smaller than 0.
  1699. *
  1700. * This is similar to the modulo operator but it works with floating point numbers.
  1701. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1702. * With t = 5 and length = 2.5, the result would be 0.0.
  1703. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1704. * @param value the value
  1705. * @param length the length
  1706. * @returns the looped value
  1707. */
  1708. static Repeat(value: number, length: number): number;
  1709. /**
  1710. * Normalize the value between 0.0 and 1.0 using min and max values
  1711. * @param value value to normalize
  1712. * @param min max to normalize between
  1713. * @param max min to normalize between
  1714. * @returns the normalized value
  1715. */
  1716. static Normalize(value: number, min: number, max: number): number;
  1717. /**
  1718. * Denormalize the value from 0.0 and 1.0 using min and max values
  1719. * @param normalized value to denormalize
  1720. * @param min max to denormalize between
  1721. * @param max min to denormalize between
  1722. * @returns the denormalized value
  1723. */
  1724. static Denormalize(normalized: number, min: number, max: number): number;
  1725. /**
  1726. * Calculates the shortest difference between two given angles given in degrees.
  1727. * @param current current angle in degrees
  1728. * @param target target angle in degrees
  1729. * @returns the delta
  1730. */
  1731. static DeltaAngle(current: number, target: number): number;
  1732. /**
  1733. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1734. * @param tx value
  1735. * @param length length
  1736. * @returns The returned value will move back and forth between 0 and length
  1737. */
  1738. static PingPong(tx: number, length: number): number;
  1739. /**
  1740. * Interpolates between min and max with smoothing at the limits.
  1741. *
  1742. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1743. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1744. * @param from from
  1745. * @param to to
  1746. * @param tx value
  1747. * @returns the smooth stepped value
  1748. */
  1749. static SmoothStep(from: number, to: number, tx: number): number;
  1750. /**
  1751. * Moves a value current towards target.
  1752. *
  1753. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1754. * Negative values of maxDelta pushes the value away from target.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting value
  1759. */
  1760. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1763. *
  1764. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1765. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1766. * @param current current value
  1767. * @param target target value
  1768. * @param maxDelta max distance to move
  1769. * @returns resulting angle
  1770. */
  1771. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1772. /**
  1773. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1774. * @param start start value
  1775. * @param end target value
  1776. * @param amount amount to lerp between
  1777. * @returns the lerped value
  1778. */
  1779. static Lerp(start: number, end: number, amount: number): number;
  1780. /**
  1781. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static LerpAngle(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1791. * @param a start value
  1792. * @param b target value
  1793. * @param value value between a and b
  1794. * @returns the inverseLerp value
  1795. */
  1796. static InverseLerp(a: number, b: number, value: number): number;
  1797. /**
  1798. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1799. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1800. * @param value1 spline value
  1801. * @param tangent1 spline value
  1802. * @param value2 spline value
  1803. * @param tangent2 spline value
  1804. * @param amount input value
  1805. * @returns hermite result
  1806. */
  1807. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1808. /**
  1809. * Returns a random float number between and min and max values
  1810. * @param min min value of random
  1811. * @param max max value of random
  1812. * @returns random value
  1813. */
  1814. static RandomRange(min: number, max: number): number;
  1815. /**
  1816. * This function returns percentage of a number in a given range.
  1817. *
  1818. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1819. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1820. * @param number to convert to percentage
  1821. * @param min min range
  1822. * @param max max range
  1823. * @returns the percentage
  1824. */
  1825. static RangeToPercent(number: number, min: number, max: number): number;
  1826. /**
  1827. * This function returns number that corresponds to the percentage in a given range.
  1828. *
  1829. * PercentToRange(0.34,0,100) will return 34.
  1830. * @param percent to convert to number
  1831. * @param min min range
  1832. * @param max max range
  1833. * @returns the number
  1834. */
  1835. static PercentToRange(percent: number, min: number, max: number): number;
  1836. /**
  1837. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1838. * @param angle The angle to normalize in radian.
  1839. * @return The converted angle.
  1840. */
  1841. static NormalizeRadians(angle: number): number;
  1842. }
  1843. }
  1844. declare module "babylonjs/Maths/math.constants" {
  1845. /**
  1846. * Constant used to convert a value to gamma space
  1847. * @ignorenaming
  1848. */
  1849. export const ToGammaSpace: number;
  1850. /**
  1851. * Constant used to convert a value to linear space
  1852. * @ignorenaming
  1853. */
  1854. export const ToLinearSpace = 2.2;
  1855. /**
  1856. * Constant used to define the minimal number value in Babylon.js
  1857. * @ignorenaming
  1858. */
  1859. let Epsilon: number;
  1860. export { Epsilon };
  1861. }
  1862. declare module "babylonjs/Maths/math.viewport" {
  1863. /**
  1864. * Class used to represent a viewport on screen
  1865. */
  1866. export class Viewport {
  1867. /** viewport left coordinate */
  1868. x: number;
  1869. /** viewport top coordinate */
  1870. y: number;
  1871. /**viewport width */
  1872. width: number;
  1873. /** viewport height */
  1874. height: number;
  1875. /**
  1876. * Creates a Viewport object located at (x, y) and sized (width, height)
  1877. * @param x defines viewport left coordinate
  1878. * @param y defines viewport top coordinate
  1879. * @param width defines the viewport width
  1880. * @param height defines the viewport height
  1881. */
  1882. constructor(
  1883. /** viewport left coordinate */
  1884. x: number,
  1885. /** viewport top coordinate */
  1886. y: number,
  1887. /**viewport width */
  1888. width: number,
  1889. /** viewport height */
  1890. height: number);
  1891. /**
  1892. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1893. * @param renderWidth defines the rendering width
  1894. * @param renderHeight defines the rendering height
  1895. * @returns a new Viewport
  1896. */
  1897. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1898. /**
  1899. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @param ref defines the target viewport
  1903. * @returns the current viewport
  1904. */
  1905. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1906. /**
  1907. * Returns a new Viewport copied from the current one
  1908. * @returns a new Viewport
  1909. */
  1910. clone(): Viewport;
  1911. }
  1912. }
  1913. declare module "babylonjs/Misc/arrayTools" {
  1914. /**
  1915. * Class containing a set of static utilities functions for arrays.
  1916. */
  1917. export class ArrayTools {
  1918. /**
  1919. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1920. * @param size the number of element to construct and put in the array
  1921. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1922. * @returns a new array filled with new objects
  1923. */
  1924. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1925. }
  1926. }
  1927. declare module "babylonjs/Maths/math.vector" {
  1928. import { Viewport } from "babylonjs/Maths/math.viewport";
  1929. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1930. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1931. /**
  1932. * Class representing a vector containing 2 coordinates
  1933. */
  1934. export class Vector2 {
  1935. /** defines the first coordinate */
  1936. x: number;
  1937. /** defines the second coordinate */
  1938. y: number;
  1939. /**
  1940. * Creates a new Vector2 from the given x and y coordinates
  1941. * @param x defines the first coordinate
  1942. * @param y defines the second coordinate
  1943. */
  1944. constructor(
  1945. /** defines the first coordinate */
  1946. x?: number,
  1947. /** defines the second coordinate */
  1948. y?: number);
  1949. /**
  1950. * Gets a string with the Vector2 coordinates
  1951. * @returns a string with the Vector2 coordinates
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Gets class name
  1956. * @returns the string "Vector2"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Gets current vector hash code
  1961. * @returns the Vector2 hash code as a number
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1966. * @param array defines the source array
  1967. * @param index defines the offset in source array
  1968. * @returns the current Vector2
  1969. */
  1970. toArray(array: FloatArray, index?: number): Vector2;
  1971. /**
  1972. * Copy the current vector to an array
  1973. * @returns a new array with 2 elements: the Vector2 coordinates.
  1974. */
  1975. asArray(): number[];
  1976. /**
  1977. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1978. * @param source defines the source Vector2
  1979. * @returns the current updated Vector2
  1980. */
  1981. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Sets the Vector2 coordinates with the given floats
  1984. * @param x defines the first coordinate
  1985. * @param y defines the second coordinate
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFromFloats(x: number, y: number): Vector2;
  1989. /**
  1990. * Sets the Vector2 coordinates with the given floats
  1991. * @param x defines the first coordinate
  1992. * @param y defines the second coordinate
  1993. * @returns the current updated Vector2
  1994. */
  1995. set(x: number, y: number): Vector2;
  1996. /**
  1997. * Add another vector with the current one
  1998. * @param otherVector defines the other vector
  1999. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2000. */
  2001. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @param result defines the target vector
  2006. * @returns the unmodified current Vector2
  2007. */
  2008. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2009. /**
  2010. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2011. * @param otherVector defines the other vector
  2012. * @returns the current updated Vector2
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2015. /**
  2016. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2
  2019. */
  2020. addVector3(otherVector: Vector3): Vector2;
  2021. /**
  2022. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2023. * @param otherVector defines the other vector
  2024. * @returns a new Vector2
  2025. */
  2026. subtract(otherVector: Vector2): Vector2;
  2027. /**
  2028. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2029. * @param otherVector defines the other vector
  2030. * @param result defines the target vector
  2031. * @returns the unmodified current Vector2
  2032. */
  2033. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2034. /**
  2035. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns the current updated Vector2
  2038. */
  2039. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2040. /**
  2041. * Multiplies in place the current Vector2 coordinates by the given ones
  2042. * @param otherVector defines the other vector
  2043. * @returns the current updated Vector2
  2044. */
  2045. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2046. /**
  2047. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @returns a new Vector2
  2050. */
  2051. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2054. * @param otherVector defines the other vector
  2055. * @param result defines the target vector
  2056. * @returns the unmodified current Vector2
  2057. */
  2058. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2059. /**
  2060. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. * @returns a new Vector2
  2064. */
  2065. multiplyByFloats(x: number, y: number): Vector2;
  2066. /**
  2067. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2068. * @param otherVector defines the other vector
  2069. * @returns a new Vector2
  2070. */
  2071. divide(otherVector: Vector2): Vector2;
  2072. /**
  2073. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2074. * @param otherVector defines the other vector
  2075. * @param result defines the target vector
  2076. * @returns the unmodified current Vector2
  2077. */
  2078. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2079. /**
  2080. * Divides the current Vector2 coordinates by the given ones
  2081. * @param otherVector defines the other vector
  2082. * @returns the current updated Vector2
  2083. */
  2084. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2085. /**
  2086. * Gets a new Vector2 with current Vector2 negated coordinates
  2087. * @returns a new Vector2
  2088. */
  2089. negate(): Vector2;
  2090. /**
  2091. * Negate this vector in place
  2092. * @returns this
  2093. */
  2094. negateInPlace(): Vector2;
  2095. /**
  2096. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2097. * @param result defines the Vector3 object where to store the result
  2098. * @returns the current Vector2
  2099. */
  2100. negateToRef(result: Vector2): Vector2;
  2101. /**
  2102. * Multiply the Vector2 coordinates by scale
  2103. * @param scale defines the scaling factor
  2104. * @returns the current updated Vector2
  2105. */
  2106. scaleInPlace(scale: number): Vector2;
  2107. /**
  2108. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2109. * @param scale defines the scaling factor
  2110. * @returns a new Vector2
  2111. */
  2112. scale(scale: number): Vector2;
  2113. /**
  2114. * Scale the current Vector2 values by a factor to a given Vector2
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector2 object where to store the result
  2117. * @returns the unmodified current Vector2
  2118. */
  2119. scaleToRef(scale: number, result: Vector2): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2122. * @param scale defines the scale factor
  2123. * @param result defines the Vector2 object where to store the result
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Gets a boolean if two vectors are equals
  2129. * @param otherVector defines the other vector
  2130. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2131. */
  2132. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2133. /**
  2134. * Gets a boolean if two vectors are equals (using an epsilon value)
  2135. * @param otherVector defines the other vector
  2136. * @param epsilon defines the minimal distance to consider equality
  2137. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2138. */
  2139. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2140. /**
  2141. * Gets a new Vector2 from current Vector2 floored values
  2142. * @returns a new Vector2
  2143. */
  2144. floor(): Vector2;
  2145. /**
  2146. * Gets a new Vector2 from current Vector2 floored values
  2147. * @returns a new Vector2
  2148. */
  2149. fract(): Vector2;
  2150. /**
  2151. * Gets the length of the vector
  2152. * @returns the vector length (float)
  2153. */
  2154. length(): number;
  2155. /**
  2156. * Gets the vector squared length
  2157. * @returns the vector squared length (float)
  2158. */
  2159. lengthSquared(): number;
  2160. /**
  2161. * Normalize the vector
  2162. * @returns the current updated Vector2
  2163. */
  2164. normalize(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 copied from the Vector2
  2167. * @returns a new Vector2
  2168. */
  2169. clone(): Vector2;
  2170. /**
  2171. * Gets a new Vector2(0, 0)
  2172. * @returns a new Vector2
  2173. */
  2174. static Zero(): Vector2;
  2175. /**
  2176. * Gets a new Vector2(1, 1)
  2177. * @returns a new Vector2
  2178. */
  2179. static One(): Vector2;
  2180. /**
  2181. * Gets a new Vector2 set from the given index element of the given array
  2182. * @param array defines the data source
  2183. * @param offset defines the offset in the data source
  2184. * @returns a new Vector2
  2185. */
  2186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2187. /**
  2188. * Sets "result" from the given index element of the given array
  2189. * @param array defines the data source
  2190. * @param offset defines the offset in the data source
  2191. * @param result defines the target vector
  2192. */
  2193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2194. /**
  2195. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2196. * @param value1 defines 1st point of control
  2197. * @param value2 defines 2nd point of control
  2198. * @param value3 defines 3rd point of control
  2199. * @param value4 defines 4th point of control
  2200. * @param amount defines the interpolation factor
  2201. * @returns a new Vector2
  2202. */
  2203. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2204. /**
  2205. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2206. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2207. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2208. * @param value defines the value to clamp
  2209. * @param min defines the lower limit
  2210. * @param max defines the upper limit
  2211. * @returns a new Vector2
  2212. */
  2213. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2216. * @param value1 defines the 1st control point
  2217. * @param tangent1 defines the outgoing tangent
  2218. * @param value2 defines the 2nd control point
  2219. * @param tangent2 defines the incoming tangent
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2226. * @param start defines the start vector
  2227. * @param end defines the end vector
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Gets the dot product of the vector "left" and the vector "right"
  2234. * @param left defines first vector
  2235. * @param right defines second vector
  2236. * @returns the dot product (float)
  2237. */
  2238. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2239. /**
  2240. * Returns a new Vector2 equal to the normalized given vector
  2241. * @param vector defines the vector to normalize
  2242. * @returns a new Vector2
  2243. */
  2244. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2247. * @param left defines 1st vector
  2248. * @param right defines 2nd vector
  2249. * @returns a new Vector2
  2250. */
  2251. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2254. * @param left defines 1st vector
  2255. * @param right defines 2nd vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2261. * @param vector defines the vector to transform
  2262. * @param transformation defines the matrix to apply
  2263. * @returns a new Vector2
  2264. */
  2265. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2266. /**
  2267. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @param result defines the target vector
  2271. */
  2272. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2273. /**
  2274. * Determines if a given vector is included in a triangle
  2275. * @param p defines the vector to test
  2276. * @param p0 defines 1st triangle point
  2277. * @param p1 defines 2nd triangle point
  2278. * @param p2 defines 3rd triangle point
  2279. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2280. */
  2281. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2282. /**
  2283. * Gets the distance between the vectors "value1" and "value2"
  2284. * @param value1 defines first vector
  2285. * @param value2 defines second vector
  2286. * @returns the distance between vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2289. /**
  2290. * Returns the squared distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the squared distance between vectors
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns a new Vector2
  2301. */
  2302. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2303. /**
  2304. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2305. * @param p defines the middle point
  2306. * @param segA defines one point of the segment
  2307. * @param segB defines the other point of the segment
  2308. * @returns the shortest distance
  2309. */
  2310. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2311. }
  2312. /**
  2313. * Class used to store (x,y,z) vector representation
  2314. * A Vector3 is the main object used in 3D geometry
  2315. * It can represent etiher the coordinates of a point the space, either a direction
  2316. * Reminder: js uses a left handed forward facing system
  2317. */
  2318. export class Vector3 {
  2319. /**
  2320. * Defines the first coordinates (on X axis)
  2321. */
  2322. x: number;
  2323. /**
  2324. * Defines the second coordinates (on Y axis)
  2325. */
  2326. y: number;
  2327. /**
  2328. * Defines the third coordinates (on Z axis)
  2329. */
  2330. z: number;
  2331. private static _UpReadOnly;
  2332. private static _ZeroReadOnly;
  2333. /**
  2334. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2335. * @param x defines the first coordinates (on X axis)
  2336. * @param y defines the second coordinates (on Y axis)
  2337. * @param z defines the third coordinates (on Z axis)
  2338. */
  2339. constructor(
  2340. /**
  2341. * Defines the first coordinates (on X axis)
  2342. */
  2343. x?: number,
  2344. /**
  2345. * Defines the second coordinates (on Y axis)
  2346. */
  2347. y?: number,
  2348. /**
  2349. * Defines the third coordinates (on Z axis)
  2350. */
  2351. z?: number);
  2352. /**
  2353. * Creates a string representation of the Vector3
  2354. * @returns a string with the Vector3 coordinates.
  2355. */
  2356. toString(): string;
  2357. /**
  2358. * Gets the class name
  2359. * @returns the string "Vector3"
  2360. */
  2361. getClassName(): string;
  2362. /**
  2363. * Creates the Vector3 hash code
  2364. * @returns a number which tends to be unique between Vector3 instances
  2365. */
  2366. getHashCode(): number;
  2367. /**
  2368. * Creates an array containing three elements : the coordinates of the Vector3
  2369. * @returns a new array of numbers
  2370. */
  2371. asArray(): number[];
  2372. /**
  2373. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2374. * @param array defines the destination array
  2375. * @param index defines the offset in the destination array
  2376. * @returns the current Vector3
  2377. */
  2378. toArray(array: FloatArray, index?: number): Vector3;
  2379. /**
  2380. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2381. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2382. */
  2383. toQuaternion(): Quaternion;
  2384. /**
  2385. * Adds the given vector to the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Adds the given coordinates to the current Vector3
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2400. * @param otherVector defines the second operand
  2401. * @returns the resulting Vector3
  2402. */
  2403. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2404. /**
  2405. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2406. * @param otherVector defines the second operand
  2407. * @param result defines the Vector3 object where to store the result
  2408. * @returns the current Vector3
  2409. */
  2410. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2411. /**
  2412. * Subtract the given vector from the current Vector3
  2413. * @param otherVector defines the second operand
  2414. * @returns the current updated Vector3
  2415. */
  2416. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2417. /**
  2418. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2419. * @param otherVector defines the second operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2423. /**
  2424. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2425. * @param otherVector defines the second operand
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2430. /**
  2431. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @returns the resulting Vector3
  2436. */
  2437. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2438. /**
  2439. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2447. /**
  2448. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2449. * @returns a new Vector3
  2450. */
  2451. negate(): Vector3;
  2452. /**
  2453. * Negate this vector in place
  2454. * @returns this
  2455. */
  2456. negateInPlace(): Vector3;
  2457. /**
  2458. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. negateToRef(result: Vector3): Vector3;
  2463. /**
  2464. * Multiplies the Vector3 coordinates by the float "scale"
  2465. * @param scale defines the multiplier factor
  2466. * @returns the current updated Vector3
  2467. */
  2468. scaleInPlace(scale: number): Vector3;
  2469. /**
  2470. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2471. * @param scale defines the multiplier factor
  2472. * @returns a new Vector3
  2473. */
  2474. scale(scale: number): Vector3;
  2475. /**
  2476. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2477. * @param scale defines the multiplier factor
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the current Vector3
  2480. */
  2481. scaleToRef(scale: number, result: Vector3): Vector3;
  2482. /**
  2483. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2484. * @param scale defines the scale factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the unmodified current Vector3
  2487. */
  2488. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2491. * @param otherVector defines the second operand
  2492. * @returns true if both vectors are equals
  2493. */
  2494. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2495. /**
  2496. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2497. * @param otherVector defines the second operand
  2498. * @param epsilon defines the minimal distance to define values as equals
  2499. * @returns true if both vectors are distant less than epsilon
  2500. */
  2501. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 coordinates equals the given floats
  2504. * @param x defines the x coordinate of the operand
  2505. * @param y defines the y coordinate of the operand
  2506. * @param z defines the z coordinate of the operand
  2507. * @returns true if both vectors are equals
  2508. */
  2509. equalsToFloats(x: number, y: number, z: number): boolean;
  2510. /**
  2511. * Multiplies the current Vector3 coordinates by the given ones
  2512. * @param otherVector defines the second operand
  2513. * @returns the current updated Vector3
  2514. */
  2515. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2516. /**
  2517. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2531. * @param x defines the x coordinate of the operand
  2532. * @param y defines the y coordinate of the operand
  2533. * @param z defines the z coordinate of the operand
  2534. * @returns the new Vector3
  2535. */
  2536. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2537. /**
  2538. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2539. * @param otherVector defines the second operand
  2540. * @returns the new Vector3
  2541. */
  2542. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones.
  2552. * @param otherVector defines the second operand
  2553. * @returns the current updated Vector3
  2554. */
  2555. divideInPlace(otherVector: Vector3): Vector3;
  2556. /**
  2557. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2558. * @param other defines the second operand
  2559. * @returns the current updated Vector3
  2560. */
  2561. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2562. /**
  2563. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2564. * @param other defines the second operand
  2565. * @returns the current updated Vector3
  2566. */
  2567. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2568. /**
  2569. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2570. * @param x defines the x coordinate of the operand
  2571. * @param y defines the y coordinate of the operand
  2572. * @param z defines the z coordinate of the operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2576. /**
  2577. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2586. * Check if is non uniform within a certain amount of decimal places to account for this
  2587. * @param epsilon the amount the values can differ
  2588. * @returns if the the vector is non uniform to a certain number of decimal places
  2589. */
  2590. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2591. /**
  2592. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2593. */
  2594. get isNonUniform(): boolean;
  2595. /**
  2596. * Gets a new Vector3 from current Vector3 floored values
  2597. * @returns a new Vector3
  2598. */
  2599. floor(): Vector3;
  2600. /**
  2601. * Gets a new Vector3 from current Vector3 floored values
  2602. * @returns a new Vector3
  2603. */
  2604. fract(): Vector3;
  2605. /**
  2606. * Gets the length of the Vector3
  2607. * @returns the length of the Vector3
  2608. */
  2609. length(): number;
  2610. /**
  2611. * Gets the squared length of the Vector3
  2612. * @returns squared length of the Vector3
  2613. */
  2614. lengthSquared(): number;
  2615. /**
  2616. * Normalize the current Vector3.
  2617. * Please note that this is an in place operation.
  2618. * @returns the current updated Vector3
  2619. */
  2620. normalize(): Vector3;
  2621. /**
  2622. * Reorders the x y z properties of the vector in place
  2623. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2624. * @returns the current updated vector
  2625. */
  2626. reorderInPlace(order: string): this;
  2627. /**
  2628. * Rotates the vector around 0,0,0 by a quaternion
  2629. * @param quaternion the rotation quaternion
  2630. * @param result vector to store the result
  2631. * @returns the resulting vector
  2632. */
  2633. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2634. /**
  2635. * Rotates a vector around a given point
  2636. * @param quaternion the rotation quaternion
  2637. * @param point the point to rotate around
  2638. * @param result vector to store the result
  2639. * @returns the resulting vector
  2640. */
  2641. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2642. /**
  2643. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2644. * The cross product is then orthogonal to both current and "other"
  2645. * @param other defines the right operand
  2646. * @returns the cross product
  2647. */
  2648. cross(other: Vector3): Vector3;
  2649. /**
  2650. * Normalize the current Vector3 with the given input length.
  2651. * Please note that this is an in place operation.
  2652. * @param len the length of the vector
  2653. * @returns the current updated Vector3
  2654. */
  2655. normalizeFromLength(len: number): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 to a new vector
  2658. * @returns the new Vector3
  2659. */
  2660. normalizeToNew(): Vector3;
  2661. /**
  2662. * Normalize the current Vector3 to the reference
  2663. * @param reference define the Vector3 to update
  2664. * @returns the updated Vector3
  2665. */
  2666. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Creates a new Vector3 copied from the current Vector3
  2669. * @returns the new Vector3
  2670. */
  2671. clone(): Vector3;
  2672. /**
  2673. * Copies the given vector coordinates to the current Vector3 ones
  2674. * @param source defines the source Vector3
  2675. * @returns the current updated Vector3
  2676. */
  2677. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Copies the given floats to the current Vector3 coordinates
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns the current updated Vector3
  2684. */
  2685. copyFromFloats(x: number, y: number, z: number): Vector3;
  2686. /**
  2687. * Copies the given floats to the current Vector3 coordinates
  2688. * @param x defines the x coordinate of the operand
  2689. * @param y defines the y coordinate of the operand
  2690. * @param z defines the z coordinate of the operand
  2691. * @returns the current updated Vector3
  2692. */
  2693. set(x: number, y: number, z: number): Vector3;
  2694. /**
  2695. * Copies the given float to the current Vector3 coordinates
  2696. * @param v defines the x, y and z coordinates of the operand
  2697. * @returns the current updated Vector3
  2698. */
  2699. setAll(v: number): Vector3;
  2700. /**
  2701. * Get the clip factor between two vectors
  2702. * @param vector0 defines the first operand
  2703. * @param vector1 defines the second operand
  2704. * @param axis defines the axis to use
  2705. * @param size defines the size along the axis
  2706. * @returns the clip factor
  2707. */
  2708. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2709. /**
  2710. * Get angle between two vectors
  2711. * @param vector0 angle between vector0 and vector1
  2712. * @param vector1 angle between vector0 and vector1
  2713. * @param normal direction of the normal
  2714. * @return the angle between vector0 and vector1
  2715. */
  2716. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2717. /**
  2718. * Returns a new Vector3 set from the index "offset" of the given array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @returns the new Vector3
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. * @deprecated Please use FromArray instead.
  2730. */
  2731. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2732. /**
  2733. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2734. * @param array defines the source array
  2735. * @param offset defines the offset in the source array
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2741. * @param array defines the source array
  2742. * @param offset defines the offset in the source array
  2743. * @param result defines the Vector3 where to store the result
  2744. * @deprecated Please use FromArrayToRef instead.
  2745. */
  2746. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2747. /**
  2748. * Sets the given vector "result" with the given floats.
  2749. * @param x defines the x coordinate of the source
  2750. * @param y defines the y coordinate of the source
  2751. * @param z defines the z coordinate of the source
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2757. * @returns a new empty Vector3
  2758. */
  2759. static Zero(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2762. * @returns a new unit Vector3
  2763. */
  2764. static One(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2767. * @returns a new up Vector3
  2768. */
  2769. static Up(): Vector3;
  2770. /**
  2771. * Gets a up Vector3 that must not be updated
  2772. */
  2773. static get UpReadOnly(): DeepImmutable<Vector3>;
  2774. /**
  2775. * Gets a zero Vector3 that must not be updated
  2776. */
  2777. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2778. /**
  2779. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2780. * @returns a new down Vector3
  2781. */
  2782. static Down(): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2785. * @returns a new forward Vector3
  2786. */
  2787. static Forward(): Vector3;
  2788. /**
  2789. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2790. * @returns a new forward Vector3
  2791. */
  2792. static Backward(): Vector3;
  2793. /**
  2794. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2795. * @returns a new right Vector3
  2796. */
  2797. static Right(): Vector3;
  2798. /**
  2799. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2800. * @returns a new left Vector3
  2801. */
  2802. static Left(): Vector3;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2805. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the transformed Vector3
  2809. */
  2810. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2813. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2821. * This method computes tranformed coordinates only, not transformed direction vectors
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2831. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2832. * @param vector defines the Vector3 to transform
  2833. * @param transformation defines the transformation matrix
  2834. * @returns the new Vector3
  2835. */
  2836. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2837. /**
  2838. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2839. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2840. * @param vector defines the Vector3 to transform
  2841. * @param transformation defines the transformation matrix
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2847. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2848. * @param x define the x coordinate of the source vector
  2849. * @param y define the y coordinate of the source vector
  2850. * @param z define the z coordinate of the source vector
  2851. * @param transformation defines the transformation matrix
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2855. /**
  2856. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2857. * @param value1 defines the first control point
  2858. * @param value2 defines the second control point
  2859. * @param value3 defines the third control point
  2860. * @param value4 defines the fourth control point
  2861. * @param amount defines the amount on the spline to use
  2862. * @returns the new Vector3
  2863. */
  2864. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2865. /**
  2866. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2867. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2868. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2869. * @param value defines the current value
  2870. * @param min defines the lower range value
  2871. * @param max defines the upper range value
  2872. * @returns the new Vector3
  2873. */
  2874. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2875. /**
  2876. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2877. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2878. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2879. * @param value defines the current value
  2880. * @param min defines the lower range value
  2881. * @param max defines the upper range value
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2885. /**
  2886. * Checks if a given vector is inside a specific range
  2887. * @param v defines the vector to test
  2888. * @param min defines the minimum range
  2889. * @param max defines the maximum range
  2890. */
  2891. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2894. * @param value1 defines the first control point
  2895. * @param tangent1 defines the first tangent vector
  2896. * @param value2 defines the second control point
  2897. * @param tangent2 defines the second tangent vector
  2898. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2899. * @returns the new Vector3
  2900. */
  2901. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2902. /**
  2903. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2904. * @param start defines the start value
  2905. * @param end defines the end value
  2906. * @param amount max defines amount between both (between 0 and 1)
  2907. * @returns the new Vector3
  2908. */
  2909. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2910. /**
  2911. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2912. * @param start defines the start value
  2913. * @param end defines the end value
  2914. * @param amount max defines amount between both (between 0 and 1)
  2915. * @param result defines the Vector3 where to store the result
  2916. */
  2917. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2918. /**
  2919. * Returns the dot product (float) between the vectors "left" and "right"
  2920. * @param left defines the left operand
  2921. * @param right defines the right operand
  2922. * @returns the dot product
  2923. */
  2924. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2925. /**
  2926. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2927. * The cross product is then orthogonal to both "left" and "right"
  2928. * @param left defines the left operand
  2929. * @param right defines the right operand
  2930. * @returns the cross product
  2931. */
  2932. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2933. /**
  2934. * Sets the given vector "result" with the cross product of "left" and "right"
  2935. * The cross product is then orthogonal to both "left" and "right"
  2936. * @param left defines the left operand
  2937. * @param right defines the right operand
  2938. * @param result defines the Vector3 where to store the result
  2939. */
  2940. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2941. /**
  2942. * Returns a new Vector3 as the normalization of the given vector
  2943. * @param vector defines the Vector3 to normalize
  2944. * @returns the new Vector3
  2945. */
  2946. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" with the normalization of the given first vector
  2949. * @param vector defines the Vector3 to normalize
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2953. /**
  2954. * Project a Vector3 onto screen space
  2955. * @param vector defines the Vector3 to project
  2956. * @param world defines the world matrix to use
  2957. * @param transform defines the transform (view x projection) matrix to use
  2958. * @param viewport defines the screen viewport to use
  2959. * @returns the new Vector3
  2960. */
  2961. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2962. /** @hidden */
  2963. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param transform defines the transform (view x projection) matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @returns the new Vector3
  2983. */
  2984. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param source defines the screen space Vector3 to use
  2988. * @param viewportWidth defines the current width of the viewport
  2989. * @param viewportHeight defines the current height of the viewport
  2990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2991. * @param view defines the view matrix to use
  2992. * @param projection defines the projection matrix to use
  2993. * @param result defines the Vector3 where to store the result
  2994. */
  2995. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2996. /**
  2997. * Unproject from screen space to object space
  2998. * @param sourceX defines the screen space x coordinate to use
  2999. * @param sourceY defines the screen space y coordinate to use
  3000. * @param sourceZ defines the screen space z coordinate to use
  3001. * @param viewportWidth defines the current width of the viewport
  3002. * @param viewportHeight defines the current height of the viewport
  3003. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3004. * @param view defines the view matrix to use
  3005. * @param projection defines the projection matrix to use
  3006. * @param result defines the Vector3 where to store the result
  3007. */
  3008. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3009. /**
  3010. * Gets the minimal coordinate values between two Vector3
  3011. * @param left defines the first operand
  3012. * @param right defines the second operand
  3013. * @returns the new Vector3
  3014. */
  3015. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3016. /**
  3017. * Gets the maximal coordinate values between two Vector3
  3018. * @param left defines the first operand
  3019. * @param right defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Returns the distance between the vectors "value1" and "value2"
  3025. * @param value1 defines the first operand
  3026. * @param value2 defines the second operand
  3027. * @returns the distance
  3028. */
  3029. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3030. /**
  3031. * Returns the squared distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the squared distance
  3035. */
  3036. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns a new Vector3 located at the center between "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the new Vector3
  3042. */
  3043. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3046. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3047. * to something in order to rotate it from its local system to the given target system
  3048. * Note: axis1, axis2 and axis3 are normalized during this operation
  3049. * @param axis1 defines the first axis
  3050. * @param axis2 defines the second axis
  3051. * @param axis3 defines the third axis
  3052. * @returns a new Vector3
  3053. */
  3054. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3057. * @param axis1 defines the first axis
  3058. * @param axis2 defines the second axis
  3059. * @param axis3 defines the third axis
  3060. * @param ref defines the Vector3 where to store the result
  3061. */
  3062. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3063. }
  3064. /**
  3065. * Vector4 class created for EulerAngle class conversion to Quaternion
  3066. */
  3067. export class Vector4 {
  3068. /** x value of the vector */
  3069. x: number;
  3070. /** y value of the vector */
  3071. y: number;
  3072. /** z value of the vector */
  3073. z: number;
  3074. /** w value of the vector */
  3075. w: number;
  3076. /**
  3077. * Creates a Vector4 object from the given floats.
  3078. * @param x x value of the vector
  3079. * @param y y value of the vector
  3080. * @param z z value of the vector
  3081. * @param w w value of the vector
  3082. */
  3083. constructor(
  3084. /** x value of the vector */
  3085. x: number,
  3086. /** y value of the vector */
  3087. y: number,
  3088. /** z value of the vector */
  3089. z: number,
  3090. /** w value of the vector */
  3091. w: number);
  3092. /**
  3093. * Returns the string with the Vector4 coordinates.
  3094. * @returns a string containing all the vector values
  3095. */
  3096. toString(): string;
  3097. /**
  3098. * Returns the string "Vector4".
  3099. * @returns "Vector4"
  3100. */
  3101. getClassName(): string;
  3102. /**
  3103. * Returns the Vector4 hash code.
  3104. * @returns a unique hash code
  3105. */
  3106. getHashCode(): number;
  3107. /**
  3108. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3109. * @returns the resulting array
  3110. */
  3111. asArray(): number[];
  3112. /**
  3113. * Populates the given array from the given index with the Vector4 coordinates.
  3114. * @param array array to populate
  3115. * @param index index of the array to start at (default: 0)
  3116. * @returns the Vector4.
  3117. */
  3118. toArray(array: FloatArray, index?: number): Vector4;
  3119. /**
  3120. * Adds the given vector to the current Vector4.
  3121. * @param otherVector the vector to add
  3122. * @returns the updated Vector4.
  3123. */
  3124. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3127. * @param otherVector the vector to add
  3128. * @returns the resulting vector
  3129. */
  3130. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3133. * @param otherVector the vector to add
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Subtract in place the given vector from the current Vector4.
  3140. * @param otherVector the vector to subtract
  3141. * @returns the updated Vector4.
  3142. */
  3143. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3144. /**
  3145. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3146. * @param otherVector the vector to add
  3147. * @returns the new vector with the result
  3148. */
  3149. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3150. /**
  3151. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3152. * @param otherVector the vector to subtract
  3153. * @param result the vector to store the result
  3154. * @returns the current Vector4.
  3155. */
  3156. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3159. */
  3160. /**
  3161. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3162. * @param x value to subtract
  3163. * @param y value to subtract
  3164. * @param z value to subtract
  3165. * @param w value to subtract
  3166. * @returns new vector containing the result
  3167. */
  3168. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3169. /**
  3170. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3171. * @param x value to subtract
  3172. * @param y value to subtract
  3173. * @param z value to subtract
  3174. * @param w value to subtract
  3175. * @param result the vector to store the result in
  3176. * @returns the current Vector4.
  3177. */
  3178. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3179. /**
  3180. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3181. * @returns a new vector with the negated values
  3182. */
  3183. negate(): Vector4;
  3184. /**
  3185. * Negate this vector in place
  3186. * @returns this
  3187. */
  3188. negateInPlace(): Vector4;
  3189. /**
  3190. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3191. * @param result defines the Vector3 object where to store the result
  3192. * @returns the current Vector4
  3193. */
  3194. negateToRef(result: Vector4): Vector4;
  3195. /**
  3196. * Multiplies the current Vector4 coordinates by scale (float).
  3197. * @param scale the number to scale with
  3198. * @returns the updated Vector4.
  3199. */
  3200. scaleInPlace(scale: number): Vector4;
  3201. /**
  3202. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3203. * @param scale the number to scale with
  3204. * @returns a new vector with the result
  3205. */
  3206. scale(scale: number): Vector4;
  3207. /**
  3208. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3209. * @param scale the number to scale with
  3210. * @param result a vector to store the result in
  3211. * @returns the current Vector4.
  3212. */
  3213. scaleToRef(scale: number, result: Vector4): Vector4;
  3214. /**
  3215. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3216. * @param scale defines the scale factor
  3217. * @param result defines the Vector4 object where to store the result
  3218. * @returns the unmodified current Vector4
  3219. */
  3220. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3223. * @param otherVector the vector to compare against
  3224. * @returns true if they are equal
  3225. */
  3226. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3227. /**
  3228. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3229. * @param otherVector vector to compare against
  3230. * @param epsilon (Default: very small number)
  3231. * @returns true if they are equal
  3232. */
  3233. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3234. /**
  3235. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3236. * @param x x value to compare against
  3237. * @param y y value to compare against
  3238. * @param z z value to compare against
  3239. * @param w w value to compare against
  3240. * @returns true if equal
  3241. */
  3242. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3243. /**
  3244. * Multiplies in place the current Vector4 by the given one.
  3245. * @param otherVector vector to multiple with
  3246. * @returns the updated Vector4.
  3247. */
  3248. multiplyInPlace(otherVector: Vector4): Vector4;
  3249. /**
  3250. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3251. * @param otherVector vector to multiple with
  3252. * @returns resulting new vector
  3253. */
  3254. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3255. /**
  3256. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3257. * @param otherVector vector to multiple with
  3258. * @param result vector to store the result
  3259. * @returns the current Vector4.
  3260. */
  3261. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3264. * @param x x value multiply with
  3265. * @param y y value multiply with
  3266. * @param z z value multiply with
  3267. * @param w w value multiply with
  3268. * @returns resulting new vector
  3269. */
  3270. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3273. * @param otherVector vector to devide with
  3274. * @returns resulting new vector
  3275. */
  3276. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3277. /**
  3278. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3279. * @param otherVector vector to devide with
  3280. * @param result vector to store the result
  3281. * @returns the current Vector4.
  3282. */
  3283. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3284. /**
  3285. * Divides the current Vector3 coordinates by the given ones.
  3286. * @param otherVector vector to devide with
  3287. * @returns the updated Vector3.
  3288. */
  3289. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3290. /**
  3291. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3292. * @param other defines the second operand
  3293. * @returns the current updated Vector4
  3294. */
  3295. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3296. /**
  3297. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3298. * @param other defines the second operand
  3299. * @returns the current updated Vector4
  3300. */
  3301. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Gets a new Vector4 from current Vector4 floored values
  3304. * @returns a new Vector4
  3305. */
  3306. floor(): Vector4;
  3307. /**
  3308. * Gets a new Vector4 from current Vector3 floored values
  3309. * @returns a new Vector4
  3310. */
  3311. fract(): Vector4;
  3312. /**
  3313. * Returns the Vector4 length (float).
  3314. * @returns the length
  3315. */
  3316. length(): number;
  3317. /**
  3318. * Returns the Vector4 squared length (float).
  3319. * @returns the length squared
  3320. */
  3321. lengthSquared(): number;
  3322. /**
  3323. * Normalizes in place the Vector4.
  3324. * @returns the updated Vector4.
  3325. */
  3326. normalize(): Vector4;
  3327. /**
  3328. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3329. * @returns this converted to a new vector3
  3330. */
  3331. toVector3(): Vector3;
  3332. /**
  3333. * Returns a new Vector4 copied from the current one.
  3334. * @returns the new cloned vector
  3335. */
  3336. clone(): Vector4;
  3337. /**
  3338. * Updates the current Vector4 with the given one coordinates.
  3339. * @param source the source vector to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to copy from
  3346. * @param y float to copy from
  3347. * @param z float to copy from
  3348. * @param w float to copy from
  3349. * @returns the updated Vector4.
  3350. */
  3351. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Updates the current Vector4 coordinates with the given floats.
  3354. * @param x float to set from
  3355. * @param y float to set from
  3356. * @param z float to set from
  3357. * @param w float to set from
  3358. * @returns the updated Vector4.
  3359. */
  3360. set(x: number, y: number, z: number, w: number): Vector4;
  3361. /**
  3362. * Copies the given float to the current Vector3 coordinates
  3363. * @param v defines the x, y, z and w coordinates of the operand
  3364. * @returns the current updated Vector3
  3365. */
  3366. setAll(v: number): Vector4;
  3367. /**
  3368. * Returns a new Vector4 set from the starting index of the given array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @returns the new vector
  3372. */
  3373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3374. /**
  3375. * Updates the given vector "result" from the starting index of the given array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @param result the vector to store the result in
  3379. */
  3380. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given Float32Array.
  3383. * @param array the array to pull values from
  3384. * @param offset the offset into the array to start at
  3385. * @param result the vector to store the result in
  3386. */
  3387. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" coordinates from the given floats.
  3390. * @param x float to set from
  3391. * @param y float to set from
  3392. * @param z float to set from
  3393. * @param w float to set from
  3394. * @param result the vector to the floats in
  3395. */
  3396. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3397. /**
  3398. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3399. * @returns the new vector
  3400. */
  3401. static Zero(): Vector4;
  3402. /**
  3403. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3404. * @returns the new vector
  3405. */
  3406. static One(): Vector4;
  3407. /**
  3408. * Returns a new normalized Vector4 from the given one.
  3409. * @param vector the vector to normalize
  3410. * @returns the vector
  3411. */
  3412. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" from the normalization of the given one.
  3415. * @param vector the vector to normalize
  3416. * @param result the vector to store the result in
  3417. */
  3418. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3419. /**
  3420. * Returns a vector with the minimum values from the left and right vectors
  3421. * @param left left vector to minimize
  3422. * @param right right vector to minimize
  3423. * @returns a new vector with the minimum of the left and right vector values
  3424. */
  3425. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Returns a vector with the maximum values from the left and right vectors
  3428. * @param left left vector to maximize
  3429. * @param right right vector to maximize
  3430. * @returns a new vector with the maximum of the left and right vector values
  3431. */
  3432. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns the distance (float) between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the distance between
  3436. * @param value2 value to calulate the distance between
  3437. * @return the distance between the two vectors
  3438. */
  3439. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3440. /**
  3441. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the distance between
  3443. * @param value2 value to calulate the distance between
  3444. * @return the distance between the two vectors squared
  3445. */
  3446. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the center between
  3450. * @param value2 value to calulate the center between
  3451. * @return the center between the two vectors
  3452. */
  3453. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3454. /**
  3455. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3456. * This methods computes transformed normalized direction vectors only.
  3457. * @param vector the vector to transform
  3458. * @param transformation the transformation matrix to apply
  3459. * @returns the new vector
  3460. */
  3461. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3462. /**
  3463. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3464. * This methods computes transformed normalized direction vectors only.
  3465. * @param vector the vector to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the result in
  3468. */
  3469. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3472. * This methods computes transformed normalized direction vectors only.
  3473. * @param x value to transform
  3474. * @param y value to transform
  3475. * @param z value to transform
  3476. * @param w value to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @param result the vector to store the results in
  3479. */
  3480. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3481. /**
  3482. * Creates a new Vector4 from a Vector3
  3483. * @param source defines the source data
  3484. * @param w defines the 4th component (default is 0)
  3485. * @returns a new Vector4
  3486. */
  3487. static FromVector3(source: Vector3, w?: number): Vector4;
  3488. }
  3489. /**
  3490. * Class used to store quaternion data
  3491. * @see https://en.wikipedia.org/wiki/Quaternion
  3492. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3493. */
  3494. export class Quaternion {
  3495. /** defines the first component (0 by default) */
  3496. x: number;
  3497. /** defines the second component (0 by default) */
  3498. y: number;
  3499. /** defines the third component (0 by default) */
  3500. z: number;
  3501. /** defines the fourth component (1.0 by default) */
  3502. w: number;
  3503. /**
  3504. * Creates a new Quaternion from the given floats
  3505. * @param x defines the first component (0 by default)
  3506. * @param y defines the second component (0 by default)
  3507. * @param z defines the third component (0 by default)
  3508. * @param w defines the fourth component (1.0 by default)
  3509. */
  3510. constructor(
  3511. /** defines the first component (0 by default) */
  3512. x?: number,
  3513. /** defines the second component (0 by default) */
  3514. y?: number,
  3515. /** defines the third component (0 by default) */
  3516. z?: number,
  3517. /** defines the fourth component (1.0 by default) */
  3518. w?: number);
  3519. /**
  3520. * Gets a string representation for the current quaternion
  3521. * @returns a string with the Quaternion coordinates
  3522. */
  3523. toString(): string;
  3524. /**
  3525. * Gets the class name of the quaternion
  3526. * @returns the string "Quaternion"
  3527. */
  3528. getClassName(): string;
  3529. /**
  3530. * Gets a hash code for this quaternion
  3531. * @returns the quaternion hash code
  3532. */
  3533. getHashCode(): number;
  3534. /**
  3535. * Copy the quaternion to an array
  3536. * @returns a new array populated with 4 elements from the quaternion coordinates
  3537. */
  3538. asArray(): number[];
  3539. /**
  3540. * Check if two quaternions are equals
  3541. * @param otherQuaternion defines the second operand
  3542. * @return true if the current quaternion and the given one coordinates are strictly equals
  3543. */
  3544. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3545. /**
  3546. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3547. * @param otherQuaternion defines the other quaternion
  3548. * @param epsilon defines the minimal distance to consider equality
  3549. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3550. */
  3551. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3552. /**
  3553. * Clone the current quaternion
  3554. * @returns a new quaternion copied from the current one
  3555. */
  3556. clone(): Quaternion;
  3557. /**
  3558. * Copy a quaternion to the current one
  3559. * @param other defines the other quaternion
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Updates the current quaternion with the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Updates the current quaternion from the given float coordinates
  3574. * @param x defines the x coordinate
  3575. * @param y defines the y coordinate
  3576. * @param z defines the z coordinate
  3577. * @param w defines the w coordinate
  3578. * @returns the updated current quaternion
  3579. */
  3580. set(x: number, y: number, z: number, w: number): Quaternion;
  3581. /**
  3582. * Adds two quaternions
  3583. * @param other defines the second operand
  3584. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3585. */
  3586. add(other: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Add a quaternion to the current one
  3589. * @param other defines the quaternion to add
  3590. * @returns the current quaternion
  3591. */
  3592. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3593. /**
  3594. * Subtract two quaternions
  3595. * @param other defines the second operand
  3596. * @returns a new quaternion as the subtraction result of the given one from the current one
  3597. */
  3598. subtract(other: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies the current quaternion by a scale factor
  3601. * @param value defines the scale factor
  3602. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3603. */
  3604. scale(value: number): Quaternion;
  3605. /**
  3606. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3607. * @param scale defines the scale factor
  3608. * @param result defines the Quaternion object where to store the result
  3609. * @returns the unmodified current quaternion
  3610. */
  3611. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3612. /**
  3613. * Multiplies in place the current quaternion by a scale factor
  3614. * @param value defines the scale factor
  3615. * @returns the current modified quaternion
  3616. */
  3617. scaleInPlace(value: number): Quaternion;
  3618. /**
  3619. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3620. * @param scale defines the scale factor
  3621. * @param result defines the Quaternion object where to store the result
  3622. * @returns the unmodified current quaternion
  3623. */
  3624. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3625. /**
  3626. * Multiplies two quaternions
  3627. * @param q1 defines the second operand
  3628. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3629. */
  3630. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3631. /**
  3632. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3633. * @param q1 defines the second operand
  3634. * @param result defines the target quaternion
  3635. * @returns the current quaternion
  3636. */
  3637. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3638. /**
  3639. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @returns the currentupdated quaternion
  3642. */
  3643. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3644. /**
  3645. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3646. * @param ref defines the target quaternion
  3647. * @returns the current quaternion
  3648. */
  3649. conjugateToRef(ref: Quaternion): Quaternion;
  3650. /**
  3651. * Conjugates in place (1-q) the current quaternion
  3652. * @returns the current updated quaternion
  3653. */
  3654. conjugateInPlace(): Quaternion;
  3655. /**
  3656. * Conjugates in place (1-q) the current quaternion
  3657. * @returns a new quaternion
  3658. */
  3659. conjugate(): Quaternion;
  3660. /**
  3661. * Gets length of current quaternion
  3662. * @returns the quaternion length (float)
  3663. */
  3664. length(): number;
  3665. /**
  3666. * Normalize in place the current quaternion
  3667. * @returns the current updated quaternion
  3668. */
  3669. normalize(): Quaternion;
  3670. /**
  3671. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3672. * @param order is a reserved parameter and is ignore for now
  3673. * @returns a new Vector3 containing the Euler angles
  3674. */
  3675. toEulerAngles(order?: string): Vector3;
  3676. /**
  3677. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3678. * @param result defines the vector which will be filled with the Euler angles
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns the current unchanged quaternion
  3681. */
  3682. toEulerAnglesToRef(result: Vector3): Quaternion;
  3683. /**
  3684. * Updates the given rotation matrix with the current quaternion values
  3685. * @param result defines the target matrix
  3686. * @returns the current unchanged quaternion
  3687. */
  3688. toRotationMatrix(result: Matrix): Quaternion;
  3689. /**
  3690. * Updates the current quaternion from the given rotation matrix values
  3691. * @param matrix defines the source matrix
  3692. * @returns the current updated quaternion
  3693. */
  3694. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3695. /**
  3696. * Creates a new quaternion from a rotation matrix
  3697. * @param matrix defines the source matrix
  3698. * @returns a new quaternion created from the given rotation matrix values
  3699. */
  3700. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3701. /**
  3702. * Updates the given quaternion with the given rotation matrix values
  3703. * @param matrix defines the source matrix
  3704. * @param result defines the target quaternion
  3705. */
  3706. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3707. /**
  3708. * Returns the dot product (float) between the quaternions "left" and "right"
  3709. * @param left defines the left operand
  3710. * @param right defines the right operand
  3711. * @returns the dot product
  3712. */
  3713. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3714. /**
  3715. * Checks if the two quaternions are close to each other
  3716. * @param quat0 defines the first quaternion to check
  3717. * @param quat1 defines the second quaternion to check
  3718. * @returns true if the two quaternions are close to each other
  3719. */
  3720. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates an empty quaternion
  3723. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3724. */
  3725. static Zero(): Quaternion;
  3726. /**
  3727. * Inverse a given quaternion
  3728. * @param q defines the source quaternion
  3729. * @returns a new quaternion as the inverted current quaternion
  3730. */
  3731. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3732. /**
  3733. * Inverse a given quaternion
  3734. * @param q defines the source quaternion
  3735. * @param result the quaternion the result will be stored in
  3736. * @returns the result quaternion
  3737. */
  3738. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates an identity quaternion
  3741. * @returns the identity quaternion
  3742. */
  3743. static Identity(): Quaternion;
  3744. /**
  3745. * Gets a boolean indicating if the given quaternion is identity
  3746. * @param quaternion defines the quaternion to check
  3747. * @returns true if the quaternion is identity
  3748. */
  3749. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3750. /**
  3751. * Creates a quaternion from a rotation around an axis
  3752. * @param axis defines the axis to use
  3753. * @param angle defines the angle to use
  3754. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3755. */
  3756. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3757. /**
  3758. * Creates a rotation around an axis and stores it into the given quaternion
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @param result defines the target quaternion
  3762. * @returns the target quaternion
  3763. */
  3764. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from data stored into an array
  3767. * @param array defines the data source
  3768. * @param offset defines the offset in the source array where the data starts
  3769. * @returns a new quaternion
  3770. */
  3771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3772. /**
  3773. * Updates the given quaternion "result" from the starting index of the given array.
  3774. * @param array the array to pull values from
  3775. * @param offset the offset into the array to start at
  3776. * @param result the quaternion to store the result in
  3777. */
  3778. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3779. /**
  3780. * Create a quaternion from Euler rotation angles
  3781. * @param x Pitch
  3782. * @param y Yaw
  3783. * @param z Roll
  3784. * @returns the new Quaternion
  3785. */
  3786. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3787. /**
  3788. * Updates a quaternion from Euler rotation angles
  3789. * @param x Pitch
  3790. * @param y Yaw
  3791. * @param z Roll
  3792. * @param result the quaternion to store the result
  3793. * @returns the updated quaternion
  3794. */
  3795. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3796. /**
  3797. * Create a quaternion from Euler rotation vector
  3798. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3799. * @returns the new Quaternion
  3800. */
  3801. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * Updates a quaternion from Euler rotation vector
  3804. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3805. * @param result the quaternion to store the result
  3806. * @returns the updated quaternion
  3807. */
  3808. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3811. * @param yaw defines the rotation around Y axis
  3812. * @param pitch defines the rotation around X axis
  3813. * @param roll defines the rotation around Z axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3817. /**
  3818. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3819. * @param yaw defines the rotation around Y axis
  3820. * @param pitch defines the rotation around X axis
  3821. * @param roll defines the rotation around Z axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3825. /**
  3826. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3827. * @param alpha defines the rotation around first axis
  3828. * @param beta defines the rotation around second axis
  3829. * @param gamma defines the rotation around third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3833. /**
  3834. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3835. * @param alpha defines the rotation around first axis
  3836. * @param beta defines the rotation around second axis
  3837. * @param gamma defines the rotation around third axis
  3838. * @param result defines the target quaternion
  3839. */
  3840. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3841. /**
  3842. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3843. * @param axis1 defines the first axis
  3844. * @param axis2 defines the second axis
  3845. * @param axis3 defines the third axis
  3846. * @returns the new quaternion
  3847. */
  3848. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3849. /**
  3850. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3851. * @param axis1 defines the first axis
  3852. * @param axis2 defines the second axis
  3853. * @param axis3 defines the third axis
  3854. * @param ref defines the target quaternion
  3855. */
  3856. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3857. /**
  3858. * Interpolates between two quaternions
  3859. * @param left defines first quaternion
  3860. * @param right defines second quaternion
  3861. * @param amount defines the gradient to use
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. /**
  3866. * Interpolates between two quaternions and stores it into a target quaternion
  3867. * @param left defines first quaternion
  3868. * @param right defines second quaternion
  3869. * @param amount defines the gradient to use
  3870. * @param result defines the target quaternion
  3871. */
  3872. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3873. /**
  3874. * Interpolate between two quaternions using Hermite interpolation
  3875. * @param value1 defines first quaternion
  3876. * @param tangent1 defines the incoming tangent
  3877. * @param value2 defines second quaternion
  3878. * @param tangent2 defines the outgoing tangent
  3879. * @param amount defines the target quaternion
  3880. * @returns the new interpolated quaternion
  3881. */
  3882. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3883. }
  3884. /**
  3885. * Class used to store matrix data (4x4)
  3886. */
  3887. export class Matrix {
  3888. private static _updateFlagSeed;
  3889. private static _identityReadOnly;
  3890. private _isIdentity;
  3891. private _isIdentityDirty;
  3892. private _isIdentity3x2;
  3893. private _isIdentity3x2Dirty;
  3894. /**
  3895. * Gets the update flag of the matrix which is an unique number for the matrix.
  3896. * It will be incremented every time the matrix data change.
  3897. * You can use it to speed the comparison between two versions of the same matrix.
  3898. */
  3899. updateFlag: number;
  3900. private readonly _m;
  3901. /**
  3902. * Gets the internal data of the matrix
  3903. */
  3904. get m(): DeepImmutable<Float32Array>;
  3905. /** @hidden */
  3906. _markAsUpdated(): void;
  3907. /** @hidden */
  3908. private _updateIdentityStatus;
  3909. /**
  3910. * Creates an empty matrix (filled with zeros)
  3911. */
  3912. constructor();
  3913. /**
  3914. * Check if the current matrix is identity
  3915. * @returns true is the matrix is the identity matrix
  3916. */
  3917. isIdentity(): boolean;
  3918. /**
  3919. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3920. * @returns true is the matrix is the identity matrix
  3921. */
  3922. isIdentityAs3x2(): boolean;
  3923. /**
  3924. * Gets the determinant of the matrix
  3925. * @returns the matrix determinant
  3926. */
  3927. determinant(): number;
  3928. /**
  3929. * Returns the matrix as a Float32Array
  3930. * @returns the matrix underlying array
  3931. */
  3932. toArray(): DeepImmutable<Float32Array>;
  3933. /**
  3934. * Returns the matrix as a Float32Array
  3935. * @returns the matrix underlying array.
  3936. */
  3937. asArray(): DeepImmutable<Float32Array>;
  3938. /**
  3939. * Inverts the current matrix in place
  3940. * @returns the current inverted matrix
  3941. */
  3942. invert(): Matrix;
  3943. /**
  3944. * Sets all the matrix elements to zero
  3945. * @returns the current matrix
  3946. */
  3947. reset(): Matrix;
  3948. /**
  3949. * Adds the current matrix with a second one
  3950. * @param other defines the matrix to add
  3951. * @returns a new matrix as the addition of the current matrix and the given one
  3952. */
  3953. add(other: DeepImmutable<Matrix>): Matrix;
  3954. /**
  3955. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3956. * @param other defines the matrix to add
  3957. * @param result defines the target matrix
  3958. * @returns the current matrix
  3959. */
  3960. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3961. /**
  3962. * Adds in place the given matrix to the current matrix
  3963. * @param other defines the second operand
  3964. * @returns the current updated matrix
  3965. */
  3966. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3967. /**
  3968. * Sets the given matrix to the current inverted Matrix
  3969. * @param other defines the target matrix
  3970. * @returns the unmodified current matrix
  3971. */
  3972. invertToRef(other: Matrix): Matrix;
  3973. /**
  3974. * add a value at the specified position in the current Matrix
  3975. * @param index the index of the value within the matrix. between 0 and 15.
  3976. * @param value the value to be added
  3977. * @returns the current updated matrix
  3978. */
  3979. addAtIndex(index: number, value: number): Matrix;
  3980. /**
  3981. * mutiply the specified position in the current Matrix by a value
  3982. * @param index the index of the value within the matrix. between 0 and 15.
  3983. * @param value the value to be added
  3984. * @returns the current updated matrix
  3985. */
  3986. multiplyAtIndex(index: number, value: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector (using 3 floats) in the current matrix
  3989. * @param x defines the 1st component of the translation
  3990. * @param y defines the 2nd component of the translation
  3991. * @param z defines the 3rd component of the translation
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3995. /**
  3996. * Adds the translation vector (using 3 floats) in the current matrix
  3997. * @param x defines the 1st component of the translation
  3998. * @param y defines the 2nd component of the translation
  3999. * @param z defines the 3rd component of the translation
  4000. * @returns the current updated matrix
  4001. */
  4002. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4003. /**
  4004. * Inserts the translation vector in the current matrix
  4005. * @param vector3 defines the translation to insert
  4006. * @returns the current updated matrix
  4007. */
  4008. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4009. /**
  4010. * Gets the translation value of the current matrix
  4011. * @returns a new Vector3 as the extracted translation from the matrix
  4012. */
  4013. getTranslation(): Vector3;
  4014. /**
  4015. * Fill a Vector3 with the extracted translation from the matrix
  4016. * @param result defines the Vector3 where to store the translation
  4017. * @returns the current matrix
  4018. */
  4019. getTranslationToRef(result: Vector3): Matrix;
  4020. /**
  4021. * Remove rotation and scaling part from the matrix
  4022. * @returns the updated matrix
  4023. */
  4024. removeRotationAndScaling(): Matrix;
  4025. /**
  4026. * Multiply two matrices
  4027. * @param other defines the second operand
  4028. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4029. */
  4030. multiply(other: DeepImmutable<Matrix>): Matrix;
  4031. /**
  4032. * Copy the current matrix from the given one
  4033. * @param other defines the source matrix
  4034. * @returns the current updated matrix
  4035. */
  4036. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4037. /**
  4038. * Populates the given array from the starting index with the current matrix values
  4039. * @param array defines the target array
  4040. * @param offset defines the offset in the target array where to start storing values
  4041. * @returns the current matrix
  4042. */
  4043. copyToArray(array: Float32Array, offset?: number): Matrix;
  4044. /**
  4045. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4046. * @param other defines the second operand
  4047. * @param result defines the matrix where to store the multiplication
  4048. * @returns the current matrix
  4049. */
  4050. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4051. /**
  4052. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4053. * @param other defines the second operand
  4054. * @param result defines the array where to store the multiplication
  4055. * @param offset defines the offset in the target array where to start storing values
  4056. * @returns the current matrix
  4057. */
  4058. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4059. /**
  4060. * Check equality between this matrix and a second one
  4061. * @param value defines the second matrix to compare
  4062. * @returns true is the current matrix and the given one values are strictly equal
  4063. */
  4064. equals(value: DeepImmutable<Matrix>): boolean;
  4065. /**
  4066. * Clone the current matrix
  4067. * @returns a new matrix from the current matrix
  4068. */
  4069. clone(): Matrix;
  4070. /**
  4071. * Returns the name of the current matrix class
  4072. * @returns the string "Matrix"
  4073. */
  4074. getClassName(): string;
  4075. /**
  4076. * Gets the hash code of the current matrix
  4077. * @returns the hash code
  4078. */
  4079. getHashCode(): number;
  4080. /**
  4081. * Decomposes the current Matrix into a translation, rotation and scaling components
  4082. * @param scale defines the scale vector3 given as a reference to update
  4083. * @param rotation defines the rotation quaternion given as a reference to update
  4084. * @param translation defines the translation vector3 given as a reference to update
  4085. * @returns true if operation was successful
  4086. */
  4087. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4088. /**
  4089. * Gets specific row of the matrix
  4090. * @param index defines the number of the row to get
  4091. * @returns the index-th row of the current matrix as a new Vector4
  4092. */
  4093. getRow(index: number): Nullable<Vector4>;
  4094. /**
  4095. * Sets the index-th row of the current matrix to the vector4 values
  4096. * @param index defines the number of the row to set
  4097. * @param row defines the target vector4
  4098. * @returns the updated current matrix
  4099. */
  4100. setRow(index: number, row: Vector4): Matrix;
  4101. /**
  4102. * Compute the transpose of the matrix
  4103. * @returns the new transposed matrix
  4104. */
  4105. transpose(): Matrix;
  4106. /**
  4107. * Compute the transpose of the matrix and store it in a given matrix
  4108. * @param result defines the target matrix
  4109. * @returns the current matrix
  4110. */
  4111. transposeToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Sets the index-th row of the current matrix with the given 4 x float values
  4114. * @param index defines the row index
  4115. * @param x defines the x component to set
  4116. * @param y defines the y component to set
  4117. * @param z defines the z component to set
  4118. * @param w defines the w component to set
  4119. * @returns the updated current matrix
  4120. */
  4121. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4122. /**
  4123. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4124. * @param scale defines the scale factor
  4125. * @returns a new matrix
  4126. */
  4127. scale(scale: number): Matrix;
  4128. /**
  4129. * Scale the current matrix values by a factor to a given result matrix
  4130. * @param scale defines the scale factor
  4131. * @param result defines the matrix to store the result
  4132. * @returns the current matrix
  4133. */
  4134. scaleToRef(scale: number, result: Matrix): Matrix;
  4135. /**
  4136. * Scale the current matrix values by a factor and add the result to a given matrix
  4137. * @param scale defines the scale factor
  4138. * @param result defines the Matrix to store the result
  4139. * @returns the current matrix
  4140. */
  4141. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4142. /**
  4143. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4144. * @param ref matrix to store the result
  4145. */
  4146. toNormalMatrix(ref: Matrix): void;
  4147. /**
  4148. * Gets only rotation part of the current matrix
  4149. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4150. */
  4151. getRotationMatrix(): Matrix;
  4152. /**
  4153. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4154. * @param result defines the target matrix to store data to
  4155. * @returns the current matrix
  4156. */
  4157. getRotationMatrixToRef(result: Matrix): Matrix;
  4158. /**
  4159. * Toggles model matrix from being right handed to left handed in place and vice versa
  4160. */
  4161. toggleModelMatrixHandInPlace(): void;
  4162. /**
  4163. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleProjectionMatrixHandInPlace(): void;
  4166. /**
  4167. * Creates a matrix from an array
  4168. * @param array defines the source array
  4169. * @param offset defines an offset in the source array
  4170. * @returns a new Matrix set from the starting index of the given array
  4171. */
  4172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4173. /**
  4174. * Copy the content of an array into a given matrix
  4175. * @param array defines the source array
  4176. * @param offset defines an offset in the source array
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4180. /**
  4181. * Stores an array into a matrix after having multiplied each component by a given factor
  4182. * @param array defines the source array
  4183. * @param offset defines the offset in the source array
  4184. * @param scale defines the scaling factor
  4185. * @param result defines the target matrix
  4186. */
  4187. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4188. /**
  4189. * Gets an identity matrix that must not be updated
  4190. */
  4191. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4192. /**
  4193. * Stores a list of values (16) inside a given matrix
  4194. * @param initialM11 defines 1st value of 1st row
  4195. * @param initialM12 defines 2nd value of 1st row
  4196. * @param initialM13 defines 3rd value of 1st row
  4197. * @param initialM14 defines 4th value of 1st row
  4198. * @param initialM21 defines 1st value of 2nd row
  4199. * @param initialM22 defines 2nd value of 2nd row
  4200. * @param initialM23 defines 3rd value of 2nd row
  4201. * @param initialM24 defines 4th value of 2nd row
  4202. * @param initialM31 defines 1st value of 3rd row
  4203. * @param initialM32 defines 2nd value of 3rd row
  4204. * @param initialM33 defines 3rd value of 3rd row
  4205. * @param initialM34 defines 4th value of 3rd row
  4206. * @param initialM41 defines 1st value of 4th row
  4207. * @param initialM42 defines 2nd value of 4th row
  4208. * @param initialM43 defines 3rd value of 4th row
  4209. * @param initialM44 defines 4th value of 4th row
  4210. * @param result defines the target matrix
  4211. */
  4212. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4213. /**
  4214. * Creates new matrix from a list of values (16)
  4215. * @param initialM11 defines 1st value of 1st row
  4216. * @param initialM12 defines 2nd value of 1st row
  4217. * @param initialM13 defines 3rd value of 1st row
  4218. * @param initialM14 defines 4th value of 1st row
  4219. * @param initialM21 defines 1st value of 2nd row
  4220. * @param initialM22 defines 2nd value of 2nd row
  4221. * @param initialM23 defines 3rd value of 2nd row
  4222. * @param initialM24 defines 4th value of 2nd row
  4223. * @param initialM31 defines 1st value of 3rd row
  4224. * @param initialM32 defines 2nd value of 3rd row
  4225. * @param initialM33 defines 3rd value of 3rd row
  4226. * @param initialM34 defines 4th value of 3rd row
  4227. * @param initialM41 defines 1st value of 4th row
  4228. * @param initialM42 defines 2nd value of 4th row
  4229. * @param initialM43 defines 3rd value of 4th row
  4230. * @param initialM44 defines 4th value of 4th row
  4231. * @returns the new matrix
  4232. */
  4233. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4234. /**
  4235. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4236. * @param scale defines the scale vector3
  4237. * @param rotation defines the rotation quaternion
  4238. * @param translation defines the translation vector3
  4239. * @returns a new matrix
  4240. */
  4241. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4242. /**
  4243. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4244. * @param scale defines the scale vector3
  4245. * @param rotation defines the rotation quaternion
  4246. * @param translation defines the translation vector3
  4247. * @param result defines the target matrix
  4248. */
  4249. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4250. /**
  4251. * Creates a new identity matrix
  4252. * @returns a new identity matrix
  4253. */
  4254. static Identity(): Matrix;
  4255. /**
  4256. * Creates a new identity matrix and stores the result in a given matrix
  4257. * @param result defines the target matrix
  4258. */
  4259. static IdentityToRef(result: Matrix): void;
  4260. /**
  4261. * Creates a new zero matrix
  4262. * @returns a new zero matrix
  4263. */
  4264. static Zero(): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the X axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationX(angle: number): Matrix;
  4271. /**
  4272. * Creates a new matrix as the invert of a given matrix
  4273. * @param source defines the source matrix
  4274. * @returns the new matrix
  4275. */
  4276. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationXToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Y axis
  4285. * @param angle defines the angle (in radians) to use
  4286. * @return the new matrix
  4287. */
  4288. static RotationY(angle: number): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Z axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationZ(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationZToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the given axis
  4309. * @param axis defines the axis to use
  4310. * @param angle defines the angle (in radians) to use
  4311. * @return the new matrix
  4312. */
  4313. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4314. /**
  4315. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4316. * @param axis defines the axis to use
  4317. * @param angle defines the angle (in radians) to use
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4321. /**
  4322. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4323. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4324. * @param from defines the vector to align
  4325. * @param to defines the vector to align to
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4329. /**
  4330. * Creates a rotation matrix
  4331. * @param yaw defines the yaw angle in radians (Y axis)
  4332. * @param pitch defines the pitch angle in radians (X axis)
  4333. * @param roll defines the roll angle in radians (X axis)
  4334. * @returns the new rotation matrix
  4335. */
  4336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4337. /**
  4338. * Creates a rotation matrix and stores it in a given matrix
  4339. * @param yaw defines the yaw angle in radians (Y axis)
  4340. * @param pitch defines the pitch angle in radians (X axis)
  4341. * @param roll defines the roll angle in radians (X axis)
  4342. * @param result defines the target matrix
  4343. */
  4344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4345. /**
  4346. * Creates a scaling matrix
  4347. * @param x defines the scale factor on X axis
  4348. * @param y defines the scale factor on Y axis
  4349. * @param z defines the scale factor on Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Scaling(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a scaling matrix and stores it in a given matrix
  4355. * @param x defines the scale factor on X axis
  4356. * @param y defines the scale factor on Y axis
  4357. * @param z defines the scale factor on Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Creates a translation matrix
  4363. * @param x defines the translation on X axis
  4364. * @param y defines the translation on Y axis
  4365. * @param z defines the translationon Z axis
  4366. * @returns the new matrix
  4367. */
  4368. static Translation(x: number, y: number, z: number): Matrix;
  4369. /**
  4370. * Creates a translation matrix and stores it in a given matrix
  4371. * @param x defines the translation on X axis
  4372. * @param y defines the translation on Y axis
  4373. * @param z defines the translationon Z axis
  4374. * @param result defines the target matrix
  4375. */
  4376. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4377. /**
  4378. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4379. * @param startValue defines the start value
  4380. * @param endValue defines the end value
  4381. * @param gradient defines the gradient factor
  4382. * @returns the new matrix
  4383. */
  4384. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4385. /**
  4386. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4387. * @param startValue defines the start value
  4388. * @param endValue defines the end value
  4389. * @param gradient defines the gradient factor
  4390. * @param result defines the Matrix object where to store data
  4391. */
  4392. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Builds a new matrix whose values are computed by:
  4395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4398. * @param startValue defines the first matrix
  4399. * @param endValue defines the second matrix
  4400. * @param gradient defines the gradient between the two matrices
  4401. * @returns the new matrix
  4402. */
  4403. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4404. /**
  4405. * Update a matrix to values which are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @param result defines the target matrix
  4413. */
  4414. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4415. /**
  4416. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4417. * This function works in left handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4426. * This function works in left handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4435. * This function works in right handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @returns the new matrix
  4440. */
  4441. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @param result defines the target matrix
  4449. */
  4450. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed orthographic projection matrix
  4458. */
  4459. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Store a left-handed orthographic projection to a given matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Create a left-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a right-handed orthographic projection matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a right-handed orthographic projection matrix
  4500. */
  4501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a right-handed orthographic projection into a given matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @param result defines the target matrix
  4511. */
  4512. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4513. /**
  4514. * Creates a left-handed perspective projection matrix
  4515. * @param width defines the viewport width
  4516. * @param height defines the viewport height
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @returns a new matrix as a left-handed perspective projection matrix
  4520. */
  4521. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a left-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Creates a right-handed perspective projection matrix
  4553. * @param fov defines the horizontal field of view
  4554. * @param aspect defines the aspect ratio
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a right-handed perspective projection matrix
  4558. */
  4559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Stores a right-handed perspective projection into a given matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4568. */
  4569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4570. /**
  4571. * Stores a right-handed perspective projection into a given matrix
  4572. * @param fov defines the horizontal field of view
  4573. * @param aspect defines the aspect ratio
  4574. * @param znear defines the near clip plane
  4575. * @param zfar not used as infinity is used as far clip
  4576. * @param result defines the target matrix
  4577. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4578. */
  4579. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4580. /**
  4581. * Stores a perspective projection for WebVR info a given matrix
  4582. * @param fov defines the field of view
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @param result defines the target matrix
  4586. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4587. */
  4588. static PerspectiveFovWebVRToRef(fov: {
  4589. upDegrees: number;
  4590. downDegrees: number;
  4591. leftDegrees: number;
  4592. rightDegrees: number;
  4593. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4594. /**
  4595. * Computes a complete transformation matrix
  4596. * @param viewport defines the viewport to use
  4597. * @param world defines the world matrix
  4598. * @param view defines the view matrix
  4599. * @param projection defines the projection matrix
  4600. * @param zmin defines the near clip plane
  4601. * @param zmax defines the far clip plane
  4602. * @returns the transformation matrix
  4603. */
  4604. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4605. /**
  4606. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4607. * @param matrix defines the matrix to use
  4608. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4609. */
  4610. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4611. /**
  4612. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4613. * @param matrix defines the matrix to use
  4614. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4615. */
  4616. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4617. /**
  4618. * Compute the transpose of a given matrix
  4619. * @param matrix defines the matrix to transpose
  4620. * @returns the new matrix
  4621. */
  4622. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4623. /**
  4624. * Compute the transpose of a matrix and store it in a target matrix
  4625. * @param matrix defines the matrix to transpose
  4626. * @param result defines the target matrix
  4627. */
  4628. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4629. /**
  4630. * Computes a reflection matrix from a plane
  4631. * @param plane defines the reflection plane
  4632. * @returns a new matrix
  4633. */
  4634. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4635. /**
  4636. * Computes a reflection matrix from a plane
  4637. * @param plane defines the reflection plane
  4638. * @param result defines the target matrix
  4639. */
  4640. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4641. /**
  4642. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4643. * @param xaxis defines the value of the 1st axis
  4644. * @param yaxis defines the value of the 2nd axis
  4645. * @param zaxis defines the value of the 3rd axis
  4646. * @param result defines the target matrix
  4647. */
  4648. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4649. /**
  4650. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4651. * @param quat defines the quaternion to use
  4652. * @param result defines the target matrix
  4653. */
  4654. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4655. }
  4656. /**
  4657. * @hidden
  4658. */
  4659. export class TmpVectors {
  4660. static Vector2: Vector2[];
  4661. static Vector3: Vector3[];
  4662. static Vector4: Vector4[];
  4663. static Quaternion: Quaternion[];
  4664. static Matrix: Matrix[];
  4665. }
  4666. }
  4667. declare module "babylonjs/Maths/math.path" {
  4668. import { DeepImmutable, Nullable } from "babylonjs/types";
  4669. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4670. /**
  4671. * Defines potential orientation for back face culling
  4672. */
  4673. export enum Orientation {
  4674. /**
  4675. * Clockwise
  4676. */
  4677. CW = 0,
  4678. /** Counter clockwise */
  4679. CCW = 1
  4680. }
  4681. /** Class used to represent a Bezier curve */
  4682. export class BezierCurve {
  4683. /**
  4684. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4685. * @param t defines the time
  4686. * @param x1 defines the left coordinate on X axis
  4687. * @param y1 defines the left coordinate on Y axis
  4688. * @param x2 defines the right coordinate on X axis
  4689. * @param y2 defines the right coordinate on Y axis
  4690. * @returns the interpolated value
  4691. */
  4692. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4693. }
  4694. /**
  4695. * Defines angle representation
  4696. */
  4697. export class Angle {
  4698. private _radians;
  4699. /**
  4700. * Creates an Angle object of "radians" radians (float).
  4701. * @param radians the angle in radians
  4702. */
  4703. constructor(radians: number);
  4704. /**
  4705. * Get value in degrees
  4706. * @returns the Angle value in degrees (float)
  4707. */
  4708. degrees(): number;
  4709. /**
  4710. * Get value in radians
  4711. * @returns the Angle value in radians (float)
  4712. */
  4713. radians(): number;
  4714. /**
  4715. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4716. * @param a defines first vector
  4717. * @param b defines second vector
  4718. * @returns a new Angle
  4719. */
  4720. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4721. /**
  4722. * Gets a new Angle object from the given float in radians
  4723. * @param radians defines the angle value in radians
  4724. * @returns a new Angle
  4725. */
  4726. static FromRadians(radians: number): Angle;
  4727. /**
  4728. * Gets a new Angle object from the given float in degrees
  4729. * @param degrees defines the angle value in degrees
  4730. * @returns a new Angle
  4731. */
  4732. static FromDegrees(degrees: number): Angle;
  4733. }
  4734. /**
  4735. * This represents an arc in a 2d space.
  4736. */
  4737. export class Arc2 {
  4738. /** Defines the start point of the arc */
  4739. startPoint: Vector2;
  4740. /** Defines the mid point of the arc */
  4741. midPoint: Vector2;
  4742. /** Defines the end point of the arc */
  4743. endPoint: Vector2;
  4744. /**
  4745. * Defines the center point of the arc.
  4746. */
  4747. centerPoint: Vector2;
  4748. /**
  4749. * Defines the radius of the arc.
  4750. */
  4751. radius: number;
  4752. /**
  4753. * Defines the angle of the arc (from mid point to end point).
  4754. */
  4755. angle: Angle;
  4756. /**
  4757. * Defines the start angle of the arc (from start point to middle point).
  4758. */
  4759. startAngle: Angle;
  4760. /**
  4761. * Defines the orientation of the arc (clock wise/counter clock wise).
  4762. */
  4763. orientation: Orientation;
  4764. /**
  4765. * Creates an Arc object from the three given points : start, middle and end.
  4766. * @param startPoint Defines the start point of the arc
  4767. * @param midPoint Defines the midlle point of the arc
  4768. * @param endPoint Defines the end point of the arc
  4769. */
  4770. constructor(
  4771. /** Defines the start point of the arc */
  4772. startPoint: Vector2,
  4773. /** Defines the mid point of the arc */
  4774. midPoint: Vector2,
  4775. /** Defines the end point of the arc */
  4776. endPoint: Vector2);
  4777. }
  4778. /**
  4779. * Represents a 2D path made up of multiple 2D points
  4780. */
  4781. export class Path2 {
  4782. private _points;
  4783. private _length;
  4784. /**
  4785. * If the path start and end point are the same
  4786. */
  4787. closed: boolean;
  4788. /**
  4789. * Creates a Path2 object from the starting 2D coordinates x and y.
  4790. * @param x the starting points x value
  4791. * @param y the starting points y value
  4792. */
  4793. constructor(x: number, y: number);
  4794. /**
  4795. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4796. * @param x the added points x value
  4797. * @param y the added points y value
  4798. * @returns the updated Path2.
  4799. */
  4800. addLineTo(x: number, y: number): Path2;
  4801. /**
  4802. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4803. * @param midX middle point x value
  4804. * @param midY middle point y value
  4805. * @param endX end point x value
  4806. * @param endY end point y value
  4807. * @param numberOfSegments (default: 36)
  4808. * @returns the updated Path2.
  4809. */
  4810. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4811. /**
  4812. * Closes the Path2.
  4813. * @returns the Path2.
  4814. */
  4815. close(): Path2;
  4816. /**
  4817. * Gets the sum of the distance between each sequential point in the path
  4818. * @returns the Path2 total length (float).
  4819. */
  4820. length(): number;
  4821. /**
  4822. * Gets the points which construct the path
  4823. * @returns the Path2 internal array of points.
  4824. */
  4825. getPoints(): Vector2[];
  4826. /**
  4827. * Retreives the point at the distance aways from the starting point
  4828. * @param normalizedLengthPosition the length along the path to retreive the point from
  4829. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4830. */
  4831. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4832. /**
  4833. * Creates a new path starting from an x and y position
  4834. * @param x starting x value
  4835. * @param y starting y value
  4836. * @returns a new Path2 starting at the coordinates (x, y).
  4837. */
  4838. static StartingAt(x: number, y: number): Path2;
  4839. }
  4840. /**
  4841. * Represents a 3D path made up of multiple 3D points
  4842. */
  4843. export class Path3D {
  4844. /**
  4845. * an array of Vector3, the curve axis of the Path3D
  4846. */
  4847. path: Vector3[];
  4848. private _curve;
  4849. private _distances;
  4850. private _tangents;
  4851. private _normals;
  4852. private _binormals;
  4853. private _raw;
  4854. private _alignTangentsWithPath;
  4855. private readonly _pointAtData;
  4856. /**
  4857. * new Path3D(path, normal, raw)
  4858. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4859. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4860. * @param path an array of Vector3, the curve axis of the Path3D
  4861. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4862. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4864. */
  4865. constructor(
  4866. /**
  4867. * an array of Vector3, the curve axis of the Path3D
  4868. */
  4869. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4870. /**
  4871. * Returns the Path3D array of successive Vector3 designing its curve.
  4872. * @returns the Path3D array of successive Vector3 designing its curve.
  4873. */
  4874. getCurve(): Vector3[];
  4875. /**
  4876. * Returns the Path3D array of successive Vector3 designing its curve.
  4877. * @returns the Path3D array of successive Vector3 designing its curve.
  4878. */
  4879. getPoints(): Vector3[];
  4880. /**
  4881. * @returns the computed length (float) of the path.
  4882. */
  4883. length(): number;
  4884. /**
  4885. * Returns an array populated with tangent vectors on each Path3D curve point.
  4886. * @returns an array populated with tangent vectors on each Path3D curve point.
  4887. */
  4888. getTangents(): Vector3[];
  4889. /**
  4890. * Returns an array populated with normal vectors on each Path3D curve point.
  4891. * @returns an array populated with normal vectors on each Path3D curve point.
  4892. */
  4893. getNormals(): Vector3[];
  4894. /**
  4895. * Returns an array populated with binormal vectors on each Path3D curve point.
  4896. * @returns an array populated with binormal vectors on each Path3D curve point.
  4897. */
  4898. getBinormals(): Vector3[];
  4899. /**
  4900. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4901. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4902. */
  4903. getDistances(): number[];
  4904. /**
  4905. * Returns an interpolated point along this path
  4906. * @param position the position of the point along this path, from 0.0 to 1.0
  4907. * @returns a new Vector3 as the point
  4908. */
  4909. getPointAt(position: number): Vector3;
  4910. /**
  4911. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4914. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4915. */
  4916. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4921. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4922. */
  4923. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4924. /**
  4925. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4926. * @param position the position of the point along this path, from 0.0 to 1.0
  4927. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4928. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4929. */
  4930. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4931. /**
  4932. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4933. * @param position the position of the point along this path, from 0.0 to 1.0
  4934. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4935. */
  4936. getDistanceAt(position: number): number;
  4937. /**
  4938. * Returns the array index of the previous point of an interpolated point along this path
  4939. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4940. * @returns the array index
  4941. */
  4942. getPreviousPointIndexAt(position: number): number;
  4943. /**
  4944. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4945. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4946. * @returns the sub position
  4947. */
  4948. getSubPositionAt(position: number): number;
  4949. /**
  4950. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4951. * @param target the vector of which to get the closest position to
  4952. * @returns the position of the closest virtual point on this path to the target vector
  4953. */
  4954. getClosestPositionTo(target: Vector3): number;
  4955. /**
  4956. * Returns a sub path (slice) of this path
  4957. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4958. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4959. * @returns a sub path (slice) of this path
  4960. */
  4961. slice(start?: number, end?: number): Path3D;
  4962. /**
  4963. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4964. * @param path path which all values are copied into the curves points
  4965. * @param firstNormal which should be projected onto the curve
  4966. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4967. * @returns the same object updated.
  4968. */
  4969. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4970. private _compute;
  4971. private _getFirstNonNullVector;
  4972. private _getLastNonNullVector;
  4973. private _normalVector;
  4974. /**
  4975. * Updates the point at data for an interpolated point along this curve
  4976. * @param position the position of the point along this curve, from 0.0 to 1.0
  4977. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4978. * @returns the (updated) point at data
  4979. */
  4980. private _updatePointAtData;
  4981. /**
  4982. * Updates the point at data from the specified parameters
  4983. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4984. * @param point the interpolated point
  4985. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4986. */
  4987. private _setPointAtData;
  4988. /**
  4989. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4990. */
  4991. private _updateInterpolationMatrix;
  4992. }
  4993. /**
  4994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4995. * A Curve3 is designed from a series of successive Vector3.
  4996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4997. */
  4998. export class Curve3 {
  4999. private _points;
  5000. private _length;
  5001. /**
  5002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5004. * @param v1 (Vector3) the control point
  5005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5006. * @param nbPoints (integer) the wanted number of points in the curve
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5010. /**
  5011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5013. * @param v1 (Vector3) the first control point
  5014. * @param v2 (Vector3) the second control point
  5015. * @param v3 (Vector3) the end point of the Cubic Bezier
  5016. * @param nbPoints (integer) the wanted number of points in the curve
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5020. /**
  5021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5022. * @param p1 (Vector3) the origin point of the Hermite Spline
  5023. * @param t1 (Vector3) the tangent vector at the origin point
  5024. * @param p2 (Vector3) the end point of the Hermite Spline
  5025. * @param t2 (Vector3) the tangent vector at the end point
  5026. * @param nbPoints (integer) the wanted number of points in the curve
  5027. * @returns the created Curve3
  5028. */
  5029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5030. /**
  5031. * Returns a Curve3 object along a CatmullRom Spline curve :
  5032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5033. * @param nbPoints (integer) the wanted number of points between each curve control points
  5034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5035. * @returns the created Curve3
  5036. */
  5037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5038. /**
  5039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5040. * A Curve3 is designed from a series of successive Vector3.
  5041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5042. * @param points points which make up the curve
  5043. */
  5044. constructor(points: Vector3[]);
  5045. /**
  5046. * @returns the Curve3 stored array of successive Vector3
  5047. */
  5048. getPoints(): Vector3[];
  5049. /**
  5050. * @returns the computed length (float) of the curve.
  5051. */
  5052. length(): number;
  5053. /**
  5054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5056. * curveA and curveB keep unchanged.
  5057. * @param curve the curve to continue from this curve
  5058. * @returns the newly constructed curve
  5059. */
  5060. continue(curve: DeepImmutable<Curve3>): Curve3;
  5061. private _computeLength;
  5062. }
  5063. }
  5064. declare module "babylonjs/Animations/easing" {
  5065. /**
  5066. * This represents the main contract an easing function should follow.
  5067. * Easing functions are used throughout the animation system.
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export interface IEasingFunction {
  5071. /**
  5072. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5073. * of the easing function.
  5074. * The link below provides some of the most common examples of easing functions.
  5075. * @see https://easings.net/
  5076. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5077. * @returns the corresponding value on the curve defined by the easing function
  5078. */
  5079. ease(gradient: number): number;
  5080. }
  5081. /**
  5082. * Base class used for every default easing function.
  5083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5084. */
  5085. export class EasingFunction implements IEasingFunction {
  5086. /**
  5087. * Interpolation follows the mathematical formula associated with the easing function.
  5088. */
  5089. static readonly EASINGMODE_EASEIN: number;
  5090. /**
  5091. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEOUT: number;
  5094. /**
  5095. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5096. */
  5097. static readonly EASINGMODE_EASEINOUT: number;
  5098. private _easingMode;
  5099. /**
  5100. * Sets the easing mode of the current function.
  5101. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5102. */
  5103. setEasingMode(easingMode: number): void;
  5104. /**
  5105. * Gets the current easing mode.
  5106. * @returns the easing mode
  5107. */
  5108. getEasingMode(): number;
  5109. /**
  5110. * @hidden
  5111. */
  5112. easeInCore(gradient: number): number;
  5113. /**
  5114. * Given an input gradient between 0 and 1, this returns the corresponding value
  5115. * of the easing function.
  5116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5117. * @returns the corresponding value on the curve defined by the easing function
  5118. */
  5119. ease(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a circle shape (see link below).
  5123. * @see https://easings.net/#easeInCirc
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CircleEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a ease back shape (see link below).
  5132. * @see https://easings.net/#easeInBack
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class BackEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the amplitude of the function */
  5137. amplitude: number;
  5138. /**
  5139. * Instantiates a back ease easing
  5140. * @see https://easings.net/#easeInBack
  5141. * @param amplitude Defines the amplitude of the function
  5142. */
  5143. constructor(
  5144. /** Defines the amplitude of the function */
  5145. amplitude?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a bouncing shape (see link below).
  5151. * @see https://easings.net/#easeInBounce
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class BounceEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the number of bounces */
  5156. bounces: number;
  5157. /** Defines the amplitude of the bounce */
  5158. bounciness: number;
  5159. /**
  5160. * Instantiates a bounce easing
  5161. * @see https://easings.net/#easeInBounce
  5162. * @param bounces Defines the number of bounces
  5163. * @param bounciness Defines the amplitude of the bounce
  5164. */
  5165. constructor(
  5166. /** Defines the number of bounces */
  5167. bounces?: number,
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 3 shape (see link below).
  5175. * @see https://easings.net/#easeInCubic
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class CubicEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an elastic shape (see link below).
  5184. * @see https://easings.net/#easeInElastic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the number of oscillations*/
  5189. oscillations: number;
  5190. /** Defines the amplitude of the oscillations*/
  5191. springiness: number;
  5192. /**
  5193. * Instantiates an elastic easing function
  5194. * @see https://easings.net/#easeInElastic
  5195. * @param oscillations Defines the number of oscillations
  5196. * @param springiness Defines the amplitude of the oscillations
  5197. */
  5198. constructor(
  5199. /** Defines the number of oscillations*/
  5200. oscillations?: number,
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness?: number);
  5203. /** @hidden */
  5204. easeInCore(gradient: number): number;
  5205. }
  5206. /**
  5207. * Easing function with an exponential shape (see link below).
  5208. * @see https://easings.net/#easeInExpo
  5209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5212. /** Defines the exponent of the function */
  5213. exponent: number;
  5214. /**
  5215. * Instantiates an exponential easing function
  5216. * @see https://easings.net/#easeInExpo
  5217. * @param exponent Defines the exponent of the function
  5218. */
  5219. constructor(
  5220. /** Defines the exponent of the function */
  5221. exponent?: number);
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power shape (see link below).
  5227. * @see https://easings.net/#easeInQuad
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class PowerEase extends EasingFunction implements IEasingFunction {
  5231. /** Defines the power of the function */
  5232. power: number;
  5233. /**
  5234. * Instantiates an power base easing function
  5235. * @see https://easings.net/#easeInQuad
  5236. * @param power Defines the power of the function
  5237. */
  5238. constructor(
  5239. /** Defines the power of the function */
  5240. power?: number);
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 2 shape (see link below).
  5246. * @see https://easings.net/#easeInQuad
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 4 shape (see link below).
  5255. * @see https://easings.net/#easeInQuart
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 5 shape (see link below).
  5264. * @see https://easings.net/#easeInQuint
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a sin shape (see link below).
  5273. * @see https://easings.net/#easeInSine
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class SineEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a bezier shape (see link below).
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the x component of the start tangent in the bezier curve */
  5287. x1: number;
  5288. /** Defines the y component of the start tangent in the bezier curve */
  5289. y1: number;
  5290. /** Defines the x component of the end tangent in the bezier curve */
  5291. x2: number;
  5292. /** Defines the y component of the end tangent in the bezier curve */
  5293. y2: number;
  5294. /**
  5295. * Instantiates a bezier function
  5296. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5297. * @param x1 Defines the x component of the start tangent in the bezier curve
  5298. * @param y1 Defines the y component of the start tangent in the bezier curve
  5299. * @param x2 Defines the x component of the end tangent in the bezier curve
  5300. * @param y2 Defines the y component of the end tangent in the bezier curve
  5301. */
  5302. constructor(
  5303. /** Defines the x component of the start tangent in the bezier curve */
  5304. x1?: number,
  5305. /** Defines the y component of the start tangent in the bezier curve */
  5306. y1?: number,
  5307. /** Defines the x component of the end tangent in the bezier curve */
  5308. x2?: number,
  5309. /** Defines the y component of the end tangent in the bezier curve */
  5310. y2?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. }
  5315. declare module "babylonjs/Maths/math.color" {
  5316. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5317. /**
  5318. * Class used to hold a RBG color
  5319. */
  5320. export class Color3 {
  5321. /**
  5322. * Defines the red component (between 0 and 1, default is 0)
  5323. */
  5324. r: number;
  5325. /**
  5326. * Defines the green component (between 0 and 1, default is 0)
  5327. */
  5328. g: number;
  5329. /**
  5330. * Defines the blue component (between 0 and 1, default is 0)
  5331. */
  5332. b: number;
  5333. /**
  5334. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5335. * @param r defines the red component (between 0 and 1, default is 0)
  5336. * @param g defines the green component (between 0 and 1, default is 0)
  5337. * @param b defines the blue component (between 0 and 1, default is 0)
  5338. */
  5339. constructor(
  5340. /**
  5341. * Defines the red component (between 0 and 1, default is 0)
  5342. */
  5343. r?: number,
  5344. /**
  5345. * Defines the green component (between 0 and 1, default is 0)
  5346. */
  5347. g?: number,
  5348. /**
  5349. * Defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. b?: number);
  5352. /**
  5353. * Creates a string with the Color3 current values
  5354. * @returns the string representation of the Color3 object
  5355. */
  5356. toString(): string;
  5357. /**
  5358. * Returns the string "Color3"
  5359. * @returns "Color3"
  5360. */
  5361. getClassName(): string;
  5362. /**
  5363. * Compute the Color3 hash code
  5364. * @returns an unique number that can be used to hash Color3 objects
  5365. */
  5366. getHashCode(): number;
  5367. /**
  5368. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5369. * @param array defines the array where to store the r,g,b components
  5370. * @param index defines an optional index in the target array to define where to start storing values
  5371. * @returns the current Color3 object
  5372. */
  5373. toArray(array: FloatArray, index?: number): Color3;
  5374. /**
  5375. * Returns a new Color4 object from the current Color3 and the given alpha
  5376. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5377. * @returns a new Color4 object
  5378. */
  5379. toColor4(alpha?: number): Color4;
  5380. /**
  5381. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5382. * @returns the new array
  5383. */
  5384. asArray(): number[];
  5385. /**
  5386. * Returns the luminance value
  5387. * @returns a float value
  5388. */
  5389. toLuminance(): number;
  5390. /**
  5391. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5392. * @param otherColor defines the second operand
  5393. * @returns the new Color3 object
  5394. */
  5395. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5396. /**
  5397. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5398. * @param otherColor defines the second operand
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the current Color3
  5401. */
  5402. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5403. /**
  5404. * Determines equality between Color3 objects
  5405. * @param otherColor defines the second operand
  5406. * @returns true if the rgb values are equal to the given ones
  5407. */
  5408. equals(otherColor: DeepImmutable<Color3>): boolean;
  5409. /**
  5410. * Determines equality between the current Color3 object and a set of r,b,g values
  5411. * @param r defines the red component to check
  5412. * @param g defines the green component to check
  5413. * @param b defines the blue component to check
  5414. * @returns true if the rgb values are equal to the given ones
  5415. */
  5416. equalsFloats(r: number, g: number, b: number): boolean;
  5417. /**
  5418. * Multiplies in place each rgb value by scale
  5419. * @param scale defines the scaling factor
  5420. * @returns the updated Color3
  5421. */
  5422. scale(scale: number): Color3;
  5423. /**
  5424. * Multiplies the rgb values by scale and stores the result into "result"
  5425. * @param scale defines the scaling factor
  5426. * @param result defines the Color3 object where to store the result
  5427. * @returns the unmodified current Color3
  5428. */
  5429. scaleToRef(scale: number, result: Color3): Color3;
  5430. /**
  5431. * Scale the current Color3 values by a factor and add the result to a given Color3
  5432. * @param scale defines the scale factor
  5433. * @param result defines color to store the result into
  5434. * @returns the unmodified current Color3
  5435. */
  5436. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5437. /**
  5438. * Clamps the rgb values by the min and max values and stores the result into "result"
  5439. * @param min defines minimum clamping value (default is 0)
  5440. * @param max defines maximum clamping value (default is 1)
  5441. * @param result defines color to store the result into
  5442. * @returns the original Color3
  5443. */
  5444. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5445. /**
  5446. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5447. * @param otherColor defines the second operand
  5448. * @returns the new Color3
  5449. */
  5450. add(otherColor: DeepImmutable<Color3>): Color3;
  5451. /**
  5452. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5453. * @param otherColor defines the second operand
  5454. * @param result defines Color3 object to store the result into
  5455. * @returns the unmodified current Color3
  5456. */
  5457. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5458. /**
  5459. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5460. * @param otherColor defines the second operand
  5461. * @returns the new Color3
  5462. */
  5463. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5466. * @param otherColor defines the second operand
  5467. * @param result defines Color3 object to store the result into
  5468. * @returns the unmodified current Color3
  5469. */
  5470. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5471. /**
  5472. * Copy the current object
  5473. * @returns a new Color3 copied the current one
  5474. */
  5475. clone(): Color3;
  5476. /**
  5477. * Copies the rgb values from the source in the current Color3
  5478. * @param source defines the source Color3 object
  5479. * @returns the updated Color3 object
  5480. */
  5481. copyFrom(source: DeepImmutable<Color3>): Color3;
  5482. /**
  5483. * Updates the Color3 rgb values from the given floats
  5484. * @param r defines the red component to read from
  5485. * @param g defines the green component to read from
  5486. * @param b defines the blue component to read from
  5487. * @returns the current Color3 object
  5488. */
  5489. copyFromFloats(r: number, g: number, b: number): Color3;
  5490. /**
  5491. * Updates the Color3 rgb values from the given floats
  5492. * @param r defines the red component to read from
  5493. * @param g defines the green component to read from
  5494. * @param b defines the blue component to read from
  5495. * @returns the current Color3 object
  5496. */
  5497. set(r: number, g: number, b: number): Color3;
  5498. /**
  5499. * Compute the Color3 hexadecimal code as a string
  5500. * @returns a string containing the hexadecimal representation of the Color3 object
  5501. */
  5502. toHexString(): string;
  5503. /**
  5504. * Computes a new Color3 converted from the current one to linear space
  5505. * @returns a new Color3 object
  5506. */
  5507. toLinearSpace(): Color3;
  5508. /**
  5509. * Converts current color in rgb space to HSV values
  5510. * @returns a new color3 representing the HSV values
  5511. */
  5512. toHSV(): Color3;
  5513. /**
  5514. * Converts current color in rgb space to HSV values
  5515. * @param result defines the Color3 where to store the HSV values
  5516. */
  5517. toHSVToRef(result: Color3): void;
  5518. /**
  5519. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5520. * @param convertedColor defines the Color3 object where to store the linear space version
  5521. * @returns the unmodified Color3
  5522. */
  5523. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5524. /**
  5525. * Computes a new Color3 converted from the current one to gamma space
  5526. * @returns a new Color3 object
  5527. */
  5528. toGammaSpace(): Color3;
  5529. /**
  5530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the gamma space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5535. private static _BlackReadOnly;
  5536. /**
  5537. * Convert Hue, saturation and value to a Color3 (RGB)
  5538. * @param hue defines the hue
  5539. * @param saturation defines the saturation
  5540. * @param value defines the value
  5541. * @param result defines the Color3 where to store the RGB values
  5542. */
  5543. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5544. /**
  5545. * Creates a new Color3 from the string containing valid hexadecimal values
  5546. * @param hex defines a string containing valid hexadecimal values
  5547. * @returns a new Color3 object
  5548. */
  5549. static FromHexString(hex: string): Color3;
  5550. /**
  5551. * Creates a new Color3 from the starting index of the given array
  5552. * @param array defines the source array
  5553. * @param offset defines an offset in the source array
  5554. * @returns a new Color3 object
  5555. */
  5556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5557. /**
  5558. * Creates a new Color3 from integer values (< 256)
  5559. * @param r defines the red component to read from (value between 0 and 255)
  5560. * @param g defines the green component to read from (value between 0 and 255)
  5561. * @param b defines the blue component to read from (value between 0 and 255)
  5562. * @returns a new Color3 object
  5563. */
  5564. static FromInts(r: number, g: number, b: number): Color3;
  5565. /**
  5566. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5567. * @param start defines the start Color3 value
  5568. * @param end defines the end Color3 value
  5569. * @param amount defines the gradient value between start and end
  5570. * @returns a new Color3 object
  5571. */
  5572. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5573. /**
  5574. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5575. * @param left defines the start value
  5576. * @param right defines the end value
  5577. * @param amount defines the gradient factor
  5578. * @param result defines the Color3 object where to store the result
  5579. */
  5580. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5581. /**
  5582. * Returns a Color3 value containing a red color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Red(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a green color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Green(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a blue color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Blue(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a black color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Black(): Color3;
  5601. /**
  5602. * Gets a Color3 value containing a black color that must not be updated
  5603. */
  5604. static get BlackReadOnly(): DeepImmutable<Color3>;
  5605. /**
  5606. * Returns a Color3 value containing a white color
  5607. * @returns a new Color3 object
  5608. */
  5609. static White(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a purple color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Purple(): Color3;
  5615. /**
  5616. * Returns a Color3 value containing a magenta color
  5617. * @returns a new Color3 object
  5618. */
  5619. static Magenta(): Color3;
  5620. /**
  5621. * Returns a Color3 value containing a yellow color
  5622. * @returns a new Color3 object
  5623. */
  5624. static Yellow(): Color3;
  5625. /**
  5626. * Returns a Color3 value containing a gray color
  5627. * @returns a new Color3 object
  5628. */
  5629. static Gray(): Color3;
  5630. /**
  5631. * Returns a Color3 value containing a teal color
  5632. * @returns a new Color3 object
  5633. */
  5634. static Teal(): Color3;
  5635. /**
  5636. * Returns a Color3 value containing a random color
  5637. * @returns a new Color3 object
  5638. */
  5639. static Random(): Color3;
  5640. }
  5641. /**
  5642. * Class used to hold a RBGA color
  5643. */
  5644. export class Color4 {
  5645. /**
  5646. * Defines the red component (between 0 and 1, default is 0)
  5647. */
  5648. r: number;
  5649. /**
  5650. * Defines the green component (between 0 and 1, default is 0)
  5651. */
  5652. g: number;
  5653. /**
  5654. * Defines the blue component (between 0 and 1, default is 0)
  5655. */
  5656. b: number;
  5657. /**
  5658. * Defines the alpha component (between 0 and 1, default is 1)
  5659. */
  5660. a: number;
  5661. /**
  5662. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5663. * @param r defines the red component (between 0 and 1, default is 0)
  5664. * @param g defines the green component (between 0 and 1, default is 0)
  5665. * @param b defines the blue component (between 0 and 1, default is 0)
  5666. * @param a defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. constructor(
  5669. /**
  5670. * Defines the red component (between 0 and 1, default is 0)
  5671. */
  5672. r?: number,
  5673. /**
  5674. * Defines the green component (between 0 and 1, default is 0)
  5675. */
  5676. g?: number,
  5677. /**
  5678. * Defines the blue component (between 0 and 1, default is 0)
  5679. */
  5680. b?: number,
  5681. /**
  5682. * Defines the alpha component (between 0 and 1, default is 1)
  5683. */
  5684. a?: number);
  5685. /**
  5686. * Adds in place the given Color4 values to the current Color4 object
  5687. * @param right defines the second operand
  5688. * @returns the current updated Color4 object
  5689. */
  5690. addInPlace(right: DeepImmutable<Color4>): Color4;
  5691. /**
  5692. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5693. * @returns the new array
  5694. */
  5695. asArray(): number[];
  5696. /**
  5697. * Stores from the starting index in the given array the Color4 successive values
  5698. * @param array defines the array where to store the r,g,b components
  5699. * @param index defines an optional index in the target array to define where to start storing values
  5700. * @returns the current Color4 object
  5701. */
  5702. toArray(array: number[], index?: number): Color4;
  5703. /**
  5704. * Determines equality between Color4 objects
  5705. * @param otherColor defines the second operand
  5706. * @returns true if the rgba values are equal to the given ones
  5707. */
  5708. equals(otherColor: DeepImmutable<Color4>): boolean;
  5709. /**
  5710. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5711. * @param right defines the second operand
  5712. * @returns a new Color4 object
  5713. */
  5714. add(right: DeepImmutable<Color4>): Color4;
  5715. /**
  5716. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5717. * @param right defines the second operand
  5718. * @returns a new Color4 object
  5719. */
  5720. subtract(right: DeepImmutable<Color4>): Color4;
  5721. /**
  5722. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5723. * @param right defines the second operand
  5724. * @param result defines the Color4 object where to store the result
  5725. * @returns the current Color4 object
  5726. */
  5727. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5728. /**
  5729. * Creates a new Color4 with the current Color4 values multiplied by scale
  5730. * @param scale defines the scaling factor to apply
  5731. * @returns a new Color4 object
  5732. */
  5733. scale(scale: number): Color4;
  5734. /**
  5735. * Multiplies the current Color4 values by scale and stores the result in "result"
  5736. * @param scale defines the scaling factor to apply
  5737. * @param result defines the Color4 object where to store the result
  5738. * @returns the current unmodified Color4
  5739. */
  5740. scaleToRef(scale: number, result: Color4): Color4;
  5741. /**
  5742. * Scale the current Color4 values by a factor and add the result to a given Color4
  5743. * @param scale defines the scale factor
  5744. * @param result defines the Color4 object where to store the result
  5745. * @returns the unmodified current Color4
  5746. */
  5747. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5748. /**
  5749. * Clamps the rgb values by the min and max values and stores the result into "result"
  5750. * @param min defines minimum clamping value (default is 0)
  5751. * @param max defines maximum clamping value (default is 1)
  5752. * @param result defines color to store the result into.
  5753. * @returns the cuurent Color4
  5754. */
  5755. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5756. /**
  5757. * Multipy an Color4 value by another and return a new Color4 object
  5758. * @param color defines the Color4 value to multiply by
  5759. * @returns a new Color4 object
  5760. */
  5761. multiply(color: Color4): Color4;
  5762. /**
  5763. * Multipy a Color4 value by another and push the result in a reference value
  5764. * @param color defines the Color4 value to multiply by
  5765. * @param result defines the Color4 to fill the result in
  5766. * @returns the result Color4
  5767. */
  5768. multiplyToRef(color: Color4, result: Color4): Color4;
  5769. /**
  5770. * Creates a string with the Color4 current values
  5771. * @returns the string representation of the Color4 object
  5772. */
  5773. toString(): string;
  5774. /**
  5775. * Returns the string "Color4"
  5776. * @returns "Color4"
  5777. */
  5778. getClassName(): string;
  5779. /**
  5780. * Compute the Color4 hash code
  5781. * @returns an unique number that can be used to hash Color4 objects
  5782. */
  5783. getHashCode(): number;
  5784. /**
  5785. * Creates a new Color4 copied from the current one
  5786. * @returns a new Color4 object
  5787. */
  5788. clone(): Color4;
  5789. /**
  5790. * Copies the given Color4 values into the current one
  5791. * @param source defines the source Color4 object
  5792. * @returns the current updated Color4 object
  5793. */
  5794. copyFrom(source: Color4): Color4;
  5795. /**
  5796. * Copies the given float values into the current one
  5797. * @param r defines the red component to read from
  5798. * @param g defines the green component to read from
  5799. * @param b defines the blue component to read from
  5800. * @param a defines the alpha component to read from
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. set(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Compute the Color4 hexadecimal code as a string
  5815. * @returns a string containing the hexadecimal representation of the Color4 object
  5816. */
  5817. toHexString(): string;
  5818. /**
  5819. * Computes a new Color4 converted from the current one to linear space
  5820. * @returns a new Color4 object
  5821. */
  5822. toLinearSpace(): Color4;
  5823. /**
  5824. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5825. * @param convertedColor defines the Color4 object where to store the linear space version
  5826. * @returns the unmodified Color4
  5827. */
  5828. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5829. /**
  5830. * Computes a new Color4 converted from the current one to gamma space
  5831. * @returns a new Color4 object
  5832. */
  5833. toGammaSpace(): Color4;
  5834. /**
  5835. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5836. * @param convertedColor defines the Color4 object where to store the gamma space version
  5837. * @returns the unmodified Color4
  5838. */
  5839. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5840. /**
  5841. * Creates a new Color4 from the string containing valid hexadecimal values
  5842. * @param hex defines a string containing valid hexadecimal values
  5843. * @returns a new Color4 object
  5844. */
  5845. static FromHexString(hex: string): Color4;
  5846. /**
  5847. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5848. * @param left defines the start value
  5849. * @param right defines the end value
  5850. * @param amount defines the gradient factor
  5851. * @returns a new Color4 object
  5852. */
  5853. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5854. /**
  5855. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5856. * @param left defines the start value
  5857. * @param right defines the end value
  5858. * @param amount defines the gradient factor
  5859. * @param result defines the Color4 object where to store data
  5860. */
  5861. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5862. /**
  5863. * Creates a new Color4 from a Color3 and an alpha value
  5864. * @param color3 defines the source Color3 to read from
  5865. * @param alpha defines the alpha component (1.0 by default)
  5866. * @returns a new Color4 object
  5867. */
  5868. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5869. /**
  5870. * Creates a new Color4 from the starting index element of the given array
  5871. * @param array defines the source array to read from
  5872. * @param offset defines the offset in the source array
  5873. * @returns a new Color4 object
  5874. */
  5875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5876. /**
  5877. * Creates a new Color3 from integer values (< 256)
  5878. * @param r defines the red component to read from (value between 0 and 255)
  5879. * @param g defines the green component to read from (value between 0 and 255)
  5880. * @param b defines the blue component to read from (value between 0 and 255)
  5881. * @param a defines the alpha component to read from (value between 0 and 255)
  5882. * @returns a new Color3 object
  5883. */
  5884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5885. /**
  5886. * Check the content of a given array and convert it to an array containing RGBA data
  5887. * If the original array was already containing count * 4 values then it is returned directly
  5888. * @param colors defines the array to check
  5889. * @param count defines the number of RGBA data to expect
  5890. * @returns an array containing count * 4 values (RGBA)
  5891. */
  5892. static CheckColors4(colors: number[], count: number): number[];
  5893. }
  5894. /**
  5895. * @hidden
  5896. */
  5897. export class TmpColors {
  5898. static Color3: Color3[];
  5899. static Color4: Color4[];
  5900. }
  5901. }
  5902. declare module "babylonjs/Animations/animationKey" {
  5903. /**
  5904. * Defines an interface which represents an animation key frame
  5905. */
  5906. export interface IAnimationKey {
  5907. /**
  5908. * Frame of the key frame
  5909. */
  5910. frame: number;
  5911. /**
  5912. * Value at the specifies key frame
  5913. */
  5914. value: any;
  5915. /**
  5916. * The input tangent for the cubic hermite spline
  5917. */
  5918. inTangent?: any;
  5919. /**
  5920. * The output tangent for the cubic hermite spline
  5921. */
  5922. outTangent?: any;
  5923. /**
  5924. * The animation interpolation type
  5925. */
  5926. interpolation?: AnimationKeyInterpolation;
  5927. }
  5928. /**
  5929. * Enum for the animation key frame interpolation type
  5930. */
  5931. export enum AnimationKeyInterpolation {
  5932. /**
  5933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5934. */
  5935. STEP = 1
  5936. }
  5937. }
  5938. declare module "babylonjs/Animations/animationRange" {
  5939. /**
  5940. * Represents the range of an animation
  5941. */
  5942. export class AnimationRange {
  5943. /**The name of the animation range**/
  5944. name: string;
  5945. /**The starting frame of the animation */
  5946. from: number;
  5947. /**The ending frame of the animation*/
  5948. to: number;
  5949. /**
  5950. * Initializes the range of an animation
  5951. * @param name The name of the animation range
  5952. * @param from The starting frame of the animation
  5953. * @param to The ending frame of the animation
  5954. */
  5955. constructor(
  5956. /**The name of the animation range**/
  5957. name: string,
  5958. /**The starting frame of the animation */
  5959. from: number,
  5960. /**The ending frame of the animation*/
  5961. to: number);
  5962. /**
  5963. * Makes a copy of the animation range
  5964. * @returns A copy of the animation range
  5965. */
  5966. clone(): AnimationRange;
  5967. }
  5968. }
  5969. declare module "babylonjs/Animations/animationEvent" {
  5970. /**
  5971. * Composed of a frame, and an action function
  5972. */
  5973. export class AnimationEvent {
  5974. /** The frame for which the event is triggered **/
  5975. frame: number;
  5976. /** The event to perform when triggered **/
  5977. action: (currentFrame: number) => void;
  5978. /** Specifies if the event should be triggered only once**/
  5979. onlyOnce?: boolean | undefined;
  5980. /**
  5981. * Specifies if the animation event is done
  5982. */
  5983. isDone: boolean;
  5984. /**
  5985. * Initializes the animation event
  5986. * @param frame The frame for which the event is triggered
  5987. * @param action The event to perform when triggered
  5988. * @param onlyOnce Specifies if the event should be triggered only once
  5989. */
  5990. constructor(
  5991. /** The frame for which the event is triggered **/
  5992. frame: number,
  5993. /** The event to perform when triggered **/
  5994. action: (currentFrame: number) => void,
  5995. /** Specifies if the event should be triggered only once**/
  5996. onlyOnce?: boolean | undefined);
  5997. /** @hidden */
  5998. _clone(): AnimationEvent;
  5999. }
  6000. }
  6001. declare module "babylonjs/Behaviors/behavior" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * Interface used to define a behavior
  6005. */
  6006. export interface Behavior<T> {
  6007. /** gets or sets behavior's name */
  6008. name: string;
  6009. /**
  6010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6011. */
  6012. init(): void;
  6013. /**
  6014. * Called when the behavior is attached to a target
  6015. * @param target defines the target where the behavior is attached to
  6016. */
  6017. attach(target: T): void;
  6018. /**
  6019. * Called when the behavior is detached from its target
  6020. */
  6021. detach(): void;
  6022. }
  6023. /**
  6024. * Interface implemented by classes supporting behaviors
  6025. */
  6026. export interface IBehaviorAware<T> {
  6027. /**
  6028. * Attach a behavior
  6029. * @param behavior defines the behavior to attach
  6030. * @returns the current host
  6031. */
  6032. addBehavior(behavior: Behavior<T>): T;
  6033. /**
  6034. * Remove a behavior from the current object
  6035. * @param behavior defines the behavior to detach
  6036. * @returns the current host
  6037. */
  6038. removeBehavior(behavior: Behavior<T>): T;
  6039. /**
  6040. * Gets a behavior using its name to search
  6041. * @param name defines the name to search
  6042. * @returns the behavior or null if not found
  6043. */
  6044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6045. }
  6046. }
  6047. declare module "babylonjs/Misc/smartArray" {
  6048. /**
  6049. * Defines an array and its length.
  6050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6051. */
  6052. export interface ISmartArrayLike<T> {
  6053. /**
  6054. * The data of the array.
  6055. */
  6056. data: Array<T>;
  6057. /**
  6058. * The active length of the array.
  6059. */
  6060. length: number;
  6061. }
  6062. /**
  6063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6064. */
  6065. export class SmartArray<T> implements ISmartArrayLike<T> {
  6066. /**
  6067. * The full set of data from the array.
  6068. */
  6069. data: Array<T>;
  6070. /**
  6071. * The active length of the array.
  6072. */
  6073. length: number;
  6074. protected _id: number;
  6075. /**
  6076. * Instantiates a Smart Array.
  6077. * @param capacity defines the default capacity of the array.
  6078. */
  6079. constructor(capacity: number);
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * @param value defines the object to push in the array.
  6083. */
  6084. push(value: T): void;
  6085. /**
  6086. * Iterates over the active data and apply the lambda to them.
  6087. * @param func defines the action to apply on each value.
  6088. */
  6089. forEach(func: (content: T) => void): void;
  6090. /**
  6091. * Sorts the full sets of data.
  6092. * @param compareFn defines the comparison function to apply.
  6093. */
  6094. sort(compareFn: (a: T, b: T) => number): void;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Releases all the data from the array as well as the array.
  6101. */
  6102. dispose(): void;
  6103. /**
  6104. * Concats the active data with a given array.
  6105. * @param array defines the data to concatenate with.
  6106. */
  6107. concat(array: any): void;
  6108. /**
  6109. * Returns the position of a value in the active data.
  6110. * @param value defines the value to find the index for
  6111. * @returns the index if found in the active data otherwise -1
  6112. */
  6113. indexOf(value: T): number;
  6114. /**
  6115. * Returns whether an element is part of the active data.
  6116. * @param value defines the value to look for
  6117. * @returns true if found in the active data otherwise false
  6118. */
  6119. contains(value: T): boolean;
  6120. private static _GlobalId;
  6121. }
  6122. /**
  6123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6124. * The data in this array can only be present once
  6125. */
  6126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6127. private _duplicateId;
  6128. /**
  6129. * Pushes a value at the end of the active data.
  6130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6131. * @param value defines the object to push in the array.
  6132. */
  6133. push(value: T): void;
  6134. /**
  6135. * Pushes a value at the end of the active data.
  6136. * If the data is already present, it won t be added again
  6137. * @param value defines the object to push in the array.
  6138. * @returns true if added false if it was already present
  6139. */
  6140. pushNoDuplicate(value: T): boolean;
  6141. /**
  6142. * Resets the active data to an empty array.
  6143. */
  6144. reset(): void;
  6145. /**
  6146. * Concats the active data with a given array.
  6147. * This ensures no dupplicate will be present in the result.
  6148. * @param array defines the data to concatenate with.
  6149. */
  6150. concatWithNoDuplicate(array: any): void;
  6151. }
  6152. }
  6153. declare module "babylonjs/Cameras/cameraInputsManager" {
  6154. import { Nullable } from "babylonjs/types";
  6155. import { Camera } from "babylonjs/Cameras/camera";
  6156. /**
  6157. * @ignore
  6158. * This is a list of all the different input types that are available in the application.
  6159. * Fo instance: ArcRotateCameraGamepadInput...
  6160. */
  6161. export var CameraInputTypes: {};
  6162. /**
  6163. * This is the contract to implement in order to create a new input class.
  6164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6165. */
  6166. export interface ICameraInput<TCamera extends Camera> {
  6167. /**
  6168. * Defines the camera the input is attached to.
  6169. */
  6170. camera: Nullable<TCamera>;
  6171. /**
  6172. * Gets the class name of the current intput.
  6173. * @returns the class name
  6174. */
  6175. getClassName(): string;
  6176. /**
  6177. * Get the friendly name associated with the input class.
  6178. * @returns the input friendly name
  6179. */
  6180. getSimpleName(): string;
  6181. /**
  6182. * Attach the input controls to a specific dom element to get the input from.
  6183. * @param element Defines the element the controls should be listened from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current controls from the specified dom element.
  6189. * @param element Defines the element to stop listening the inputs from
  6190. */
  6191. detachControl(element: Nullable<HTMLElement>): void;
  6192. /**
  6193. * Update the current camera state depending on the inputs that have been used this frame.
  6194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6195. */
  6196. checkInputs?: () => void;
  6197. }
  6198. /**
  6199. * Represents a map of input types to input instance or input index to input instance.
  6200. */
  6201. export interface CameraInputsMap<TCamera extends Camera> {
  6202. /**
  6203. * Accessor to the input by input type.
  6204. */
  6205. [name: string]: ICameraInput<TCamera>;
  6206. /**
  6207. * Accessor to the input by input index.
  6208. */
  6209. [idx: number]: ICameraInput<TCamera>;
  6210. }
  6211. /**
  6212. * This represents the input manager used within a camera.
  6213. * It helps dealing with all the different kind of input attached to a camera.
  6214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6215. */
  6216. export class CameraInputsManager<TCamera extends Camera> {
  6217. /**
  6218. * Defines the list of inputs attahed to the camera.
  6219. */
  6220. attached: CameraInputsMap<TCamera>;
  6221. /**
  6222. * Defines the dom element the camera is collecting inputs from.
  6223. * This is null if the controls have not been attached.
  6224. */
  6225. attachedElement: Nullable<HTMLElement>;
  6226. /**
  6227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. noPreventDefault: boolean;
  6230. /**
  6231. * Defined the camera the input manager belongs to.
  6232. */
  6233. camera: TCamera;
  6234. /**
  6235. * Update the current camera state depending on the inputs that have been used this frame.
  6236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6237. */
  6238. checkInputs: () => void;
  6239. /**
  6240. * Instantiate a new Camera Input Manager.
  6241. * @param camera Defines the camera the input manager blongs to
  6242. */
  6243. constructor(camera: TCamera);
  6244. /**
  6245. * Add an input method to a camera
  6246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6247. * @param input camera input method
  6248. */
  6249. add(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Remove a specific input method from a camera
  6252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6253. * @param inputToRemove camera input method
  6254. */
  6255. remove(inputToRemove: ICameraInput<TCamera>): void;
  6256. /**
  6257. * Remove a specific input type from a camera
  6258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6259. * @param inputType the type of the input to remove
  6260. */
  6261. removeByType(inputType: string): void;
  6262. private _addCheckInputs;
  6263. /**
  6264. * Attach the input controls to the currently attached dom element to listen the events from.
  6265. * @param input Defines the input to attach
  6266. */
  6267. attachInput(input: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6270. * @param element Defines the dom element to collect the events from
  6271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6272. */
  6273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6274. /**
  6275. * Detach the current manager inputs controls from a specific dom element.
  6276. * @param element Defines the dom element to collect the events from
  6277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6278. */
  6279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6280. /**
  6281. * Rebuild the dynamic inputCheck function from the current list of
  6282. * defined inputs in the manager.
  6283. */
  6284. rebuildInputCheck(): void;
  6285. /**
  6286. * Remove all attached input methods from a camera
  6287. */
  6288. clear(): void;
  6289. /**
  6290. * Serialize the current input manager attached to a camera.
  6291. * This ensures than once parsed,
  6292. * the input associated to the camera will be identical to the current ones
  6293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6294. */
  6295. serialize(serializedCamera: any): void;
  6296. /**
  6297. * Parses an input manager serialized JSON to restore the previous list of inputs
  6298. * and states associated to a camera.
  6299. * @param parsedCamera Defines the JSON to parse
  6300. */
  6301. parse(parsedCamera: any): void;
  6302. }
  6303. }
  6304. declare module "babylonjs/Meshes/buffer" {
  6305. import { Nullable, DataArray } from "babylonjs/types";
  6306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6307. /**
  6308. * Class used to store data that will be store in GPU memory
  6309. */
  6310. export class Buffer {
  6311. private _engine;
  6312. private _buffer;
  6313. /** @hidden */
  6314. _data: Nullable<DataArray>;
  6315. private _updatable;
  6316. private _instanced;
  6317. private _divisor;
  6318. /**
  6319. * Gets the byte stride.
  6320. */
  6321. readonly byteStride: number;
  6322. /**
  6323. * Constructor
  6324. * @param engine the engine
  6325. * @param data the data to use for this buffer
  6326. * @param updatable whether the data is updatable
  6327. * @param stride the stride (optional)
  6328. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6329. * @param instanced whether the buffer is instanced (optional)
  6330. * @param useBytes set to true if the stride in in bytes (optional)
  6331. * @param divisor sets an optional divisor for instances (1 by default)
  6332. */
  6333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6334. /**
  6335. * Create a new VertexBuffer based on the current buffer
  6336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6337. * @param offset defines offset in the buffer (0 by default)
  6338. * @param size defines the size in floats of attributes (position is 3 for instance)
  6339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6340. * @param instanced defines if the vertex buffer contains indexed data
  6341. * @param useBytes defines if the offset and stride are in bytes *
  6342. * @param divisor sets an optional divisor for instances (1 by default)
  6343. * @returns the new vertex buffer
  6344. */
  6345. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6346. /**
  6347. * Gets a boolean indicating if the Buffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * @returns the stride in float32 units
  6365. * @deprecated Please use byteStride instead.
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6370. * @param data defines the data to store
  6371. */
  6372. create(data?: Nullable<DataArray>): void;
  6373. /** @hidden */
  6374. _rebuild(): void;
  6375. /**
  6376. * Update current buffer data
  6377. * @param data defines the data to store
  6378. */
  6379. update(data: DataArray): void;
  6380. /**
  6381. * Updates the data directly.
  6382. * @param data the new data
  6383. * @param offset the new offset
  6384. * @param vertexCount the vertex count (optional)
  6385. * @param useBytes set to true if the offset is in bytes
  6386. */
  6387. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6388. /**
  6389. * Release all resources
  6390. */
  6391. dispose(): void;
  6392. }
  6393. /**
  6394. * Specialized buffer used to store vertex data
  6395. */
  6396. export class VertexBuffer {
  6397. /** @hidden */
  6398. _buffer: Buffer;
  6399. private _kind;
  6400. private _size;
  6401. private _ownsBuffer;
  6402. private _instanced;
  6403. private _instanceDivisor;
  6404. /**
  6405. * The byte type.
  6406. */
  6407. static readonly BYTE: number;
  6408. /**
  6409. * The unsigned byte type.
  6410. */
  6411. static readonly UNSIGNED_BYTE: number;
  6412. /**
  6413. * The short type.
  6414. */
  6415. static readonly SHORT: number;
  6416. /**
  6417. * The unsigned short type.
  6418. */
  6419. static readonly UNSIGNED_SHORT: number;
  6420. /**
  6421. * The integer type.
  6422. */
  6423. static readonly INT: number;
  6424. /**
  6425. * The unsigned integer type.
  6426. */
  6427. static readonly UNSIGNED_INT: number;
  6428. /**
  6429. * The float type.
  6430. */
  6431. static readonly FLOAT: number;
  6432. /**
  6433. * Gets or sets the instance divisor when in instanced mode
  6434. */
  6435. get instanceDivisor(): number;
  6436. set instanceDivisor(value: number);
  6437. /**
  6438. * Gets the byte stride.
  6439. */
  6440. readonly byteStride: number;
  6441. /**
  6442. * Gets the byte offset.
  6443. */
  6444. readonly byteOffset: number;
  6445. /**
  6446. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6447. */
  6448. readonly normalized: boolean;
  6449. /**
  6450. * Gets the data type of each component in the array.
  6451. */
  6452. readonly type: number;
  6453. /**
  6454. * Constructor
  6455. * @param engine the engine
  6456. * @param data the data to use for this vertex buffer
  6457. * @param kind the vertex buffer kind
  6458. * @param updatable whether the data is updatable
  6459. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6460. * @param stride the stride (optional)
  6461. * @param instanced whether the buffer is instanced (optional)
  6462. * @param offset the offset of the data (optional)
  6463. * @param size the number of components (optional)
  6464. * @param type the type of the component (optional)
  6465. * @param normalized whether the data contains normalized data (optional)
  6466. * @param useBytes set to true if stride and offset are in bytes (optional)
  6467. * @param divisor defines the instance divisor to use (1 by default)
  6468. */
  6469. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6470. /** @hidden */
  6471. _rebuild(): void;
  6472. /**
  6473. * Returns the kind of the VertexBuffer (string)
  6474. * @returns a string
  6475. */
  6476. getKind(): string;
  6477. /**
  6478. * Gets a boolean indicating if the VertexBuffer is updatable?
  6479. * @returns true if the buffer is updatable
  6480. */
  6481. isUpdatable(): boolean;
  6482. /**
  6483. * Gets current buffer's data
  6484. * @returns a DataArray or null
  6485. */
  6486. getData(): Nullable<DataArray>;
  6487. /**
  6488. * Gets underlying native buffer
  6489. * @returns underlying native buffer
  6490. */
  6491. getBuffer(): Nullable<DataBuffer>;
  6492. /**
  6493. * Gets the stride in float32 units (i.e. byte stride / 4).
  6494. * May not be an integer if the byte stride is not divisible by 4.
  6495. * @returns the stride in float32 units
  6496. * @deprecated Please use byteStride instead.
  6497. */
  6498. getStrideSize(): number;
  6499. /**
  6500. * Returns the offset as a multiple of the type byte length.
  6501. * @returns the offset in bytes
  6502. * @deprecated Please use byteOffset instead.
  6503. */
  6504. getOffset(): number;
  6505. /**
  6506. * Returns the number of components per vertex attribute (integer)
  6507. * @returns the size in float
  6508. */
  6509. getSize(): number;
  6510. /**
  6511. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6512. * @returns true if this buffer is instanced
  6513. */
  6514. getIsInstanced(): boolean;
  6515. /**
  6516. * Returns the instancing divisor, zero for non-instanced (integer).
  6517. * @returns a number
  6518. */
  6519. getInstanceDivisor(): number;
  6520. /**
  6521. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6522. * @param data defines the data to store
  6523. */
  6524. create(data?: DataArray): void;
  6525. /**
  6526. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6527. * This function will create a new buffer if the current one is not updatable
  6528. * @param data defines the data to store
  6529. */
  6530. update(data: DataArray): void;
  6531. /**
  6532. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6533. * Returns the directly updated WebGLBuffer.
  6534. * @param data the new data
  6535. * @param offset the new offset
  6536. * @param useBytes set to true if the offset is in bytes
  6537. */
  6538. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6539. /**
  6540. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6541. */
  6542. dispose(): void;
  6543. /**
  6544. * Enumerates each value of this vertex buffer as numbers.
  6545. * @param count the number of values to enumerate
  6546. * @param callback the callback function called for each value
  6547. */
  6548. forEach(count: number, callback: (value: number, index: number) => void): void;
  6549. /**
  6550. * Positions
  6551. */
  6552. static readonly PositionKind: string;
  6553. /**
  6554. * Normals
  6555. */
  6556. static readonly NormalKind: string;
  6557. /**
  6558. * Tangents
  6559. */
  6560. static readonly TangentKind: string;
  6561. /**
  6562. * Texture coordinates
  6563. */
  6564. static readonly UVKind: string;
  6565. /**
  6566. * Texture coordinates 2
  6567. */
  6568. static readonly UV2Kind: string;
  6569. /**
  6570. * Texture coordinates 3
  6571. */
  6572. static readonly UV3Kind: string;
  6573. /**
  6574. * Texture coordinates 4
  6575. */
  6576. static readonly UV4Kind: string;
  6577. /**
  6578. * Texture coordinates 5
  6579. */
  6580. static readonly UV5Kind: string;
  6581. /**
  6582. * Texture coordinates 6
  6583. */
  6584. static readonly UV6Kind: string;
  6585. /**
  6586. * Colors
  6587. */
  6588. static readonly ColorKind: string;
  6589. /**
  6590. * Matrix indices (for bones)
  6591. */
  6592. static readonly MatricesIndicesKind: string;
  6593. /**
  6594. * Matrix weights (for bones)
  6595. */
  6596. static readonly MatricesWeightsKind: string;
  6597. /**
  6598. * Additional matrix indices (for bones)
  6599. */
  6600. static readonly MatricesIndicesExtraKind: string;
  6601. /**
  6602. * Additional matrix weights (for bones)
  6603. */
  6604. static readonly MatricesWeightsExtraKind: string;
  6605. /**
  6606. * Deduces the stride given a kind.
  6607. * @param kind The kind string to deduce
  6608. * @returns The deduced stride
  6609. */
  6610. static DeduceStride(kind: string): number;
  6611. /**
  6612. * Gets the byte length of the given type.
  6613. * @param type the type
  6614. * @returns the number of bytes
  6615. */
  6616. static GetTypeByteLength(type: number): number;
  6617. /**
  6618. * Enumerates each value of the given parameters as numbers.
  6619. * @param data the data to enumerate
  6620. * @param byteOffset the byte offset of the data
  6621. * @param byteStride the byte stride of the data
  6622. * @param componentCount the number of components per element
  6623. * @param componentType the type of the component
  6624. * @param count the number of values to enumerate
  6625. * @param normalized whether the data is normalized
  6626. * @param callback the callback function called for each value
  6627. */
  6628. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6629. private static _GetFloatValue;
  6630. }
  6631. }
  6632. declare module "babylonjs/Collisions/intersectionInfo" {
  6633. import { Nullable } from "babylonjs/types";
  6634. /**
  6635. * @hidden
  6636. */
  6637. export class IntersectionInfo {
  6638. bu: Nullable<number>;
  6639. bv: Nullable<number>;
  6640. distance: number;
  6641. faceId: number;
  6642. subMeshId: number;
  6643. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6644. }
  6645. }
  6646. declare module "babylonjs/Maths/math.plane" {
  6647. import { DeepImmutable } from "babylonjs/types";
  6648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6649. /**
  6650. * Represens a plane by the equation ax + by + cz + d = 0
  6651. */
  6652. export class Plane {
  6653. private static _TmpMatrix;
  6654. /**
  6655. * Normal of the plane (a,b,c)
  6656. */
  6657. normal: Vector3;
  6658. /**
  6659. * d component of the plane
  6660. */
  6661. d: number;
  6662. /**
  6663. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6664. * @param a a component of the plane
  6665. * @param b b component of the plane
  6666. * @param c c component of the plane
  6667. * @param d d component of the plane
  6668. */
  6669. constructor(a: number, b: number, c: number, d: number);
  6670. /**
  6671. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6672. */
  6673. asArray(): number[];
  6674. /**
  6675. * @returns a new plane copied from the current Plane.
  6676. */
  6677. clone(): Plane;
  6678. /**
  6679. * @returns the string "Plane".
  6680. */
  6681. getClassName(): string;
  6682. /**
  6683. * @returns the Plane hash code.
  6684. */
  6685. getHashCode(): number;
  6686. /**
  6687. * Normalize the current Plane in place.
  6688. * @returns the updated Plane.
  6689. */
  6690. normalize(): Plane;
  6691. /**
  6692. * Applies a transformation the plane and returns the result
  6693. * @param transformation the transformation matrix to be applied to the plane
  6694. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6695. */
  6696. transform(transformation: DeepImmutable<Matrix>): Plane;
  6697. /**
  6698. * Calcualtte the dot product between the point and the plane normal
  6699. * @param point point to calculate the dot product with
  6700. * @returns the dot product (float) of the point coordinates and the plane normal.
  6701. */
  6702. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6703. /**
  6704. * Updates the current Plane from the plane defined by the three given points.
  6705. * @param point1 one of the points used to contruct the plane
  6706. * @param point2 one of the points used to contruct the plane
  6707. * @param point3 one of the points used to contruct the plane
  6708. * @returns the updated Plane.
  6709. */
  6710. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6711. /**
  6712. * Checks if the plane is facing a given direction
  6713. * @param direction the direction to check if the plane is facing
  6714. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6715. * @returns True is the vector "direction" is the same side than the plane normal.
  6716. */
  6717. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6718. /**
  6719. * Calculates the distance to a point
  6720. * @param point point to calculate distance to
  6721. * @returns the signed distance (float) from the given point to the Plane.
  6722. */
  6723. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6724. /**
  6725. * Creates a plane from an array
  6726. * @param array the array to create a plane from
  6727. * @returns a new Plane from the given array.
  6728. */
  6729. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6730. /**
  6731. * Creates a plane from three points
  6732. * @param point1 point used to create the plane
  6733. * @param point2 point used to create the plane
  6734. * @param point3 point used to create the plane
  6735. * @returns a new Plane defined by the three given points.
  6736. */
  6737. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6738. /**
  6739. * Creates a plane from an origin point and a normal
  6740. * @param origin origin of the plane to be constructed
  6741. * @param normal normal of the plane to be constructed
  6742. * @returns a new Plane the normal vector to this plane at the given origin point.
  6743. * Note : the vector "normal" is updated because normalized.
  6744. */
  6745. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6746. /**
  6747. * Calculates the distance from a plane and a point
  6748. * @param origin origin of the plane to be constructed
  6749. * @param normal normal of the plane to be constructed
  6750. * @param point point to calculate distance to
  6751. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6752. */
  6753. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6754. }
  6755. }
  6756. declare module "babylonjs/Culling/boundingSphere" {
  6757. import { DeepImmutable } from "babylonjs/types";
  6758. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6759. import { Plane } from "babylonjs/Maths/math.plane";
  6760. /**
  6761. * Class used to store bounding sphere information
  6762. */
  6763. export class BoundingSphere {
  6764. /**
  6765. * Gets the center of the bounding sphere in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Radius of the bounding sphere in local space
  6770. */
  6771. radius: number;
  6772. /**
  6773. * Gets the center of the bounding sphere in world space
  6774. */
  6775. readonly centerWorld: Vector3;
  6776. /**
  6777. * Radius of the bounding sphere in world space
  6778. */
  6779. radiusWorld: number;
  6780. /**
  6781. * Gets the minimum vector in local space
  6782. */
  6783. readonly minimum: Vector3;
  6784. /**
  6785. * Gets the maximum vector in local space
  6786. */
  6787. readonly maximum: Vector3;
  6788. private _worldMatrix;
  6789. private static readonly TmpVector3;
  6790. /**
  6791. * Creates a new bounding sphere
  6792. * @param min defines the minimum vector (in local space)
  6793. * @param max defines the maximum vector (in local space)
  6794. * @param worldMatrix defines the new world matrix
  6795. */
  6796. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6797. /**
  6798. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6799. * @param min defines the new minimum vector (in local space)
  6800. * @param max defines the new maximum vector (in local space)
  6801. * @param worldMatrix defines the new world matrix
  6802. */
  6803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Scale the current bounding sphere by applying a scale factor
  6806. * @param factor defines the scale factor to apply
  6807. * @returns the current bounding box
  6808. */
  6809. scale(factor: number): BoundingSphere;
  6810. /**
  6811. * Gets the world matrix of the bounding box
  6812. * @returns a matrix
  6813. */
  6814. getWorldMatrix(): DeepImmutable<Matrix>;
  6815. /** @hidden */
  6816. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6817. /**
  6818. * Tests if the bounding sphere is intersecting the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an intersection
  6821. */
  6822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if the bounding sphere center is in between the frustum planes.
  6825. * Used for optimistic fast inclusion.
  6826. * @param frustumPlanes defines the frustum planes to test
  6827. * @returns true if the sphere center is in between the frustum planes
  6828. */
  6829. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6830. /**
  6831. * Tests if a point is inside the bounding sphere
  6832. * @param point defines the point to test
  6833. * @returns true if the point is inside the bounding sphere
  6834. */
  6835. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6836. /**
  6837. * Checks if two sphere intersct
  6838. * @param sphere0 sphere 0
  6839. * @param sphere1 sphere 1
  6840. * @returns true if the speres intersect
  6841. */
  6842. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Culling/boundingBox" {
  6846. import { DeepImmutable } from "babylonjs/types";
  6847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6848. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6849. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6850. import { Plane } from "babylonjs/Maths/math.plane";
  6851. /**
  6852. * Class used to store bounding box information
  6853. */
  6854. export class BoundingBox implements ICullable {
  6855. /**
  6856. * Gets the 8 vectors representing the bounding box in local space
  6857. */
  6858. readonly vectors: Vector3[];
  6859. /**
  6860. * Gets the center of the bounding box in local space
  6861. */
  6862. readonly center: Vector3;
  6863. /**
  6864. * Gets the center of the bounding box in world space
  6865. */
  6866. readonly centerWorld: Vector3;
  6867. /**
  6868. * Gets the extend size in local space
  6869. */
  6870. readonly extendSize: Vector3;
  6871. /**
  6872. * Gets the extend size in world space
  6873. */
  6874. readonly extendSizeWorld: Vector3;
  6875. /**
  6876. * Gets the OBB (object bounding box) directions
  6877. */
  6878. readonly directions: Vector3[];
  6879. /**
  6880. * Gets the 8 vectors representing the bounding box in world space
  6881. */
  6882. readonly vectorsWorld: Vector3[];
  6883. /**
  6884. * Gets the minimum vector in world space
  6885. */
  6886. readonly minimumWorld: Vector3;
  6887. /**
  6888. * Gets the maximum vector in world space
  6889. */
  6890. readonly maximumWorld: Vector3;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * @hidden
  6903. */
  6904. _tag: number;
  6905. /**
  6906. * Creates a new bounding box
  6907. * @param min defines the minimum vector (in local space)
  6908. * @param max defines the maximum vector (in local space)
  6909. * @param worldMatrix defines the new world matrix
  6910. */
  6911. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6912. /**
  6913. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6914. * @param min defines the new minimum vector (in local space)
  6915. * @param max defines the new maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6919. /**
  6920. * Scale the current bounding box by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding box
  6923. */
  6924. scale(factor: number): BoundingBox;
  6925. /**
  6926. * Gets the world matrix of the bounding box
  6927. * @returns a matrix
  6928. */
  6929. getWorldMatrix(): DeepImmutable<Matrix>;
  6930. /** @hidden */
  6931. _update(world: DeepImmutable<Matrix>): void;
  6932. /**
  6933. * Tests if the bounding box is intersecting the frustum planes
  6934. * @param frustumPlanes defines the frustum planes to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /**
  6939. * Tests if the bounding box is entirely inside the frustum planes
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if there is an inclusion
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding box
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding box
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Tests if the bounding box intersects with a bounding sphere
  6952. * @param sphere defines the sphere to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6956. /**
  6957. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6958. * @param min defines the min vector to use
  6959. * @param max defines the max vector to use
  6960. * @returns true if there is an intersection
  6961. */
  6962. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Tests if two bounding boxes are intersections
  6965. * @param box0 defines the first box to test
  6966. * @param box1 defines the second box to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6970. /**
  6971. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6972. * @param minPoint defines the minimum vector of the bounding box
  6973. * @param maxPoint defines the maximum vector of the bounding box
  6974. * @param sphereCenter defines the sphere center
  6975. * @param sphereRadius defines the sphere radius
  6976. * @returns true if there is an intersection
  6977. */
  6978. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6979. /**
  6980. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6982. * @param frustumPlanes defines the frustum planes to test
  6983. * @return true if there is an inclusion
  6984. */
  6985. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6986. /**
  6987. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6988. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6989. * @param frustumPlanes defines the frustum planes to test
  6990. * @return true if there is an intersection
  6991. */
  6992. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6993. }
  6994. }
  6995. declare module "babylonjs/Collisions/collider" {
  6996. import { Nullable, IndicesArray } from "babylonjs/types";
  6997. import { Vector3 } from "babylonjs/Maths/math.vector";
  6998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6999. import { Plane } from "babylonjs/Maths/math.plane";
  7000. /** @hidden */
  7001. export class Collider {
  7002. /** Define if a collision was found */
  7003. collisionFound: boolean;
  7004. /**
  7005. * Define last intersection point in local space
  7006. */
  7007. intersectionPoint: Vector3;
  7008. /**
  7009. * Define last collided mesh
  7010. */
  7011. collidedMesh: Nullable<AbstractMesh>;
  7012. private _collisionPoint;
  7013. private _planeIntersectionPoint;
  7014. private _tempVector;
  7015. private _tempVector2;
  7016. private _tempVector3;
  7017. private _tempVector4;
  7018. private _edge;
  7019. private _baseToVertex;
  7020. private _destinationPoint;
  7021. private _slidePlaneNormal;
  7022. private _displacementVector;
  7023. /** @hidden */
  7024. _radius: Vector3;
  7025. /** @hidden */
  7026. _retry: number;
  7027. private _velocity;
  7028. private _basePoint;
  7029. private _epsilon;
  7030. /** @hidden */
  7031. _velocityWorldLength: number;
  7032. /** @hidden */
  7033. _basePointWorld: Vector3;
  7034. private _velocityWorld;
  7035. private _normalizedVelocity;
  7036. /** @hidden */
  7037. _initialVelocity: Vector3;
  7038. /** @hidden */
  7039. _initialPosition: Vector3;
  7040. private _nearestDistance;
  7041. private _collisionMask;
  7042. get collisionMask(): number;
  7043. set collisionMask(mask: number);
  7044. /**
  7045. * Gets the plane normal used to compute the sliding response (in local space)
  7046. */
  7047. get slidePlaneNormal(): Vector3;
  7048. /** @hidden */
  7049. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7050. /** @hidden */
  7051. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7052. /** @hidden */
  7053. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7054. /** @hidden */
  7055. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7056. /** @hidden */
  7057. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7058. /** @hidden */
  7059. _getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module "babylonjs/Culling/boundingInfo" {
  7063. import { DeepImmutable } from "babylonjs/types";
  7064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7065. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7066. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7067. import { Plane } from "babylonjs/Maths/math.plane";
  7068. import { Collider } from "babylonjs/Collisions/collider";
  7069. /**
  7070. * Interface for cullable objects
  7071. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7072. */
  7073. export interface ICullable {
  7074. /**
  7075. * Checks if the object or part of the object is in the frustum
  7076. * @param frustumPlanes Camera near/planes
  7077. * @returns true if the object is in frustum otherwise false
  7078. */
  7079. isInFrustum(frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Checks if a cullable object (mesh...) is in the camera frustum
  7082. * Unlike isInFrustum this cheks the full bounding box
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7087. }
  7088. /**
  7089. * Info for a bounding data of a mesh
  7090. */
  7091. export class BoundingInfo implements ICullable {
  7092. /**
  7093. * Bounding box for the mesh
  7094. */
  7095. readonly boundingBox: BoundingBox;
  7096. /**
  7097. * Bounding sphere for the mesh
  7098. */
  7099. readonly boundingSphere: BoundingSphere;
  7100. private _isLocked;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * Constructs bounding info
  7104. * @param minimum min vector of the bounding box/sphere
  7105. * @param maximum max vector of the bounding box/sphere
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7109. /**
  7110. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7111. * @param min defines the new minimum vector (in local space)
  7112. * @param max defines the new maximum vector (in local space)
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * min vector of the bounding box/sphere
  7118. */
  7119. get minimum(): Vector3;
  7120. /**
  7121. * max vector of the bounding box/sphere
  7122. */
  7123. get maximum(): Vector3;
  7124. /**
  7125. * If the info is locked and won't be updated to avoid perf overhead
  7126. */
  7127. get isLocked(): boolean;
  7128. set isLocked(value: boolean);
  7129. /**
  7130. * Updates the bounding sphere and box
  7131. * @param world world matrix to be used to update
  7132. */
  7133. update(world: DeepImmutable<Matrix>): void;
  7134. /**
  7135. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7136. * @param center New center of the bounding info
  7137. * @param extend New extend of the bounding info
  7138. * @returns the current bounding info
  7139. */
  7140. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7141. /**
  7142. * Scale the current bounding info by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding info
  7145. */
  7146. scale(factor: number): BoundingInfo;
  7147. /**
  7148. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7149. * @param frustumPlanes defines the frustum to test
  7150. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7151. * @returns true if the bounding info is in the frustum planes
  7152. */
  7153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7154. /**
  7155. * Gets the world distance between the min and max points of the bounding box
  7156. */
  7157. get diagonalLength(): number;
  7158. /**
  7159. * Checks if a cullable object (mesh...) is in the camera frustum
  7160. * Unlike isInFrustum this cheks the full bounding box
  7161. * @param frustumPlanes Camera near/planes
  7162. * @returns true if the object is in frustum otherwise false
  7163. */
  7164. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /** @hidden */
  7166. _checkCollision(collider: Collider): boolean;
  7167. /**
  7168. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7169. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7170. * @param point the point to check intersection with
  7171. * @returns if the point intersects
  7172. */
  7173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7174. /**
  7175. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param boundingInfo the bounding info to check intersection with
  7178. * @param precise if the intersection should be done using OBB
  7179. * @returns if the bounding info intersects
  7180. */
  7181. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Maths/math.functions" {
  7185. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7187. /**
  7188. * Extracts minimum and maximum values from a list of indexed positions
  7189. * @param positions defines the positions to use
  7190. * @param indices defines the indices to the positions
  7191. * @param indexStart defines the start index
  7192. * @param indexCount defines the end index
  7193. * @param bias defines bias value to add to the result
  7194. * @return minimum and maximum values
  7195. */
  7196. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7197. minimum: Vector3;
  7198. maximum: Vector3;
  7199. };
  7200. /**
  7201. * Extracts minimum and maximum values from a list of positions
  7202. * @param positions defines the positions to use
  7203. * @param start defines the start index in the positions array
  7204. * @param count defines the number of positions to handle
  7205. * @param bias defines bias value to add to the result
  7206. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. }
  7214. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7216. /** @hidden */
  7217. export class WebGLDataBuffer extends DataBuffer {
  7218. private _buffer;
  7219. constructor(resource: WebGLBuffer);
  7220. get underlyingResource(): any;
  7221. }
  7222. }
  7223. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7225. import { Nullable } from "babylonjs/types";
  7226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7227. /** @hidden */
  7228. export class WebGLPipelineContext implements IPipelineContext {
  7229. engine: ThinEngine;
  7230. program: Nullable<WebGLProgram>;
  7231. context?: WebGLRenderingContext;
  7232. vertexShader?: WebGLShader;
  7233. fragmentShader?: WebGLShader;
  7234. isParallelCompiled: boolean;
  7235. onCompiled?: () => void;
  7236. transformFeedback?: WebGLTransformFeedback | null;
  7237. vertexCompilationError: Nullable<string>;
  7238. fragmentCompilationError: Nullable<string>;
  7239. programLinkError: Nullable<string>;
  7240. programValidationError: Nullable<string>;
  7241. get isAsync(): boolean;
  7242. get isReady(): boolean;
  7243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7244. _getVertexShaderCode(): string | null;
  7245. _getFragmentShaderCode(): string | null;
  7246. }
  7247. }
  7248. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7249. import { FloatArray, Nullable } from "babylonjs/types";
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. module "babylonjs/Engines/thinEngine" {
  7253. interface ThinEngine {
  7254. /**
  7255. * Create an uniform buffer
  7256. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7257. * @param elements defines the content of the uniform buffer
  7258. * @returns the webGL uniform buffer
  7259. */
  7260. createUniformBuffer(elements: FloatArray): DataBuffer;
  7261. /**
  7262. * Create a dynamic uniform buffer
  7263. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7264. * @param elements defines the content of the uniform buffer
  7265. * @returns the webGL uniform buffer
  7266. */
  7267. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7268. /**
  7269. * Update an existing uniform buffer
  7270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7271. * @param uniformBuffer defines the target uniform buffer
  7272. * @param elements defines the content to update
  7273. * @param offset defines the offset in the uniform buffer where update should start
  7274. * @param count defines the size of the data to update
  7275. */
  7276. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7277. /**
  7278. * Bind an uniform buffer to the current webGL context
  7279. * @param buffer defines the buffer to bind
  7280. */
  7281. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7282. /**
  7283. * Bind a buffer to the current webGL context at a given location
  7284. * @param buffer defines the buffer to bind
  7285. * @param location defines the index where to bind the buffer
  7286. */
  7287. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7288. /**
  7289. * Bind a specific block at a given index in a specific shader program
  7290. * @param pipelineContext defines the pipeline context to use
  7291. * @param blockName defines the block name
  7292. * @param index defines the index where to bind the block
  7293. */
  7294. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7295. }
  7296. }
  7297. }
  7298. declare module "babylonjs/Materials/uniformBuffer" {
  7299. import { Nullable, FloatArray } from "babylonjs/types";
  7300. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7301. import { Engine } from "babylonjs/Engines/engine";
  7302. import { Effect } from "babylonjs/Materials/effect";
  7303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7304. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7305. import { Color3 } from "babylonjs/Maths/math.color";
  7306. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7307. /**
  7308. * Uniform buffer objects.
  7309. *
  7310. * Handles blocks of uniform on the GPU.
  7311. *
  7312. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7313. *
  7314. * For more information, please refer to :
  7315. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7316. */
  7317. export class UniformBuffer {
  7318. private _engine;
  7319. private _buffer;
  7320. private _data;
  7321. private _bufferData;
  7322. private _dynamic?;
  7323. private _uniformLocations;
  7324. private _uniformSizes;
  7325. private _uniformLocationPointer;
  7326. private _needSync;
  7327. private _noUBO;
  7328. private _currentEffect;
  7329. /** @hidden */
  7330. _alreadyBound: boolean;
  7331. private static _MAX_UNIFORM_SIZE;
  7332. private static _tempBuffer;
  7333. /**
  7334. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7339. /**
  7340. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7345. /**
  7346. * Lambda to Update a single float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat: (name: string, x: number) => void;
  7351. /**
  7352. * Lambda to Update a vec2 of float in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7357. /**
  7358. * Lambda to Update a vec3 of float in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7363. /**
  7364. * Lambda to Update a vec4 of float in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7369. /**
  7370. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateMatrix: (name: string, mat: Matrix) => void;
  7375. /**
  7376. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateVector3: (name: string, vector: Vector3) => void;
  7381. /**
  7382. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7383. * This is dynamic to allow compat with webgl 1 and 2.
  7384. * You will need to pass the name of the uniform as well as the value.
  7385. */
  7386. updateVector4: (name: string, vector: Vector4) => void;
  7387. /**
  7388. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7389. * This is dynamic to allow compat with webgl 1 and 2.
  7390. * You will need to pass the name of the uniform as well as the value.
  7391. */
  7392. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7393. /**
  7394. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7395. * This is dynamic to allow compat with webgl 1 and 2.
  7396. * You will need to pass the name of the uniform as well as the value.
  7397. */
  7398. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7399. /**
  7400. * Instantiates a new Uniform buffer objects.
  7401. *
  7402. * Handles blocks of uniform on the GPU.
  7403. *
  7404. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7405. *
  7406. * For more information, please refer to :
  7407. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7408. * @param engine Define the engine the buffer is associated with
  7409. * @param data Define the data contained in the buffer
  7410. * @param dynamic Define if the buffer is updatable
  7411. */
  7412. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7413. /**
  7414. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7415. * or just falling back on setUniformXXX calls.
  7416. */
  7417. get useUbo(): boolean;
  7418. /**
  7419. * Indicates if the WebGL underlying uniform buffer is in sync
  7420. * with the javascript cache data.
  7421. */
  7422. get isSync(): boolean;
  7423. /**
  7424. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7425. * Also, a dynamic UniformBuffer will disable cache verification and always
  7426. * update the underlying WebGL uniform buffer to the GPU.
  7427. * @returns if Dynamic, otherwise false
  7428. */
  7429. isDynamic(): boolean;
  7430. /**
  7431. * The data cache on JS side.
  7432. * @returns the underlying data as a float array
  7433. */
  7434. getData(): Float32Array;
  7435. /**
  7436. * The underlying WebGL Uniform buffer.
  7437. * @returns the webgl buffer
  7438. */
  7439. getBuffer(): Nullable<DataBuffer>;
  7440. /**
  7441. * std140 layout specifies how to align data within an UBO structure.
  7442. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7443. * for specs.
  7444. */
  7445. private _fillAlignment;
  7446. /**
  7447. * Adds an uniform in the buffer.
  7448. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7449. * for the layout to be correct !
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. * @param size Data size, or data directly.
  7452. */
  7453. addUniform(name: string, size: number | number[]): void;
  7454. /**
  7455. * Adds a Matrix 4x4 to the uniform buffer.
  7456. * @param name Name of the uniform, as used in the uniform block in the shader.
  7457. * @param mat A 4x4 matrix.
  7458. */
  7459. addMatrix(name: string, mat: Matrix): void;
  7460. /**
  7461. * Adds a vec2 to the uniform buffer.
  7462. * @param name Name of the uniform, as used in the uniform block in the shader.
  7463. * @param x Define the x component value of the vec2
  7464. * @param y Define the y component value of the vec2
  7465. */
  7466. addFloat2(name: string, x: number, y: number): void;
  7467. /**
  7468. * Adds a vec3 to the uniform buffer.
  7469. * @param name Name of the uniform, as used in the uniform block in the shader.
  7470. * @param x Define the x component value of the vec3
  7471. * @param y Define the y component value of the vec3
  7472. * @param z Define the z component value of the vec3
  7473. */
  7474. addFloat3(name: string, x: number, y: number, z: number): void;
  7475. /**
  7476. * Adds a vec3 to the uniform buffer.
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param color Define the vec3 from a Color
  7479. */
  7480. addColor3(name: string, color: Color3): void;
  7481. /**
  7482. * Adds a vec4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param color Define the rgb components from a Color
  7485. * @param alpha Define the a component of the vec4
  7486. */
  7487. addColor4(name: string, color: Color3, alpha: number): void;
  7488. /**
  7489. * Adds a vec3 to the uniform buffer.
  7490. * @param name Name of the uniform, as used in the uniform block in the shader.
  7491. * @param vector Define the vec3 components from a Vector
  7492. */
  7493. addVector3(name: string, vector: Vector3): void;
  7494. /**
  7495. * Adds a Matrix 3x3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. */
  7498. addMatrix3x3(name: string): void;
  7499. /**
  7500. * Adds a Matrix 2x2 to the uniform buffer.
  7501. * @param name Name of the uniform, as used in the uniform block in the shader.
  7502. */
  7503. addMatrix2x2(name: string): void;
  7504. /**
  7505. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7506. */
  7507. create(): void;
  7508. /** @hidden */
  7509. _rebuild(): void;
  7510. /**
  7511. * Updates the WebGL Uniform Buffer on the GPU.
  7512. * If the `dynamic` flag is set to true, no cache comparison is done.
  7513. * Otherwise, the buffer will be updated only if the cache differs.
  7514. */
  7515. update(): void;
  7516. /**
  7517. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7518. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7519. * @param data Define the flattened data
  7520. * @param size Define the size of the data.
  7521. */
  7522. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7523. private _valueCache;
  7524. private _cacheMatrix;
  7525. private _updateMatrix3x3ForUniform;
  7526. private _updateMatrix3x3ForEffect;
  7527. private _updateMatrix2x2ForEffect;
  7528. private _updateMatrix2x2ForUniform;
  7529. private _updateFloatForEffect;
  7530. private _updateFloatForUniform;
  7531. private _updateFloat2ForEffect;
  7532. private _updateFloat2ForUniform;
  7533. private _updateFloat3ForEffect;
  7534. private _updateFloat3ForUniform;
  7535. private _updateFloat4ForEffect;
  7536. private _updateFloat4ForUniform;
  7537. private _updateMatrixForEffect;
  7538. private _updateMatrixForUniform;
  7539. private _updateVector3ForEffect;
  7540. private _updateVector3ForUniform;
  7541. private _updateVector4ForEffect;
  7542. private _updateVector4ForUniform;
  7543. private _updateColor3ForEffect;
  7544. private _updateColor3ForUniform;
  7545. private _updateColor4ForEffect;
  7546. private _updateColor4ForUniform;
  7547. /**
  7548. * Sets a sampler uniform on the effect.
  7549. * @param name Define the name of the sampler.
  7550. * @param texture Define the texture to set in the sampler
  7551. */
  7552. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7553. /**
  7554. * Directly updates the value of the uniform in the cache AND on the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. */
  7558. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7559. /**
  7560. * Binds this uniform buffer to an effect.
  7561. * @param effect Define the effect to bind the buffer to
  7562. * @param name Name of the uniform block in the shader.
  7563. */
  7564. bindToEffect(effect: Effect, name: string): void;
  7565. /**
  7566. * Disposes the uniform buffer.
  7567. */
  7568. dispose(): void;
  7569. }
  7570. }
  7571. declare module "babylonjs/Misc/iInspectable" {
  7572. /**
  7573. * Enum that determines the text-wrapping mode to use.
  7574. */
  7575. export enum InspectableType {
  7576. /**
  7577. * Checkbox for booleans
  7578. */
  7579. Checkbox = 0,
  7580. /**
  7581. * Sliders for numbers
  7582. */
  7583. Slider = 1,
  7584. /**
  7585. * Vector3
  7586. */
  7587. Vector3 = 2,
  7588. /**
  7589. * Quaternions
  7590. */
  7591. Quaternion = 3,
  7592. /**
  7593. * Color3
  7594. */
  7595. Color3 = 4,
  7596. /**
  7597. * String
  7598. */
  7599. String = 5
  7600. }
  7601. /**
  7602. * Interface used to define custom inspectable properties.
  7603. * This interface is used by the inspector to display custom property grids
  7604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7605. */
  7606. export interface IInspectable {
  7607. /**
  7608. * Gets the label to display
  7609. */
  7610. label: string;
  7611. /**
  7612. * Gets the name of the property to edit
  7613. */
  7614. propertyName: string;
  7615. /**
  7616. * Gets the type of the editor to use
  7617. */
  7618. type: InspectableType;
  7619. /**
  7620. * Gets the minimum value of the property when using in "slider" mode
  7621. */
  7622. min?: number;
  7623. /**
  7624. * Gets the maximum value of the property when using in "slider" mode
  7625. */
  7626. max?: number;
  7627. /**
  7628. * Gets the setp to use when using in "slider" mode
  7629. */
  7630. step?: number;
  7631. }
  7632. }
  7633. declare module "babylonjs/Misc/timingTools" {
  7634. /**
  7635. * Class used to provide helper for timing
  7636. */
  7637. export class TimingTools {
  7638. /**
  7639. * Polyfill for setImmediate
  7640. * @param action defines the action to execute after the current execution block
  7641. */
  7642. static SetImmediate(action: () => void): void;
  7643. }
  7644. }
  7645. declare module "babylonjs/Misc/instantiationTools" {
  7646. /**
  7647. * Class used to enable instatition of objects by class name
  7648. */
  7649. export class InstantiationTools {
  7650. /**
  7651. * Use this object to register external classes like custom textures or material
  7652. * to allow the laoders to instantiate them
  7653. */
  7654. static RegisteredExternalClasses: {
  7655. [key: string]: Object;
  7656. };
  7657. /**
  7658. * Tries to instantiate a new object from a given class name
  7659. * @param className defines the class name to instantiate
  7660. * @returns the new object or null if the system was not able to do the instantiation
  7661. */
  7662. static Instantiate(className: string): any;
  7663. }
  7664. }
  7665. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7666. /**
  7667. * Define options used to create a depth texture
  7668. */
  7669. export class DepthTextureCreationOptions {
  7670. /** Specifies whether or not a stencil should be allocated in the texture */
  7671. generateStencil?: boolean;
  7672. /** Specifies whether or not bilinear filtering is enable on the texture */
  7673. bilinearFiltering?: boolean;
  7674. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7675. comparisonFunction?: number;
  7676. /** Specifies if the created texture is a cube texture */
  7677. isCube?: boolean;
  7678. }
  7679. }
  7680. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7681. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7682. import { Nullable } from "babylonjs/types";
  7683. import { Scene } from "babylonjs/scene";
  7684. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7685. module "babylonjs/Engines/thinEngine" {
  7686. interface ThinEngine {
  7687. /**
  7688. * Creates a depth stencil cube texture.
  7689. * This is only available in WebGL 2.
  7690. * @param size The size of face edge in the cube texture.
  7691. * @param options The options defining the cube texture.
  7692. * @returns The cube texture
  7693. */
  7694. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7695. /**
  7696. * Creates a cube texture
  7697. * @param rootUrl defines the url where the files to load is located
  7698. * @param scene defines the current scene
  7699. * @param files defines the list of files to load (1 per face)
  7700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7701. * @param onLoad defines an optional callback raised when the texture is loaded
  7702. * @param onError defines an optional callback raised if there is an issue to load the texture
  7703. * @param format defines the format of the data
  7704. * @param forcedExtension defines the extension to use to pick the right loader
  7705. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7706. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7707. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7708. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7709. * @returns the cube texture as an InternalTexture
  7710. */
  7711. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7712. /**
  7713. * Creates a cube texture
  7714. * @param rootUrl defines the url where the files to load is located
  7715. * @param scene defines the current scene
  7716. * @param files defines the list of files to load (1 per face)
  7717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7718. * @param onLoad defines an optional callback raised when the texture is loaded
  7719. * @param onError defines an optional callback raised if there is an issue to load the texture
  7720. * @param format defines the format of the data
  7721. * @param forcedExtension defines the extension to use to pick the right loader
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7725. /**
  7726. * Creates a cube texture
  7727. * @param rootUrl defines the url where the files to load is located
  7728. * @param scene defines the current scene
  7729. * @param files defines the list of files to load (1 per face)
  7730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7731. * @param onLoad defines an optional callback raised when the texture is loaded
  7732. * @param onError defines an optional callback raised if there is an issue to load the texture
  7733. * @param format defines the format of the data
  7734. * @param forcedExtension defines the extension to use to pick the right loader
  7735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @returns the cube texture as an InternalTexture
  7739. */
  7740. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7741. /** @hidden */
  7742. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7747. /** @hidden */
  7748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7749. /**
  7750. * @hidden
  7751. */
  7752. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7753. }
  7754. }
  7755. }
  7756. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7757. import { Nullable } from "babylonjs/types";
  7758. import { Scene } from "babylonjs/scene";
  7759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7761. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7762. import { Observable } from "babylonjs/Misc/observable";
  7763. /**
  7764. * Class for creating a cube texture
  7765. */
  7766. export class CubeTexture extends BaseTexture {
  7767. private _delayedOnLoad;
  7768. /**
  7769. * Observable triggered once the texture has been loaded.
  7770. */
  7771. onLoadObservable: Observable<CubeTexture>;
  7772. /**
  7773. * The url of the texture
  7774. */
  7775. url: string;
  7776. /**
  7777. * Gets or sets the center of the bounding box associated with the cube texture.
  7778. * It must define where the camera used to render the texture was set
  7779. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7780. */
  7781. boundingBoxPosition: Vector3;
  7782. private _boundingBoxSize;
  7783. /**
  7784. * Gets or sets the size of the bounding box associated with the cube texture
  7785. * When defined, the cubemap will switch to local mode
  7786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7787. * @example https://www.babylonjs-playground.com/#RNASML
  7788. */
  7789. set boundingBoxSize(value: Vector3);
  7790. /**
  7791. * Returns the bounding box size
  7792. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7793. */
  7794. get boundingBoxSize(): Vector3;
  7795. protected _rotationY: number;
  7796. /**
  7797. * Sets texture matrix rotation angle around Y axis in radians.
  7798. */
  7799. set rotationY(value: number);
  7800. /**
  7801. * Gets texture matrix rotation angle around Y axis radians.
  7802. */
  7803. get rotationY(): number;
  7804. /**
  7805. * Are mip maps generated for this texture or not.
  7806. */
  7807. get noMipmap(): boolean;
  7808. private _noMipmap;
  7809. private _files;
  7810. protected _forcedExtension: Nullable<string>;
  7811. private _extensions;
  7812. private _textureMatrix;
  7813. private _format;
  7814. private _createPolynomials;
  7815. /** @hidden */
  7816. _prefiltered: boolean;
  7817. /**
  7818. * Creates a cube texture from an array of image urls
  7819. * @param files defines an array of image urls
  7820. * @param scene defines the hosting scene
  7821. * @param noMipmap specifies if mip maps are not used
  7822. * @returns a cube texture
  7823. */
  7824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7825. /**
  7826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7827. * @param url defines the url of the prefiltered texture
  7828. * @param scene defines the scene the texture is attached to
  7829. * @param forcedExtension defines the extension of the file if different from the url
  7830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7831. * @return the prefiltered texture
  7832. */
  7833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7834. /**
  7835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7836. * as prefiltered data.
  7837. * @param rootUrl defines the url of the texture or the root name of the six images
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7840. * @param noMipmap defines if mipmaps should be created or not
  7841. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7843. * @param onError defines a callback triggered in case of error during load
  7844. * @param format defines the internal format to use for the texture once loaded
  7845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7850. * @return the cube texture
  7851. */
  7852. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7853. /**
  7854. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7855. */
  7856. get isPrefiltered(): boolean;
  7857. /**
  7858. * Get the current class name of the texture useful for serialization or dynamic coding.
  7859. * @returns "CubeTexture"
  7860. */
  7861. getClassName(): string;
  7862. /**
  7863. * Update the url (and optional buffer) of this texture if url was null during construction.
  7864. * @param url the url of the texture
  7865. * @param forcedExtension defines the extension to use
  7866. * @param onLoad callback called when the texture is loaded (defaults to null)
  7867. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7868. */
  7869. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7870. /**
  7871. * Delays loading of the cube texture
  7872. * @param forcedExtension defines the extension to use
  7873. */
  7874. delayLoad(forcedExtension?: string): void;
  7875. /**
  7876. * Returns the reflection texture matrix
  7877. * @returns the reflection texture matrix
  7878. */
  7879. getReflectionTextureMatrix(): Matrix;
  7880. /**
  7881. * Sets the reflection texture matrix
  7882. * @param value Reflection texture matrix
  7883. */
  7884. setReflectionTextureMatrix(value: Matrix): void;
  7885. /**
  7886. * Parses text to create a cube texture
  7887. * @param parsedTexture define the serialized text to read from
  7888. * @param scene defines the hosting scene
  7889. * @param rootUrl defines the root url of the cube texture
  7890. * @returns a cube texture
  7891. */
  7892. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7893. /**
  7894. * Makes a clone, or deep copy, of the cube texture
  7895. * @returns a new cube texture
  7896. */
  7897. clone(): CubeTexture;
  7898. }
  7899. }
  7900. declare module "babylonjs/Materials/materialDefines" {
  7901. /**
  7902. * Manages the defines for the Material
  7903. */
  7904. export class MaterialDefines {
  7905. /** @hidden */
  7906. protected _keys: string[];
  7907. private _isDirty;
  7908. /** @hidden */
  7909. _renderId: number;
  7910. /** @hidden */
  7911. _areLightsDirty: boolean;
  7912. /** @hidden */
  7913. _areLightsDisposed: boolean;
  7914. /** @hidden */
  7915. _areAttributesDirty: boolean;
  7916. /** @hidden */
  7917. _areTexturesDirty: boolean;
  7918. /** @hidden */
  7919. _areFresnelDirty: boolean;
  7920. /** @hidden */
  7921. _areMiscDirty: boolean;
  7922. /** @hidden */
  7923. _areImageProcessingDirty: boolean;
  7924. /** @hidden */
  7925. _normals: boolean;
  7926. /** @hidden */
  7927. _uvs: boolean;
  7928. /** @hidden */
  7929. _needNormals: boolean;
  7930. /** @hidden */
  7931. _needUVs: boolean;
  7932. [id: string]: any;
  7933. /**
  7934. * Specifies if the material needs to be re-calculated
  7935. */
  7936. get isDirty(): boolean;
  7937. /**
  7938. * Marks the material to indicate that it has been re-calculated
  7939. */
  7940. markAsProcessed(): void;
  7941. /**
  7942. * Marks the material to indicate that it needs to be re-calculated
  7943. */
  7944. markAsUnprocessed(): void;
  7945. /**
  7946. * Marks the material to indicate all of its defines need to be re-calculated
  7947. */
  7948. markAllAsDirty(): void;
  7949. /**
  7950. * Marks the material to indicate that image processing needs to be re-calculated
  7951. */
  7952. markAsImageProcessingDirty(): void;
  7953. /**
  7954. * Marks the material to indicate the lights need to be re-calculated
  7955. * @param disposed Defines whether the light is dirty due to dispose or not
  7956. */
  7957. markAsLightDirty(disposed?: boolean): void;
  7958. /**
  7959. * Marks the attribute state as changed
  7960. */
  7961. markAsAttributesDirty(): void;
  7962. /**
  7963. * Marks the texture state as changed
  7964. */
  7965. markAsTexturesDirty(): void;
  7966. /**
  7967. * Marks the fresnel state as changed
  7968. */
  7969. markAsFresnelDirty(): void;
  7970. /**
  7971. * Marks the misc state as changed
  7972. */
  7973. markAsMiscDirty(): void;
  7974. /**
  7975. * Rebuilds the material defines
  7976. */
  7977. rebuild(): void;
  7978. /**
  7979. * Specifies if two material defines are equal
  7980. * @param other - A material define instance to compare to
  7981. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7982. */
  7983. isEqual(other: MaterialDefines): boolean;
  7984. /**
  7985. * Clones this instance's defines to another instance
  7986. * @param other - material defines to clone values to
  7987. */
  7988. cloneTo(other: MaterialDefines): void;
  7989. /**
  7990. * Resets the material define values
  7991. */
  7992. reset(): void;
  7993. /**
  7994. * Converts the material define values to a string
  7995. * @returns - String of material define information
  7996. */
  7997. toString(): string;
  7998. }
  7999. }
  8000. declare module "babylonjs/Materials/colorCurves" {
  8001. import { Effect } from "babylonjs/Materials/effect";
  8002. /**
  8003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8005. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8007. */
  8008. export class ColorCurves {
  8009. private _dirty;
  8010. private _tempColor;
  8011. private _globalCurve;
  8012. private _highlightsCurve;
  8013. private _midtonesCurve;
  8014. private _shadowsCurve;
  8015. private _positiveCurve;
  8016. private _negativeCurve;
  8017. private _globalHue;
  8018. private _globalDensity;
  8019. private _globalSaturation;
  8020. private _globalExposure;
  8021. /**
  8022. * Gets the global Hue value.
  8023. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8024. */
  8025. get globalHue(): number;
  8026. /**
  8027. * Sets the global Hue value.
  8028. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8029. */
  8030. set globalHue(value: number);
  8031. /**
  8032. * Gets the global Density value.
  8033. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8034. * Values less than zero provide a filter of opposite hue.
  8035. */
  8036. get globalDensity(): number;
  8037. /**
  8038. * Sets the global Density value.
  8039. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8040. * Values less than zero provide a filter of opposite hue.
  8041. */
  8042. set globalDensity(value: number);
  8043. /**
  8044. * Gets the global Saturation value.
  8045. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8046. */
  8047. get globalSaturation(): number;
  8048. /**
  8049. * Sets the global Saturation value.
  8050. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8051. */
  8052. set globalSaturation(value: number);
  8053. /**
  8054. * Gets the global Exposure value.
  8055. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8056. */
  8057. get globalExposure(): number;
  8058. /**
  8059. * Sets the global Exposure value.
  8060. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8061. */
  8062. set globalExposure(value: number);
  8063. private _highlightsHue;
  8064. private _highlightsDensity;
  8065. private _highlightsSaturation;
  8066. private _highlightsExposure;
  8067. /**
  8068. * Gets the highlights Hue value.
  8069. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8070. */
  8071. get highlightsHue(): number;
  8072. /**
  8073. * Sets the highlights Hue value.
  8074. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8075. */
  8076. set highlightsHue(value: number);
  8077. /**
  8078. * Gets the highlights Density value.
  8079. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get highlightsDensity(): number;
  8083. /**
  8084. * Sets the highlights Density value.
  8085. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set highlightsDensity(value: number);
  8089. /**
  8090. * Gets the highlights Saturation value.
  8091. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8092. */
  8093. get highlightsSaturation(): number;
  8094. /**
  8095. * Sets the highlights Saturation value.
  8096. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8097. */
  8098. set highlightsSaturation(value: number);
  8099. /**
  8100. * Gets the highlights Exposure value.
  8101. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8102. */
  8103. get highlightsExposure(): number;
  8104. /**
  8105. * Sets the highlights Exposure value.
  8106. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8107. */
  8108. set highlightsExposure(value: number);
  8109. private _midtonesHue;
  8110. private _midtonesDensity;
  8111. private _midtonesSaturation;
  8112. private _midtonesExposure;
  8113. /**
  8114. * Gets the midtones Hue value.
  8115. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8116. */
  8117. get midtonesHue(): number;
  8118. /**
  8119. * Sets the midtones Hue value.
  8120. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8121. */
  8122. set midtonesHue(value: number);
  8123. /**
  8124. * Gets the midtones Density value.
  8125. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get midtonesDensity(): number;
  8129. /**
  8130. * Sets the midtones Density value.
  8131. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set midtonesDensity(value: number);
  8135. /**
  8136. * Gets the midtones Saturation value.
  8137. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8138. */
  8139. get midtonesSaturation(): number;
  8140. /**
  8141. * Sets the midtones Saturation value.
  8142. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8143. */
  8144. set midtonesSaturation(value: number);
  8145. /**
  8146. * Gets the midtones Exposure value.
  8147. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8148. */
  8149. get midtonesExposure(): number;
  8150. /**
  8151. * Sets the midtones Exposure value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8153. */
  8154. set midtonesExposure(value: number);
  8155. private _shadowsHue;
  8156. private _shadowsDensity;
  8157. private _shadowsSaturation;
  8158. private _shadowsExposure;
  8159. /**
  8160. * Gets the shadows Hue value.
  8161. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8162. */
  8163. get shadowsHue(): number;
  8164. /**
  8165. * Sets the shadows Hue value.
  8166. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8167. */
  8168. set shadowsHue(value: number);
  8169. /**
  8170. * Gets the shadows Density value.
  8171. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get shadowsDensity(): number;
  8175. /**
  8176. * Sets the shadows Density value.
  8177. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set shadowsDensity(value: number);
  8181. /**
  8182. * Gets the shadows Saturation value.
  8183. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8184. */
  8185. get shadowsSaturation(): number;
  8186. /**
  8187. * Sets the shadows Saturation value.
  8188. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8189. */
  8190. set shadowsSaturation(value: number);
  8191. /**
  8192. * Gets the shadows Exposure value.
  8193. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8194. */
  8195. get shadowsExposure(): number;
  8196. /**
  8197. * Sets the shadows Exposure value.
  8198. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8199. */
  8200. set shadowsExposure(value: number);
  8201. /**
  8202. * Returns the class name
  8203. * @returns The class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Binds the color curves to the shader.
  8208. * @param colorCurves The color curve to bind
  8209. * @param effect The effect to bind to
  8210. * @param positiveUniform The positive uniform shader parameter
  8211. * @param neutralUniform The neutral uniform shader parameter
  8212. * @param negativeUniform The negative uniform shader parameter
  8213. */
  8214. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8215. /**
  8216. * Prepare the list of uniforms associated with the ColorCurves effects.
  8217. * @param uniformsList The list of uniforms used in the effect
  8218. */
  8219. static PrepareUniforms(uniformsList: string[]): void;
  8220. /**
  8221. * Returns color grading data based on a hue, density, saturation and exposure value.
  8222. * @param filterHue The hue of the color filter.
  8223. * @param filterDensity The density of the color filter.
  8224. * @param saturation The saturation.
  8225. * @param exposure The exposure.
  8226. * @param result The result data container.
  8227. */
  8228. private getColorGradingDataToRef;
  8229. /**
  8230. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8231. * @param value The input slider value in range [-100,100].
  8232. * @returns Adjusted value.
  8233. */
  8234. private static applyColorGradingSliderNonlinear;
  8235. /**
  8236. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8237. * @param hue The hue (H) input.
  8238. * @param saturation The saturation (S) input.
  8239. * @param brightness The brightness (B) input.
  8240. * @result An RGBA color represented as Vector4.
  8241. */
  8242. private static fromHSBToRef;
  8243. /**
  8244. * Returns a value clamped between min and max
  8245. * @param value The value to clamp
  8246. * @param min The minimum of value
  8247. * @param max The maximum of value
  8248. * @returns The clamped value.
  8249. */
  8250. private static clamp;
  8251. /**
  8252. * Clones the current color curve instance.
  8253. * @return The cloned curves
  8254. */
  8255. clone(): ColorCurves;
  8256. /**
  8257. * Serializes the current color curve instance to a json representation.
  8258. * @return a JSON representation
  8259. */
  8260. serialize(): any;
  8261. /**
  8262. * Parses the color curve from a json representation.
  8263. * @param source the JSON source to parse
  8264. * @return The parsed curves
  8265. */
  8266. static Parse(source: any): ColorCurves;
  8267. }
  8268. }
  8269. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8270. import { Observable } from "babylonjs/Misc/observable";
  8271. import { Nullable } from "babylonjs/types";
  8272. import { Color4 } from "babylonjs/Maths/math.color";
  8273. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8274. import { Effect } from "babylonjs/Materials/effect";
  8275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8276. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8277. /**
  8278. * Interface to follow in your material defines to integrate easily the
  8279. * Image proccessing functions.
  8280. * @hidden
  8281. */
  8282. export interface IImageProcessingConfigurationDefines {
  8283. IMAGEPROCESSING: boolean;
  8284. VIGNETTE: boolean;
  8285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8286. VIGNETTEBLENDMODEOPAQUE: boolean;
  8287. TONEMAPPING: boolean;
  8288. TONEMAPPING_ACES: boolean;
  8289. CONTRAST: boolean;
  8290. EXPOSURE: boolean;
  8291. COLORCURVES: boolean;
  8292. COLORGRADING: boolean;
  8293. COLORGRADING3D: boolean;
  8294. SAMPLER3DGREENDEPTH: boolean;
  8295. SAMPLER3DBGRMAP: boolean;
  8296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8297. }
  8298. /**
  8299. * @hidden
  8300. */
  8301. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8302. IMAGEPROCESSING: boolean;
  8303. VIGNETTE: boolean;
  8304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8305. VIGNETTEBLENDMODEOPAQUE: boolean;
  8306. TONEMAPPING: boolean;
  8307. TONEMAPPING_ACES: boolean;
  8308. CONTRAST: boolean;
  8309. COLORCURVES: boolean;
  8310. COLORGRADING: boolean;
  8311. COLORGRADING3D: boolean;
  8312. SAMPLER3DGREENDEPTH: boolean;
  8313. SAMPLER3DBGRMAP: boolean;
  8314. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8315. EXPOSURE: boolean;
  8316. constructor();
  8317. }
  8318. /**
  8319. * This groups together the common properties used for image processing either in direct forward pass
  8320. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8321. * or not.
  8322. */
  8323. export class ImageProcessingConfiguration {
  8324. /**
  8325. * Default tone mapping applied in BabylonJS.
  8326. */
  8327. static readonly TONEMAPPING_STANDARD: number;
  8328. /**
  8329. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8330. * to other engines rendering to increase portability.
  8331. */
  8332. static readonly TONEMAPPING_ACES: number;
  8333. /**
  8334. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8335. */
  8336. colorCurves: Nullable<ColorCurves>;
  8337. private _colorCurvesEnabled;
  8338. /**
  8339. * Gets wether the color curves effect is enabled.
  8340. */
  8341. get colorCurvesEnabled(): boolean;
  8342. /**
  8343. * Sets wether the color curves effect is enabled.
  8344. */
  8345. set colorCurvesEnabled(value: boolean);
  8346. private _colorGradingTexture;
  8347. /**
  8348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8349. */
  8350. get colorGradingTexture(): Nullable<BaseTexture>;
  8351. /**
  8352. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8353. */
  8354. set colorGradingTexture(value: Nullable<BaseTexture>);
  8355. private _colorGradingEnabled;
  8356. /**
  8357. * Gets wether the color grading effect is enabled.
  8358. */
  8359. get colorGradingEnabled(): boolean;
  8360. /**
  8361. * Sets wether the color grading effect is enabled.
  8362. */
  8363. set colorGradingEnabled(value: boolean);
  8364. private _colorGradingWithGreenDepth;
  8365. /**
  8366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8367. */
  8368. get colorGradingWithGreenDepth(): boolean;
  8369. /**
  8370. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8371. */
  8372. set colorGradingWithGreenDepth(value: boolean);
  8373. private _colorGradingBGR;
  8374. /**
  8375. * Gets wether the color grading texture contains BGR values.
  8376. */
  8377. get colorGradingBGR(): boolean;
  8378. /**
  8379. * Sets wether the color grading texture contains BGR values.
  8380. */
  8381. set colorGradingBGR(value: boolean);
  8382. /** @hidden */
  8383. _exposure: number;
  8384. /**
  8385. * Gets the Exposure used in the effect.
  8386. */
  8387. get exposure(): number;
  8388. /**
  8389. * Sets the Exposure used in the effect.
  8390. */
  8391. set exposure(value: number);
  8392. private _toneMappingEnabled;
  8393. /**
  8394. * Gets wether the tone mapping effect is enabled.
  8395. */
  8396. get toneMappingEnabled(): boolean;
  8397. /**
  8398. * Sets wether the tone mapping effect is enabled.
  8399. */
  8400. set toneMappingEnabled(value: boolean);
  8401. private _toneMappingType;
  8402. /**
  8403. * Gets the type of tone mapping effect.
  8404. */
  8405. get toneMappingType(): number;
  8406. /**
  8407. * Sets the type of tone mapping effect used in BabylonJS.
  8408. */
  8409. set toneMappingType(value: number);
  8410. protected _contrast: number;
  8411. /**
  8412. * Gets the contrast used in the effect.
  8413. */
  8414. get contrast(): number;
  8415. /**
  8416. * Sets the contrast used in the effect.
  8417. */
  8418. set contrast(value: number);
  8419. /**
  8420. * Vignette stretch size.
  8421. */
  8422. vignetteStretch: number;
  8423. /**
  8424. * Vignette centre X Offset.
  8425. */
  8426. vignetteCentreX: number;
  8427. /**
  8428. * Vignette centre Y Offset.
  8429. */
  8430. vignetteCentreY: number;
  8431. /**
  8432. * Vignette weight or intensity of the vignette effect.
  8433. */
  8434. vignetteWeight: number;
  8435. /**
  8436. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8437. * if vignetteEnabled is set to true.
  8438. */
  8439. vignetteColor: Color4;
  8440. /**
  8441. * Camera field of view used by the Vignette effect.
  8442. */
  8443. vignetteCameraFov: number;
  8444. private _vignetteBlendMode;
  8445. /**
  8446. * Gets the vignette blend mode allowing different kind of effect.
  8447. */
  8448. get vignetteBlendMode(): number;
  8449. /**
  8450. * Sets the vignette blend mode allowing different kind of effect.
  8451. */
  8452. set vignetteBlendMode(value: number);
  8453. private _vignetteEnabled;
  8454. /**
  8455. * Gets wether the vignette effect is enabled.
  8456. */
  8457. get vignetteEnabled(): boolean;
  8458. /**
  8459. * Sets wether the vignette effect is enabled.
  8460. */
  8461. set vignetteEnabled(value: boolean);
  8462. private _applyByPostProcess;
  8463. /**
  8464. * Gets wether the image processing is applied through a post process or not.
  8465. */
  8466. get applyByPostProcess(): boolean;
  8467. /**
  8468. * Sets wether the image processing is applied through a post process or not.
  8469. */
  8470. set applyByPostProcess(value: boolean);
  8471. private _isEnabled;
  8472. /**
  8473. * Gets wether the image processing is enabled or not.
  8474. */
  8475. get isEnabled(): boolean;
  8476. /**
  8477. * Sets wether the image processing is enabled or not.
  8478. */
  8479. set isEnabled(value: boolean);
  8480. /**
  8481. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8482. */
  8483. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8484. /**
  8485. * Method called each time the image processing information changes requires to recompile the effect.
  8486. */
  8487. protected _updateParameters(): void;
  8488. /**
  8489. * Gets the current class name.
  8490. * @return "ImageProcessingConfiguration"
  8491. */
  8492. getClassName(): string;
  8493. /**
  8494. * Prepare the list of uniforms associated with the Image Processing effects.
  8495. * @param uniforms The list of uniforms used in the effect
  8496. * @param defines the list of defines currently in use
  8497. */
  8498. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8499. /**
  8500. * Prepare the list of samplers associated with the Image Processing effects.
  8501. * @param samplersList The list of uniforms used in the effect
  8502. * @param defines the list of defines currently in use
  8503. */
  8504. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8505. /**
  8506. * Prepare the list of defines associated to the shader.
  8507. * @param defines the list of defines to complete
  8508. * @param forPostProcess Define if we are currently in post process mode or not
  8509. */
  8510. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8511. /**
  8512. * Returns true if all the image processing information are ready.
  8513. * @returns True if ready, otherwise, false
  8514. */
  8515. isReady(): boolean;
  8516. /**
  8517. * Binds the image processing to the shader.
  8518. * @param effect The effect to bind to
  8519. * @param overrideAspectRatio Override the aspect ratio of the effect
  8520. */
  8521. bind(effect: Effect, overrideAspectRatio?: number): void;
  8522. /**
  8523. * Clones the current image processing instance.
  8524. * @return The cloned image processing
  8525. */
  8526. clone(): ImageProcessingConfiguration;
  8527. /**
  8528. * Serializes the current image processing instance to a json representation.
  8529. * @return a JSON representation
  8530. */
  8531. serialize(): any;
  8532. /**
  8533. * Parses the image processing from a json representation.
  8534. * @param source the JSON source to parse
  8535. * @return The parsed image processing
  8536. */
  8537. static Parse(source: any): ImageProcessingConfiguration;
  8538. private static _VIGNETTEMODE_MULTIPLY;
  8539. private static _VIGNETTEMODE_OPAQUE;
  8540. /**
  8541. * Used to apply the vignette as a mix with the pixel color.
  8542. */
  8543. static get VIGNETTEMODE_MULTIPLY(): number;
  8544. /**
  8545. * Used to apply the vignette as a replacement of the pixel color.
  8546. */
  8547. static get VIGNETTEMODE_OPAQUE(): number;
  8548. }
  8549. }
  8550. declare module "babylonjs/Shaders/postprocess.vertex" {
  8551. /** @hidden */
  8552. export var postprocessVertexShader: {
  8553. name: string;
  8554. shader: string;
  8555. };
  8556. }
  8557. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8559. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8560. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8561. module "babylonjs/Engines/thinEngine" {
  8562. interface ThinEngine {
  8563. /**
  8564. * Creates a new render target texture
  8565. * @param size defines the size of the texture
  8566. * @param options defines the options used to create the texture
  8567. * @returns a new render target texture stored in an InternalTexture
  8568. */
  8569. createRenderTargetTexture(size: number | {
  8570. width: number;
  8571. height: number;
  8572. layers?: number;
  8573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8574. /**
  8575. * Creates a depth stencil texture.
  8576. * This is only available in WebGL 2 or with the depth texture extension available.
  8577. * @param size The size of face edge in the texture.
  8578. * @param options The options defining the texture.
  8579. * @returns The texture
  8580. */
  8581. createDepthStencilTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: DepthTextureCreationOptions): InternalTexture;
  8586. /** @hidden */
  8587. _createDepthStencilTexture(size: number | {
  8588. width: number;
  8589. height: number;
  8590. layers?: number;
  8591. }, options: DepthTextureCreationOptions): InternalTexture;
  8592. }
  8593. }
  8594. }
  8595. declare module "babylonjs/Maths/math.axis" {
  8596. import { Vector3 } from "babylonjs/Maths/math.vector";
  8597. /** Defines supported spaces */
  8598. export enum Space {
  8599. /** Local (object) space */
  8600. LOCAL = 0,
  8601. /** World space */
  8602. WORLD = 1,
  8603. /** Bone space */
  8604. BONE = 2
  8605. }
  8606. /** Defines the 3 main axes */
  8607. export class Axis {
  8608. /** X axis */
  8609. static X: Vector3;
  8610. /** Y axis */
  8611. static Y: Vector3;
  8612. /** Z axis */
  8613. static Z: Vector3;
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/targetCamera" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { Camera } from "babylonjs/Cameras/camera";
  8619. import { Scene } from "babylonjs/scene";
  8620. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8621. /**
  8622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8623. * This is the base of the follow, arc rotate cameras and Free camera
  8624. * @see http://doc.babylonjs.com/features/cameras
  8625. */
  8626. export class TargetCamera extends Camera {
  8627. private static _RigCamTransformMatrix;
  8628. private static _TargetTransformMatrix;
  8629. private static _TargetFocalPoint;
  8630. /**
  8631. * Define the current direction the camera is moving to
  8632. */
  8633. cameraDirection: Vector3;
  8634. /**
  8635. * Define the current rotation the camera is rotating to
  8636. */
  8637. cameraRotation: Vector2;
  8638. /**
  8639. * When set, the up vector of the camera will be updated by the rotation of the camera
  8640. */
  8641. updateUpVectorFromRotation: boolean;
  8642. private _tmpQuaternion;
  8643. /**
  8644. * Define the current rotation of the camera
  8645. */
  8646. rotation: Vector3;
  8647. /**
  8648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8649. */
  8650. rotationQuaternion: Quaternion;
  8651. /**
  8652. * Define the current speed of the camera
  8653. */
  8654. speed: number;
  8655. /**
  8656. * Add constraint to the camera to prevent it to move freely in all directions and
  8657. * around all axis.
  8658. */
  8659. noRotationConstraint: boolean;
  8660. /**
  8661. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8662. * panning
  8663. */
  8664. invertRotation: boolean;
  8665. /**
  8666. * Speed multiplier for inverse camera panning
  8667. */
  8668. inverseRotationSpeed: number;
  8669. /**
  8670. * Define the current target of the camera as an object or a position.
  8671. */
  8672. lockedTarget: any;
  8673. /** @hidden */
  8674. _currentTarget: Vector3;
  8675. /** @hidden */
  8676. _initialFocalDistance: number;
  8677. /** @hidden */
  8678. _viewMatrix: Matrix;
  8679. /** @hidden */
  8680. _camMatrix: Matrix;
  8681. /** @hidden */
  8682. _cameraTransformMatrix: Matrix;
  8683. /** @hidden */
  8684. _cameraRotationMatrix: Matrix;
  8685. /** @hidden */
  8686. _referencePoint: Vector3;
  8687. /** @hidden */
  8688. _transformedReferencePoint: Vector3;
  8689. protected _globalCurrentTarget: Vector3;
  8690. protected _globalCurrentUpVector: Vector3;
  8691. /** @hidden */
  8692. _reset: () => void;
  8693. private _defaultUp;
  8694. /**
  8695. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8696. * This is the base of the follow, arc rotate cameras and Free camera
  8697. * @see http://doc.babylonjs.com/features/cameras
  8698. * @param name Defines the name of the camera in the scene
  8699. * @param position Defines the start position of the camera in the scene
  8700. * @param scene Defines the scene the camera belongs to
  8701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8702. */
  8703. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8704. /**
  8705. * Gets the position in front of the camera at a given distance.
  8706. * @param distance The distance from the camera we want the position to be
  8707. * @returns the position
  8708. */
  8709. getFrontPosition(distance: number): Vector3;
  8710. /** @hidden */
  8711. _getLockedTargetPosition(): Nullable<Vector3>;
  8712. private _storedPosition;
  8713. private _storedRotation;
  8714. private _storedRotationQuaternion;
  8715. /**
  8716. * Store current camera state of the camera (fov, position, rotation, etc..)
  8717. * @returns the camera
  8718. */
  8719. storeState(): Camera;
  8720. /**
  8721. * Restored camera state. You must call storeState() first
  8722. * @returns whether it was successful or not
  8723. * @hidden
  8724. */
  8725. _restoreStateValues(): boolean;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _updateCache(ignoreParentClass?: boolean): void;
  8730. /** @hidden */
  8731. _isSynchronizedViewMatrix(): boolean;
  8732. /** @hidden */
  8733. _computeLocalCameraSpeed(): number;
  8734. /**
  8735. * Defines the target the camera should look at.
  8736. * @param target Defines the new target as a Vector or a mesh
  8737. */
  8738. setTarget(target: Vector3): void;
  8739. /**
  8740. * Return the current target position of the camera. This value is expressed in local space.
  8741. * @returns the target position
  8742. */
  8743. getTarget(): Vector3;
  8744. /** @hidden */
  8745. _decideIfNeedsToMove(): boolean;
  8746. /** @hidden */
  8747. _updatePosition(): void;
  8748. /** @hidden */
  8749. _checkInputs(): void;
  8750. protected _updateCameraRotationMatrix(): void;
  8751. /**
  8752. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8753. * @returns the current camera
  8754. */
  8755. private _rotateUpVectorWithCameraRotationMatrix;
  8756. private _cachedRotationZ;
  8757. private _cachedQuaternionRotationZ;
  8758. /** @hidden */
  8759. _getViewMatrix(): Matrix;
  8760. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8761. /**
  8762. * @hidden
  8763. */
  8764. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8765. /**
  8766. * @hidden
  8767. */
  8768. _updateRigCameras(): void;
  8769. private _getRigCamPositionAndTarget;
  8770. /**
  8771. * Gets the current object class name.
  8772. * @return the class name
  8773. */
  8774. getClassName(): string;
  8775. }
  8776. }
  8777. declare module "babylonjs/Events/keyboardEvents" {
  8778. /**
  8779. * Gather the list of keyboard event types as constants.
  8780. */
  8781. export class KeyboardEventTypes {
  8782. /**
  8783. * The keydown event is fired when a key becomes active (pressed).
  8784. */
  8785. static readonly KEYDOWN: number;
  8786. /**
  8787. * The keyup event is fired when a key has been released.
  8788. */
  8789. static readonly KEYUP: number;
  8790. }
  8791. /**
  8792. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8793. */
  8794. export class KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Instantiates a new keyboard info.
  8805. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8806. * @param type Defines the type of event (KeyboardEventTypes)
  8807. * @param event Defines the related dom event
  8808. */
  8809. constructor(
  8810. /**
  8811. * Defines the type of event (KeyboardEventTypes)
  8812. */
  8813. type: number,
  8814. /**
  8815. * Defines the related dom event
  8816. */
  8817. event: KeyboardEvent);
  8818. }
  8819. /**
  8820. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8821. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8822. */
  8823. export class KeyboardInfoPre extends KeyboardInfo {
  8824. /**
  8825. * Defines the type of event (KeyboardEventTypes)
  8826. */
  8827. type: number;
  8828. /**
  8829. * Defines the related dom event
  8830. */
  8831. event: KeyboardEvent;
  8832. /**
  8833. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8834. */
  8835. skipOnPointerObservable: boolean;
  8836. /**
  8837. * Instantiates a new keyboard pre info.
  8838. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8839. * @param type Defines the type of event (KeyboardEventTypes)
  8840. * @param event Defines the related dom event
  8841. */
  8842. constructor(
  8843. /**
  8844. * Defines the type of event (KeyboardEventTypes)
  8845. */
  8846. type: number,
  8847. /**
  8848. * Defines the related dom event
  8849. */
  8850. event: KeyboardEvent);
  8851. }
  8852. }
  8853. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8854. import { Nullable } from "babylonjs/types";
  8855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8856. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8857. /**
  8858. * Manage the keyboard inputs to control the movement of a free camera.
  8859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8860. */
  8861. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8862. /**
  8863. * Defines the camera the input is attached to.
  8864. */
  8865. camera: FreeCamera;
  8866. /**
  8867. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8868. */
  8869. keysUp: number[];
  8870. /**
  8871. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8872. */
  8873. keysUpward: number[];
  8874. /**
  8875. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8876. */
  8877. keysDown: number[];
  8878. /**
  8879. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8880. */
  8881. keysDownward: number[];
  8882. /**
  8883. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8884. */
  8885. keysLeft: number[];
  8886. /**
  8887. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8888. */
  8889. keysRight: number[];
  8890. private _keys;
  8891. private _onCanvasBlurObserver;
  8892. private _onKeyboardObserver;
  8893. private _engine;
  8894. private _scene;
  8895. /**
  8896. * Attach the input controls to a specific dom element to get the input from.
  8897. * @param element Defines the element the controls should be listened from
  8898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8899. */
  8900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8901. /**
  8902. * Detach the current controls from the specified dom element.
  8903. * @param element Defines the element to stop listening the inputs from
  8904. */
  8905. detachControl(element: Nullable<HTMLElement>): void;
  8906. /**
  8907. * Update the current camera state depending on the inputs that have been used this frame.
  8908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8909. */
  8910. checkInputs(): void;
  8911. /**
  8912. * Gets the class name of the current intput.
  8913. * @returns the class name
  8914. */
  8915. getClassName(): string;
  8916. /** @hidden */
  8917. _onLostFocus(): void;
  8918. /**
  8919. * Get the friendly name associated with the input class.
  8920. * @returns the input friendly name
  8921. */
  8922. getSimpleName(): string;
  8923. }
  8924. }
  8925. declare module "babylonjs/Lights/shadowLight" {
  8926. import { Camera } from "babylonjs/Cameras/camera";
  8927. import { Scene } from "babylonjs/scene";
  8928. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8930. import { Light } from "babylonjs/Lights/light";
  8931. /**
  8932. * Interface describing all the common properties and methods a shadow light needs to implement.
  8933. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8934. * as well as binding the different shadow properties to the effects.
  8935. */
  8936. export interface IShadowLight extends Light {
  8937. /**
  8938. * The light id in the scene (used in scene.findLighById for instance)
  8939. */
  8940. id: string;
  8941. /**
  8942. * The position the shdow will be casted from.
  8943. */
  8944. position: Vector3;
  8945. /**
  8946. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8947. */
  8948. direction: Vector3;
  8949. /**
  8950. * The transformed position. Position of the light in world space taking parenting in account.
  8951. */
  8952. transformedPosition: Vector3;
  8953. /**
  8954. * The transformed direction. Direction of the light in world space taking parenting in account.
  8955. */
  8956. transformedDirection: Vector3;
  8957. /**
  8958. * The friendly name of the light in the scene.
  8959. */
  8960. name: string;
  8961. /**
  8962. * Defines the shadow projection clipping minimum z value.
  8963. */
  8964. shadowMinZ: number;
  8965. /**
  8966. * Defines the shadow projection clipping maximum z value.
  8967. */
  8968. shadowMaxZ: number;
  8969. /**
  8970. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8971. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8972. */
  8973. computeTransformedInformation(): boolean;
  8974. /**
  8975. * Gets the scene the light belongs to.
  8976. * @returns The scene
  8977. */
  8978. getScene(): Scene;
  8979. /**
  8980. * Callback defining a custom Projection Matrix Builder.
  8981. * This can be used to override the default projection matrix computation.
  8982. */
  8983. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8984. /**
  8985. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8986. * @param matrix The materix to updated with the projection information
  8987. * @param viewMatrix The transform matrix of the light
  8988. * @param renderList The list of mesh to render in the map
  8989. * @returns The current light
  8990. */
  8991. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8992. /**
  8993. * Gets the current depth scale used in ESM.
  8994. * @returns The scale
  8995. */
  8996. getDepthScale(): number;
  8997. /**
  8998. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8999. * @returns true if a cube texture needs to be use
  9000. */
  9001. needCube(): boolean;
  9002. /**
  9003. * Detects if the projection matrix requires to be recomputed this frame.
  9004. * @returns true if it requires to be recomputed otherwise, false.
  9005. */
  9006. needProjectionMatrixCompute(): boolean;
  9007. /**
  9008. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9009. */
  9010. forceProjectionMatrixCompute(): void;
  9011. /**
  9012. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9013. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9014. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9015. */
  9016. getShadowDirection(faceIndex?: number): Vector3;
  9017. /**
  9018. * Gets the minZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the min for
  9020. * @returns the depth min z
  9021. */
  9022. getDepthMinZ(activeCamera: Camera): number;
  9023. /**
  9024. * Gets the maxZ used for shadow according to both the scene and the light.
  9025. * @param activeCamera The camera we are returning the max for
  9026. * @returns the depth max z
  9027. */
  9028. getDepthMaxZ(activeCamera: Camera): number;
  9029. }
  9030. /**
  9031. * Base implementation IShadowLight
  9032. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9033. */
  9034. export abstract class ShadowLight extends Light implements IShadowLight {
  9035. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9036. protected _position: Vector3;
  9037. protected _setPosition(value: Vector3): void;
  9038. /**
  9039. * Sets the position the shadow will be casted from. Also use as the light position for both
  9040. * point and spot lights.
  9041. */
  9042. get position(): Vector3;
  9043. /**
  9044. * Sets the position the shadow will be casted from. Also use as the light position for both
  9045. * point and spot lights.
  9046. */
  9047. set position(value: Vector3);
  9048. protected _direction: Vector3;
  9049. protected _setDirection(value: Vector3): void;
  9050. /**
  9051. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9052. * Also use as the light direction on spot and directional lights.
  9053. */
  9054. get direction(): Vector3;
  9055. /**
  9056. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9057. * Also use as the light direction on spot and directional lights.
  9058. */
  9059. set direction(value: Vector3);
  9060. protected _shadowMinZ: number;
  9061. /**
  9062. * Gets the shadow projection clipping minimum z value.
  9063. */
  9064. get shadowMinZ(): number;
  9065. /**
  9066. * Sets the shadow projection clipping minimum z value.
  9067. */
  9068. set shadowMinZ(value: number);
  9069. protected _shadowMaxZ: number;
  9070. /**
  9071. * Sets the shadow projection clipping maximum z value.
  9072. */
  9073. get shadowMaxZ(): number;
  9074. /**
  9075. * Gets the shadow projection clipping maximum z value.
  9076. */
  9077. set shadowMaxZ(value: number);
  9078. /**
  9079. * Callback defining a custom Projection Matrix Builder.
  9080. * This can be used to override the default projection matrix computation.
  9081. */
  9082. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9083. /**
  9084. * The transformed position. Position of the light in world space taking parenting in account.
  9085. */
  9086. transformedPosition: Vector3;
  9087. /**
  9088. * The transformed direction. Direction of the light in world space taking parenting in account.
  9089. */
  9090. transformedDirection: Vector3;
  9091. private _needProjectionMatrixCompute;
  9092. /**
  9093. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9094. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9095. */
  9096. computeTransformedInformation(): boolean;
  9097. /**
  9098. * Return the depth scale used for the shadow map.
  9099. * @returns the depth scale.
  9100. */
  9101. getDepthScale(): number;
  9102. /**
  9103. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9106. */
  9107. getShadowDirection(faceIndex?: number): Vector3;
  9108. /**
  9109. * Returns the ShadowLight absolute position in the World.
  9110. * @returns the position vector in world space
  9111. */
  9112. getAbsolutePosition(): Vector3;
  9113. /**
  9114. * Sets the ShadowLight direction toward the passed target.
  9115. * @param target The point to target in local space
  9116. * @returns the updated ShadowLight direction
  9117. */
  9118. setDirectionToTarget(target: Vector3): Vector3;
  9119. /**
  9120. * Returns the light rotation in euler definition.
  9121. * @returns the x y z rotation in local space.
  9122. */
  9123. getRotation(): Vector3;
  9124. /**
  9125. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9126. * @returns true if a cube texture needs to be use
  9127. */
  9128. needCube(): boolean;
  9129. /**
  9130. * Detects if the projection matrix requires to be recomputed this frame.
  9131. * @returns true if it requires to be recomputed otherwise, false.
  9132. */
  9133. needProjectionMatrixCompute(): boolean;
  9134. /**
  9135. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9136. */
  9137. forceProjectionMatrixCompute(): void;
  9138. /** @hidden */
  9139. _initCache(): void;
  9140. /** @hidden */
  9141. _isSynchronized(): boolean;
  9142. /**
  9143. * Computes the world matrix of the node
  9144. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9145. * @returns the world matrix
  9146. */
  9147. computeWorldMatrix(force?: boolean): Matrix;
  9148. /**
  9149. * Gets the minZ used for shadow according to both the scene and the light.
  9150. * @param activeCamera The camera we are returning the min for
  9151. * @returns the depth min z
  9152. */
  9153. getDepthMinZ(activeCamera: Camera): number;
  9154. /**
  9155. * Gets the maxZ used for shadow according to both the scene and the light.
  9156. * @param activeCamera The camera we are returning the max for
  9157. * @returns the depth max z
  9158. */
  9159. getDepthMaxZ(activeCamera: Camera): number;
  9160. /**
  9161. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9162. * @param matrix The materix to updated with the projection information
  9163. * @param viewMatrix The transform matrix of the light
  9164. * @param renderList The list of mesh to render in the map
  9165. * @returns The current light
  9166. */
  9167. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9168. }
  9169. }
  9170. declare module "babylonjs/Materials/effectFallbacks" {
  9171. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9172. import { Effect } from "babylonjs/Materials/effect";
  9173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9174. /**
  9175. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9176. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9177. */
  9178. export class EffectFallbacks implements IEffectFallbacks {
  9179. private _defines;
  9180. private _currentRank;
  9181. private _maxRank;
  9182. private _mesh;
  9183. /**
  9184. * Removes the fallback from the bound mesh.
  9185. */
  9186. unBindMesh(): void;
  9187. /**
  9188. * Adds a fallback on the specified property.
  9189. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9190. * @param define The name of the define in the shader
  9191. */
  9192. addFallback(rank: number, define: string): void;
  9193. /**
  9194. * Sets the mesh to use CPU skinning when needing to fallback.
  9195. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9196. * @param mesh The mesh to use the fallbacks.
  9197. */
  9198. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9199. /**
  9200. * Checks to see if more fallbacks are still availible.
  9201. */
  9202. get hasMoreFallbacks(): boolean;
  9203. /**
  9204. * Removes the defines that should be removed when falling back.
  9205. * @param currentDefines defines the current define statements for the shader.
  9206. * @param effect defines the current effect we try to compile
  9207. * @returns The resulting defines with defines of the current rank removed.
  9208. */
  9209. reduce(currentDefines: string, effect: Effect): string;
  9210. }
  9211. }
  9212. declare module "babylonjs/Materials/materialHelper" {
  9213. import { Nullable } from "babylonjs/types";
  9214. import { Scene } from "babylonjs/scene";
  9215. import { Engine } from "babylonjs/Engines/engine";
  9216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9217. import { Light } from "babylonjs/Lights/light";
  9218. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9219. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9222. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9223. /**
  9224. * "Static Class" containing the most commonly used helper while dealing with material for
  9225. * rendering purpose.
  9226. *
  9227. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9228. *
  9229. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9230. */
  9231. export class MaterialHelper {
  9232. /**
  9233. * Bind the current view position to an effect.
  9234. * @param effect The effect to be bound
  9235. * @param scene The scene the eyes position is used from
  9236. */
  9237. static BindEyePosition(effect: Effect, scene: Scene): void;
  9238. /**
  9239. * Helps preparing the defines values about the UVs in used in the effect.
  9240. * UVs are shared as much as we can accross channels in the shaders.
  9241. * @param texture The texture we are preparing the UVs for
  9242. * @param defines The defines to update
  9243. * @param key The channel key "diffuse", "specular"... used in the shader
  9244. */
  9245. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9246. /**
  9247. * Binds a texture matrix value to its corrsponding uniform
  9248. * @param texture The texture to bind the matrix for
  9249. * @param uniformBuffer The uniform buffer receivin the data
  9250. * @param key The channel key "diffuse", "specular"... used in the shader
  9251. */
  9252. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9253. /**
  9254. * Gets the current status of the fog (should it be enabled?)
  9255. * @param mesh defines the mesh to evaluate for fog support
  9256. * @param scene defines the hosting scene
  9257. * @returns true if fog must be enabled
  9258. */
  9259. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9260. /**
  9261. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9262. * @param mesh defines the current mesh
  9263. * @param scene defines the current scene
  9264. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9265. * @param pointsCloud defines if point cloud rendering has to be turned on
  9266. * @param fogEnabled defines if fog has to be turned on
  9267. * @param alphaTest defines if alpha testing has to be turned on
  9268. * @param defines defines the current list of defines
  9269. */
  9270. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9271. /**
  9272. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9273. * @param scene defines the current scene
  9274. * @param engine defines the current engine
  9275. * @param defines specifies the list of active defines
  9276. * @param useInstances defines if instances have to be turned on
  9277. * @param useClipPlane defines if clip plane have to be turned on
  9278. */
  9279. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9280. /**
  9281. * Prepares the defines for bones
  9282. * @param mesh The mesh containing the geometry data we will draw
  9283. * @param defines The defines to update
  9284. */
  9285. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9286. /**
  9287. * Prepares the defines for morph targets
  9288. * @param mesh The mesh containing the geometry data we will draw
  9289. * @param defines The defines to update
  9290. */
  9291. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9292. /**
  9293. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9294. * @param mesh The mesh containing the geometry data we will draw
  9295. * @param defines The defines to update
  9296. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9297. * @param useBones Precise whether bones should be used or not (override mesh info)
  9298. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9299. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9300. * @returns false if defines are considered not dirty and have not been checked
  9301. */
  9302. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9303. /**
  9304. * Prepares the defines related to multiview
  9305. * @param scene The scene we are intending to draw
  9306. * @param defines The defines to update
  9307. */
  9308. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9309. /**
  9310. * Prepares the defines related to the light information passed in parameter
  9311. * @param scene The scene we are intending to draw
  9312. * @param mesh The mesh the effect is compiling for
  9313. * @param light The light the effect is compiling for
  9314. * @param lightIndex The index of the light
  9315. * @param defines The defines to update
  9316. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9317. * @param state Defines the current state regarding what is needed (normals, etc...)
  9318. */
  9319. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9320. needNormals: boolean;
  9321. needRebuild: boolean;
  9322. shadowEnabled: boolean;
  9323. specularEnabled: boolean;
  9324. lightmapMode: boolean;
  9325. }): void;
  9326. /**
  9327. * Prepares the defines related to the light information passed in parameter
  9328. * @param scene The scene we are intending to draw
  9329. * @param mesh The mesh the effect is compiling for
  9330. * @param defines The defines to update
  9331. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9332. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9333. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9334. * @returns true if normals will be required for the rest of the effect
  9335. */
  9336. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9337. /**
  9338. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9339. * @param lightIndex defines the light index
  9340. * @param uniformsList The uniform list
  9341. * @param samplersList The sampler list
  9342. * @param projectedLightTexture defines if projected texture must be used
  9343. * @param uniformBuffersList defines an optional list of uniform buffers
  9344. */
  9345. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9346. /**
  9347. * Prepares the uniforms and samplers list to be used in the effect
  9348. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9349. * @param samplersList The sampler list
  9350. * @param defines The defines helping in the list generation
  9351. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9352. */
  9353. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9354. /**
  9355. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9356. * @param defines The defines to update while falling back
  9357. * @param fallbacks The authorized effect fallbacks
  9358. * @param maxSimultaneousLights The maximum number of lights allowed
  9359. * @param rank the current rank of the Effect
  9360. * @returns The newly affected rank
  9361. */
  9362. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9363. private static _TmpMorphInfluencers;
  9364. /**
  9365. * Prepares the list of attributes required for morph targets according to the effect defines.
  9366. * @param attribs The current list of supported attribs
  9367. * @param mesh The mesh to prepare the morph targets attributes for
  9368. * @param influencers The number of influencers
  9369. */
  9370. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9371. /**
  9372. * Prepares the list of attributes required for morph targets according to the effect defines.
  9373. * @param attribs The current list of supported attribs
  9374. * @param mesh The mesh to prepare the morph targets attributes for
  9375. * @param defines The current Defines of the effect
  9376. */
  9377. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9378. /**
  9379. * Prepares the list of attributes required for bones according to the effect defines.
  9380. * @param attribs The current list of supported attribs
  9381. * @param mesh The mesh to prepare the bones attributes for
  9382. * @param defines The current Defines of the effect
  9383. * @param fallbacks The current efffect fallback strategy
  9384. */
  9385. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9386. /**
  9387. * Check and prepare the list of attributes required for instances according to the effect defines.
  9388. * @param attribs The current list of supported attribs
  9389. * @param defines The current MaterialDefines of the effect
  9390. */
  9391. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9392. /**
  9393. * Add the list of attributes required for instances to the attribs array.
  9394. * @param attribs The current list of supported attribs
  9395. */
  9396. static PushAttributesForInstances(attribs: string[]): void;
  9397. /**
  9398. * Binds the light information to the effect.
  9399. * @param light The light containing the generator
  9400. * @param effect The effect we are binding the data to
  9401. * @param lightIndex The light index in the effect used to render
  9402. */
  9403. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9404. /**
  9405. * Binds the lights information from the scene to the effect for the given mesh.
  9406. * @param light Light to bind
  9407. * @param lightIndex Light index
  9408. * @param scene The scene where the light belongs to
  9409. * @param effect The effect we are binding the data to
  9410. * @param useSpecular Defines if specular is supported
  9411. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9412. */
  9413. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9414. /**
  9415. * Binds the lights information from the scene to the effect for the given mesh.
  9416. * @param scene The scene the lights belongs to
  9417. * @param mesh The mesh we are binding the information to render
  9418. * @param effect The effect we are binding the data to
  9419. * @param defines The generated defines for the effect
  9420. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9421. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9422. */
  9423. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9424. private static _tempFogColor;
  9425. /**
  9426. * Binds the fog information from the scene to the effect for the given mesh.
  9427. * @param scene The scene the lights belongs to
  9428. * @param mesh The mesh we are binding the information to render
  9429. * @param effect The effect we are binding the data to
  9430. * @param linearSpace Defines if the fog effect is applied in linear space
  9431. */
  9432. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9433. /**
  9434. * Binds the bones information from the mesh to the effect.
  9435. * @param mesh The mesh we are binding the information to render
  9436. * @param effect The effect we are binding the data to
  9437. */
  9438. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9439. /**
  9440. * Binds the morph targets information from the mesh to the effect.
  9441. * @param abstractMesh The mesh we are binding the information to render
  9442. * @param effect The effect we are binding the data to
  9443. */
  9444. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9445. /**
  9446. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9447. * @param defines The generated defines used in the effect
  9448. * @param effect The effect we are binding the data to
  9449. * @param scene The scene we are willing to render with logarithmic scale for
  9450. */
  9451. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9452. /**
  9453. * Binds the clip plane information from the scene to the effect.
  9454. * @param scene The scene the clip plane information are extracted from
  9455. * @param effect The effect we are binding the data to
  9456. */
  9457. static BindClipPlane(effect: Effect, scene: Scene): void;
  9458. }
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9461. /** @hidden */
  9462. export var packingFunctions: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9468. /** @hidden */
  9469. export var clipPlaneFragmentDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9475. /** @hidden */
  9476. export var clipPlaneFragment: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9482. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9484. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9485. /** @hidden */
  9486. export var shadowMapPixelShader: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9492. /** @hidden */
  9493. export var bonesDeclaration: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9499. /** @hidden */
  9500. export var morphTargetsVertexGlobalDeclaration: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9506. /** @hidden */
  9507. export var morphTargetsVertexDeclaration: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9513. /** @hidden */
  9514. export var instancesDeclaration: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9520. /** @hidden */
  9521. export var helperFunctions: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9527. /** @hidden */
  9528. export var clipPlaneVertexDeclaration: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9534. /** @hidden */
  9535. export var morphTargetsVertex: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9541. /** @hidden */
  9542. export var instancesVertex: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9548. /** @hidden */
  9549. export var bonesVertex: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9555. /** @hidden */
  9556. export var clipPlaneVertex: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9562. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9563. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9564. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9565. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9566. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9567. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9569. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9570. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9572. /** @hidden */
  9573. export var shadowMapVertexShader: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9579. /** @hidden */
  9580. export var depthBoxBlurPixelShader: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module "babylonjs/Culling/ray" {
  9586. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9587. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9589. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9590. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9591. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9592. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9593. import { Plane } from "babylonjs/Maths/math.plane";
  9594. /**
  9595. * Class representing a ray with position and direction
  9596. */
  9597. export class Ray {
  9598. /** origin point */
  9599. origin: Vector3;
  9600. /** direction */
  9601. direction: Vector3;
  9602. /** length of the ray */
  9603. length: number;
  9604. private static readonly TmpVector3;
  9605. private _tmpRay;
  9606. /**
  9607. * Creates a new ray
  9608. * @param origin origin point
  9609. * @param direction direction
  9610. * @param length length of the ray
  9611. */
  9612. constructor(
  9613. /** origin point */
  9614. origin: Vector3,
  9615. /** direction */
  9616. direction: Vector3,
  9617. /** length of the ray */
  9618. length?: number);
  9619. /**
  9620. * Checks if the ray intersects a box
  9621. * @param minimum bound of the box
  9622. * @param maximum bound of the box
  9623. * @param intersectionTreshold extra extend to be added to the box in all direction
  9624. * @returns if the box was hit
  9625. */
  9626. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9627. /**
  9628. * Checks if the ray intersects a box
  9629. * @param box the bounding box to check
  9630. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9631. * @returns if the box was hit
  9632. */
  9633. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9634. /**
  9635. * If the ray hits a sphere
  9636. * @param sphere the bounding sphere to check
  9637. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9638. * @returns true if it hits the sphere
  9639. */
  9640. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9641. /**
  9642. * If the ray hits a triange
  9643. * @param vertex0 triangle vertex
  9644. * @param vertex1 triangle vertex
  9645. * @param vertex2 triangle vertex
  9646. * @returns intersection information if hit
  9647. */
  9648. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9649. /**
  9650. * Checks if ray intersects a plane
  9651. * @param plane the plane to check
  9652. * @returns the distance away it was hit
  9653. */
  9654. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9655. /**
  9656. * Calculate the intercept of a ray on a given axis
  9657. * @param axis to check 'x' | 'y' | 'z'
  9658. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9659. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9660. */
  9661. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9662. /**
  9663. * Checks if ray intersects a mesh
  9664. * @param mesh the mesh to check
  9665. * @param fastCheck if only the bounding box should checked
  9666. * @returns picking info of the intersecton
  9667. */
  9668. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9669. /**
  9670. * Checks if ray intersects a mesh
  9671. * @param meshes the meshes to check
  9672. * @param fastCheck if only the bounding box should checked
  9673. * @param results array to store result in
  9674. * @returns Array of picking infos
  9675. */
  9676. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9677. private _comparePickingInfo;
  9678. private static smallnum;
  9679. private static rayl;
  9680. /**
  9681. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9682. * @param sega the first point of the segment to test the intersection against
  9683. * @param segb the second point of the segment to test the intersection against
  9684. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9685. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9686. */
  9687. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9688. /**
  9689. * Update the ray from viewport position
  9690. * @param x position
  9691. * @param y y position
  9692. * @param viewportWidth viewport width
  9693. * @param viewportHeight viewport height
  9694. * @param world world matrix
  9695. * @param view view matrix
  9696. * @param projection projection matrix
  9697. * @returns this ray updated
  9698. */
  9699. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9700. /**
  9701. * Creates a ray with origin and direction of 0,0,0
  9702. * @returns the new ray
  9703. */
  9704. static Zero(): Ray;
  9705. /**
  9706. * Creates a new ray from screen space and viewport
  9707. * @param x position
  9708. * @param y y position
  9709. * @param viewportWidth viewport width
  9710. * @param viewportHeight viewport height
  9711. * @param world world matrix
  9712. * @param view view matrix
  9713. * @param projection projection matrix
  9714. * @returns new ray
  9715. */
  9716. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9717. /**
  9718. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9719. * transformed to the given world matrix.
  9720. * @param origin The origin point
  9721. * @param end The end point
  9722. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9723. * @returns the new ray
  9724. */
  9725. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9726. /**
  9727. * Transforms a ray by a matrix
  9728. * @param ray ray to transform
  9729. * @param matrix matrix to apply
  9730. * @returns the resulting new ray
  9731. */
  9732. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9733. /**
  9734. * Transforms a ray by a matrix
  9735. * @param ray ray to transform
  9736. * @param matrix matrix to apply
  9737. * @param result ray to store result in
  9738. */
  9739. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9740. /**
  9741. * Unproject a ray from screen space to object space
  9742. * @param sourceX defines the screen space x coordinate to use
  9743. * @param sourceY defines the screen space y coordinate to use
  9744. * @param viewportWidth defines the current width of the viewport
  9745. * @param viewportHeight defines the current height of the viewport
  9746. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9747. * @param view defines the view matrix to use
  9748. * @param projection defines the projection matrix to use
  9749. */
  9750. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9751. }
  9752. /**
  9753. * Type used to define predicate used to select faces when a mesh intersection is detected
  9754. */
  9755. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9756. module "babylonjs/scene" {
  9757. interface Scene {
  9758. /** @hidden */
  9759. _tempPickingRay: Nullable<Ray>;
  9760. /** @hidden */
  9761. _cachedRayForTransform: Ray;
  9762. /** @hidden */
  9763. _pickWithRayInverseMatrix: Matrix;
  9764. /** @hidden */
  9765. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9766. /** @hidden */
  9767. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9768. }
  9769. }
  9770. }
  9771. declare module "babylonjs/sceneComponent" {
  9772. import { Scene } from "babylonjs/scene";
  9773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9774. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9775. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9776. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9777. import { Nullable } from "babylonjs/types";
  9778. import { Camera } from "babylonjs/Cameras/camera";
  9779. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9780. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9781. import { AbstractScene } from "babylonjs/abstractScene";
  9782. import { Mesh } from "babylonjs/Meshes/mesh";
  9783. /**
  9784. * Groups all the scene component constants in one place to ease maintenance.
  9785. * @hidden
  9786. */
  9787. export class SceneComponentConstants {
  9788. static readonly NAME_EFFECTLAYER: string;
  9789. static readonly NAME_LAYER: string;
  9790. static readonly NAME_LENSFLARESYSTEM: string;
  9791. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9792. static readonly NAME_PARTICLESYSTEM: string;
  9793. static readonly NAME_GAMEPAD: string;
  9794. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9795. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9796. static readonly NAME_DEPTHRENDERER: string;
  9797. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9798. static readonly NAME_SPRITE: string;
  9799. static readonly NAME_OUTLINERENDERER: string;
  9800. static readonly NAME_PROCEDURALTEXTURE: string;
  9801. static readonly NAME_SHADOWGENERATOR: string;
  9802. static readonly NAME_OCTREE: string;
  9803. static readonly NAME_PHYSICSENGINE: string;
  9804. static readonly NAME_AUDIO: string;
  9805. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9806. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9807. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9808. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9809. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9810. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9811. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9812. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9813. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9814. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9815. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9816. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9817. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9818. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9819. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9820. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9821. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9822. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9823. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9824. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9825. static readonly STEP_AFTERRENDER_AUDIO: number;
  9826. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9827. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9828. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9829. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9830. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9831. static readonly STEP_POINTERMOVE_SPRITE: number;
  9832. static readonly STEP_POINTERDOWN_SPRITE: number;
  9833. static readonly STEP_POINTERUP_SPRITE: number;
  9834. }
  9835. /**
  9836. * This represents a scene component.
  9837. *
  9838. * This is used to decouple the dependency the scene is having on the different workloads like
  9839. * layers, post processes...
  9840. */
  9841. export interface ISceneComponent {
  9842. /**
  9843. * The name of the component. Each component must have a unique name.
  9844. */
  9845. name: string;
  9846. /**
  9847. * The scene the component belongs to.
  9848. */
  9849. scene: Scene;
  9850. /**
  9851. * Register the component to one instance of a scene.
  9852. */
  9853. register(): void;
  9854. /**
  9855. * Rebuilds the elements related to this component in case of
  9856. * context lost for instance.
  9857. */
  9858. rebuild(): void;
  9859. /**
  9860. * Disposes the component and the associated ressources.
  9861. */
  9862. dispose(): void;
  9863. }
  9864. /**
  9865. * This represents a SERIALIZABLE scene component.
  9866. *
  9867. * This extends Scene Component to add Serialization methods on top.
  9868. */
  9869. export interface ISceneSerializableComponent extends ISceneComponent {
  9870. /**
  9871. * Adds all the elements from the container to the scene
  9872. * @param container the container holding the elements
  9873. */
  9874. addFromContainer(container: AbstractScene): void;
  9875. /**
  9876. * Removes all the elements in the container from the scene
  9877. * @param container contains the elements to remove
  9878. * @param dispose if the removed element should be disposed (default: false)
  9879. */
  9880. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9881. /**
  9882. * Serializes the component data to the specified json object
  9883. * @param serializationObject The object to serialize to
  9884. */
  9885. serialize(serializationObject: any): void;
  9886. }
  9887. /**
  9888. * Strong typing of a Mesh related stage step action
  9889. */
  9890. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9891. /**
  9892. * Strong typing of a Evaluate Sub Mesh related stage step action
  9893. */
  9894. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9895. /**
  9896. * Strong typing of a Active Mesh related stage step action
  9897. */
  9898. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9899. /**
  9900. * Strong typing of a Camera related stage step action
  9901. */
  9902. export type CameraStageAction = (camera: Camera) => void;
  9903. /**
  9904. * Strong typing of a Camera Frame buffer related stage step action
  9905. */
  9906. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9907. /**
  9908. * Strong typing of a Render Target related stage step action
  9909. */
  9910. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9911. /**
  9912. * Strong typing of a RenderingGroup related stage step action
  9913. */
  9914. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9915. /**
  9916. * Strong typing of a Mesh Render related stage step action
  9917. */
  9918. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9919. /**
  9920. * Strong typing of a simple stage step action
  9921. */
  9922. export type SimpleStageAction = () => void;
  9923. /**
  9924. * Strong typing of a render target action.
  9925. */
  9926. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9927. /**
  9928. * Strong typing of a pointer move action.
  9929. */
  9930. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9931. /**
  9932. * Strong typing of a pointer up/down action.
  9933. */
  9934. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9935. /**
  9936. * Representation of a stage in the scene (Basically a list of ordered steps)
  9937. * @hidden
  9938. */
  9939. export class Stage<T extends Function> extends Array<{
  9940. index: number;
  9941. component: ISceneComponent;
  9942. action: T;
  9943. }> {
  9944. /**
  9945. * Hide ctor from the rest of the world.
  9946. * @param items The items to add.
  9947. */
  9948. private constructor();
  9949. /**
  9950. * Creates a new Stage.
  9951. * @returns A new instance of a Stage
  9952. */
  9953. static Create<T extends Function>(): Stage<T>;
  9954. /**
  9955. * Registers a step in an ordered way in the targeted stage.
  9956. * @param index Defines the position to register the step in
  9957. * @param component Defines the component attached to the step
  9958. * @param action Defines the action to launch during the step
  9959. */
  9960. registerStep(index: number, component: ISceneComponent, action: T): void;
  9961. /**
  9962. * Clears all the steps from the stage.
  9963. */
  9964. clear(): void;
  9965. }
  9966. }
  9967. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9968. import { Nullable } from "babylonjs/types";
  9969. import { Observable } from "babylonjs/Misc/observable";
  9970. import { Scene } from "babylonjs/scene";
  9971. import { Sprite } from "babylonjs/Sprites/sprite";
  9972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9973. import { Ray } from "babylonjs/Culling/ray";
  9974. import { Camera } from "babylonjs/Cameras/camera";
  9975. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9976. import { ISceneComponent } from "babylonjs/sceneComponent";
  9977. module "babylonjs/scene" {
  9978. interface Scene {
  9979. /** @hidden */
  9980. _pointerOverSprite: Nullable<Sprite>;
  9981. /** @hidden */
  9982. _pickedDownSprite: Nullable<Sprite>;
  9983. /** @hidden */
  9984. _tempSpritePickingRay: Nullable<Ray>;
  9985. /**
  9986. * All of the sprite managers added to this scene
  9987. * @see http://doc.babylonjs.com/babylon101/sprites
  9988. */
  9989. spriteManagers: Array<ISpriteManager>;
  9990. /**
  9991. * An event triggered when sprites rendering is about to start
  9992. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9993. */
  9994. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9995. /**
  9996. * An event triggered when sprites rendering is done
  9997. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9998. */
  9999. onAfterSpritesRenderingObservable: Observable<Scene>;
  10000. /** @hidden */
  10001. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10002. /** Launch a ray to try to pick a sprite in the scene
  10003. * @param x position on screen
  10004. * @param y position on screen
  10005. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10006. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10007. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10008. * @returns a PickingInfo
  10009. */
  10010. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10011. /** Use the given ray to pick a sprite in the scene
  10012. * @param ray The ray (in world space) to use to pick meshes
  10013. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10014. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10015. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10016. * @returns a PickingInfo
  10017. */
  10018. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10019. /** @hidden */
  10020. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10021. /** Launch a ray to try to pick sprites in the scene
  10022. * @param x position on screen
  10023. * @param y position on screen
  10024. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10025. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10026. * @returns a PickingInfo array
  10027. */
  10028. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10029. /** Use the given ray to pick sprites in the scene
  10030. * @param ray The ray (in world space) to use to pick meshes
  10031. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10032. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10033. * @returns a PickingInfo array
  10034. */
  10035. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10036. /**
  10037. * Force the sprite under the pointer
  10038. * @param sprite defines the sprite to use
  10039. */
  10040. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10041. /**
  10042. * Gets the sprite under the pointer
  10043. * @returns a Sprite or null if no sprite is under the pointer
  10044. */
  10045. getPointerOverSprite(): Nullable<Sprite>;
  10046. }
  10047. }
  10048. /**
  10049. * Defines the sprite scene component responsible to manage sprites
  10050. * in a given scene.
  10051. */
  10052. export class SpriteSceneComponent implements ISceneComponent {
  10053. /**
  10054. * The component name helpfull to identify the component in the list of scene components.
  10055. */
  10056. readonly name: string;
  10057. /**
  10058. * The scene the component belongs to.
  10059. */
  10060. scene: Scene;
  10061. /** @hidden */
  10062. private _spritePredicate;
  10063. /**
  10064. * Creates a new instance of the component for the given scene
  10065. * @param scene Defines the scene to register the component in
  10066. */
  10067. constructor(scene: Scene);
  10068. /**
  10069. * Registers the component in a given scene
  10070. */
  10071. register(): void;
  10072. /**
  10073. * Rebuilds the elements related to this component in case of
  10074. * context lost for instance.
  10075. */
  10076. rebuild(): void;
  10077. /**
  10078. * Disposes the component and the associated ressources.
  10079. */
  10080. dispose(): void;
  10081. private _pickSpriteButKeepRay;
  10082. private _pointerMove;
  10083. private _pointerDown;
  10084. private _pointerUp;
  10085. }
  10086. }
  10087. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10088. /** @hidden */
  10089. export var fogFragmentDeclaration: {
  10090. name: string;
  10091. shader: string;
  10092. };
  10093. }
  10094. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10095. /** @hidden */
  10096. export var fogFragment: {
  10097. name: string;
  10098. shader: string;
  10099. };
  10100. }
  10101. declare module "babylonjs/Shaders/sprites.fragment" {
  10102. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10103. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10104. /** @hidden */
  10105. export var spritesPixelShader: {
  10106. name: string;
  10107. shader: string;
  10108. };
  10109. }
  10110. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10111. /** @hidden */
  10112. export var fogVertexDeclaration: {
  10113. name: string;
  10114. shader: string;
  10115. };
  10116. }
  10117. declare module "babylonjs/Shaders/sprites.vertex" {
  10118. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10119. /** @hidden */
  10120. export var spritesVertexShader: {
  10121. name: string;
  10122. shader: string;
  10123. };
  10124. }
  10125. declare module "babylonjs/Sprites/spriteManager" {
  10126. import { IDisposable, Scene } from "babylonjs/scene";
  10127. import { Nullable } from "babylonjs/types";
  10128. import { Observable } from "babylonjs/Misc/observable";
  10129. import { Sprite } from "babylonjs/Sprites/sprite";
  10130. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10131. import { Camera } from "babylonjs/Cameras/camera";
  10132. import { Texture } from "babylonjs/Materials/Textures/texture";
  10133. import "babylonjs/Shaders/sprites.fragment";
  10134. import "babylonjs/Shaders/sprites.vertex";
  10135. import { Ray } from "babylonjs/Culling/ray";
  10136. /**
  10137. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10138. */
  10139. export interface ISpriteManager extends IDisposable {
  10140. /**
  10141. * Restricts the camera to viewing objects with the same layerMask.
  10142. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10143. */
  10144. layerMask: number;
  10145. /**
  10146. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10147. */
  10148. isPickable: boolean;
  10149. /**
  10150. * Specifies the rendering group id for this mesh (0 by default)
  10151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10152. */
  10153. renderingGroupId: number;
  10154. /**
  10155. * Defines the list of sprites managed by the manager.
  10156. */
  10157. sprites: Array<Sprite>;
  10158. /**
  10159. * Tests the intersection of a sprite with a specific ray.
  10160. * @param ray The ray we are sending to test the collision
  10161. * @param camera The camera space we are sending rays in
  10162. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10163. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10164. * @returns picking info or null.
  10165. */
  10166. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10167. /**
  10168. * Intersects the sprites with a ray
  10169. * @param ray defines the ray to intersect with
  10170. * @param camera defines the current active camera
  10171. * @param predicate defines a predicate used to select candidate sprites
  10172. * @returns null if no hit or a PickingInfo array
  10173. */
  10174. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10175. /**
  10176. * Renders the list of sprites on screen.
  10177. */
  10178. render(): void;
  10179. }
  10180. /**
  10181. * Class used to manage multiple sprites on the same spritesheet
  10182. * @see http://doc.babylonjs.com/babylon101/sprites
  10183. */
  10184. export class SpriteManager implements ISpriteManager {
  10185. /** defines the manager's name */
  10186. name: string;
  10187. /** Gets the list of sprites */
  10188. sprites: Sprite[];
  10189. /** Gets or sets the rendering group id (0 by default) */
  10190. renderingGroupId: number;
  10191. /** Gets or sets camera layer mask */
  10192. layerMask: number;
  10193. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10194. fogEnabled: boolean;
  10195. /** Gets or sets a boolean indicating if the sprites are pickable */
  10196. isPickable: boolean;
  10197. /** Defines the default width of a cell in the spritesheet */
  10198. cellWidth: number;
  10199. /** Defines the default height of a cell in the spritesheet */
  10200. cellHeight: number;
  10201. /** Associative array from JSON sprite data file */
  10202. private _cellData;
  10203. /** Array of sprite names from JSON sprite data file */
  10204. private _spriteMap;
  10205. /** True when packed cell data from JSON file is ready*/
  10206. private _packedAndReady;
  10207. /**
  10208. * An event triggered when the manager is disposed.
  10209. */
  10210. onDisposeObservable: Observable<SpriteManager>;
  10211. private _onDisposeObserver;
  10212. /**
  10213. * Callback called when the manager is disposed
  10214. */
  10215. set onDispose(callback: () => void);
  10216. private _capacity;
  10217. private _fromPacked;
  10218. private _spriteTexture;
  10219. private _epsilon;
  10220. private _scene;
  10221. private _vertexData;
  10222. private _buffer;
  10223. private _vertexBuffers;
  10224. private _indexBuffer;
  10225. private _effectBase;
  10226. private _effectFog;
  10227. /**
  10228. * Gets or sets the spritesheet texture
  10229. */
  10230. get texture(): Texture;
  10231. set texture(value: Texture);
  10232. private _blendMode;
  10233. /**
  10234. * Blend mode use to render the particle, it can be any of
  10235. * the static Constants.ALPHA_x properties provided in this class.
  10236. * Default value is Constants.ALPHA_COMBINE
  10237. */
  10238. get blendMode(): number;
  10239. set blendMode(blendMode: number);
  10240. /** Disables writing to the depth buffer when rendering the sprites.
  10241. * It can be handy to disable depth writing when using textures without alpha channel
  10242. * and setting some specific blend modes.
  10243. */
  10244. disableDepthWrite: boolean;
  10245. /**
  10246. * Creates a new sprite manager
  10247. * @param name defines the manager's name
  10248. * @param imgUrl defines the sprite sheet url
  10249. * @param capacity defines the maximum allowed number of sprites
  10250. * @param cellSize defines the size of a sprite cell
  10251. * @param scene defines the hosting scene
  10252. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10253. * @param samplingMode defines the smapling mode to use with spritesheet
  10254. * @param fromPacked set to false; do not alter
  10255. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10256. */
  10257. constructor(
  10258. /** defines the manager's name */
  10259. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10260. private _makePacked;
  10261. private _appendSpriteVertex;
  10262. /**
  10263. * Intersects the sprites with a ray
  10264. * @param ray defines the ray to intersect with
  10265. * @param camera defines the current active camera
  10266. * @param predicate defines a predicate used to select candidate sprites
  10267. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10268. * @returns null if no hit or a PickingInfo
  10269. */
  10270. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10271. /**
  10272. * Intersects the sprites with a ray
  10273. * @param ray defines the ray to intersect with
  10274. * @param camera defines the current active camera
  10275. * @param predicate defines a predicate used to select candidate sprites
  10276. * @returns null if no hit or a PickingInfo array
  10277. */
  10278. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10279. /**
  10280. * Render all child sprites
  10281. */
  10282. render(): void;
  10283. /**
  10284. * Release associated resources
  10285. */
  10286. dispose(): void;
  10287. }
  10288. }
  10289. declare module "babylonjs/Misc/gradients" {
  10290. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10291. /** Interface used by value gradients (color, factor, ...) */
  10292. export interface IValueGradient {
  10293. /**
  10294. * Gets or sets the gradient value (between 0 and 1)
  10295. */
  10296. gradient: number;
  10297. }
  10298. /** Class used to store color4 gradient */
  10299. export class ColorGradient implements IValueGradient {
  10300. /**
  10301. * Gets or sets the gradient value (between 0 and 1)
  10302. */
  10303. gradient: number;
  10304. /**
  10305. * Gets or sets first associated color
  10306. */
  10307. color1: Color4;
  10308. /**
  10309. * Gets or sets second associated color
  10310. */
  10311. color2?: Color4;
  10312. /**
  10313. * Will get a color picked randomly between color1 and color2.
  10314. * If color2 is undefined then color1 will be used
  10315. * @param result defines the target Color4 to store the result in
  10316. */
  10317. getColorToRef(result: Color4): void;
  10318. }
  10319. /** Class used to store color 3 gradient */
  10320. export class Color3Gradient implements IValueGradient {
  10321. /**
  10322. * Gets or sets the gradient value (between 0 and 1)
  10323. */
  10324. gradient: number;
  10325. /**
  10326. * Gets or sets the associated color
  10327. */
  10328. color: Color3;
  10329. }
  10330. /** Class used to store factor gradient */
  10331. export class FactorGradient implements IValueGradient {
  10332. /**
  10333. * Gets or sets the gradient value (between 0 and 1)
  10334. */
  10335. gradient: number;
  10336. /**
  10337. * Gets or sets first associated factor
  10338. */
  10339. factor1: number;
  10340. /**
  10341. * Gets or sets second associated factor
  10342. */
  10343. factor2?: number;
  10344. /**
  10345. * Will get a number picked randomly between factor1 and factor2.
  10346. * If factor2 is undefined then factor1 will be used
  10347. * @returns the picked number
  10348. */
  10349. getFactor(): number;
  10350. }
  10351. /**
  10352. * Helper used to simplify some generic gradient tasks
  10353. */
  10354. export class GradientHelper {
  10355. /**
  10356. * Gets the current gradient from an array of IValueGradient
  10357. * @param ratio defines the current ratio to get
  10358. * @param gradients defines the array of IValueGradient
  10359. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10360. */
  10361. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10362. }
  10363. }
  10364. declare module "babylonjs/Maths/math.size" {
  10365. /**
  10366. * Interface for the size containing width and height
  10367. */
  10368. export interface ISize {
  10369. /**
  10370. * Width
  10371. */
  10372. width: number;
  10373. /**
  10374. * Heighht
  10375. */
  10376. height: number;
  10377. }
  10378. /**
  10379. * Size containing widht and height
  10380. */
  10381. export class Size implements ISize {
  10382. /**
  10383. * Width
  10384. */
  10385. width: number;
  10386. /**
  10387. * Height
  10388. */
  10389. height: number;
  10390. /**
  10391. * Creates a Size object from the given width and height (floats).
  10392. * @param width width of the new size
  10393. * @param height height of the new size
  10394. */
  10395. constructor(width: number, height: number);
  10396. /**
  10397. * Returns a string with the Size width and height
  10398. * @returns a string with the Size width and height
  10399. */
  10400. toString(): string;
  10401. /**
  10402. * "Size"
  10403. * @returns the string "Size"
  10404. */
  10405. getClassName(): string;
  10406. /**
  10407. * Returns the Size hash code.
  10408. * @returns a hash code for a unique width and height
  10409. */
  10410. getHashCode(): number;
  10411. /**
  10412. * Updates the current size from the given one.
  10413. * @param src the given size
  10414. */
  10415. copyFrom(src: Size): void;
  10416. /**
  10417. * Updates in place the current Size from the given floats.
  10418. * @param width width of the new size
  10419. * @param height height of the new size
  10420. * @returns the updated Size.
  10421. */
  10422. copyFromFloats(width: number, height: number): Size;
  10423. /**
  10424. * Updates in place the current Size from the given floats.
  10425. * @param width width to set
  10426. * @param height height to set
  10427. * @returns the updated Size.
  10428. */
  10429. set(width: number, height: number): Size;
  10430. /**
  10431. * Multiplies the width and height by numbers
  10432. * @param w factor to multiple the width by
  10433. * @param h factor to multiple the height by
  10434. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10435. */
  10436. multiplyByFloats(w: number, h: number): Size;
  10437. /**
  10438. * Clones the size
  10439. * @returns a new Size copied from the given one.
  10440. */
  10441. clone(): Size;
  10442. /**
  10443. * True if the current Size and the given one width and height are strictly equal.
  10444. * @param other the other size to compare against
  10445. * @returns True if the current Size and the given one width and height are strictly equal.
  10446. */
  10447. equals(other: Size): boolean;
  10448. /**
  10449. * The surface of the Size : width * height (float).
  10450. */
  10451. get surface(): number;
  10452. /**
  10453. * Create a new size of zero
  10454. * @returns a new Size set to (0.0, 0.0)
  10455. */
  10456. static Zero(): Size;
  10457. /**
  10458. * Sums the width and height of two sizes
  10459. * @param otherSize size to add to this size
  10460. * @returns a new Size set as the addition result of the current Size and the given one.
  10461. */
  10462. add(otherSize: Size): Size;
  10463. /**
  10464. * Subtracts the width and height of two
  10465. * @param otherSize size to subtract to this size
  10466. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10467. */
  10468. subtract(otherSize: Size): Size;
  10469. /**
  10470. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10471. * @param start starting size to lerp between
  10472. * @param end end size to lerp between
  10473. * @param amount amount to lerp between the start and end values
  10474. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10475. */
  10476. static Lerp(start: Size, end: Size, amount: number): Size;
  10477. }
  10478. }
  10479. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10481. import { Nullable } from "babylonjs/types";
  10482. module "babylonjs/Engines/thinEngine" {
  10483. interface ThinEngine {
  10484. /**
  10485. * Creates a dynamic texture
  10486. * @param width defines the width of the texture
  10487. * @param height defines the height of the texture
  10488. * @param generateMipMaps defines if the engine should generate the mip levels
  10489. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10490. * @returns the dynamic texture inside an InternalTexture
  10491. */
  10492. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10493. /**
  10494. * Update the content of a dynamic texture
  10495. * @param texture defines the texture to update
  10496. * @param canvas defines the canvas containing the source
  10497. * @param invertY defines if data must be stored with Y axis inverted
  10498. * @param premulAlpha defines if alpha is stored as premultiplied
  10499. * @param format defines the format of the data
  10500. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10501. */
  10502. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10503. }
  10504. }
  10505. }
  10506. declare module "babylonjs/Misc/canvasGenerator" {
  10507. /**
  10508. * Helper class used to generate a canvas to manipulate images
  10509. */
  10510. export class CanvasGenerator {
  10511. /**
  10512. * Create a new canvas (or offscreen canvas depending on the context)
  10513. * @param width defines the expected width
  10514. * @param height defines the expected height
  10515. * @return a new canvas or offscreen canvas
  10516. */
  10517. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10518. }
  10519. }
  10520. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10521. import { Scene } from "babylonjs/scene";
  10522. import { Texture } from "babylonjs/Materials/Textures/texture";
  10523. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10524. /**
  10525. * A class extending Texture allowing drawing on a texture
  10526. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10527. */
  10528. export class DynamicTexture extends Texture {
  10529. private _generateMipMaps;
  10530. private _canvas;
  10531. private _context;
  10532. private _engine;
  10533. /**
  10534. * Creates a DynamicTexture
  10535. * @param name defines the name of the texture
  10536. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10537. * @param scene defines the scene where you want the texture
  10538. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10539. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10540. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10541. */
  10542. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10543. /**
  10544. * Get the current class name of the texture useful for serialization or dynamic coding.
  10545. * @returns "DynamicTexture"
  10546. */
  10547. getClassName(): string;
  10548. /**
  10549. * Gets the current state of canRescale
  10550. */
  10551. get canRescale(): boolean;
  10552. private _recreate;
  10553. /**
  10554. * Scales the texture
  10555. * @param ratio the scale factor to apply to both width and height
  10556. */
  10557. scale(ratio: number): void;
  10558. /**
  10559. * Resizes the texture
  10560. * @param width the new width
  10561. * @param height the new height
  10562. */
  10563. scaleTo(width: number, height: number): void;
  10564. /**
  10565. * Gets the context of the canvas used by the texture
  10566. * @returns the canvas context of the dynamic texture
  10567. */
  10568. getContext(): CanvasRenderingContext2D;
  10569. /**
  10570. * Clears the texture
  10571. */
  10572. clear(): void;
  10573. /**
  10574. * Updates the texture
  10575. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10576. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10577. */
  10578. update(invertY?: boolean, premulAlpha?: boolean): void;
  10579. /**
  10580. * Draws text onto the texture
  10581. * @param text defines the text to be drawn
  10582. * @param x defines the placement of the text from the left
  10583. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10584. * @param font defines the font to be used with font-style, font-size, font-name
  10585. * @param color defines the color used for the text
  10586. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10587. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10588. * @param update defines whether texture is immediately update (default is true)
  10589. */
  10590. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10591. /**
  10592. * Clones the texture
  10593. * @returns the clone of the texture.
  10594. */
  10595. clone(): DynamicTexture;
  10596. /**
  10597. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10598. * @returns a serialized dynamic texture object
  10599. */
  10600. serialize(): any;
  10601. /** @hidden */
  10602. _rebuild(): void;
  10603. }
  10604. }
  10605. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10606. import { Nullable } from "babylonjs/types";
  10607. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10608. import { Scene } from "babylonjs/scene";
  10609. module "babylonjs/Engines/engine" {
  10610. interface Engine {
  10611. /**
  10612. * Creates a raw texture
  10613. * @param data defines the data to store in the texture
  10614. * @param width defines the width of the texture
  10615. * @param height defines the height of the texture
  10616. * @param format defines the format of the data
  10617. * @param generateMipMaps defines if the engine should generate the mip levels
  10618. * @param invertY defines if data must be stored with Y axis inverted
  10619. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10620. * @param compression defines the compression used (null by default)
  10621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10622. * @returns the raw texture inside an InternalTexture
  10623. */
  10624. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10625. /**
  10626. * Update a raw texture
  10627. * @param texture defines the texture to update
  10628. * @param data defines the data to store in the texture
  10629. * @param format defines the format of the data
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. */
  10632. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10633. /**
  10634. * Update a raw texture
  10635. * @param texture defines the texture to update
  10636. * @param data defines the data to store in the texture
  10637. * @param format defines the format of the data
  10638. * @param invertY defines if data must be stored with Y axis inverted
  10639. * @param compression defines the compression used (null by default)
  10640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10641. */
  10642. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10643. /**
  10644. * Creates a new raw cube texture
  10645. * @param data defines the array of data to use to create each face
  10646. * @param size defines the size of the textures
  10647. * @param format defines the format of the data
  10648. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10649. * @param generateMipMaps defines if the engine should generate the mip levels
  10650. * @param invertY defines if data must be stored with Y axis inverted
  10651. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10652. * @param compression defines the compression used (null by default)
  10653. * @returns the cube texture as an InternalTexture
  10654. */
  10655. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10656. /**
  10657. * Update a raw cube texture
  10658. * @param texture defines the texture to udpdate
  10659. * @param data defines the data to store
  10660. * @param format defines the data format
  10661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10662. * @param invertY defines if data must be stored with Y axis inverted
  10663. */
  10664. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10665. /**
  10666. * Update a raw cube texture
  10667. * @param texture defines the texture to udpdate
  10668. * @param data defines the data to store
  10669. * @param format defines the data format
  10670. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10671. * @param invertY defines if data must be stored with Y axis inverted
  10672. * @param compression defines the compression used (null by default)
  10673. */
  10674. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10675. /**
  10676. * Update a raw cube texture
  10677. * @param texture defines the texture to udpdate
  10678. * @param data defines the data to store
  10679. * @param format defines the data format
  10680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10681. * @param invertY defines if data must be stored with Y axis inverted
  10682. * @param compression defines the compression used (null by default)
  10683. * @param level defines which level of the texture to update
  10684. */
  10685. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10686. /**
  10687. * Creates a new raw cube texture from a specified url
  10688. * @param url defines the url where the data is located
  10689. * @param scene defines the current scene
  10690. * @param size defines the size of the textures
  10691. * @param format defines the format of the data
  10692. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10693. * @param noMipmap defines if the engine should avoid generating the mip levels
  10694. * @param callback defines a callback used to extract texture data from loaded data
  10695. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10696. * @param onLoad defines a callback called when texture is loaded
  10697. * @param onError defines a callback called if there is an error
  10698. * @returns the cube texture as an InternalTexture
  10699. */
  10700. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10701. /**
  10702. * Creates a new raw cube texture from a specified url
  10703. * @param url defines the url where the data is located
  10704. * @param scene defines the current scene
  10705. * @param size defines the size of the textures
  10706. * @param format defines the format of the data
  10707. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10708. * @param noMipmap defines if the engine should avoid generating the mip levels
  10709. * @param callback defines a callback used to extract texture data from loaded data
  10710. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10711. * @param onLoad defines a callback called when texture is loaded
  10712. * @param onError defines a callback called if there is an error
  10713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10714. * @param invertY defines if data must be stored with Y axis inverted
  10715. * @returns the cube texture as an InternalTexture
  10716. */
  10717. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10718. /**
  10719. * Creates a new raw 3D texture
  10720. * @param data defines the data used to create the texture
  10721. * @param width defines the width of the texture
  10722. * @param height defines the height of the texture
  10723. * @param depth defines the depth of the texture
  10724. * @param format defines the format of the texture
  10725. * @param generateMipMaps defines if the engine must generate mip levels
  10726. * @param invertY defines if data must be stored with Y axis inverted
  10727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10728. * @param compression defines the compressed used (can be null)
  10729. * @param textureType defines the compressed used (can be null)
  10730. * @returns a new raw 3D texture (stored in an InternalTexture)
  10731. */
  10732. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10733. /**
  10734. * Update a raw 3D texture
  10735. * @param texture defines the texture to update
  10736. * @param data defines the data to store
  10737. * @param format defines the data format
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. */
  10740. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10741. /**
  10742. * Update a raw 3D texture
  10743. * @param texture defines the texture to update
  10744. * @param data defines the data to store
  10745. * @param format defines the data format
  10746. * @param invertY defines if data must be stored with Y axis inverted
  10747. * @param compression defines the used compression (can be null)
  10748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10749. */
  10750. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10751. /**
  10752. * Creates a new raw 2D array texture
  10753. * @param data defines the data used to create the texture
  10754. * @param width defines the width of the texture
  10755. * @param height defines the height of the texture
  10756. * @param depth defines the number of layers of the texture
  10757. * @param format defines the format of the texture
  10758. * @param generateMipMaps defines if the engine must generate mip levels
  10759. * @param invertY defines if data must be stored with Y axis inverted
  10760. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10761. * @param compression defines the compressed used (can be null)
  10762. * @param textureType defines the compressed used (can be null)
  10763. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10764. */
  10765. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10766. /**
  10767. * Update a raw 2D array texture
  10768. * @param texture defines the texture to update
  10769. * @param data defines the data to store
  10770. * @param format defines the data format
  10771. * @param invertY defines if data must be stored with Y axis inverted
  10772. */
  10773. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10774. /**
  10775. * Update a raw 2D array texture
  10776. * @param texture defines the texture to update
  10777. * @param data defines the data to store
  10778. * @param format defines the data format
  10779. * @param invertY defines if data must be stored with Y axis inverted
  10780. * @param compression defines the used compression (can be null)
  10781. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10782. */
  10783. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10784. }
  10785. }
  10786. }
  10787. declare module "babylonjs/Materials/Textures/rawTexture" {
  10788. import { Scene } from "babylonjs/scene";
  10789. import { Texture } from "babylonjs/Materials/Textures/texture";
  10790. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10791. /**
  10792. * Raw texture can help creating a texture directly from an array of data.
  10793. * This can be super useful if you either get the data from an uncompressed source or
  10794. * if you wish to create your texture pixel by pixel.
  10795. */
  10796. export class RawTexture extends Texture {
  10797. /**
  10798. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10799. */
  10800. format: number;
  10801. private _engine;
  10802. /**
  10803. * Instantiates a new RawTexture.
  10804. * Raw texture can help creating a texture directly from an array of data.
  10805. * This can be super useful if you either get the data from an uncompressed source or
  10806. * if you wish to create your texture pixel by pixel.
  10807. * @param data define the array of data to use to create the texture
  10808. * @param width define the width of the texture
  10809. * @param height define the height of the texture
  10810. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10811. * @param scene define the scene the texture belongs to
  10812. * @param generateMipMaps define whether mip maps should be generated or not
  10813. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10814. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10815. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10816. */
  10817. constructor(data: ArrayBufferView, width: number, height: number,
  10818. /**
  10819. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10820. */
  10821. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10822. /**
  10823. * Updates the texture underlying data.
  10824. * @param data Define the new data of the texture
  10825. */
  10826. update(data: ArrayBufferView): void;
  10827. /**
  10828. * Creates a luminance texture from some data.
  10829. * @param data Define the texture data
  10830. * @param width Define the width of the texture
  10831. * @param height Define the height of the texture
  10832. * @param scene Define the scene the texture belongs to
  10833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10836. * @returns the luminance texture
  10837. */
  10838. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10839. /**
  10840. * Creates a luminance alpha texture from some data.
  10841. * @param data Define the texture data
  10842. * @param width Define the width of the texture
  10843. * @param height Define the height of the texture
  10844. * @param scene Define the scene the texture belongs to
  10845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10848. * @returns the luminance alpha texture
  10849. */
  10850. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10851. /**
  10852. * Creates an alpha texture from some data.
  10853. * @param data Define the texture data
  10854. * @param width Define the width of the texture
  10855. * @param height Define the height of the texture
  10856. * @param scene Define the scene the texture belongs to
  10857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10860. * @returns the alpha texture
  10861. */
  10862. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10863. /**
  10864. * Creates a RGB texture from some data.
  10865. * @param data Define the texture data
  10866. * @param width Define the width of the texture
  10867. * @param height Define the height of the texture
  10868. * @param scene Define the scene the texture belongs to
  10869. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10872. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10873. * @returns the RGB alpha texture
  10874. */
  10875. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10876. /**
  10877. * Creates a RGBA texture from some data.
  10878. * @param data Define the texture data
  10879. * @param width Define the width of the texture
  10880. * @param height Define the height of the texture
  10881. * @param scene Define the scene the texture belongs to
  10882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10885. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10886. * @returns the RGBA texture
  10887. */
  10888. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10889. /**
  10890. * Creates a R texture from some data.
  10891. * @param data Define the texture data
  10892. * @param width Define the width of the texture
  10893. * @param height Define the height of the texture
  10894. * @param scene Define the scene the texture belongs to
  10895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10898. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10899. * @returns the R texture
  10900. */
  10901. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10902. }
  10903. }
  10904. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10905. import { Scene } from "babylonjs/scene";
  10906. import { ISceneComponent } from "babylonjs/sceneComponent";
  10907. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10908. module "babylonjs/abstractScene" {
  10909. interface AbstractScene {
  10910. /**
  10911. * The list of procedural textures added to the scene
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10913. */
  10914. proceduralTextures: Array<ProceduralTexture>;
  10915. }
  10916. }
  10917. /**
  10918. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10919. * in a given scene.
  10920. */
  10921. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10922. /**
  10923. * The component name helpfull to identify the component in the list of scene components.
  10924. */
  10925. readonly name: string;
  10926. /**
  10927. * The scene the component belongs to.
  10928. */
  10929. scene: Scene;
  10930. /**
  10931. * Creates a new instance of the component for the given scene
  10932. * @param scene Defines the scene to register the component in
  10933. */
  10934. constructor(scene: Scene);
  10935. /**
  10936. * Registers the component in a given scene
  10937. */
  10938. register(): void;
  10939. /**
  10940. * Rebuilds the elements related to this component in case of
  10941. * context lost for instance.
  10942. */
  10943. rebuild(): void;
  10944. /**
  10945. * Disposes the component and the associated ressources.
  10946. */
  10947. dispose(): void;
  10948. private _beforeClear;
  10949. }
  10950. }
  10951. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10953. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10954. module "babylonjs/Engines/thinEngine" {
  10955. interface ThinEngine {
  10956. /**
  10957. * Creates a new render target cube texture
  10958. * @param size defines the size of the texture
  10959. * @param options defines the options used to create the texture
  10960. * @returns a new render target cube texture stored in an InternalTexture
  10961. */
  10962. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10963. }
  10964. }
  10965. }
  10966. declare module "babylonjs/Shaders/procedural.vertex" {
  10967. /** @hidden */
  10968. export var proceduralVertexShader: {
  10969. name: string;
  10970. shader: string;
  10971. };
  10972. }
  10973. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10974. import { Observable } from "babylonjs/Misc/observable";
  10975. import { Nullable } from "babylonjs/types";
  10976. import { Scene } from "babylonjs/scene";
  10977. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10978. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10979. import { Effect } from "babylonjs/Materials/effect";
  10980. import { Texture } from "babylonjs/Materials/Textures/texture";
  10981. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10982. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10983. import "babylonjs/Shaders/procedural.vertex";
  10984. /**
  10985. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10986. * This is the base class of any Procedural texture and contains most of the shareable code.
  10987. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10988. */
  10989. export class ProceduralTexture extends Texture {
  10990. isCube: boolean;
  10991. /**
  10992. * Define if the texture is enabled or not (disabled texture will not render)
  10993. */
  10994. isEnabled: boolean;
  10995. /**
  10996. * Define if the texture must be cleared before rendering (default is true)
  10997. */
  10998. autoClear: boolean;
  10999. /**
  11000. * Callback called when the texture is generated
  11001. */
  11002. onGenerated: () => void;
  11003. /**
  11004. * Event raised when the texture is generated
  11005. */
  11006. onGeneratedObservable: Observable<ProceduralTexture>;
  11007. /** @hidden */
  11008. _generateMipMaps: boolean;
  11009. /** @hidden **/
  11010. _effect: Effect;
  11011. /** @hidden */
  11012. _textures: {
  11013. [key: string]: Texture;
  11014. };
  11015. private _size;
  11016. private _currentRefreshId;
  11017. private _frameId;
  11018. private _refreshRate;
  11019. private _vertexBuffers;
  11020. private _indexBuffer;
  11021. private _uniforms;
  11022. private _samplers;
  11023. private _fragment;
  11024. private _floats;
  11025. private _ints;
  11026. private _floatsArrays;
  11027. private _colors3;
  11028. private _colors4;
  11029. private _vectors2;
  11030. private _vectors3;
  11031. private _matrices;
  11032. private _fallbackTexture;
  11033. private _fallbackTextureUsed;
  11034. private _engine;
  11035. private _cachedDefines;
  11036. private _contentUpdateId;
  11037. private _contentData;
  11038. /**
  11039. * Instantiates a new procedural texture.
  11040. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11041. * This is the base class of any Procedural texture and contains most of the shareable code.
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11043. * @param name Define the name of the texture
  11044. * @param size Define the size of the texture to create
  11045. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11046. * @param scene Define the scene the texture belongs to
  11047. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11048. * @param generateMipMaps Define if the texture should creates mip maps or not
  11049. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11050. */
  11051. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11052. /**
  11053. * The effect that is created when initializing the post process.
  11054. * @returns The created effect corresponding the the postprocess.
  11055. */
  11056. getEffect(): Effect;
  11057. /**
  11058. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11059. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11060. */
  11061. getContent(): Nullable<ArrayBufferView>;
  11062. private _createIndexBuffer;
  11063. /** @hidden */
  11064. _rebuild(): void;
  11065. /**
  11066. * Resets the texture in order to recreate its associated resources.
  11067. * This can be called in case of context loss
  11068. */
  11069. reset(): void;
  11070. protected _getDefines(): string;
  11071. /**
  11072. * Is the texture ready to be used ? (rendered at least once)
  11073. * @returns true if ready, otherwise, false.
  11074. */
  11075. isReady(): boolean;
  11076. /**
  11077. * Resets the refresh counter of the texture and start bak from scratch.
  11078. * Could be useful to regenerate the texture if it is setup to render only once.
  11079. */
  11080. resetRefreshCounter(): void;
  11081. /**
  11082. * Set the fragment shader to use in order to render the texture.
  11083. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11084. */
  11085. setFragment(fragment: any): void;
  11086. /**
  11087. * Define the refresh rate of the texture or the rendering frequency.
  11088. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11089. */
  11090. get refreshRate(): number;
  11091. set refreshRate(value: number);
  11092. /** @hidden */
  11093. _shouldRender(): boolean;
  11094. /**
  11095. * Get the size the texture is rendering at.
  11096. * @returns the size (texture is always squared)
  11097. */
  11098. getRenderSize(): number;
  11099. /**
  11100. * Resize the texture to new value.
  11101. * @param size Define the new size the texture should have
  11102. * @param generateMipMaps Define whether the new texture should create mip maps
  11103. */
  11104. resize(size: number, generateMipMaps: boolean): void;
  11105. private _checkUniform;
  11106. /**
  11107. * Set a texture in the shader program used to render.
  11108. * @param name Define the name of the uniform samplers as defined in the shader
  11109. * @param texture Define the texture to bind to this sampler
  11110. * @return the texture itself allowing "fluent" like uniform updates
  11111. */
  11112. setTexture(name: string, texture: Texture): ProceduralTexture;
  11113. /**
  11114. * Set a float in the shader.
  11115. * @param name Define the name of the uniform as defined in the shader
  11116. * @param value Define the value to give to the uniform
  11117. * @return the texture itself allowing "fluent" like uniform updates
  11118. */
  11119. setFloat(name: string, value: number): ProceduralTexture;
  11120. /**
  11121. * Set a int in the shader.
  11122. * @param name Define the name of the uniform as defined in the shader
  11123. * @param value Define the value to give to the uniform
  11124. * @return the texture itself allowing "fluent" like uniform updates
  11125. */
  11126. setInt(name: string, value: number): ProceduralTexture;
  11127. /**
  11128. * Set an array of floats in the shader.
  11129. * @param name Define the name of the uniform as defined in the shader
  11130. * @param value Define the value to give to the uniform
  11131. * @return the texture itself allowing "fluent" like uniform updates
  11132. */
  11133. setFloats(name: string, value: number[]): ProceduralTexture;
  11134. /**
  11135. * Set a vec3 in the shader from a Color3.
  11136. * @param name Define the name of the uniform as defined in the shader
  11137. * @param value Define the value to give to the uniform
  11138. * @return the texture itself allowing "fluent" like uniform updates
  11139. */
  11140. setColor3(name: string, value: Color3): ProceduralTexture;
  11141. /**
  11142. * Set a vec4 in the shader from a Color4.
  11143. * @param name Define the name of the uniform as defined in the shader
  11144. * @param value Define the value to give to the uniform
  11145. * @return the texture itself allowing "fluent" like uniform updates
  11146. */
  11147. setColor4(name: string, value: Color4): ProceduralTexture;
  11148. /**
  11149. * Set a vec2 in the shader from a Vector2.
  11150. * @param name Define the name of the uniform as defined in the shader
  11151. * @param value Define the value to give to the uniform
  11152. * @return the texture itself allowing "fluent" like uniform updates
  11153. */
  11154. setVector2(name: string, value: Vector2): ProceduralTexture;
  11155. /**
  11156. * Set a vec3 in the shader from a Vector3.
  11157. * @param name Define the name of the uniform as defined in the shader
  11158. * @param value Define the value to give to the uniform
  11159. * @return the texture itself allowing "fluent" like uniform updates
  11160. */
  11161. setVector3(name: string, value: Vector3): ProceduralTexture;
  11162. /**
  11163. * Set a mat4 in the shader from a MAtrix.
  11164. * @param name Define the name of the uniform as defined in the shader
  11165. * @param value Define the value to give to the uniform
  11166. * @return the texture itself allowing "fluent" like uniform updates
  11167. */
  11168. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11169. /**
  11170. * Render the texture to its associated render target.
  11171. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11172. */
  11173. render(useCameraPostProcess?: boolean): void;
  11174. /**
  11175. * Clone the texture.
  11176. * @returns the cloned texture
  11177. */
  11178. clone(): ProceduralTexture;
  11179. /**
  11180. * Dispose the texture and release its asoociated resources.
  11181. */
  11182. dispose(): void;
  11183. }
  11184. }
  11185. declare module "babylonjs/Particles/baseParticleSystem" {
  11186. import { Nullable } from "babylonjs/types";
  11187. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11189. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11190. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11191. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11192. import { Scene } from "babylonjs/scene";
  11193. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11194. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11195. import { Texture } from "babylonjs/Materials/Textures/texture";
  11196. import { Color4 } from "babylonjs/Maths/math.color";
  11197. import { Animation } from "babylonjs/Animations/animation";
  11198. /**
  11199. * This represents the base class for particle system in Babylon.
  11200. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11201. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11202. * @example https://doc.babylonjs.com/babylon101/particles
  11203. */
  11204. export class BaseParticleSystem {
  11205. /**
  11206. * Source color is added to the destination color without alpha affecting the result
  11207. */
  11208. static BLENDMODE_ONEONE: number;
  11209. /**
  11210. * Blend current color and particle color using particle’s alpha
  11211. */
  11212. static BLENDMODE_STANDARD: number;
  11213. /**
  11214. * Add current color and particle color multiplied by particle’s alpha
  11215. */
  11216. static BLENDMODE_ADD: number;
  11217. /**
  11218. * Multiply current color with particle color
  11219. */
  11220. static BLENDMODE_MULTIPLY: number;
  11221. /**
  11222. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11223. */
  11224. static BLENDMODE_MULTIPLYADD: number;
  11225. /**
  11226. * List of animations used by the particle system.
  11227. */
  11228. animations: Animation[];
  11229. /**
  11230. * The id of the Particle system.
  11231. */
  11232. id: string;
  11233. /**
  11234. * The friendly name of the Particle system.
  11235. */
  11236. name: string;
  11237. /**
  11238. * The rendering group used by the Particle system to chose when to render.
  11239. */
  11240. renderingGroupId: number;
  11241. /**
  11242. * The emitter represents the Mesh or position we are attaching the particle system to.
  11243. */
  11244. emitter: Nullable<AbstractMesh | Vector3>;
  11245. /**
  11246. * The maximum number of particles to emit per frame
  11247. */
  11248. emitRate: number;
  11249. /**
  11250. * If you want to launch only a few particles at once, that can be done, as well.
  11251. */
  11252. manualEmitCount: number;
  11253. /**
  11254. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11255. */
  11256. updateSpeed: number;
  11257. /**
  11258. * The amount of time the particle system is running (depends of the overall update speed).
  11259. */
  11260. targetStopDuration: number;
  11261. /**
  11262. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11263. */
  11264. disposeOnStop: boolean;
  11265. /**
  11266. * Minimum power of emitting particles.
  11267. */
  11268. minEmitPower: number;
  11269. /**
  11270. * Maximum power of emitting particles.
  11271. */
  11272. maxEmitPower: number;
  11273. /**
  11274. * Minimum life time of emitting particles.
  11275. */
  11276. minLifeTime: number;
  11277. /**
  11278. * Maximum life time of emitting particles.
  11279. */
  11280. maxLifeTime: number;
  11281. /**
  11282. * Minimum Size of emitting particles.
  11283. */
  11284. minSize: number;
  11285. /**
  11286. * Maximum Size of emitting particles.
  11287. */
  11288. maxSize: number;
  11289. /**
  11290. * Minimum scale of emitting particles on X axis.
  11291. */
  11292. minScaleX: number;
  11293. /**
  11294. * Maximum scale of emitting particles on X axis.
  11295. */
  11296. maxScaleX: number;
  11297. /**
  11298. * Minimum scale of emitting particles on Y axis.
  11299. */
  11300. minScaleY: number;
  11301. /**
  11302. * Maximum scale of emitting particles on Y axis.
  11303. */
  11304. maxScaleY: number;
  11305. /**
  11306. * Gets or sets the minimal initial rotation in radians.
  11307. */
  11308. minInitialRotation: number;
  11309. /**
  11310. * Gets or sets the maximal initial rotation in radians.
  11311. */
  11312. maxInitialRotation: number;
  11313. /**
  11314. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11315. */
  11316. minAngularSpeed: number;
  11317. /**
  11318. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11319. */
  11320. maxAngularSpeed: number;
  11321. /**
  11322. * The texture used to render each particle. (this can be a spritesheet)
  11323. */
  11324. particleTexture: Nullable<Texture>;
  11325. /**
  11326. * The layer mask we are rendering the particles through.
  11327. */
  11328. layerMask: number;
  11329. /**
  11330. * This can help using your own shader to render the particle system.
  11331. * The according effect will be created
  11332. */
  11333. customShader: any;
  11334. /**
  11335. * By default particle system starts as soon as they are created. This prevents the
  11336. * automatic start to happen and let you decide when to start emitting particles.
  11337. */
  11338. preventAutoStart: boolean;
  11339. private _noiseTexture;
  11340. /**
  11341. * Gets or sets a texture used to add random noise to particle positions
  11342. */
  11343. get noiseTexture(): Nullable<ProceduralTexture>;
  11344. set noiseTexture(value: Nullable<ProceduralTexture>);
  11345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11346. noiseStrength: Vector3;
  11347. /**
  11348. * Callback triggered when the particle animation is ending.
  11349. */
  11350. onAnimationEnd: Nullable<() => void>;
  11351. /**
  11352. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11353. */
  11354. blendMode: number;
  11355. /**
  11356. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11357. * to override the particles.
  11358. */
  11359. forceDepthWrite: boolean;
  11360. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11361. preWarmCycles: number;
  11362. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11363. preWarmStepOffset: number;
  11364. /**
  11365. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11366. */
  11367. spriteCellChangeSpeed: number;
  11368. /**
  11369. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11370. */
  11371. startSpriteCellID: number;
  11372. /**
  11373. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11374. */
  11375. endSpriteCellID: number;
  11376. /**
  11377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11378. */
  11379. spriteCellWidth: number;
  11380. /**
  11381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11382. */
  11383. spriteCellHeight: number;
  11384. /**
  11385. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11386. */
  11387. spriteRandomStartCell: boolean;
  11388. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11389. translationPivot: Vector2;
  11390. /** @hidden */
  11391. protected _isAnimationSheetEnabled: boolean;
  11392. /**
  11393. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11394. */
  11395. beginAnimationOnStart: boolean;
  11396. /**
  11397. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11398. */
  11399. beginAnimationFrom: number;
  11400. /**
  11401. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11402. */
  11403. beginAnimationTo: number;
  11404. /**
  11405. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11406. */
  11407. beginAnimationLoop: boolean;
  11408. /**
  11409. * Gets or sets a world offset applied to all particles
  11410. */
  11411. worldOffset: Vector3;
  11412. /**
  11413. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11414. */
  11415. get isAnimationSheetEnabled(): boolean;
  11416. set isAnimationSheetEnabled(value: boolean);
  11417. /**
  11418. * Get hosting scene
  11419. * @returns the scene
  11420. */
  11421. getScene(): Scene;
  11422. /**
  11423. * You can use gravity if you want to give an orientation to your particles.
  11424. */
  11425. gravity: Vector3;
  11426. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11427. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11428. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11429. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11430. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11431. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11432. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11433. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11434. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11435. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11436. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11437. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11438. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11439. /**
  11440. * Defines the delay in milliseconds before starting the system (0 by default)
  11441. */
  11442. startDelay: number;
  11443. /**
  11444. * Gets the current list of drag gradients.
  11445. * You must use addDragGradient and removeDragGradient to udpate this list
  11446. * @returns the list of drag gradients
  11447. */
  11448. getDragGradients(): Nullable<Array<FactorGradient>>;
  11449. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11450. limitVelocityDamping: number;
  11451. /**
  11452. * Gets the current list of limit velocity gradients.
  11453. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11454. * @returns the list of limit velocity gradients
  11455. */
  11456. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11457. /**
  11458. * Gets the current list of color gradients.
  11459. * You must use addColorGradient and removeColorGradient to udpate this list
  11460. * @returns the list of color gradients
  11461. */
  11462. getColorGradients(): Nullable<Array<ColorGradient>>;
  11463. /**
  11464. * Gets the current list of size gradients.
  11465. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11466. * @returns the list of size gradients
  11467. */
  11468. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11469. /**
  11470. * Gets the current list of color remap gradients.
  11471. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11472. * @returns the list of color remap gradients
  11473. */
  11474. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11475. /**
  11476. * Gets the current list of alpha remap gradients.
  11477. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11478. * @returns the list of alpha remap gradients
  11479. */
  11480. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11481. /**
  11482. * Gets the current list of life time gradients.
  11483. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11484. * @returns the list of life time gradients
  11485. */
  11486. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11487. /**
  11488. * Gets the current list of angular speed gradients.
  11489. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11490. * @returns the list of angular speed gradients
  11491. */
  11492. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11493. /**
  11494. * Gets the current list of velocity gradients.
  11495. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11496. * @returns the list of velocity gradients
  11497. */
  11498. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11499. /**
  11500. * Gets the current list of start size gradients.
  11501. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11502. * @returns the list of start size gradients
  11503. */
  11504. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11505. /**
  11506. * Gets the current list of emit rate gradients.
  11507. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11508. * @returns the list of emit rate gradients
  11509. */
  11510. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11511. /**
  11512. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11513. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11514. */
  11515. get direction1(): Vector3;
  11516. set direction1(value: Vector3);
  11517. /**
  11518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11520. */
  11521. get direction2(): Vector3;
  11522. set direction2(value: Vector3);
  11523. /**
  11524. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11526. */
  11527. get minEmitBox(): Vector3;
  11528. set minEmitBox(value: Vector3);
  11529. /**
  11530. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11532. */
  11533. get maxEmitBox(): Vector3;
  11534. set maxEmitBox(value: Vector3);
  11535. /**
  11536. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11537. */
  11538. color1: Color4;
  11539. /**
  11540. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11541. */
  11542. color2: Color4;
  11543. /**
  11544. * Color the particle will have at the end of its lifetime
  11545. */
  11546. colorDead: Color4;
  11547. /**
  11548. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11549. */
  11550. textureMask: Color4;
  11551. /**
  11552. * The particle emitter type defines the emitter used by the particle system.
  11553. * It can be for example box, sphere, or cone...
  11554. */
  11555. particleEmitterType: IParticleEmitterType;
  11556. /** @hidden */
  11557. _isSubEmitter: boolean;
  11558. /**
  11559. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11560. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11561. */
  11562. billboardMode: number;
  11563. protected _isBillboardBased: boolean;
  11564. /**
  11565. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11566. */
  11567. get isBillboardBased(): boolean;
  11568. set isBillboardBased(value: boolean);
  11569. /**
  11570. * The scene the particle system belongs to.
  11571. */
  11572. protected _scene: Scene;
  11573. /**
  11574. * Local cache of defines for image processing.
  11575. */
  11576. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11577. /**
  11578. * Default configuration related to image processing available in the standard Material.
  11579. */
  11580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11581. /**
  11582. * Gets the image processing configuration used either in this material.
  11583. */
  11584. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11585. /**
  11586. * Sets the Default image processing configuration used either in the this material.
  11587. *
  11588. * If sets to null, the scene one is in use.
  11589. */
  11590. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11591. /**
  11592. * Attaches a new image processing configuration to the Standard Material.
  11593. * @param configuration
  11594. */
  11595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11596. /** @hidden */
  11597. protected _reset(): void;
  11598. /** @hidden */
  11599. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11600. /**
  11601. * Instantiates a particle system.
  11602. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11603. * @param name The name of the particle system
  11604. */
  11605. constructor(name: string);
  11606. /**
  11607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11610. * @returns the emitter
  11611. */
  11612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11613. /**
  11614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11615. * @param radius The radius of the hemisphere to emit from
  11616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11617. * @returns the emitter
  11618. */
  11619. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11620. /**
  11621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11622. * @param radius The radius of the sphere to emit from
  11623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11624. * @returns the emitter
  11625. */
  11626. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11627. /**
  11628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11629. * @param radius The radius of the sphere to emit from
  11630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11632. * @returns the emitter
  11633. */
  11634. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11635. /**
  11636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11637. * @param radius The radius of the emission cylinder
  11638. * @param height The height of the emission cylinder
  11639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11641. * @returns the emitter
  11642. */
  11643. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11644. /**
  11645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11646. * @param radius The radius of the cylinder to emit from
  11647. * @param height The height of the emission cylinder
  11648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11651. * @returns the emitter
  11652. */
  11653. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11654. /**
  11655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11656. * @param radius The radius of the cone to emit from
  11657. * @param angle The base angle of the cone
  11658. * @returns the emitter
  11659. */
  11660. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11661. /**
  11662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11667. * @returns the emitter
  11668. */
  11669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11670. }
  11671. }
  11672. declare module "babylonjs/Particles/subEmitter" {
  11673. import { Scene } from "babylonjs/scene";
  11674. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11675. /**
  11676. * Type of sub emitter
  11677. */
  11678. export enum SubEmitterType {
  11679. /**
  11680. * Attached to the particle over it's lifetime
  11681. */
  11682. ATTACHED = 0,
  11683. /**
  11684. * Created when the particle dies
  11685. */
  11686. END = 1
  11687. }
  11688. /**
  11689. * Sub emitter class used to emit particles from an existing particle
  11690. */
  11691. export class SubEmitter {
  11692. /**
  11693. * the particle system to be used by the sub emitter
  11694. */
  11695. particleSystem: ParticleSystem;
  11696. /**
  11697. * Type of the submitter (Default: END)
  11698. */
  11699. type: SubEmitterType;
  11700. /**
  11701. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11702. * Note: This only is supported when using an emitter of type Mesh
  11703. */
  11704. inheritDirection: boolean;
  11705. /**
  11706. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11707. */
  11708. inheritedVelocityAmount: number;
  11709. /**
  11710. * Creates a sub emitter
  11711. * @param particleSystem the particle system to be used by the sub emitter
  11712. */
  11713. constructor(
  11714. /**
  11715. * the particle system to be used by the sub emitter
  11716. */
  11717. particleSystem: ParticleSystem);
  11718. /**
  11719. * Clones the sub emitter
  11720. * @returns the cloned sub emitter
  11721. */
  11722. clone(): SubEmitter;
  11723. /**
  11724. * Serialize current object to a JSON object
  11725. * @returns the serialized object
  11726. */
  11727. serialize(): any;
  11728. /** @hidden */
  11729. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11730. /**
  11731. * Creates a new SubEmitter from a serialized JSON version
  11732. * @param serializationObject defines the JSON object to read from
  11733. * @param scene defines the hosting scene
  11734. * @param rootUrl defines the rootUrl for data loading
  11735. * @returns a new SubEmitter
  11736. */
  11737. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11738. /** Release associated resources */
  11739. dispose(): void;
  11740. }
  11741. }
  11742. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11743. /** @hidden */
  11744. export var imageProcessingDeclaration: {
  11745. name: string;
  11746. shader: string;
  11747. };
  11748. }
  11749. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11750. /** @hidden */
  11751. export var imageProcessingFunctions: {
  11752. name: string;
  11753. shader: string;
  11754. };
  11755. }
  11756. declare module "babylonjs/Shaders/particles.fragment" {
  11757. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11758. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11759. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11760. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11761. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11762. /** @hidden */
  11763. export var particlesPixelShader: {
  11764. name: string;
  11765. shader: string;
  11766. };
  11767. }
  11768. declare module "babylonjs/Shaders/particles.vertex" {
  11769. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11770. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11771. /** @hidden */
  11772. export var particlesVertexShader: {
  11773. name: string;
  11774. shader: string;
  11775. };
  11776. }
  11777. declare module "babylonjs/Particles/particleSystem" {
  11778. import { Nullable } from "babylonjs/types";
  11779. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11780. import { Observable } from "babylonjs/Misc/observable";
  11781. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11782. import { Effect } from "babylonjs/Materials/effect";
  11783. import { Scene, IDisposable } from "babylonjs/scene";
  11784. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11785. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11786. import { Particle } from "babylonjs/Particles/particle";
  11787. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11788. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11789. import "babylonjs/Shaders/particles.fragment";
  11790. import "babylonjs/Shaders/particles.vertex";
  11791. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11792. /**
  11793. * This represents a particle system in Babylon.
  11794. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11795. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11796. * @example https://doc.babylonjs.com/babylon101/particles
  11797. */
  11798. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11799. /**
  11800. * Billboard mode will only apply to Y axis
  11801. */
  11802. static readonly BILLBOARDMODE_Y: number;
  11803. /**
  11804. * Billboard mode will apply to all axes
  11805. */
  11806. static readonly BILLBOARDMODE_ALL: number;
  11807. /**
  11808. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11809. */
  11810. static readonly BILLBOARDMODE_STRETCHED: number;
  11811. /**
  11812. * This function can be defined to provide custom update for active particles.
  11813. * This function will be called instead of regular update (age, position, color, etc.).
  11814. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11815. */
  11816. updateFunction: (particles: Particle[]) => void;
  11817. private _emitterWorldMatrix;
  11818. /**
  11819. * This function can be defined to specify initial direction for every new particle.
  11820. * It by default use the emitterType defined function
  11821. */
  11822. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11823. /**
  11824. * This function can be defined to specify initial position for every new particle.
  11825. * It by default use the emitterType defined function
  11826. */
  11827. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11828. /**
  11829. * @hidden
  11830. */
  11831. _inheritedVelocityOffset: Vector3;
  11832. /**
  11833. * An event triggered when the system is disposed
  11834. */
  11835. onDisposeObservable: Observable<ParticleSystem>;
  11836. private _onDisposeObserver;
  11837. /**
  11838. * Sets a callback that will be triggered when the system is disposed
  11839. */
  11840. set onDispose(callback: () => void);
  11841. private _particles;
  11842. private _epsilon;
  11843. private _capacity;
  11844. private _stockParticles;
  11845. private _newPartsExcess;
  11846. private _vertexData;
  11847. private _vertexBuffer;
  11848. private _vertexBuffers;
  11849. private _spriteBuffer;
  11850. private _indexBuffer;
  11851. private _effect;
  11852. private _customEffect;
  11853. private _cachedDefines;
  11854. private _scaledColorStep;
  11855. private _colorDiff;
  11856. private _scaledDirection;
  11857. private _scaledGravity;
  11858. private _currentRenderId;
  11859. private _alive;
  11860. private _useInstancing;
  11861. private _started;
  11862. private _stopped;
  11863. private _actualFrame;
  11864. private _scaledUpdateSpeed;
  11865. private _vertexBufferSize;
  11866. /** @hidden */
  11867. _currentEmitRateGradient: Nullable<FactorGradient>;
  11868. /** @hidden */
  11869. _currentEmitRate1: number;
  11870. /** @hidden */
  11871. _currentEmitRate2: number;
  11872. /** @hidden */
  11873. _currentStartSizeGradient: Nullable<FactorGradient>;
  11874. /** @hidden */
  11875. _currentStartSize1: number;
  11876. /** @hidden */
  11877. _currentStartSize2: number;
  11878. private readonly _rawTextureWidth;
  11879. private _rampGradientsTexture;
  11880. private _useRampGradients;
  11881. /** Gets or sets a boolean indicating that ramp gradients must be used
  11882. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11883. */
  11884. get useRampGradients(): boolean;
  11885. set useRampGradients(value: boolean);
  11886. /**
  11887. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11888. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11889. */
  11890. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11891. private _subEmitters;
  11892. /**
  11893. * @hidden
  11894. * If the particle systems emitter should be disposed when the particle system is disposed
  11895. */
  11896. _disposeEmitterOnDispose: boolean;
  11897. /**
  11898. * The current active Sub-systems, this property is used by the root particle system only.
  11899. */
  11900. activeSubSystems: Array<ParticleSystem>;
  11901. /**
  11902. * Specifies if the particles are updated in emitter local space or world space
  11903. */
  11904. isLocal: boolean;
  11905. private _rootParticleSystem;
  11906. /**
  11907. * Gets the current list of active particles
  11908. */
  11909. get particles(): Particle[];
  11910. /**
  11911. * Returns the string "ParticleSystem"
  11912. * @returns a string containing the class name
  11913. */
  11914. getClassName(): string;
  11915. /**
  11916. * Instantiates a particle system.
  11917. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11918. * @param name The name of the particle system
  11919. * @param capacity The max number of particles alive at the same time
  11920. * @param scene The scene the particle system belongs to
  11921. * @param customEffect a custom effect used to change the way particles are rendered by default
  11922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11923. * @param epsilon Offset used to render the particles
  11924. */
  11925. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11926. private _addFactorGradient;
  11927. private _removeFactorGradient;
  11928. /**
  11929. * Adds a new life time gradient
  11930. * @param gradient defines the gradient to use (between 0 and 1)
  11931. * @param factor defines the life time factor to affect to the specified gradient
  11932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11933. * @returns the current particle system
  11934. */
  11935. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11936. /**
  11937. * Remove a specific life time gradient
  11938. * @param gradient defines the gradient to remove
  11939. * @returns the current particle system
  11940. */
  11941. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11942. /**
  11943. * Adds a new size gradient
  11944. * @param gradient defines the gradient to use (between 0 and 1)
  11945. * @param factor defines the size factor to affect to the specified gradient
  11946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11947. * @returns the current particle system
  11948. */
  11949. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11950. /**
  11951. * Remove a specific size gradient
  11952. * @param gradient defines the gradient to remove
  11953. * @returns the current particle system
  11954. */
  11955. removeSizeGradient(gradient: number): IParticleSystem;
  11956. /**
  11957. * Adds a new color remap gradient
  11958. * @param gradient defines the gradient to use (between 0 and 1)
  11959. * @param min defines the color remap minimal range
  11960. * @param max defines the color remap maximal range
  11961. * @returns the current particle system
  11962. */
  11963. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11964. /**
  11965. * Remove a specific color remap gradient
  11966. * @param gradient defines the gradient to remove
  11967. * @returns the current particle system
  11968. */
  11969. removeColorRemapGradient(gradient: number): IParticleSystem;
  11970. /**
  11971. * Adds a new alpha remap gradient
  11972. * @param gradient defines the gradient to use (between 0 and 1)
  11973. * @param min defines the alpha remap minimal range
  11974. * @param max defines the alpha remap maximal range
  11975. * @returns the current particle system
  11976. */
  11977. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11978. /**
  11979. * Remove a specific alpha remap gradient
  11980. * @param gradient defines the gradient to remove
  11981. * @returns the current particle system
  11982. */
  11983. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11984. /**
  11985. * Adds a new angular speed gradient
  11986. * @param gradient defines the gradient to use (between 0 and 1)
  11987. * @param factor defines the angular speed to affect to the specified gradient
  11988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11989. * @returns the current particle system
  11990. */
  11991. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11992. /**
  11993. * Remove a specific angular speed gradient
  11994. * @param gradient defines the gradient to remove
  11995. * @returns the current particle system
  11996. */
  11997. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11998. /**
  11999. * Adds a new velocity gradient
  12000. * @param gradient defines the gradient to use (between 0 and 1)
  12001. * @param factor defines the velocity to affect to the specified gradient
  12002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12003. * @returns the current particle system
  12004. */
  12005. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12006. /**
  12007. * Remove a specific velocity gradient
  12008. * @param gradient defines the gradient to remove
  12009. * @returns the current particle system
  12010. */
  12011. removeVelocityGradient(gradient: number): IParticleSystem;
  12012. /**
  12013. * Adds a new limit velocity gradient
  12014. * @param gradient defines the gradient to use (between 0 and 1)
  12015. * @param factor defines the limit velocity value to affect to the specified gradient
  12016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12017. * @returns the current particle system
  12018. */
  12019. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12020. /**
  12021. * Remove a specific limit velocity gradient
  12022. * @param gradient defines the gradient to remove
  12023. * @returns the current particle system
  12024. */
  12025. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12026. /**
  12027. * Adds a new drag gradient
  12028. * @param gradient defines the gradient to use (between 0 and 1)
  12029. * @param factor defines the drag value to affect to the specified gradient
  12030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12031. * @returns the current particle system
  12032. */
  12033. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12034. /**
  12035. * Remove a specific drag gradient
  12036. * @param gradient defines the gradient to remove
  12037. * @returns the current particle system
  12038. */
  12039. removeDragGradient(gradient: number): IParticleSystem;
  12040. /**
  12041. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12042. * @param gradient defines the gradient to use (between 0 and 1)
  12043. * @param factor defines the emit rate value to affect to the specified gradient
  12044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12045. * @returns the current particle system
  12046. */
  12047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12048. /**
  12049. * Remove a specific emit rate gradient
  12050. * @param gradient defines the gradient to remove
  12051. * @returns the current particle system
  12052. */
  12053. removeEmitRateGradient(gradient: number): IParticleSystem;
  12054. /**
  12055. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12056. * @param gradient defines the gradient to use (between 0 and 1)
  12057. * @param factor defines the start size value to affect to the specified gradient
  12058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12059. * @returns the current particle system
  12060. */
  12061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12062. /**
  12063. * Remove a specific start size gradient
  12064. * @param gradient defines the gradient to remove
  12065. * @returns the current particle system
  12066. */
  12067. removeStartSizeGradient(gradient: number): IParticleSystem;
  12068. private _createRampGradientTexture;
  12069. /**
  12070. * Gets the current list of ramp gradients.
  12071. * You must use addRampGradient and removeRampGradient to udpate this list
  12072. * @returns the list of ramp gradients
  12073. */
  12074. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12075. /**
  12076. * Adds a new ramp gradient used to remap particle colors
  12077. * @param gradient defines the gradient to use (between 0 and 1)
  12078. * @param color defines the color to affect to the specified gradient
  12079. * @returns the current particle system
  12080. */
  12081. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12082. /**
  12083. * Remove a specific ramp gradient
  12084. * @param gradient defines the gradient to remove
  12085. * @returns the current particle system
  12086. */
  12087. removeRampGradient(gradient: number): ParticleSystem;
  12088. /**
  12089. * Adds a new color gradient
  12090. * @param gradient defines the gradient to use (between 0 and 1)
  12091. * @param color1 defines the color to affect to the specified gradient
  12092. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12093. * @returns this particle system
  12094. */
  12095. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12096. /**
  12097. * Remove a specific color gradient
  12098. * @param gradient defines the gradient to remove
  12099. * @returns this particle system
  12100. */
  12101. removeColorGradient(gradient: number): IParticleSystem;
  12102. private _fetchR;
  12103. protected _reset(): void;
  12104. private _resetEffect;
  12105. private _createVertexBuffers;
  12106. private _createIndexBuffer;
  12107. /**
  12108. * Gets the maximum number of particles active at the same time.
  12109. * @returns The max number of active particles.
  12110. */
  12111. getCapacity(): number;
  12112. /**
  12113. * Gets whether there are still active particles in the system.
  12114. * @returns True if it is alive, otherwise false.
  12115. */
  12116. isAlive(): boolean;
  12117. /**
  12118. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12119. * @returns True if it has been started, otherwise false.
  12120. */
  12121. isStarted(): boolean;
  12122. private _prepareSubEmitterInternalArray;
  12123. /**
  12124. * Starts the particle system and begins to emit
  12125. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12126. */
  12127. start(delay?: number): void;
  12128. /**
  12129. * Stops the particle system.
  12130. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12131. */
  12132. stop(stopSubEmitters?: boolean): void;
  12133. /**
  12134. * Remove all active particles
  12135. */
  12136. reset(): void;
  12137. /**
  12138. * @hidden (for internal use only)
  12139. */
  12140. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12141. /**
  12142. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12143. * Its lifetime will start back at 0.
  12144. */
  12145. recycleParticle: (particle: Particle) => void;
  12146. private _stopSubEmitters;
  12147. private _createParticle;
  12148. private _removeFromRoot;
  12149. private _emitFromParticle;
  12150. private _update;
  12151. /** @hidden */
  12152. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12153. /** @hidden */
  12154. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12155. /** @hidden */
  12156. private _getEffect;
  12157. /**
  12158. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12159. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12160. */
  12161. animate(preWarmOnly?: boolean): void;
  12162. private _appendParticleVertices;
  12163. /**
  12164. * Rebuilds the particle system.
  12165. */
  12166. rebuild(): void;
  12167. /**
  12168. * Is this system ready to be used/rendered
  12169. * @return true if the system is ready
  12170. */
  12171. isReady(): boolean;
  12172. private _render;
  12173. /**
  12174. * Renders the particle system in its current state.
  12175. * @returns the current number of particles
  12176. */
  12177. render(): number;
  12178. /**
  12179. * Disposes the particle system and free the associated resources
  12180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12181. */
  12182. dispose(disposeTexture?: boolean): void;
  12183. /**
  12184. * Clones the particle system.
  12185. * @param name The name of the cloned object
  12186. * @param newEmitter The new emitter to use
  12187. * @returns the cloned particle system
  12188. */
  12189. clone(name: string, newEmitter: any): ParticleSystem;
  12190. /**
  12191. * Serializes the particle system to a JSON object.
  12192. * @returns the JSON object
  12193. */
  12194. serialize(): any;
  12195. /** @hidden */
  12196. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12197. /** @hidden */
  12198. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12199. /**
  12200. * Parses a JSON object to create a particle system.
  12201. * @param parsedParticleSystem The JSON object to parse
  12202. * @param scene The scene to create the particle system in
  12203. * @param rootUrl The root url to use to load external dependencies like texture
  12204. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12205. * @returns the Parsed particle system
  12206. */
  12207. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12208. }
  12209. }
  12210. declare module "babylonjs/Particles/particle" {
  12211. import { Nullable } from "babylonjs/types";
  12212. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12213. import { Color4 } from "babylonjs/Maths/math.color";
  12214. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12215. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12216. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12217. /**
  12218. * A particle represents one of the element emitted by a particle system.
  12219. * This is mainly define by its coordinates, direction, velocity and age.
  12220. */
  12221. export class Particle {
  12222. /**
  12223. * The particle system the particle belongs to.
  12224. */
  12225. particleSystem: ParticleSystem;
  12226. private static _Count;
  12227. /**
  12228. * Unique ID of the particle
  12229. */
  12230. id: number;
  12231. /**
  12232. * The world position of the particle in the scene.
  12233. */
  12234. position: Vector3;
  12235. /**
  12236. * The world direction of the particle in the scene.
  12237. */
  12238. direction: Vector3;
  12239. /**
  12240. * The color of the particle.
  12241. */
  12242. color: Color4;
  12243. /**
  12244. * The color change of the particle per step.
  12245. */
  12246. colorStep: Color4;
  12247. /**
  12248. * Defines how long will the life of the particle be.
  12249. */
  12250. lifeTime: number;
  12251. /**
  12252. * The current age of the particle.
  12253. */
  12254. age: number;
  12255. /**
  12256. * The current size of the particle.
  12257. */
  12258. size: number;
  12259. /**
  12260. * The current scale of the particle.
  12261. */
  12262. scale: Vector2;
  12263. /**
  12264. * The current angle of the particle.
  12265. */
  12266. angle: number;
  12267. /**
  12268. * Defines how fast is the angle changing.
  12269. */
  12270. angularSpeed: number;
  12271. /**
  12272. * Defines the cell index used by the particle to be rendered from a sprite.
  12273. */
  12274. cellIndex: number;
  12275. /**
  12276. * The information required to support color remapping
  12277. */
  12278. remapData: Vector4;
  12279. /** @hidden */
  12280. _randomCellOffset?: number;
  12281. /** @hidden */
  12282. _initialDirection: Nullable<Vector3>;
  12283. /** @hidden */
  12284. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12285. /** @hidden */
  12286. _initialStartSpriteCellID: number;
  12287. /** @hidden */
  12288. _initialEndSpriteCellID: number;
  12289. /** @hidden */
  12290. _currentColorGradient: Nullable<ColorGradient>;
  12291. /** @hidden */
  12292. _currentColor1: Color4;
  12293. /** @hidden */
  12294. _currentColor2: Color4;
  12295. /** @hidden */
  12296. _currentSizeGradient: Nullable<FactorGradient>;
  12297. /** @hidden */
  12298. _currentSize1: number;
  12299. /** @hidden */
  12300. _currentSize2: number;
  12301. /** @hidden */
  12302. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12303. /** @hidden */
  12304. _currentAngularSpeed1: number;
  12305. /** @hidden */
  12306. _currentAngularSpeed2: number;
  12307. /** @hidden */
  12308. _currentVelocityGradient: Nullable<FactorGradient>;
  12309. /** @hidden */
  12310. _currentVelocity1: number;
  12311. /** @hidden */
  12312. _currentVelocity2: number;
  12313. /** @hidden */
  12314. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12315. /** @hidden */
  12316. _currentLimitVelocity1: number;
  12317. /** @hidden */
  12318. _currentLimitVelocity2: number;
  12319. /** @hidden */
  12320. _currentDragGradient: Nullable<FactorGradient>;
  12321. /** @hidden */
  12322. _currentDrag1: number;
  12323. /** @hidden */
  12324. _currentDrag2: number;
  12325. /** @hidden */
  12326. _randomNoiseCoordinates1: Vector3;
  12327. /** @hidden */
  12328. _randomNoiseCoordinates2: Vector3;
  12329. /** @hidden */
  12330. _localPosition?: Vector3;
  12331. /**
  12332. * Creates a new instance Particle
  12333. * @param particleSystem the particle system the particle belongs to
  12334. */
  12335. constructor(
  12336. /**
  12337. * The particle system the particle belongs to.
  12338. */
  12339. particleSystem: ParticleSystem);
  12340. private updateCellInfoFromSystem;
  12341. /**
  12342. * Defines how the sprite cell index is updated for the particle
  12343. */
  12344. updateCellIndex(): void;
  12345. /** @hidden */
  12346. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12347. /** @hidden */
  12348. _inheritParticleInfoToSubEmitters(): void;
  12349. /** @hidden */
  12350. _reset(): void;
  12351. /**
  12352. * Copy the properties of particle to another one.
  12353. * @param other the particle to copy the information to.
  12354. */
  12355. copyTo(other: Particle): void;
  12356. }
  12357. }
  12358. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12359. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12360. import { Effect } from "babylonjs/Materials/effect";
  12361. import { Particle } from "babylonjs/Particles/particle";
  12362. import { Scene } from "babylonjs/scene";
  12363. /**
  12364. * Particle emitter represents a volume emitting particles.
  12365. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12366. */
  12367. export interface IParticleEmitterType {
  12368. /**
  12369. * Called by the particle System when the direction is computed for the created particle.
  12370. * @param worldMatrix is the world matrix of the particle system
  12371. * @param directionToUpdate is the direction vector to update with the result
  12372. * @param particle is the particle we are computed the direction for
  12373. * @param isLocal defines if the direction should be set in local space
  12374. */
  12375. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12376. /**
  12377. * Called by the particle System when the position is computed for the created particle.
  12378. * @param worldMatrix is the world matrix of the particle system
  12379. * @param positionToUpdate is the position vector to update with the result
  12380. * @param particle is the particle we are computed the position for
  12381. * @param isLocal defines if the position should be set in local space
  12382. */
  12383. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12384. /**
  12385. * Clones the current emitter and returns a copy of it
  12386. * @returns the new emitter
  12387. */
  12388. clone(): IParticleEmitterType;
  12389. /**
  12390. * Called by the GPUParticleSystem to setup the update shader
  12391. * @param effect defines the update shader
  12392. */
  12393. applyToShader(effect: Effect): void;
  12394. /**
  12395. * Returns a string to use to update the GPU particles update shader
  12396. * @returns the effect defines string
  12397. */
  12398. getEffectDefines(): string;
  12399. /**
  12400. * Returns a string representing the class name
  12401. * @returns a string containing the class name
  12402. */
  12403. getClassName(): string;
  12404. /**
  12405. * Serializes the particle system to a JSON object.
  12406. * @returns the JSON object
  12407. */
  12408. serialize(): any;
  12409. /**
  12410. * Parse properties from a JSON object
  12411. * @param serializationObject defines the JSON object
  12412. * @param scene defines the hosting scene
  12413. */
  12414. parse(serializationObject: any, scene: Scene): void;
  12415. }
  12416. }
  12417. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12418. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12419. import { Effect } from "babylonjs/Materials/effect";
  12420. import { Particle } from "babylonjs/Particles/particle";
  12421. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12422. /**
  12423. * Particle emitter emitting particles from the inside of a box.
  12424. * It emits the particles randomly between 2 given directions.
  12425. */
  12426. export class BoxParticleEmitter implements IParticleEmitterType {
  12427. /**
  12428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12429. */
  12430. direction1: Vector3;
  12431. /**
  12432. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12433. */
  12434. direction2: Vector3;
  12435. /**
  12436. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12437. */
  12438. minEmitBox: Vector3;
  12439. /**
  12440. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12441. */
  12442. maxEmitBox: Vector3;
  12443. /**
  12444. * Creates a new instance BoxParticleEmitter
  12445. */
  12446. constructor();
  12447. /**
  12448. * Called by the particle System when the direction is computed for the created particle.
  12449. * @param worldMatrix is the world matrix of the particle system
  12450. * @param directionToUpdate is the direction vector to update with the result
  12451. * @param particle is the particle we are computed the direction for
  12452. * @param isLocal defines if the direction should be set in local space
  12453. */
  12454. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12455. /**
  12456. * Called by the particle System when the position is computed for the created particle.
  12457. * @param worldMatrix is the world matrix of the particle system
  12458. * @param positionToUpdate is the position vector to update with the result
  12459. * @param particle is the particle we are computed the position for
  12460. * @param isLocal defines if the position should be set in local space
  12461. */
  12462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12463. /**
  12464. * Clones the current emitter and returns a copy of it
  12465. * @returns the new emitter
  12466. */
  12467. clone(): BoxParticleEmitter;
  12468. /**
  12469. * Called by the GPUParticleSystem to setup the update shader
  12470. * @param effect defines the update shader
  12471. */
  12472. applyToShader(effect: Effect): void;
  12473. /**
  12474. * Returns a string to use to update the GPU particles update shader
  12475. * @returns a string containng the defines string
  12476. */
  12477. getEffectDefines(): string;
  12478. /**
  12479. * Returns the string "BoxParticleEmitter"
  12480. * @returns a string containing the class name
  12481. */
  12482. getClassName(): string;
  12483. /**
  12484. * Serializes the particle system to a JSON object.
  12485. * @returns the JSON object
  12486. */
  12487. serialize(): any;
  12488. /**
  12489. * Parse properties from a JSON object
  12490. * @param serializationObject defines the JSON object
  12491. */
  12492. parse(serializationObject: any): void;
  12493. }
  12494. }
  12495. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12496. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12497. import { Effect } from "babylonjs/Materials/effect";
  12498. import { Particle } from "babylonjs/Particles/particle";
  12499. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12500. /**
  12501. * Particle emitter emitting particles from the inside of a cone.
  12502. * It emits the particles alongside the cone volume from the base to the particle.
  12503. * The emission direction might be randomized.
  12504. */
  12505. export class ConeParticleEmitter implements IParticleEmitterType {
  12506. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12507. directionRandomizer: number;
  12508. private _radius;
  12509. private _angle;
  12510. private _height;
  12511. /**
  12512. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12513. */
  12514. radiusRange: number;
  12515. /**
  12516. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12517. */
  12518. heightRange: number;
  12519. /**
  12520. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12521. */
  12522. emitFromSpawnPointOnly: boolean;
  12523. /**
  12524. * Gets or sets the radius of the emission cone
  12525. */
  12526. get radius(): number;
  12527. set radius(value: number);
  12528. /**
  12529. * Gets or sets the angle of the emission cone
  12530. */
  12531. get angle(): number;
  12532. set angle(value: number);
  12533. private _buildHeight;
  12534. /**
  12535. * Creates a new instance ConeParticleEmitter
  12536. * @param radius the radius of the emission cone (1 by default)
  12537. * @param angle the cone base angle (PI by default)
  12538. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12539. */
  12540. constructor(radius?: number, angle?: number,
  12541. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12542. directionRandomizer?: number);
  12543. /**
  12544. * Called by the particle System when the direction is computed for the created particle.
  12545. * @param worldMatrix is the world matrix of the particle system
  12546. * @param directionToUpdate is the direction vector to update with the result
  12547. * @param particle is the particle we are computed the direction for
  12548. * @param isLocal defines if the direction should be set in local space
  12549. */
  12550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12551. /**
  12552. * Called by the particle System when the position is computed for the created particle.
  12553. * @param worldMatrix is the world matrix of the particle system
  12554. * @param positionToUpdate is the position vector to update with the result
  12555. * @param particle is the particle we are computed the position for
  12556. * @param isLocal defines if the position should be set in local space
  12557. */
  12558. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12559. /**
  12560. * Clones the current emitter and returns a copy of it
  12561. * @returns the new emitter
  12562. */
  12563. clone(): ConeParticleEmitter;
  12564. /**
  12565. * Called by the GPUParticleSystem to setup the update shader
  12566. * @param effect defines the update shader
  12567. */
  12568. applyToShader(effect: Effect): void;
  12569. /**
  12570. * Returns a string to use to update the GPU particles update shader
  12571. * @returns a string containng the defines string
  12572. */
  12573. getEffectDefines(): string;
  12574. /**
  12575. * Returns the string "ConeParticleEmitter"
  12576. * @returns a string containing the class name
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Serializes the particle system to a JSON object.
  12581. * @returns the JSON object
  12582. */
  12583. serialize(): any;
  12584. /**
  12585. * Parse properties from a JSON object
  12586. * @param serializationObject defines the JSON object
  12587. */
  12588. parse(serializationObject: any): void;
  12589. }
  12590. }
  12591. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12592. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12593. import { Effect } from "babylonjs/Materials/effect";
  12594. import { Particle } from "babylonjs/Particles/particle";
  12595. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12596. /**
  12597. * Particle emitter emitting particles from the inside of a cylinder.
  12598. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12599. */
  12600. export class CylinderParticleEmitter implements IParticleEmitterType {
  12601. /**
  12602. * The radius of the emission cylinder.
  12603. */
  12604. radius: number;
  12605. /**
  12606. * The height of the emission cylinder.
  12607. */
  12608. height: number;
  12609. /**
  12610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12611. */
  12612. radiusRange: number;
  12613. /**
  12614. * How much to randomize the particle direction [0-1].
  12615. */
  12616. directionRandomizer: number;
  12617. /**
  12618. * Creates a new instance CylinderParticleEmitter
  12619. * @param radius the radius of the emission cylinder (1 by default)
  12620. * @param height the height of the emission cylinder (1 by default)
  12621. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12622. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12623. */
  12624. constructor(
  12625. /**
  12626. * The radius of the emission cylinder.
  12627. */
  12628. radius?: number,
  12629. /**
  12630. * The height of the emission cylinder.
  12631. */
  12632. height?: number,
  12633. /**
  12634. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12635. */
  12636. radiusRange?: number,
  12637. /**
  12638. * How much to randomize the particle direction [0-1].
  12639. */
  12640. directionRandomizer?: number);
  12641. /**
  12642. * Called by the particle System when the direction is computed for the created particle.
  12643. * @param worldMatrix is the world matrix of the particle system
  12644. * @param directionToUpdate is the direction vector to update with the result
  12645. * @param particle is the particle we are computed the direction for
  12646. * @param isLocal defines if the direction should be set in local space
  12647. */
  12648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12649. /**
  12650. * Called by the particle System when the position is computed for the created particle.
  12651. * @param worldMatrix is the world matrix of the particle system
  12652. * @param positionToUpdate is the position vector to update with the result
  12653. * @param particle is the particle we are computed the position for
  12654. * @param isLocal defines if the position should be set in local space
  12655. */
  12656. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12657. /**
  12658. * Clones the current emitter and returns a copy of it
  12659. * @returns the new emitter
  12660. */
  12661. clone(): CylinderParticleEmitter;
  12662. /**
  12663. * Called by the GPUParticleSystem to setup the update shader
  12664. * @param effect defines the update shader
  12665. */
  12666. applyToShader(effect: Effect): void;
  12667. /**
  12668. * Returns a string to use to update the GPU particles update shader
  12669. * @returns a string containng the defines string
  12670. */
  12671. getEffectDefines(): string;
  12672. /**
  12673. * Returns the string "CylinderParticleEmitter"
  12674. * @returns a string containing the class name
  12675. */
  12676. getClassName(): string;
  12677. /**
  12678. * Serializes the particle system to a JSON object.
  12679. * @returns the JSON object
  12680. */
  12681. serialize(): any;
  12682. /**
  12683. * Parse properties from a JSON object
  12684. * @param serializationObject defines the JSON object
  12685. */
  12686. parse(serializationObject: any): void;
  12687. }
  12688. /**
  12689. * Particle emitter emitting particles from the inside of a cylinder.
  12690. * It emits the particles randomly between two vectors.
  12691. */
  12692. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12693. /**
  12694. * The min limit of the emission direction.
  12695. */
  12696. direction1: Vector3;
  12697. /**
  12698. * The max limit of the emission direction.
  12699. */
  12700. direction2: Vector3;
  12701. /**
  12702. * Creates a new instance CylinderDirectedParticleEmitter
  12703. * @param radius the radius of the emission cylinder (1 by default)
  12704. * @param height the height of the emission cylinder (1 by default)
  12705. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12706. * @param direction1 the min limit of the emission direction (up vector by default)
  12707. * @param direction2 the max limit of the emission direction (up vector by default)
  12708. */
  12709. constructor(radius?: number, height?: number, radiusRange?: number,
  12710. /**
  12711. * The min limit of the emission direction.
  12712. */
  12713. direction1?: Vector3,
  12714. /**
  12715. * The max limit of the emission direction.
  12716. */
  12717. direction2?: Vector3);
  12718. /**
  12719. * Called by the particle System when the direction is computed for the created particle.
  12720. * @param worldMatrix is the world matrix of the particle system
  12721. * @param directionToUpdate is the direction vector to update with the result
  12722. * @param particle is the particle we are computed the direction for
  12723. */
  12724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12725. /**
  12726. * Clones the current emitter and returns a copy of it
  12727. * @returns the new emitter
  12728. */
  12729. clone(): CylinderDirectedParticleEmitter;
  12730. /**
  12731. * Called by the GPUParticleSystem to setup the update shader
  12732. * @param effect defines the update shader
  12733. */
  12734. applyToShader(effect: Effect): void;
  12735. /**
  12736. * Returns a string to use to update the GPU particles update shader
  12737. * @returns a string containng the defines string
  12738. */
  12739. getEffectDefines(): string;
  12740. /**
  12741. * Returns the string "CylinderDirectedParticleEmitter"
  12742. * @returns a string containing the class name
  12743. */
  12744. getClassName(): string;
  12745. /**
  12746. * Serializes the particle system to a JSON object.
  12747. * @returns the JSON object
  12748. */
  12749. serialize(): any;
  12750. /**
  12751. * Parse properties from a JSON object
  12752. * @param serializationObject defines the JSON object
  12753. */
  12754. parse(serializationObject: any): void;
  12755. }
  12756. }
  12757. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12758. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12759. import { Effect } from "babylonjs/Materials/effect";
  12760. import { Particle } from "babylonjs/Particles/particle";
  12761. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12762. /**
  12763. * Particle emitter emitting particles from the inside of a hemisphere.
  12764. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12765. */
  12766. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12767. /**
  12768. * The radius of the emission hemisphere.
  12769. */
  12770. radius: number;
  12771. /**
  12772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12773. */
  12774. radiusRange: number;
  12775. /**
  12776. * How much to randomize the particle direction [0-1].
  12777. */
  12778. directionRandomizer: number;
  12779. /**
  12780. * Creates a new instance HemisphericParticleEmitter
  12781. * @param radius the radius of the emission hemisphere (1 by default)
  12782. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12783. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12784. */
  12785. constructor(
  12786. /**
  12787. * The radius of the emission hemisphere.
  12788. */
  12789. radius?: number,
  12790. /**
  12791. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12792. */
  12793. radiusRange?: number,
  12794. /**
  12795. * How much to randomize the particle direction [0-1].
  12796. */
  12797. directionRandomizer?: number);
  12798. /**
  12799. * Called by the particle System when the direction is computed for the created particle.
  12800. * @param worldMatrix is the world matrix of the particle system
  12801. * @param directionToUpdate is the direction vector to update with the result
  12802. * @param particle is the particle we are computed the direction for
  12803. * @param isLocal defines if the direction should be set in local space
  12804. */
  12805. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12806. /**
  12807. * Called by the particle System when the position is computed for the created particle.
  12808. * @param worldMatrix is the world matrix of the particle system
  12809. * @param positionToUpdate is the position vector to update with the result
  12810. * @param particle is the particle we are computed the position for
  12811. * @param isLocal defines if the position should be set in local space
  12812. */
  12813. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12814. /**
  12815. * Clones the current emitter and returns a copy of it
  12816. * @returns the new emitter
  12817. */
  12818. clone(): HemisphericParticleEmitter;
  12819. /**
  12820. * Called by the GPUParticleSystem to setup the update shader
  12821. * @param effect defines the update shader
  12822. */
  12823. applyToShader(effect: Effect): void;
  12824. /**
  12825. * Returns a string to use to update the GPU particles update shader
  12826. * @returns a string containng the defines string
  12827. */
  12828. getEffectDefines(): string;
  12829. /**
  12830. * Returns the string "HemisphericParticleEmitter"
  12831. * @returns a string containing the class name
  12832. */
  12833. getClassName(): string;
  12834. /**
  12835. * Serializes the particle system to a JSON object.
  12836. * @returns the JSON object
  12837. */
  12838. serialize(): any;
  12839. /**
  12840. * Parse properties from a JSON object
  12841. * @param serializationObject defines the JSON object
  12842. */
  12843. parse(serializationObject: any): void;
  12844. }
  12845. }
  12846. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12847. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12848. import { Effect } from "babylonjs/Materials/effect";
  12849. import { Particle } from "babylonjs/Particles/particle";
  12850. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12851. /**
  12852. * Particle emitter emitting particles from a point.
  12853. * It emits the particles randomly between 2 given directions.
  12854. */
  12855. export class PointParticleEmitter implements IParticleEmitterType {
  12856. /**
  12857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12858. */
  12859. direction1: Vector3;
  12860. /**
  12861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12862. */
  12863. direction2: Vector3;
  12864. /**
  12865. * Creates a new instance PointParticleEmitter
  12866. */
  12867. constructor();
  12868. /**
  12869. * Called by the particle System when the direction is computed for the created particle.
  12870. * @param worldMatrix is the world matrix of the particle system
  12871. * @param directionToUpdate is the direction vector to update with the result
  12872. * @param particle is the particle we are computed the direction for
  12873. * @param isLocal defines if the direction should be set in local space
  12874. */
  12875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12876. /**
  12877. * Called by the particle System when the position is computed for the created particle.
  12878. * @param worldMatrix is the world matrix of the particle system
  12879. * @param positionToUpdate is the position vector to update with the result
  12880. * @param particle is the particle we are computed the position for
  12881. * @param isLocal defines if the position should be set in local space
  12882. */
  12883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12884. /**
  12885. * Clones the current emitter and returns a copy of it
  12886. * @returns the new emitter
  12887. */
  12888. clone(): PointParticleEmitter;
  12889. /**
  12890. * Called by the GPUParticleSystem to setup the update shader
  12891. * @param effect defines the update shader
  12892. */
  12893. applyToShader(effect: Effect): void;
  12894. /**
  12895. * Returns a string to use to update the GPU particles update shader
  12896. * @returns a string containng the defines string
  12897. */
  12898. getEffectDefines(): string;
  12899. /**
  12900. * Returns the string "PointParticleEmitter"
  12901. * @returns a string containing the class name
  12902. */
  12903. getClassName(): string;
  12904. /**
  12905. * Serializes the particle system to a JSON object.
  12906. * @returns the JSON object
  12907. */
  12908. serialize(): any;
  12909. /**
  12910. * Parse properties from a JSON object
  12911. * @param serializationObject defines the JSON object
  12912. */
  12913. parse(serializationObject: any): void;
  12914. }
  12915. }
  12916. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12917. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12918. import { Effect } from "babylonjs/Materials/effect";
  12919. import { Particle } from "babylonjs/Particles/particle";
  12920. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12921. /**
  12922. * Particle emitter emitting particles from the inside of a sphere.
  12923. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12924. */
  12925. export class SphereParticleEmitter implements IParticleEmitterType {
  12926. /**
  12927. * The radius of the emission sphere.
  12928. */
  12929. radius: number;
  12930. /**
  12931. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12932. */
  12933. radiusRange: number;
  12934. /**
  12935. * How much to randomize the particle direction [0-1].
  12936. */
  12937. directionRandomizer: number;
  12938. /**
  12939. * Creates a new instance SphereParticleEmitter
  12940. * @param radius the radius of the emission sphere (1 by default)
  12941. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12942. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12943. */
  12944. constructor(
  12945. /**
  12946. * The radius of the emission sphere.
  12947. */
  12948. radius?: number,
  12949. /**
  12950. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12951. */
  12952. radiusRange?: number,
  12953. /**
  12954. * How much to randomize the particle direction [0-1].
  12955. */
  12956. directionRandomizer?: number);
  12957. /**
  12958. * Called by the particle System when the direction is computed for the created particle.
  12959. * @param worldMatrix is the world matrix of the particle system
  12960. * @param directionToUpdate is the direction vector to update with the result
  12961. * @param particle is the particle we are computed the direction for
  12962. * @param isLocal defines if the direction should be set in local space
  12963. */
  12964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12965. /**
  12966. * Called by the particle System when the position is computed for the created particle.
  12967. * @param worldMatrix is the world matrix of the particle system
  12968. * @param positionToUpdate is the position vector to update with the result
  12969. * @param particle is the particle we are computed the position for
  12970. * @param isLocal defines if the position should be set in local space
  12971. */
  12972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12973. /**
  12974. * Clones the current emitter and returns a copy of it
  12975. * @returns the new emitter
  12976. */
  12977. clone(): SphereParticleEmitter;
  12978. /**
  12979. * Called by the GPUParticleSystem to setup the update shader
  12980. * @param effect defines the update shader
  12981. */
  12982. applyToShader(effect: Effect): void;
  12983. /**
  12984. * Returns a string to use to update the GPU particles update shader
  12985. * @returns a string containng the defines string
  12986. */
  12987. getEffectDefines(): string;
  12988. /**
  12989. * Returns the string "SphereParticleEmitter"
  12990. * @returns a string containing the class name
  12991. */
  12992. getClassName(): string;
  12993. /**
  12994. * Serializes the particle system to a JSON object.
  12995. * @returns the JSON object
  12996. */
  12997. serialize(): any;
  12998. /**
  12999. * Parse properties from a JSON object
  13000. * @param serializationObject defines the JSON object
  13001. */
  13002. parse(serializationObject: any): void;
  13003. }
  13004. /**
  13005. * Particle emitter emitting particles from the inside of a sphere.
  13006. * It emits the particles randomly between two vectors.
  13007. */
  13008. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13009. /**
  13010. * The min limit of the emission direction.
  13011. */
  13012. direction1: Vector3;
  13013. /**
  13014. * The max limit of the emission direction.
  13015. */
  13016. direction2: Vector3;
  13017. /**
  13018. * Creates a new instance SphereDirectedParticleEmitter
  13019. * @param radius the radius of the emission sphere (1 by default)
  13020. * @param direction1 the min limit of the emission direction (up vector by default)
  13021. * @param direction2 the max limit of the emission direction (up vector by default)
  13022. */
  13023. constructor(radius?: number,
  13024. /**
  13025. * The min limit of the emission direction.
  13026. */
  13027. direction1?: Vector3,
  13028. /**
  13029. * The max limit of the emission direction.
  13030. */
  13031. direction2?: Vector3);
  13032. /**
  13033. * Called by the particle System when the direction is computed for the created particle.
  13034. * @param worldMatrix is the world matrix of the particle system
  13035. * @param directionToUpdate is the direction vector to update with the result
  13036. * @param particle is the particle we are computed the direction for
  13037. */
  13038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13039. /**
  13040. * Clones the current emitter and returns a copy of it
  13041. * @returns the new emitter
  13042. */
  13043. clone(): SphereDirectedParticleEmitter;
  13044. /**
  13045. * Called by the GPUParticleSystem to setup the update shader
  13046. * @param effect defines the update shader
  13047. */
  13048. applyToShader(effect: Effect): void;
  13049. /**
  13050. * Returns a string to use to update the GPU particles update shader
  13051. * @returns a string containng the defines string
  13052. */
  13053. getEffectDefines(): string;
  13054. /**
  13055. * Returns the string "SphereDirectedParticleEmitter"
  13056. * @returns a string containing the class name
  13057. */
  13058. getClassName(): string;
  13059. /**
  13060. * Serializes the particle system to a JSON object.
  13061. * @returns the JSON object
  13062. */
  13063. serialize(): any;
  13064. /**
  13065. * Parse properties from a JSON object
  13066. * @param serializationObject defines the JSON object
  13067. */
  13068. parse(serializationObject: any): void;
  13069. }
  13070. }
  13071. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13072. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13073. import { Effect } from "babylonjs/Materials/effect";
  13074. import { Particle } from "babylonjs/Particles/particle";
  13075. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13076. import { Nullable } from "babylonjs/types";
  13077. /**
  13078. * Particle emitter emitting particles from a custom list of positions.
  13079. */
  13080. export class CustomParticleEmitter implements IParticleEmitterType {
  13081. /**
  13082. * Gets or sets the position generator that will create the inital position of each particle.
  13083. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13084. */
  13085. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13086. /**
  13087. * Gets or sets the destination generator that will create the final destination of each particle.
  13088. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13089. */
  13090. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13091. /**
  13092. * Creates a new instance CustomParticleEmitter
  13093. */
  13094. constructor();
  13095. /**
  13096. * Called by the particle System when the direction is computed for the created particle.
  13097. * @param worldMatrix is the world matrix of the particle system
  13098. * @param directionToUpdate is the direction vector to update with the result
  13099. * @param particle is the particle we are computed the direction for
  13100. * @param isLocal defines if the direction should be set in local space
  13101. */
  13102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13103. /**
  13104. * Called by the particle System when the position is computed for the created particle.
  13105. * @param worldMatrix is the world matrix of the particle system
  13106. * @param positionToUpdate is the position vector to update with the result
  13107. * @param particle is the particle we are computed the position for
  13108. * @param isLocal defines if the position should be set in local space
  13109. */
  13110. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13111. /**
  13112. * Clones the current emitter and returns a copy of it
  13113. * @returns the new emitter
  13114. */
  13115. clone(): CustomParticleEmitter;
  13116. /**
  13117. * Called by the GPUParticleSystem to setup the update shader
  13118. * @param effect defines the update shader
  13119. */
  13120. applyToShader(effect: Effect): void;
  13121. /**
  13122. * Returns a string to use to update the GPU particles update shader
  13123. * @returns a string containng the defines string
  13124. */
  13125. getEffectDefines(): string;
  13126. /**
  13127. * Returns the string "PointParticleEmitter"
  13128. * @returns a string containing the class name
  13129. */
  13130. getClassName(): string;
  13131. /**
  13132. * Serializes the particle system to a JSON object.
  13133. * @returns the JSON object
  13134. */
  13135. serialize(): any;
  13136. /**
  13137. * Parse properties from a JSON object
  13138. * @param serializationObject defines the JSON object
  13139. */
  13140. parse(serializationObject: any): void;
  13141. }
  13142. }
  13143. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13144. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13145. import { Effect } from "babylonjs/Materials/effect";
  13146. import { Particle } from "babylonjs/Particles/particle";
  13147. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13148. import { Nullable } from "babylonjs/types";
  13149. import { Scene } from "babylonjs/scene";
  13150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13151. /**
  13152. * Particle emitter emitting particles from the inside of a box.
  13153. * It emits the particles randomly between 2 given directions.
  13154. */
  13155. export class MeshParticleEmitter implements IParticleEmitterType {
  13156. private _indices;
  13157. private _positions;
  13158. private _normals;
  13159. private _storedNormal;
  13160. private _mesh;
  13161. /**
  13162. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13163. */
  13164. direction1: Vector3;
  13165. /**
  13166. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13167. */
  13168. direction2: Vector3;
  13169. /**
  13170. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13171. */
  13172. useMeshNormalsForDirection: boolean;
  13173. /** Defines the mesh to use as source */
  13174. get mesh(): Nullable<AbstractMesh>;
  13175. set mesh(value: Nullable<AbstractMesh>);
  13176. /**
  13177. * Creates a new instance MeshParticleEmitter
  13178. * @param mesh defines the mesh to use as source
  13179. */
  13180. constructor(mesh?: Nullable<AbstractMesh>);
  13181. /**
  13182. * Called by the particle System when the direction is computed for the created particle.
  13183. * @param worldMatrix is the world matrix of the particle system
  13184. * @param directionToUpdate is the direction vector to update with the result
  13185. * @param particle is the particle we are computed the direction for
  13186. * @param isLocal defines if the direction should be set in local space
  13187. */
  13188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13189. /**
  13190. * Called by the particle System when the position is computed for the created particle.
  13191. * @param worldMatrix is the world matrix of the particle system
  13192. * @param positionToUpdate is the position vector to update with the result
  13193. * @param particle is the particle we are computed the position for
  13194. * @param isLocal defines if the position should be set in local space
  13195. */
  13196. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13197. /**
  13198. * Clones the current emitter and returns a copy of it
  13199. * @returns the new emitter
  13200. */
  13201. clone(): MeshParticleEmitter;
  13202. /**
  13203. * Called by the GPUParticleSystem to setup the update shader
  13204. * @param effect defines the update shader
  13205. */
  13206. applyToShader(effect: Effect): void;
  13207. /**
  13208. * Returns a string to use to update the GPU particles update shader
  13209. * @returns a string containng the defines string
  13210. */
  13211. getEffectDefines(): string;
  13212. /**
  13213. * Returns the string "BoxParticleEmitter"
  13214. * @returns a string containing the class name
  13215. */
  13216. getClassName(): string;
  13217. /**
  13218. * Serializes the particle system to a JSON object.
  13219. * @returns the JSON object
  13220. */
  13221. serialize(): any;
  13222. /**
  13223. * Parse properties from a JSON object
  13224. * @param serializationObject defines the JSON object
  13225. * @param scene defines the hosting scene
  13226. */
  13227. parse(serializationObject: any, scene: Scene): void;
  13228. }
  13229. }
  13230. declare module "babylonjs/Particles/EmitterTypes/index" {
  13231. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13232. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13233. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13234. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13235. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13236. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13237. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13238. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13239. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13240. }
  13241. declare module "babylonjs/Particles/IParticleSystem" {
  13242. import { Nullable } from "babylonjs/types";
  13243. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13244. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13247. import { Texture } from "babylonjs/Materials/Textures/texture";
  13248. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13249. import { Scene } from "babylonjs/scene";
  13250. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13251. import { Animation } from "babylonjs/Animations/animation";
  13252. /**
  13253. * Interface representing a particle system in Babylon.js.
  13254. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13255. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13256. */
  13257. export interface IParticleSystem {
  13258. /**
  13259. * List of animations used by the particle system.
  13260. */
  13261. animations: Animation[];
  13262. /**
  13263. * The id of the Particle system.
  13264. */
  13265. id: string;
  13266. /**
  13267. * The name of the Particle system.
  13268. */
  13269. name: string;
  13270. /**
  13271. * The emitter represents the Mesh or position we are attaching the particle system to.
  13272. */
  13273. emitter: Nullable<AbstractMesh | Vector3>;
  13274. /**
  13275. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13276. */
  13277. isBillboardBased: boolean;
  13278. /**
  13279. * The rendering group used by the Particle system to chose when to render.
  13280. */
  13281. renderingGroupId: number;
  13282. /**
  13283. * The layer mask we are rendering the particles through.
  13284. */
  13285. layerMask: number;
  13286. /**
  13287. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13288. */
  13289. updateSpeed: number;
  13290. /**
  13291. * The amount of time the particle system is running (depends of the overall update speed).
  13292. */
  13293. targetStopDuration: number;
  13294. /**
  13295. * The texture used to render each particle. (this can be a spritesheet)
  13296. */
  13297. particleTexture: Nullable<Texture>;
  13298. /**
  13299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13300. */
  13301. blendMode: number;
  13302. /**
  13303. * Minimum life time of emitting particles.
  13304. */
  13305. minLifeTime: number;
  13306. /**
  13307. * Maximum life time of emitting particles.
  13308. */
  13309. maxLifeTime: number;
  13310. /**
  13311. * Minimum Size of emitting particles.
  13312. */
  13313. minSize: number;
  13314. /**
  13315. * Maximum Size of emitting particles.
  13316. */
  13317. maxSize: number;
  13318. /**
  13319. * Minimum scale of emitting particles on X axis.
  13320. */
  13321. minScaleX: number;
  13322. /**
  13323. * Maximum scale of emitting particles on X axis.
  13324. */
  13325. maxScaleX: number;
  13326. /**
  13327. * Minimum scale of emitting particles on Y axis.
  13328. */
  13329. minScaleY: number;
  13330. /**
  13331. * Maximum scale of emitting particles on Y axis.
  13332. */
  13333. maxScaleY: number;
  13334. /**
  13335. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13336. */
  13337. color1: Color4;
  13338. /**
  13339. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13340. */
  13341. color2: Color4;
  13342. /**
  13343. * Color the particle will have at the end of its lifetime.
  13344. */
  13345. colorDead: Color4;
  13346. /**
  13347. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13348. */
  13349. emitRate: number;
  13350. /**
  13351. * You can use gravity if you want to give an orientation to your particles.
  13352. */
  13353. gravity: Vector3;
  13354. /**
  13355. * Minimum power of emitting particles.
  13356. */
  13357. minEmitPower: number;
  13358. /**
  13359. * Maximum power of emitting particles.
  13360. */
  13361. maxEmitPower: number;
  13362. /**
  13363. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13364. */
  13365. minAngularSpeed: number;
  13366. /**
  13367. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13368. */
  13369. maxAngularSpeed: number;
  13370. /**
  13371. * Gets or sets the minimal initial rotation in radians.
  13372. */
  13373. minInitialRotation: number;
  13374. /**
  13375. * Gets or sets the maximal initial rotation in radians.
  13376. */
  13377. maxInitialRotation: number;
  13378. /**
  13379. * The particle emitter type defines the emitter used by the particle system.
  13380. * It can be for example box, sphere, or cone...
  13381. */
  13382. particleEmitterType: Nullable<IParticleEmitterType>;
  13383. /**
  13384. * Defines the delay in milliseconds before starting the system (0 by default)
  13385. */
  13386. startDelay: number;
  13387. /**
  13388. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13389. */
  13390. preWarmCycles: number;
  13391. /**
  13392. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13393. */
  13394. preWarmStepOffset: number;
  13395. /**
  13396. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13397. */
  13398. spriteCellChangeSpeed: number;
  13399. /**
  13400. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13401. */
  13402. startSpriteCellID: number;
  13403. /**
  13404. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13405. */
  13406. endSpriteCellID: number;
  13407. /**
  13408. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13409. */
  13410. spriteCellWidth: number;
  13411. /**
  13412. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13413. */
  13414. spriteCellHeight: number;
  13415. /**
  13416. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13417. */
  13418. spriteRandomStartCell: boolean;
  13419. /**
  13420. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13421. */
  13422. isAnimationSheetEnabled: boolean;
  13423. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13424. translationPivot: Vector2;
  13425. /**
  13426. * Gets or sets a texture used to add random noise to particle positions
  13427. */
  13428. noiseTexture: Nullable<BaseTexture>;
  13429. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13430. noiseStrength: Vector3;
  13431. /**
  13432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13434. */
  13435. billboardMode: number;
  13436. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13437. limitVelocityDamping: number;
  13438. /**
  13439. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13440. */
  13441. beginAnimationOnStart: boolean;
  13442. /**
  13443. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13444. */
  13445. beginAnimationFrom: number;
  13446. /**
  13447. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13448. */
  13449. beginAnimationTo: number;
  13450. /**
  13451. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13452. */
  13453. beginAnimationLoop: boolean;
  13454. /**
  13455. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13456. */
  13457. disposeOnStop: boolean;
  13458. /**
  13459. * Specifies if the particles are updated in emitter local space or world space
  13460. */
  13461. isLocal: boolean;
  13462. /**
  13463. * Gets the maximum number of particles active at the same time.
  13464. * @returns The max number of active particles.
  13465. */
  13466. getCapacity(): number;
  13467. /**
  13468. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13469. * @returns True if it has been started, otherwise false.
  13470. */
  13471. isStarted(): boolean;
  13472. /**
  13473. * Animates the particle system for this frame.
  13474. */
  13475. animate(): void;
  13476. /**
  13477. * Renders the particle system in its current state.
  13478. * @returns the current number of particles
  13479. */
  13480. render(): number;
  13481. /**
  13482. * Dispose the particle system and frees its associated resources.
  13483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13484. */
  13485. dispose(disposeTexture?: boolean): void;
  13486. /**
  13487. * Clones the particle system.
  13488. * @param name The name of the cloned object
  13489. * @param newEmitter The new emitter to use
  13490. * @returns the cloned particle system
  13491. */
  13492. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13493. /**
  13494. * Serializes the particle system to a JSON object.
  13495. * @returns the JSON object
  13496. */
  13497. serialize(): any;
  13498. /**
  13499. * Rebuild the particle system
  13500. */
  13501. rebuild(): void;
  13502. /**
  13503. * Starts the particle system and begins to emit
  13504. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13505. */
  13506. start(delay?: number): void;
  13507. /**
  13508. * Stops the particle system.
  13509. */
  13510. stop(): void;
  13511. /**
  13512. * Remove all active particles
  13513. */
  13514. reset(): void;
  13515. /**
  13516. * Is this system ready to be used/rendered
  13517. * @return true if the system is ready
  13518. */
  13519. isReady(): boolean;
  13520. /**
  13521. * Returns the string "ParticleSystem"
  13522. * @returns a string containing the class name
  13523. */
  13524. getClassName(): string;
  13525. /**
  13526. * Adds a new color gradient
  13527. * @param gradient defines the gradient to use (between 0 and 1)
  13528. * @param color1 defines the color to affect to the specified gradient
  13529. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13530. * @returns the current particle system
  13531. */
  13532. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13533. /**
  13534. * Remove a specific color gradient
  13535. * @param gradient defines the gradient to remove
  13536. * @returns the current particle system
  13537. */
  13538. removeColorGradient(gradient: number): IParticleSystem;
  13539. /**
  13540. * Adds a new size gradient
  13541. * @param gradient defines the gradient to use (between 0 and 1)
  13542. * @param factor defines the size factor to affect to the specified gradient
  13543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13544. * @returns the current particle system
  13545. */
  13546. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13547. /**
  13548. * Remove a specific size gradient
  13549. * @param gradient defines the gradient to remove
  13550. * @returns the current particle system
  13551. */
  13552. removeSizeGradient(gradient: number): IParticleSystem;
  13553. /**
  13554. * Gets the current list of color gradients.
  13555. * You must use addColorGradient and removeColorGradient to udpate this list
  13556. * @returns the list of color gradients
  13557. */
  13558. getColorGradients(): Nullable<Array<ColorGradient>>;
  13559. /**
  13560. * Gets the current list of size gradients.
  13561. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13562. * @returns the list of size gradients
  13563. */
  13564. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13565. /**
  13566. * Gets the current list of angular speed gradients.
  13567. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13568. * @returns the list of angular speed gradients
  13569. */
  13570. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13571. /**
  13572. * Adds a new angular speed gradient
  13573. * @param gradient defines the gradient to use (between 0 and 1)
  13574. * @param factor defines the angular speed to affect to the specified gradient
  13575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13576. * @returns the current particle system
  13577. */
  13578. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13579. /**
  13580. * Remove a specific angular speed gradient
  13581. * @param gradient defines the gradient to remove
  13582. * @returns the current particle system
  13583. */
  13584. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13585. /**
  13586. * Gets the current list of velocity gradients.
  13587. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13588. * @returns the list of velocity gradients
  13589. */
  13590. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13591. /**
  13592. * Adds a new velocity gradient
  13593. * @param gradient defines the gradient to use (between 0 and 1)
  13594. * @param factor defines the velocity to affect to the specified gradient
  13595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13596. * @returns the current particle system
  13597. */
  13598. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13599. /**
  13600. * Remove a specific velocity gradient
  13601. * @param gradient defines the gradient to remove
  13602. * @returns the current particle system
  13603. */
  13604. removeVelocityGradient(gradient: number): IParticleSystem;
  13605. /**
  13606. * Gets the current list of limit velocity gradients.
  13607. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13608. * @returns the list of limit velocity gradients
  13609. */
  13610. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13611. /**
  13612. * Adds a new limit velocity gradient
  13613. * @param gradient defines the gradient to use (between 0 and 1)
  13614. * @param factor defines the limit velocity to affect to the specified gradient
  13615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13616. * @returns the current particle system
  13617. */
  13618. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13619. /**
  13620. * Remove a specific limit velocity gradient
  13621. * @param gradient defines the gradient to remove
  13622. * @returns the current particle system
  13623. */
  13624. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13625. /**
  13626. * Adds a new drag gradient
  13627. * @param gradient defines the gradient to use (between 0 and 1)
  13628. * @param factor defines the drag to affect to the specified gradient
  13629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13630. * @returns the current particle system
  13631. */
  13632. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13633. /**
  13634. * Remove a specific drag gradient
  13635. * @param gradient defines the gradient to remove
  13636. * @returns the current particle system
  13637. */
  13638. removeDragGradient(gradient: number): IParticleSystem;
  13639. /**
  13640. * Gets the current list of drag gradients.
  13641. * You must use addDragGradient and removeDragGradient to udpate this list
  13642. * @returns the list of drag gradients
  13643. */
  13644. getDragGradients(): Nullable<Array<FactorGradient>>;
  13645. /**
  13646. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13647. * @param gradient defines the gradient to use (between 0 and 1)
  13648. * @param factor defines the emit rate to affect to the specified gradient
  13649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13650. * @returns the current particle system
  13651. */
  13652. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13653. /**
  13654. * Remove a specific emit rate gradient
  13655. * @param gradient defines the gradient to remove
  13656. * @returns the current particle system
  13657. */
  13658. removeEmitRateGradient(gradient: number): IParticleSystem;
  13659. /**
  13660. * Gets the current list of emit rate gradients.
  13661. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13662. * @returns the list of emit rate gradients
  13663. */
  13664. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13665. /**
  13666. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13667. * @param gradient defines the gradient to use (between 0 and 1)
  13668. * @param factor defines the start size to affect to the specified gradient
  13669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13670. * @returns the current particle system
  13671. */
  13672. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13673. /**
  13674. * Remove a specific start size gradient
  13675. * @param gradient defines the gradient to remove
  13676. * @returns the current particle system
  13677. */
  13678. removeStartSizeGradient(gradient: number): IParticleSystem;
  13679. /**
  13680. * Gets the current list of start size gradients.
  13681. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13682. * @returns the list of start size gradients
  13683. */
  13684. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13685. /**
  13686. * Adds a new life time gradient
  13687. * @param gradient defines the gradient to use (between 0 and 1)
  13688. * @param factor defines the life time factor to affect to the specified gradient
  13689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13690. * @returns the current particle system
  13691. */
  13692. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13693. /**
  13694. * Remove a specific life time gradient
  13695. * @param gradient defines the gradient to remove
  13696. * @returns the current particle system
  13697. */
  13698. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13699. /**
  13700. * Gets the current list of life time gradients.
  13701. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13702. * @returns the list of life time gradients
  13703. */
  13704. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13705. /**
  13706. * Gets the current list of color gradients.
  13707. * You must use addColorGradient and removeColorGradient to udpate this list
  13708. * @returns the list of color gradients
  13709. */
  13710. getColorGradients(): Nullable<Array<ColorGradient>>;
  13711. /**
  13712. * Adds a new ramp gradient used to remap particle colors
  13713. * @param gradient defines the gradient to use (between 0 and 1)
  13714. * @param color defines the color to affect to the specified gradient
  13715. * @returns the current particle system
  13716. */
  13717. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13718. /**
  13719. * Gets the current list of ramp gradients.
  13720. * You must use addRampGradient and removeRampGradient to udpate this list
  13721. * @returns the list of ramp gradients
  13722. */
  13723. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13724. /** Gets or sets a boolean indicating that ramp gradients must be used
  13725. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13726. */
  13727. useRampGradients: boolean;
  13728. /**
  13729. * Adds a new color remap gradient
  13730. * @param gradient defines the gradient to use (between 0 and 1)
  13731. * @param min defines the color remap minimal range
  13732. * @param max defines the color remap maximal range
  13733. * @returns the current particle system
  13734. */
  13735. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13736. /**
  13737. * Gets the current list of color remap gradients.
  13738. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13739. * @returns the list of color remap gradients
  13740. */
  13741. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13742. /**
  13743. * Adds a new alpha remap gradient
  13744. * @param gradient defines the gradient to use (between 0 and 1)
  13745. * @param min defines the alpha remap minimal range
  13746. * @param max defines the alpha remap maximal range
  13747. * @returns the current particle system
  13748. */
  13749. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13750. /**
  13751. * Gets the current list of alpha remap gradients.
  13752. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13753. * @returns the list of alpha remap gradients
  13754. */
  13755. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13756. /**
  13757. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13758. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13759. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13760. * @returns the emitter
  13761. */
  13762. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13763. /**
  13764. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13765. * @param radius The radius of the hemisphere to emit from
  13766. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13767. * @returns the emitter
  13768. */
  13769. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13770. /**
  13771. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13772. * @param radius The radius of the sphere to emit from
  13773. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13774. * @returns the emitter
  13775. */
  13776. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13777. /**
  13778. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13779. * @param radius The radius of the sphere to emit from
  13780. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13781. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13782. * @returns the emitter
  13783. */
  13784. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13785. /**
  13786. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13787. * @param radius The radius of the emission cylinder
  13788. * @param height The height of the emission cylinder
  13789. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13790. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13791. * @returns the emitter
  13792. */
  13793. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13794. /**
  13795. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13796. * @param radius The radius of the cylinder to emit from
  13797. * @param height The height of the emission cylinder
  13798. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13801. * @returns the emitter
  13802. */
  13803. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13804. /**
  13805. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13806. * @param radius The radius of the cone to emit from
  13807. * @param angle The base angle of the cone
  13808. * @returns the emitter
  13809. */
  13810. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13811. /**
  13812. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13815. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13816. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13817. * @returns the emitter
  13818. */
  13819. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13820. /**
  13821. * Get hosting scene
  13822. * @returns the scene
  13823. */
  13824. getScene(): Scene;
  13825. }
  13826. }
  13827. declare module "babylonjs/Meshes/transformNode" {
  13828. import { DeepImmutable } from "babylonjs/types";
  13829. import { Observable } from "babylonjs/Misc/observable";
  13830. import { Nullable } from "babylonjs/types";
  13831. import { Camera } from "babylonjs/Cameras/camera";
  13832. import { Scene } from "babylonjs/scene";
  13833. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13834. import { Node } from "babylonjs/node";
  13835. import { Bone } from "babylonjs/Bones/bone";
  13836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13837. import { Space } from "babylonjs/Maths/math.axis";
  13838. /**
  13839. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13840. * @see https://doc.babylonjs.com/how_to/transformnode
  13841. */
  13842. export class TransformNode extends Node {
  13843. /**
  13844. * Object will not rotate to face the camera
  13845. */
  13846. static BILLBOARDMODE_NONE: number;
  13847. /**
  13848. * Object will rotate to face the camera but only on the x axis
  13849. */
  13850. static BILLBOARDMODE_X: number;
  13851. /**
  13852. * Object will rotate to face the camera but only on the y axis
  13853. */
  13854. static BILLBOARDMODE_Y: number;
  13855. /**
  13856. * Object will rotate to face the camera but only on the z axis
  13857. */
  13858. static BILLBOARDMODE_Z: number;
  13859. /**
  13860. * Object will rotate to face the camera
  13861. */
  13862. static BILLBOARDMODE_ALL: number;
  13863. /**
  13864. * Object will rotate to face the camera's position instead of orientation
  13865. */
  13866. static BILLBOARDMODE_USE_POSITION: number;
  13867. private _forward;
  13868. private _forwardInverted;
  13869. private _up;
  13870. private _right;
  13871. private _rightInverted;
  13872. private _position;
  13873. private _rotation;
  13874. private _rotationQuaternion;
  13875. protected _scaling: Vector3;
  13876. protected _isDirty: boolean;
  13877. private _transformToBoneReferal;
  13878. private _isAbsoluteSynced;
  13879. private _billboardMode;
  13880. /**
  13881. * Gets or sets the billboard mode. Default is 0.
  13882. *
  13883. * | Value | Type | Description |
  13884. * | --- | --- | --- |
  13885. * | 0 | BILLBOARDMODE_NONE | |
  13886. * | 1 | BILLBOARDMODE_X | |
  13887. * | 2 | BILLBOARDMODE_Y | |
  13888. * | 4 | BILLBOARDMODE_Z | |
  13889. * | 7 | BILLBOARDMODE_ALL | |
  13890. *
  13891. */
  13892. get billboardMode(): number;
  13893. set billboardMode(value: number);
  13894. private _preserveParentRotationForBillboard;
  13895. /**
  13896. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13897. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13898. */
  13899. get preserveParentRotationForBillboard(): boolean;
  13900. set preserveParentRotationForBillboard(value: boolean);
  13901. /**
  13902. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13903. */
  13904. scalingDeterminant: number;
  13905. private _infiniteDistance;
  13906. /**
  13907. * Gets or sets the distance of the object to max, often used by skybox
  13908. */
  13909. get infiniteDistance(): boolean;
  13910. set infiniteDistance(value: boolean);
  13911. /**
  13912. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13913. * By default the system will update normals to compensate
  13914. */
  13915. ignoreNonUniformScaling: boolean;
  13916. /**
  13917. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13918. */
  13919. reIntegrateRotationIntoRotationQuaternion: boolean;
  13920. /** @hidden */
  13921. _poseMatrix: Nullable<Matrix>;
  13922. /** @hidden */
  13923. _localMatrix: Matrix;
  13924. private _usePivotMatrix;
  13925. private _absolutePosition;
  13926. private _absoluteScaling;
  13927. private _absoluteRotationQuaternion;
  13928. private _pivotMatrix;
  13929. private _pivotMatrixInverse;
  13930. protected _postMultiplyPivotMatrix: boolean;
  13931. protected _isWorldMatrixFrozen: boolean;
  13932. /** @hidden */
  13933. _indexInSceneTransformNodesArray: number;
  13934. /**
  13935. * An event triggered after the world matrix is updated
  13936. */
  13937. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13938. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13939. /**
  13940. * Gets a string identifying the name of the class
  13941. * @returns "TransformNode" string
  13942. */
  13943. getClassName(): string;
  13944. /**
  13945. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13946. */
  13947. get position(): Vector3;
  13948. set position(newPosition: Vector3);
  13949. /**
  13950. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13951. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13952. */
  13953. get rotation(): Vector3;
  13954. set rotation(newRotation: Vector3);
  13955. /**
  13956. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13957. */
  13958. get scaling(): Vector3;
  13959. set scaling(newScaling: Vector3);
  13960. /**
  13961. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13962. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13963. */
  13964. get rotationQuaternion(): Nullable<Quaternion>;
  13965. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13966. /**
  13967. * The forward direction of that transform in world space.
  13968. */
  13969. get forward(): Vector3;
  13970. /**
  13971. * The up direction of that transform in world space.
  13972. */
  13973. get up(): Vector3;
  13974. /**
  13975. * The right direction of that transform in world space.
  13976. */
  13977. get right(): Vector3;
  13978. /**
  13979. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13980. * @param matrix the matrix to copy the pose from
  13981. * @returns this TransformNode.
  13982. */
  13983. updatePoseMatrix(matrix: Matrix): TransformNode;
  13984. /**
  13985. * Returns the mesh Pose matrix.
  13986. * @returns the pose matrix
  13987. */
  13988. getPoseMatrix(): Matrix;
  13989. /** @hidden */
  13990. _isSynchronized(): boolean;
  13991. /** @hidden */
  13992. _initCache(): void;
  13993. /**
  13994. * Flag the transform node as dirty (Forcing it to update everything)
  13995. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13996. * @returns this transform node
  13997. */
  13998. markAsDirty(property: string): TransformNode;
  13999. /**
  14000. * Returns the current mesh absolute position.
  14001. * Returns a Vector3.
  14002. */
  14003. get absolutePosition(): Vector3;
  14004. /**
  14005. * Returns the current mesh absolute scaling.
  14006. * Returns a Vector3.
  14007. */
  14008. get absoluteScaling(): Vector3;
  14009. /**
  14010. * Returns the current mesh absolute rotation.
  14011. * Returns a Quaternion.
  14012. */
  14013. get absoluteRotationQuaternion(): Quaternion;
  14014. /**
  14015. * Sets a new matrix to apply before all other transformation
  14016. * @param matrix defines the transform matrix
  14017. * @returns the current TransformNode
  14018. */
  14019. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14020. /**
  14021. * Sets a new pivot matrix to the current node
  14022. * @param matrix defines the new pivot matrix to use
  14023. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14024. * @returns the current TransformNode
  14025. */
  14026. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14027. /**
  14028. * Returns the mesh pivot matrix.
  14029. * Default : Identity.
  14030. * @returns the matrix
  14031. */
  14032. getPivotMatrix(): Matrix;
  14033. /**
  14034. * Instantiate (when possible) or clone that node with its hierarchy
  14035. * @param newParent defines the new parent to use for the instance (or clone)
  14036. * @param options defines options to configure how copy is done
  14037. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14038. * @returns an instance (or a clone) of the current node with its hiearchy
  14039. */
  14040. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14041. doNotInstantiate: boolean;
  14042. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14043. /**
  14044. * Prevents the World matrix to be computed any longer
  14045. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14046. * @returns the TransformNode.
  14047. */
  14048. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14049. /**
  14050. * Allows back the World matrix computation.
  14051. * @returns the TransformNode.
  14052. */
  14053. unfreezeWorldMatrix(): this;
  14054. /**
  14055. * True if the World matrix has been frozen.
  14056. */
  14057. get isWorldMatrixFrozen(): boolean;
  14058. /**
  14059. * Retuns the mesh absolute position in the World.
  14060. * @returns a Vector3.
  14061. */
  14062. getAbsolutePosition(): Vector3;
  14063. /**
  14064. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14065. * @param absolutePosition the absolute position to set
  14066. * @returns the TransformNode.
  14067. */
  14068. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14069. /**
  14070. * Sets the mesh position in its local space.
  14071. * @param vector3 the position to set in localspace
  14072. * @returns the TransformNode.
  14073. */
  14074. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14075. /**
  14076. * Returns the mesh position in the local space from the current World matrix values.
  14077. * @returns a new Vector3.
  14078. */
  14079. getPositionExpressedInLocalSpace(): Vector3;
  14080. /**
  14081. * Translates the mesh along the passed Vector3 in its local space.
  14082. * @param vector3 the distance to translate in localspace
  14083. * @returns the TransformNode.
  14084. */
  14085. locallyTranslate(vector3: Vector3): TransformNode;
  14086. private static _lookAtVectorCache;
  14087. /**
  14088. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14089. * @param targetPoint the position (must be in same space as current mesh) to look at
  14090. * @param yawCor optional yaw (y-axis) correction in radians
  14091. * @param pitchCor optional pitch (x-axis) correction in radians
  14092. * @param rollCor optional roll (z-axis) correction in radians
  14093. * @param space the choosen space of the target
  14094. * @returns the TransformNode.
  14095. */
  14096. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14097. /**
  14098. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14099. * This Vector3 is expressed in the World space.
  14100. * @param localAxis axis to rotate
  14101. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14102. */
  14103. getDirection(localAxis: Vector3): Vector3;
  14104. /**
  14105. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14106. * localAxis is expressed in the mesh local space.
  14107. * result is computed in the Wordl space from the mesh World matrix.
  14108. * @param localAxis axis to rotate
  14109. * @param result the resulting transformnode
  14110. * @returns this TransformNode.
  14111. */
  14112. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14113. /**
  14114. * Sets this transform node rotation to the given local axis.
  14115. * @param localAxis the axis in local space
  14116. * @param yawCor optional yaw (y-axis) correction in radians
  14117. * @param pitchCor optional pitch (x-axis) correction in radians
  14118. * @param rollCor optional roll (z-axis) correction in radians
  14119. * @returns this TransformNode
  14120. */
  14121. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14122. /**
  14123. * Sets a new pivot point to the current node
  14124. * @param point defines the new pivot point to use
  14125. * @param space defines if the point is in world or local space (local by default)
  14126. * @returns the current TransformNode
  14127. */
  14128. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14129. /**
  14130. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14131. * @returns the pivot point
  14132. */
  14133. getPivotPoint(): Vector3;
  14134. /**
  14135. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14136. * @param result the vector3 to store the result
  14137. * @returns this TransformNode.
  14138. */
  14139. getPivotPointToRef(result: Vector3): TransformNode;
  14140. /**
  14141. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14142. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14143. */
  14144. getAbsolutePivotPoint(): Vector3;
  14145. /**
  14146. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14147. * @param result vector3 to store the result
  14148. * @returns this TransformNode.
  14149. */
  14150. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14151. /**
  14152. * Defines the passed node as the parent of the current node.
  14153. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14154. * @see https://doc.babylonjs.com/how_to/parenting
  14155. * @param node the node ot set as the parent
  14156. * @returns this TransformNode.
  14157. */
  14158. setParent(node: Nullable<Node>): TransformNode;
  14159. private _nonUniformScaling;
  14160. /**
  14161. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14162. */
  14163. get nonUniformScaling(): boolean;
  14164. /** @hidden */
  14165. _updateNonUniformScalingState(value: boolean): boolean;
  14166. /**
  14167. * Attach the current TransformNode to another TransformNode associated with a bone
  14168. * @param bone Bone affecting the TransformNode
  14169. * @param affectedTransformNode TransformNode associated with the bone
  14170. * @returns this object
  14171. */
  14172. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14173. /**
  14174. * Detach the transform node if its associated with a bone
  14175. * @returns this object
  14176. */
  14177. detachFromBone(): TransformNode;
  14178. private static _rotationAxisCache;
  14179. /**
  14180. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14181. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14182. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14183. * The passed axis is also normalized.
  14184. * @param axis the axis to rotate around
  14185. * @param amount the amount to rotate in radians
  14186. * @param space Space to rotate in (Default: local)
  14187. * @returns the TransformNode.
  14188. */
  14189. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14190. /**
  14191. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14192. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14193. * The passed axis is also normalized. .
  14194. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14195. * @param point the point to rotate around
  14196. * @param axis the axis to rotate around
  14197. * @param amount the amount to rotate in radians
  14198. * @returns the TransformNode
  14199. */
  14200. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14201. /**
  14202. * Translates the mesh along the axis vector for the passed distance in the given space.
  14203. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14204. * @param axis the axis to translate in
  14205. * @param distance the distance to translate
  14206. * @param space Space to rotate in (Default: local)
  14207. * @returns the TransformNode.
  14208. */
  14209. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14210. /**
  14211. * Adds a rotation step to the mesh current rotation.
  14212. * x, y, z are Euler angles expressed in radians.
  14213. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14214. * This means this rotation is made in the mesh local space only.
  14215. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14216. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14217. * ```javascript
  14218. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14219. * ```
  14220. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14221. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14222. * @param x Rotation to add
  14223. * @param y Rotation to add
  14224. * @param z Rotation to add
  14225. * @returns the TransformNode.
  14226. */
  14227. addRotation(x: number, y: number, z: number): TransformNode;
  14228. /**
  14229. * @hidden
  14230. */
  14231. protected _getEffectiveParent(): Nullable<Node>;
  14232. /**
  14233. * Computes the world matrix of the node
  14234. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14235. * @returns the world matrix
  14236. */
  14237. computeWorldMatrix(force?: boolean): Matrix;
  14238. /**
  14239. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14240. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14241. */
  14242. resetLocalMatrix(independentOfChildren?: boolean): void;
  14243. protected _afterComputeWorldMatrix(): void;
  14244. /**
  14245. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14246. * @param func callback function to add
  14247. *
  14248. * @returns the TransformNode.
  14249. */
  14250. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14251. /**
  14252. * Removes a registered callback function.
  14253. * @param func callback function to remove
  14254. * @returns the TransformNode.
  14255. */
  14256. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14257. /**
  14258. * Gets the position of the current mesh in camera space
  14259. * @param camera defines the camera to use
  14260. * @returns a position
  14261. */
  14262. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14263. /**
  14264. * Returns the distance from the mesh to the active camera
  14265. * @param camera defines the camera to use
  14266. * @returns the distance
  14267. */
  14268. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14269. /**
  14270. * Clone the current transform node
  14271. * @param name Name of the new clone
  14272. * @param newParent New parent for the clone
  14273. * @param doNotCloneChildren Do not clone children hierarchy
  14274. * @returns the new transform node
  14275. */
  14276. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14277. /**
  14278. * Serializes the objects information.
  14279. * @param currentSerializationObject defines the object to serialize in
  14280. * @returns the serialized object
  14281. */
  14282. serialize(currentSerializationObject?: any): any;
  14283. /**
  14284. * Returns a new TransformNode object parsed from the source provided.
  14285. * @param parsedTransformNode is the source.
  14286. * @param scene the scne the object belongs to
  14287. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14288. * @returns a new TransformNode object parsed from the source provided.
  14289. */
  14290. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14291. /**
  14292. * Get all child-transformNodes of this node
  14293. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14294. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14295. * @returns an array of TransformNode
  14296. */
  14297. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14298. /**
  14299. * Releases resources associated with this transform node.
  14300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14302. */
  14303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14304. /**
  14305. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14306. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14307. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14308. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14309. * @returns the current mesh
  14310. */
  14311. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14312. private _syncAbsoluteScalingAndRotation;
  14313. }
  14314. }
  14315. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14316. /**
  14317. * Class used to override all child animations of a given target
  14318. */
  14319. export class AnimationPropertiesOverride {
  14320. /**
  14321. * Gets or sets a value indicating if animation blending must be used
  14322. */
  14323. enableBlending: boolean;
  14324. /**
  14325. * Gets or sets the blending speed to use when enableBlending is true
  14326. */
  14327. blendingSpeed: number;
  14328. /**
  14329. * Gets or sets the default loop mode to use
  14330. */
  14331. loopMode: number;
  14332. }
  14333. }
  14334. declare module "babylonjs/Bones/bone" {
  14335. import { Skeleton } from "babylonjs/Bones/skeleton";
  14336. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14337. import { Nullable } from "babylonjs/types";
  14338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14339. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14340. import { Node } from "babylonjs/node";
  14341. import { Space } from "babylonjs/Maths/math.axis";
  14342. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14343. /**
  14344. * Class used to store bone information
  14345. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14346. */
  14347. export class Bone extends Node {
  14348. /**
  14349. * defines the bone name
  14350. */
  14351. name: string;
  14352. private static _tmpVecs;
  14353. private static _tmpQuat;
  14354. private static _tmpMats;
  14355. /**
  14356. * Gets the list of child bones
  14357. */
  14358. children: Bone[];
  14359. /** Gets the animations associated with this bone */
  14360. animations: import("babylonjs/Animations/animation").Animation[];
  14361. /**
  14362. * Gets or sets bone length
  14363. */
  14364. length: number;
  14365. /**
  14366. * @hidden Internal only
  14367. * Set this value to map this bone to a different index in the transform matrices
  14368. * Set this value to -1 to exclude the bone from the transform matrices
  14369. */
  14370. _index: Nullable<number>;
  14371. private _skeleton;
  14372. private _localMatrix;
  14373. private _restPose;
  14374. private _baseMatrix;
  14375. private _absoluteTransform;
  14376. private _invertedAbsoluteTransform;
  14377. private _parent;
  14378. private _scalingDeterminant;
  14379. private _worldTransform;
  14380. private _localScaling;
  14381. private _localRotation;
  14382. private _localPosition;
  14383. private _needToDecompose;
  14384. private _needToCompose;
  14385. /** @hidden */
  14386. _linkedTransformNode: Nullable<TransformNode>;
  14387. /** @hidden */
  14388. _waitingTransformNodeId: Nullable<string>;
  14389. /** @hidden */
  14390. get _matrix(): Matrix;
  14391. /** @hidden */
  14392. set _matrix(value: Matrix);
  14393. /**
  14394. * Create a new bone
  14395. * @param name defines the bone name
  14396. * @param skeleton defines the parent skeleton
  14397. * @param parentBone defines the parent (can be null if the bone is the root)
  14398. * @param localMatrix defines the local matrix
  14399. * @param restPose defines the rest pose matrix
  14400. * @param baseMatrix defines the base matrix
  14401. * @param index defines index of the bone in the hiearchy
  14402. */
  14403. constructor(
  14404. /**
  14405. * defines the bone name
  14406. */
  14407. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14408. /**
  14409. * Gets the current object class name.
  14410. * @return the class name
  14411. */
  14412. getClassName(): string;
  14413. /**
  14414. * Gets the parent skeleton
  14415. * @returns a skeleton
  14416. */
  14417. getSkeleton(): Skeleton;
  14418. /**
  14419. * Gets parent bone
  14420. * @returns a bone or null if the bone is the root of the bone hierarchy
  14421. */
  14422. getParent(): Nullable<Bone>;
  14423. /**
  14424. * Returns an array containing the root bones
  14425. * @returns an array containing the root bones
  14426. */
  14427. getChildren(): Array<Bone>;
  14428. /**
  14429. * Gets the node index in matrix array generated for rendering
  14430. * @returns the node index
  14431. */
  14432. getIndex(): number;
  14433. /**
  14434. * Sets the parent bone
  14435. * @param parent defines the parent (can be null if the bone is the root)
  14436. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14437. */
  14438. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14439. /**
  14440. * Gets the local matrix
  14441. * @returns a matrix
  14442. */
  14443. getLocalMatrix(): Matrix;
  14444. /**
  14445. * Gets the base matrix (initial matrix which remains unchanged)
  14446. * @returns a matrix
  14447. */
  14448. getBaseMatrix(): Matrix;
  14449. /**
  14450. * Gets the rest pose matrix
  14451. * @returns a matrix
  14452. */
  14453. getRestPose(): Matrix;
  14454. /**
  14455. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14456. */
  14457. getWorldMatrix(): Matrix;
  14458. /**
  14459. * Sets the local matrix to rest pose matrix
  14460. */
  14461. returnToRest(): void;
  14462. /**
  14463. * Gets the inverse of the absolute transform matrix.
  14464. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14465. * @returns a matrix
  14466. */
  14467. getInvertedAbsoluteTransform(): Matrix;
  14468. /**
  14469. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14470. * @returns a matrix
  14471. */
  14472. getAbsoluteTransform(): Matrix;
  14473. /**
  14474. * Links with the given transform node.
  14475. * The local matrix of this bone is copied from the transform node every frame.
  14476. * @param transformNode defines the transform node to link to
  14477. */
  14478. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14479. /**
  14480. * Gets the node used to drive the bone's transformation
  14481. * @returns a transform node or null
  14482. */
  14483. getTransformNode(): Nullable<TransformNode>;
  14484. /** Gets or sets current position (in local space) */
  14485. get position(): Vector3;
  14486. set position(newPosition: Vector3);
  14487. /** Gets or sets current rotation (in local space) */
  14488. get rotation(): Vector3;
  14489. set rotation(newRotation: Vector3);
  14490. /** Gets or sets current rotation quaternion (in local space) */
  14491. get rotationQuaternion(): Quaternion;
  14492. set rotationQuaternion(newRotation: Quaternion);
  14493. /** Gets or sets current scaling (in local space) */
  14494. get scaling(): Vector3;
  14495. set scaling(newScaling: Vector3);
  14496. /**
  14497. * Gets the animation properties override
  14498. */
  14499. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14500. private _decompose;
  14501. private _compose;
  14502. /**
  14503. * Update the base and local matrices
  14504. * @param matrix defines the new base or local matrix
  14505. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14506. * @param updateLocalMatrix defines if the local matrix should be updated
  14507. */
  14508. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14509. /** @hidden */
  14510. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14511. /**
  14512. * Flag the bone as dirty (Forcing it to update everything)
  14513. */
  14514. markAsDirty(): void;
  14515. /** @hidden */
  14516. _markAsDirtyAndCompose(): void;
  14517. private _markAsDirtyAndDecompose;
  14518. /**
  14519. * Translate the bone in local or world space
  14520. * @param vec The amount to translate the bone
  14521. * @param space The space that the translation is in
  14522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14523. */
  14524. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14525. /**
  14526. * Set the postion of the bone in local or world space
  14527. * @param position The position to set the bone
  14528. * @param space The space that the position is in
  14529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14530. */
  14531. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14532. /**
  14533. * Set the absolute position of the bone (world space)
  14534. * @param position The position to set the bone
  14535. * @param mesh The mesh that this bone is attached to
  14536. */
  14537. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14538. /**
  14539. * Scale the bone on the x, y and z axes (in local space)
  14540. * @param x The amount to scale the bone on the x axis
  14541. * @param y The amount to scale the bone on the y axis
  14542. * @param z The amount to scale the bone on the z axis
  14543. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14544. */
  14545. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14546. /**
  14547. * Set the bone scaling in local space
  14548. * @param scale defines the scaling vector
  14549. */
  14550. setScale(scale: Vector3): void;
  14551. /**
  14552. * Gets the current scaling in local space
  14553. * @returns the current scaling vector
  14554. */
  14555. getScale(): Vector3;
  14556. /**
  14557. * Gets the current scaling in local space and stores it in a target vector
  14558. * @param result defines the target vector
  14559. */
  14560. getScaleToRef(result: Vector3): void;
  14561. /**
  14562. * Set the yaw, pitch, and roll of the bone in local or world space
  14563. * @param yaw The rotation of the bone on the y axis
  14564. * @param pitch The rotation of the bone on the x axis
  14565. * @param roll The rotation of the bone on the z axis
  14566. * @param space The space that the axes of rotation are in
  14567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14568. */
  14569. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14570. /**
  14571. * Add a rotation to the bone on an axis in local or world space
  14572. * @param axis The axis to rotate the bone on
  14573. * @param amount The amount to rotate the bone
  14574. * @param space The space that the axis is in
  14575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14576. */
  14577. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14578. /**
  14579. * Set the rotation of the bone to a particular axis angle in local or world space
  14580. * @param axis The axis to rotate the bone on
  14581. * @param angle The angle that the bone should be rotated to
  14582. * @param space The space that the axis is in
  14583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14584. */
  14585. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14586. /**
  14587. * Set the euler rotation of the bone in local of world space
  14588. * @param rotation The euler rotation that the bone should be set to
  14589. * @param space The space that the rotation is in
  14590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14591. */
  14592. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14593. /**
  14594. * Set the quaternion rotation of the bone in local of world space
  14595. * @param quat The quaternion rotation that the bone should be set to
  14596. * @param space The space that the rotation is in
  14597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14598. */
  14599. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14600. /**
  14601. * Set the rotation matrix of the bone in local of world space
  14602. * @param rotMat The rotation matrix that the bone should be set to
  14603. * @param space The space that the rotation is in
  14604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14605. */
  14606. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14607. private _rotateWithMatrix;
  14608. private _getNegativeRotationToRef;
  14609. /**
  14610. * Get the position of the bone in local or world space
  14611. * @param space The space that the returned position is in
  14612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14613. * @returns The position of the bone
  14614. */
  14615. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14616. /**
  14617. * Copy the position of the bone to a vector3 in local or world space
  14618. * @param space The space that the returned position is in
  14619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14620. * @param result The vector3 to copy the position to
  14621. */
  14622. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14623. /**
  14624. * Get the absolute position of the bone (world space)
  14625. * @param mesh The mesh that this bone is attached to
  14626. * @returns The absolute position of the bone
  14627. */
  14628. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14629. /**
  14630. * Copy the absolute position of the bone (world space) to the result param
  14631. * @param mesh The mesh that this bone is attached to
  14632. * @param result The vector3 to copy the absolute position to
  14633. */
  14634. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14635. /**
  14636. * Compute the absolute transforms of this bone and its children
  14637. */
  14638. computeAbsoluteTransforms(): void;
  14639. /**
  14640. * Get the world direction from an axis that is in the local space of the bone
  14641. * @param localAxis The local direction that is used to compute the world direction
  14642. * @param mesh The mesh that this bone is attached to
  14643. * @returns The world direction
  14644. */
  14645. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14646. /**
  14647. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14648. * @param localAxis The local direction that is used to compute the world direction
  14649. * @param mesh The mesh that this bone is attached to
  14650. * @param result The vector3 that the world direction will be copied to
  14651. */
  14652. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14653. /**
  14654. * Get the euler rotation of the bone in local or world space
  14655. * @param space The space that the rotation should be in
  14656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14657. * @returns The euler rotation
  14658. */
  14659. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14660. /**
  14661. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14662. * @param space The space that the rotation should be in
  14663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14664. * @param result The vector3 that the rotation should be copied to
  14665. */
  14666. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14667. /**
  14668. * Get the quaternion rotation of the bone in either local or world space
  14669. * @param space The space that the rotation should be in
  14670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14671. * @returns The quaternion rotation
  14672. */
  14673. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14674. /**
  14675. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14676. * @param space The space that the rotation should be in
  14677. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14678. * @param result The quaternion that the rotation should be copied to
  14679. */
  14680. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14681. /**
  14682. * Get the rotation matrix of the bone in local or world space
  14683. * @param space The space that the rotation should be in
  14684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14685. * @returns The rotation matrix
  14686. */
  14687. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14688. /**
  14689. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14690. * @param space The space that the rotation should be in
  14691. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14692. * @param result The quaternion that the rotation should be copied to
  14693. */
  14694. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14695. /**
  14696. * Get the world position of a point that is in the local space of the bone
  14697. * @param position The local position
  14698. * @param mesh The mesh that this bone is attached to
  14699. * @returns The world position
  14700. */
  14701. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14702. /**
  14703. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14704. * @param position The local position
  14705. * @param mesh The mesh that this bone is attached to
  14706. * @param result The vector3 that the world position should be copied to
  14707. */
  14708. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14709. /**
  14710. * Get the local position of a point that is in world space
  14711. * @param position The world position
  14712. * @param mesh The mesh that this bone is attached to
  14713. * @returns The local position
  14714. */
  14715. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14716. /**
  14717. * Get the local position of a point that is in world space and copy it to the result param
  14718. * @param position The world position
  14719. * @param mesh The mesh that this bone is attached to
  14720. * @param result The vector3 that the local position should be copied to
  14721. */
  14722. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14723. }
  14724. }
  14725. declare module "babylonjs/Animations/runtimeAnimation" {
  14726. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14727. import { Animatable } from "babylonjs/Animations/animatable";
  14728. import { Scene } from "babylonjs/scene";
  14729. /**
  14730. * Defines a runtime animation
  14731. */
  14732. export class RuntimeAnimation {
  14733. private _events;
  14734. /**
  14735. * The current frame of the runtime animation
  14736. */
  14737. private _currentFrame;
  14738. /**
  14739. * The animation used by the runtime animation
  14740. */
  14741. private _animation;
  14742. /**
  14743. * The target of the runtime animation
  14744. */
  14745. private _target;
  14746. /**
  14747. * The initiating animatable
  14748. */
  14749. private _host;
  14750. /**
  14751. * The original value of the runtime animation
  14752. */
  14753. private _originalValue;
  14754. /**
  14755. * The original blend value of the runtime animation
  14756. */
  14757. private _originalBlendValue;
  14758. /**
  14759. * The offsets cache of the runtime animation
  14760. */
  14761. private _offsetsCache;
  14762. /**
  14763. * The high limits cache of the runtime animation
  14764. */
  14765. private _highLimitsCache;
  14766. /**
  14767. * Specifies if the runtime animation has been stopped
  14768. */
  14769. private _stopped;
  14770. /**
  14771. * The blending factor of the runtime animation
  14772. */
  14773. private _blendingFactor;
  14774. /**
  14775. * The BabylonJS scene
  14776. */
  14777. private _scene;
  14778. /**
  14779. * The current value of the runtime animation
  14780. */
  14781. private _currentValue;
  14782. /** @hidden */
  14783. _animationState: _IAnimationState;
  14784. /**
  14785. * The active target of the runtime animation
  14786. */
  14787. private _activeTargets;
  14788. private _currentActiveTarget;
  14789. private _directTarget;
  14790. /**
  14791. * The target path of the runtime animation
  14792. */
  14793. private _targetPath;
  14794. /**
  14795. * The weight of the runtime animation
  14796. */
  14797. private _weight;
  14798. /**
  14799. * The ratio offset of the runtime animation
  14800. */
  14801. private _ratioOffset;
  14802. /**
  14803. * The previous delay of the runtime animation
  14804. */
  14805. private _previousDelay;
  14806. /**
  14807. * The previous ratio of the runtime animation
  14808. */
  14809. private _previousRatio;
  14810. private _enableBlending;
  14811. private _keys;
  14812. private _minFrame;
  14813. private _maxFrame;
  14814. private _minValue;
  14815. private _maxValue;
  14816. private _targetIsArray;
  14817. /**
  14818. * Gets the current frame of the runtime animation
  14819. */
  14820. get currentFrame(): number;
  14821. /**
  14822. * Gets the weight of the runtime animation
  14823. */
  14824. get weight(): number;
  14825. /**
  14826. * Gets the current value of the runtime animation
  14827. */
  14828. get currentValue(): any;
  14829. /**
  14830. * Gets the target path of the runtime animation
  14831. */
  14832. get targetPath(): string;
  14833. /**
  14834. * Gets the actual target of the runtime animation
  14835. */
  14836. get target(): any;
  14837. /** @hidden */
  14838. _onLoop: () => void;
  14839. /**
  14840. * Create a new RuntimeAnimation object
  14841. * @param target defines the target of the animation
  14842. * @param animation defines the source animation object
  14843. * @param scene defines the hosting scene
  14844. * @param host defines the initiating Animatable
  14845. */
  14846. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14847. private _preparePath;
  14848. /**
  14849. * Gets the animation from the runtime animation
  14850. */
  14851. get animation(): Animation;
  14852. /**
  14853. * Resets the runtime animation to the beginning
  14854. * @param restoreOriginal defines whether to restore the target property to the original value
  14855. */
  14856. reset(restoreOriginal?: boolean): void;
  14857. /**
  14858. * Specifies if the runtime animation is stopped
  14859. * @returns Boolean specifying if the runtime animation is stopped
  14860. */
  14861. isStopped(): boolean;
  14862. /**
  14863. * Disposes of the runtime animation
  14864. */
  14865. dispose(): void;
  14866. /**
  14867. * Apply the interpolated value to the target
  14868. * @param currentValue defines the value computed by the animation
  14869. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14870. */
  14871. setValue(currentValue: any, weight: number): void;
  14872. private _getOriginalValues;
  14873. private _setValue;
  14874. /**
  14875. * Gets the loop pmode of the runtime animation
  14876. * @returns Loop Mode
  14877. */
  14878. private _getCorrectLoopMode;
  14879. /**
  14880. * Move the current animation to a given frame
  14881. * @param frame defines the frame to move to
  14882. */
  14883. goToFrame(frame: number): void;
  14884. /**
  14885. * @hidden Internal use only
  14886. */
  14887. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14888. /**
  14889. * Execute the current animation
  14890. * @param delay defines the delay to add to the current frame
  14891. * @param from defines the lower bound of the animation range
  14892. * @param to defines the upper bound of the animation range
  14893. * @param loop defines if the current animation must loop
  14894. * @param speedRatio defines the current speed ratio
  14895. * @param weight defines the weight of the animation (default is -1 so no weight)
  14896. * @param onLoop optional callback called when animation loops
  14897. * @returns a boolean indicating if the animation is running
  14898. */
  14899. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14900. }
  14901. }
  14902. declare module "babylonjs/Animations/animatable" {
  14903. import { Animation } from "babylonjs/Animations/animation";
  14904. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14905. import { Nullable } from "babylonjs/types";
  14906. import { Observable } from "babylonjs/Misc/observable";
  14907. import { Scene } from "babylonjs/scene";
  14908. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14909. import { Node } from "babylonjs/node";
  14910. /**
  14911. * Class used to store an actual running animation
  14912. */
  14913. export class Animatable {
  14914. /** defines the target object */
  14915. target: any;
  14916. /** defines the starting frame number (default is 0) */
  14917. fromFrame: number;
  14918. /** defines the ending frame number (default is 100) */
  14919. toFrame: number;
  14920. /** defines if the animation must loop (default is false) */
  14921. loopAnimation: boolean;
  14922. /** defines a callback to call when animation ends if it is not looping */
  14923. onAnimationEnd?: (() => void) | null | undefined;
  14924. /** defines a callback to call when animation loops */
  14925. onAnimationLoop?: (() => void) | null | undefined;
  14926. private _localDelayOffset;
  14927. private _pausedDelay;
  14928. private _runtimeAnimations;
  14929. private _paused;
  14930. private _scene;
  14931. private _speedRatio;
  14932. private _weight;
  14933. private _syncRoot;
  14934. /**
  14935. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14936. * This will only apply for non looping animation (default is true)
  14937. */
  14938. disposeOnEnd: boolean;
  14939. /**
  14940. * Gets a boolean indicating if the animation has started
  14941. */
  14942. animationStarted: boolean;
  14943. /**
  14944. * Observer raised when the animation ends
  14945. */
  14946. onAnimationEndObservable: Observable<Animatable>;
  14947. /**
  14948. * Observer raised when the animation loops
  14949. */
  14950. onAnimationLoopObservable: Observable<Animatable>;
  14951. /**
  14952. * Gets the root Animatable used to synchronize and normalize animations
  14953. */
  14954. get syncRoot(): Nullable<Animatable>;
  14955. /**
  14956. * Gets the current frame of the first RuntimeAnimation
  14957. * Used to synchronize Animatables
  14958. */
  14959. get masterFrame(): number;
  14960. /**
  14961. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14962. */
  14963. get weight(): number;
  14964. set weight(value: number);
  14965. /**
  14966. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14967. */
  14968. get speedRatio(): number;
  14969. set speedRatio(value: number);
  14970. /**
  14971. * Creates a new Animatable
  14972. * @param scene defines the hosting scene
  14973. * @param target defines the target object
  14974. * @param fromFrame defines the starting frame number (default is 0)
  14975. * @param toFrame defines the ending frame number (default is 100)
  14976. * @param loopAnimation defines if the animation must loop (default is false)
  14977. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14978. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14979. * @param animations defines a group of animation to add to the new Animatable
  14980. * @param onAnimationLoop defines a callback to call when animation loops
  14981. */
  14982. constructor(scene: Scene,
  14983. /** defines the target object */
  14984. target: any,
  14985. /** defines the starting frame number (default is 0) */
  14986. fromFrame?: number,
  14987. /** defines the ending frame number (default is 100) */
  14988. toFrame?: number,
  14989. /** defines if the animation must loop (default is false) */
  14990. loopAnimation?: boolean, speedRatio?: number,
  14991. /** defines a callback to call when animation ends if it is not looping */
  14992. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14993. /** defines a callback to call when animation loops */
  14994. onAnimationLoop?: (() => void) | null | undefined);
  14995. /**
  14996. * Synchronize and normalize current Animatable with a source Animatable
  14997. * This is useful when using animation weights and when animations are not of the same length
  14998. * @param root defines the root Animatable to synchronize with
  14999. * @returns the current Animatable
  15000. */
  15001. syncWith(root: Animatable): Animatable;
  15002. /**
  15003. * Gets the list of runtime animations
  15004. * @returns an array of RuntimeAnimation
  15005. */
  15006. getAnimations(): RuntimeAnimation[];
  15007. /**
  15008. * Adds more animations to the current animatable
  15009. * @param target defines the target of the animations
  15010. * @param animations defines the new animations to add
  15011. */
  15012. appendAnimations(target: any, animations: Animation[]): void;
  15013. /**
  15014. * Gets the source animation for a specific property
  15015. * @param property defines the propertyu to look for
  15016. * @returns null or the source animation for the given property
  15017. */
  15018. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15019. /**
  15020. * Gets the runtime animation for a specific property
  15021. * @param property defines the propertyu to look for
  15022. * @returns null or the runtime animation for the given property
  15023. */
  15024. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15025. /**
  15026. * Resets the animatable to its original state
  15027. */
  15028. reset(): void;
  15029. /**
  15030. * Allows the animatable to blend with current running animations
  15031. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15032. * @param blendingSpeed defines the blending speed to use
  15033. */
  15034. enableBlending(blendingSpeed: number): void;
  15035. /**
  15036. * Disable animation blending
  15037. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15038. */
  15039. disableBlending(): void;
  15040. /**
  15041. * Jump directly to a given frame
  15042. * @param frame defines the frame to jump to
  15043. */
  15044. goToFrame(frame: number): void;
  15045. /**
  15046. * Pause the animation
  15047. */
  15048. pause(): void;
  15049. /**
  15050. * Restart the animation
  15051. */
  15052. restart(): void;
  15053. private _raiseOnAnimationEnd;
  15054. /**
  15055. * Stop and delete the current animation
  15056. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15057. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15058. */
  15059. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15060. /**
  15061. * Wait asynchronously for the animation to end
  15062. * @returns a promise which will be fullfilled when the animation ends
  15063. */
  15064. waitAsync(): Promise<Animatable>;
  15065. /** @hidden */
  15066. _animate(delay: number): boolean;
  15067. }
  15068. module "babylonjs/scene" {
  15069. interface Scene {
  15070. /** @hidden */
  15071. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15072. /** @hidden */
  15073. _processLateAnimationBindingsForMatrices(holder: {
  15074. totalWeight: number;
  15075. animations: RuntimeAnimation[];
  15076. originalValue: Matrix;
  15077. }): any;
  15078. /** @hidden */
  15079. _processLateAnimationBindingsForQuaternions(holder: {
  15080. totalWeight: number;
  15081. animations: RuntimeAnimation[];
  15082. originalValue: Quaternion;
  15083. }, refQuaternion: Quaternion): Quaternion;
  15084. /** @hidden */
  15085. _processLateAnimationBindings(): void;
  15086. /**
  15087. * Will start the animation sequence of a given target
  15088. * @param target defines the target
  15089. * @param from defines from which frame should animation start
  15090. * @param to defines until which frame should animation run.
  15091. * @param weight defines the weight to apply to the animation (1.0 by default)
  15092. * @param loop defines if the animation loops
  15093. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15094. * @param onAnimationEnd defines the function to be executed when the animation ends
  15095. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15096. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15097. * @param onAnimationLoop defines the callback to call when an animation loops
  15098. * @returns the animatable object created for this animation
  15099. */
  15100. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15101. /**
  15102. * Will start the animation sequence of a given target
  15103. * @param target defines the target
  15104. * @param from defines from which frame should animation start
  15105. * @param to defines until which frame should animation run.
  15106. * @param loop defines if the animation loops
  15107. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15108. * @param onAnimationEnd defines the function to be executed when the animation ends
  15109. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15110. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15111. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15112. * @param onAnimationLoop defines the callback to call when an animation loops
  15113. * @returns the animatable object created for this animation
  15114. */
  15115. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15116. /**
  15117. * Will start the animation sequence of a given target and its hierarchy
  15118. * @param target defines the target
  15119. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15120. * @param from defines from which frame should animation start
  15121. * @param to defines until which frame should animation run.
  15122. * @param loop defines if the animation loops
  15123. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15124. * @param onAnimationEnd defines the function to be executed when the animation ends
  15125. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15126. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15127. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15128. * @param onAnimationLoop defines the callback to call when an animation loops
  15129. * @returns the list of created animatables
  15130. */
  15131. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  15132. /**
  15133. * Begin a new animation on a given node
  15134. * @param target defines the target where the animation will take place
  15135. * @param animations defines the list of animations to start
  15136. * @param from defines the initial value
  15137. * @param to defines the final value
  15138. * @param loop defines if you want animation to loop (off by default)
  15139. * @param speedRatio defines the speed ratio to apply to all animations
  15140. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15141. * @param onAnimationLoop defines the callback to call when an animation loops
  15142. * @returns the list of created animatables
  15143. */
  15144. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15145. /**
  15146. * Begin a new animation on a given node and its hierarchy
  15147. * @param target defines the root node where the animation will take place
  15148. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15149. * @param animations defines the list of animations to start
  15150. * @param from defines the initial value
  15151. * @param to defines the final value
  15152. * @param loop defines if you want animation to loop (off by default)
  15153. * @param speedRatio defines the speed ratio to apply to all animations
  15154. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15155. * @param onAnimationLoop defines the callback to call when an animation loops
  15156. * @returns the list of animatables created for all nodes
  15157. */
  15158. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15159. /**
  15160. * Gets the animatable associated with a specific target
  15161. * @param target defines the target of the animatable
  15162. * @returns the required animatable if found
  15163. */
  15164. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15165. /**
  15166. * Gets all animatables associated with a given target
  15167. * @param target defines the target to look animatables for
  15168. * @returns an array of Animatables
  15169. */
  15170. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15171. /**
  15172. * Stops and removes all animations that have been applied to the scene
  15173. */
  15174. stopAllAnimations(): void;
  15175. /**
  15176. * Gets the current delta time used by animation engine
  15177. */
  15178. deltaTime: number;
  15179. }
  15180. }
  15181. module "babylonjs/Bones/bone" {
  15182. interface Bone {
  15183. /**
  15184. * Copy an animation range from another bone
  15185. * @param source defines the source bone
  15186. * @param rangeName defines the range name to copy
  15187. * @param frameOffset defines the frame offset
  15188. * @param rescaleAsRequired defines if rescaling must be applied if required
  15189. * @param skelDimensionsRatio defines the scaling ratio
  15190. * @returns true if operation was successful
  15191. */
  15192. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15193. }
  15194. }
  15195. }
  15196. declare module "babylonjs/Bones/skeleton" {
  15197. import { Bone } from "babylonjs/Bones/bone";
  15198. import { Observable } from "babylonjs/Misc/observable";
  15199. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15200. import { Scene } from "babylonjs/scene";
  15201. import { Nullable } from "babylonjs/types";
  15202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15203. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15204. import { Animatable } from "babylonjs/Animations/animatable";
  15205. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15206. import { Animation } from "babylonjs/Animations/animation";
  15207. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15208. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15209. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15210. /**
  15211. * Class used to handle skinning animations
  15212. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15213. */
  15214. export class Skeleton implements IAnimatable {
  15215. /** defines the skeleton name */
  15216. name: string;
  15217. /** defines the skeleton Id */
  15218. id: string;
  15219. /**
  15220. * Defines the list of child bones
  15221. */
  15222. bones: Bone[];
  15223. /**
  15224. * Defines an estimate of the dimension of the skeleton at rest
  15225. */
  15226. dimensionsAtRest: Vector3;
  15227. /**
  15228. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15229. */
  15230. needInitialSkinMatrix: boolean;
  15231. /**
  15232. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15233. */
  15234. overrideMesh: Nullable<AbstractMesh>;
  15235. /**
  15236. * Gets the list of animations attached to this skeleton
  15237. */
  15238. animations: Array<Animation>;
  15239. private _scene;
  15240. private _isDirty;
  15241. private _transformMatrices;
  15242. private _transformMatrixTexture;
  15243. private _meshesWithPoseMatrix;
  15244. private _animatables;
  15245. private _identity;
  15246. private _synchronizedWithMesh;
  15247. private _ranges;
  15248. private _lastAbsoluteTransformsUpdateId;
  15249. private _canUseTextureForBones;
  15250. private _uniqueId;
  15251. /** @hidden */
  15252. _numBonesWithLinkedTransformNode: number;
  15253. /** @hidden */
  15254. _hasWaitingData: Nullable<boolean>;
  15255. /**
  15256. * Specifies if the skeleton should be serialized
  15257. */
  15258. doNotSerialize: boolean;
  15259. private _useTextureToStoreBoneMatrices;
  15260. /**
  15261. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15262. * Please note that this option is not available if the hardware does not support it
  15263. */
  15264. get useTextureToStoreBoneMatrices(): boolean;
  15265. set useTextureToStoreBoneMatrices(value: boolean);
  15266. private _animationPropertiesOverride;
  15267. /**
  15268. * Gets or sets the animation properties override
  15269. */
  15270. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15271. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15272. /**
  15273. * List of inspectable custom properties (used by the Inspector)
  15274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15275. */
  15276. inspectableCustomProperties: IInspectable[];
  15277. /**
  15278. * An observable triggered before computing the skeleton's matrices
  15279. */
  15280. onBeforeComputeObservable: Observable<Skeleton>;
  15281. /**
  15282. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15283. */
  15284. get isUsingTextureForMatrices(): boolean;
  15285. /**
  15286. * Gets the unique ID of this skeleton
  15287. */
  15288. get uniqueId(): number;
  15289. /**
  15290. * Creates a new skeleton
  15291. * @param name defines the skeleton name
  15292. * @param id defines the skeleton Id
  15293. * @param scene defines the hosting scene
  15294. */
  15295. constructor(
  15296. /** defines the skeleton name */
  15297. name: string,
  15298. /** defines the skeleton Id */
  15299. id: string, scene: Scene);
  15300. /**
  15301. * Gets the current object class name.
  15302. * @return the class name
  15303. */
  15304. getClassName(): string;
  15305. /**
  15306. * Returns an array containing the root bones
  15307. * @returns an array containing the root bones
  15308. */
  15309. getChildren(): Array<Bone>;
  15310. /**
  15311. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15312. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15313. * @returns a Float32Array containing matrices data
  15314. */
  15315. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15316. /**
  15317. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15318. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15319. * @returns a raw texture containing the data
  15320. */
  15321. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15322. /**
  15323. * Gets the current hosting scene
  15324. * @returns a scene object
  15325. */
  15326. getScene(): Scene;
  15327. /**
  15328. * Gets a string representing the current skeleton data
  15329. * @param fullDetails defines a boolean indicating if we want a verbose version
  15330. * @returns a string representing the current skeleton data
  15331. */
  15332. toString(fullDetails?: boolean): string;
  15333. /**
  15334. * Get bone's index searching by name
  15335. * @param name defines bone's name to search for
  15336. * @return the indice of the bone. Returns -1 if not found
  15337. */
  15338. getBoneIndexByName(name: string): number;
  15339. /**
  15340. * Creater a new animation range
  15341. * @param name defines the name of the range
  15342. * @param from defines the start key
  15343. * @param to defines the end key
  15344. */
  15345. createAnimationRange(name: string, from: number, to: number): void;
  15346. /**
  15347. * Delete a specific animation range
  15348. * @param name defines the name of the range
  15349. * @param deleteFrames defines if frames must be removed as well
  15350. */
  15351. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15352. /**
  15353. * Gets a specific animation range
  15354. * @param name defines the name of the range to look for
  15355. * @returns the requested animation range or null if not found
  15356. */
  15357. getAnimationRange(name: string): Nullable<AnimationRange>;
  15358. /**
  15359. * Gets the list of all animation ranges defined on this skeleton
  15360. * @returns an array
  15361. */
  15362. getAnimationRanges(): Nullable<AnimationRange>[];
  15363. /**
  15364. * Copy animation range from a source skeleton.
  15365. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15366. * @param source defines the source skeleton
  15367. * @param name defines the name of the range to copy
  15368. * @param rescaleAsRequired defines if rescaling must be applied if required
  15369. * @returns true if operation was successful
  15370. */
  15371. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15372. /**
  15373. * Forces the skeleton to go to rest pose
  15374. */
  15375. returnToRest(): void;
  15376. private _getHighestAnimationFrame;
  15377. /**
  15378. * Begin a specific animation range
  15379. * @param name defines the name of the range to start
  15380. * @param loop defines if looping must be turned on (false by default)
  15381. * @param speedRatio defines the speed ratio to apply (1 by default)
  15382. * @param onAnimationEnd defines a callback which will be called when animation will end
  15383. * @returns a new animatable
  15384. */
  15385. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15386. /** @hidden */
  15387. _markAsDirty(): void;
  15388. /** @hidden */
  15389. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15390. /** @hidden */
  15391. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15392. private _computeTransformMatrices;
  15393. /**
  15394. * Build all resources required to render a skeleton
  15395. */
  15396. prepare(): void;
  15397. /**
  15398. * Gets the list of animatables currently running for this skeleton
  15399. * @returns an array of animatables
  15400. */
  15401. getAnimatables(): IAnimatable[];
  15402. /**
  15403. * Clone the current skeleton
  15404. * @param name defines the name of the new skeleton
  15405. * @param id defines the id of the new skeleton
  15406. * @returns the new skeleton
  15407. */
  15408. clone(name: string, id?: string): Skeleton;
  15409. /**
  15410. * Enable animation blending for this skeleton
  15411. * @param blendingSpeed defines the blending speed to apply
  15412. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15413. */
  15414. enableBlending(blendingSpeed?: number): void;
  15415. /**
  15416. * Releases all resources associated with the current skeleton
  15417. */
  15418. dispose(): void;
  15419. /**
  15420. * Serialize the skeleton in a JSON object
  15421. * @returns a JSON object
  15422. */
  15423. serialize(): any;
  15424. /**
  15425. * Creates a new skeleton from serialized data
  15426. * @param parsedSkeleton defines the serialized data
  15427. * @param scene defines the hosting scene
  15428. * @returns a new skeleton
  15429. */
  15430. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15431. /**
  15432. * Compute all node absolute transforms
  15433. * @param forceUpdate defines if computation must be done even if cache is up to date
  15434. */
  15435. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15436. /**
  15437. * Gets the root pose matrix
  15438. * @returns a matrix
  15439. */
  15440. getPoseMatrix(): Nullable<Matrix>;
  15441. /**
  15442. * Sorts bones per internal index
  15443. */
  15444. sortBones(): void;
  15445. private _sortBones;
  15446. }
  15447. }
  15448. declare module "babylonjs/Meshes/instancedMesh" {
  15449. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15450. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15451. import { Camera } from "babylonjs/Cameras/camera";
  15452. import { Node } from "babylonjs/node";
  15453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15454. import { Mesh } from "babylonjs/Meshes/mesh";
  15455. import { Material } from "babylonjs/Materials/material";
  15456. import { Skeleton } from "babylonjs/Bones/skeleton";
  15457. import { Light } from "babylonjs/Lights/light";
  15458. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15459. /**
  15460. * Creates an instance based on a source mesh.
  15461. */
  15462. export class InstancedMesh extends AbstractMesh {
  15463. private _sourceMesh;
  15464. private _currentLOD;
  15465. /** @hidden */
  15466. _indexInSourceMeshInstanceArray: number;
  15467. constructor(name: string, source: Mesh);
  15468. /**
  15469. * Returns the string "InstancedMesh".
  15470. */
  15471. getClassName(): string;
  15472. /** Gets the list of lights affecting that mesh */
  15473. get lightSources(): Light[];
  15474. _resyncLightSources(): void;
  15475. _resyncLightSource(light: Light): void;
  15476. _removeLightSource(light: Light, dispose: boolean): void;
  15477. /**
  15478. * If the source mesh receives shadows
  15479. */
  15480. get receiveShadows(): boolean;
  15481. /**
  15482. * The material of the source mesh
  15483. */
  15484. get material(): Nullable<Material>;
  15485. /**
  15486. * Visibility of the source mesh
  15487. */
  15488. get visibility(): number;
  15489. /**
  15490. * Skeleton of the source mesh
  15491. */
  15492. get skeleton(): Nullable<Skeleton>;
  15493. /**
  15494. * Rendering ground id of the source mesh
  15495. */
  15496. get renderingGroupId(): number;
  15497. set renderingGroupId(value: number);
  15498. /**
  15499. * Returns the total number of vertices (integer).
  15500. */
  15501. getTotalVertices(): number;
  15502. /**
  15503. * Returns a positive integer : the total number of indices in this mesh geometry.
  15504. * @returns the numner of indices or zero if the mesh has no geometry.
  15505. */
  15506. getTotalIndices(): number;
  15507. /**
  15508. * The source mesh of the instance
  15509. */
  15510. get sourceMesh(): Mesh;
  15511. /**
  15512. * Is this node ready to be used/rendered
  15513. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15514. * @return {boolean} is it ready
  15515. */
  15516. isReady(completeCheck?: boolean): boolean;
  15517. /**
  15518. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15519. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15520. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15521. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15522. */
  15523. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15524. /**
  15525. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15526. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15527. * The `data` are either a numeric array either a Float32Array.
  15528. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15529. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15530. * Note that a new underlying VertexBuffer object is created each call.
  15531. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15532. *
  15533. * Possible `kind` values :
  15534. * - VertexBuffer.PositionKind
  15535. * - VertexBuffer.UVKind
  15536. * - VertexBuffer.UV2Kind
  15537. * - VertexBuffer.UV3Kind
  15538. * - VertexBuffer.UV4Kind
  15539. * - VertexBuffer.UV5Kind
  15540. * - VertexBuffer.UV6Kind
  15541. * - VertexBuffer.ColorKind
  15542. * - VertexBuffer.MatricesIndicesKind
  15543. * - VertexBuffer.MatricesIndicesExtraKind
  15544. * - VertexBuffer.MatricesWeightsKind
  15545. * - VertexBuffer.MatricesWeightsExtraKind
  15546. *
  15547. * Returns the Mesh.
  15548. */
  15549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15550. /**
  15551. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15552. * If the mesh has no geometry, it is simply returned as it is.
  15553. * The `data` are either a numeric array either a Float32Array.
  15554. * No new underlying VertexBuffer object is created.
  15555. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15556. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15557. *
  15558. * Possible `kind` values :
  15559. * - VertexBuffer.PositionKind
  15560. * - VertexBuffer.UVKind
  15561. * - VertexBuffer.UV2Kind
  15562. * - VertexBuffer.UV3Kind
  15563. * - VertexBuffer.UV4Kind
  15564. * - VertexBuffer.UV5Kind
  15565. * - VertexBuffer.UV6Kind
  15566. * - VertexBuffer.ColorKind
  15567. * - VertexBuffer.MatricesIndicesKind
  15568. * - VertexBuffer.MatricesIndicesExtraKind
  15569. * - VertexBuffer.MatricesWeightsKind
  15570. * - VertexBuffer.MatricesWeightsExtraKind
  15571. *
  15572. * Returns the Mesh.
  15573. */
  15574. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15575. /**
  15576. * Sets the mesh indices.
  15577. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15578. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15579. * This method creates a new index buffer each call.
  15580. * Returns the Mesh.
  15581. */
  15582. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15583. /**
  15584. * Boolean : True if the mesh owns the requested kind of data.
  15585. */
  15586. isVerticesDataPresent(kind: string): boolean;
  15587. /**
  15588. * Returns an array of indices (IndicesArray).
  15589. */
  15590. getIndices(): Nullable<IndicesArray>;
  15591. get _positions(): Nullable<Vector3[]>;
  15592. /**
  15593. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15594. * This means the mesh underlying bounding box and sphere are recomputed.
  15595. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15596. * @returns the current mesh
  15597. */
  15598. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15599. /** @hidden */
  15600. _preActivate(): InstancedMesh;
  15601. /** @hidden */
  15602. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15603. /** @hidden */
  15604. _postActivate(): void;
  15605. getWorldMatrix(): Matrix;
  15606. get isAnInstance(): boolean;
  15607. /**
  15608. * Returns the current associated LOD AbstractMesh.
  15609. */
  15610. getLOD(camera: Camera): AbstractMesh;
  15611. /** @hidden */
  15612. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15613. /** @hidden */
  15614. _syncSubMeshes(): InstancedMesh;
  15615. /** @hidden */
  15616. _generatePointsArray(): boolean;
  15617. /**
  15618. * Creates a new InstancedMesh from the current mesh.
  15619. * - name (string) : the cloned mesh name
  15620. * - newParent (optional Node) : the optional Node to parent the clone to.
  15621. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15622. *
  15623. * Returns the clone.
  15624. */
  15625. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15626. /**
  15627. * Disposes the InstancedMesh.
  15628. * Returns nothing.
  15629. */
  15630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15631. }
  15632. module "babylonjs/Meshes/mesh" {
  15633. interface Mesh {
  15634. /**
  15635. * Register a custom buffer that will be instanced
  15636. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15637. * @param kind defines the buffer kind
  15638. * @param stride defines the stride in floats
  15639. */
  15640. registerInstancedBuffer(kind: string, stride: number): void;
  15641. /** @hidden */
  15642. _userInstancedBuffersStorage: {
  15643. data: {
  15644. [key: string]: Float32Array;
  15645. };
  15646. sizes: {
  15647. [key: string]: number;
  15648. };
  15649. vertexBuffers: {
  15650. [key: string]: Nullable<VertexBuffer>;
  15651. };
  15652. strides: {
  15653. [key: string]: number;
  15654. };
  15655. };
  15656. }
  15657. }
  15658. module "babylonjs/Meshes/abstractMesh" {
  15659. interface AbstractMesh {
  15660. /**
  15661. * Object used to store instanced buffers defined by user
  15662. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15663. */
  15664. instancedBuffers: {
  15665. [key: string]: any;
  15666. };
  15667. }
  15668. }
  15669. }
  15670. declare module "babylonjs/Materials/shaderMaterial" {
  15671. import { Scene } from "babylonjs/scene";
  15672. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15674. import { Mesh } from "babylonjs/Meshes/mesh";
  15675. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15676. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15677. import { Texture } from "babylonjs/Materials/Textures/texture";
  15678. import { Material } from "babylonjs/Materials/material";
  15679. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15680. /**
  15681. * Defines the options associated with the creation of a shader material.
  15682. */
  15683. export interface IShaderMaterialOptions {
  15684. /**
  15685. * Does the material work in alpha blend mode
  15686. */
  15687. needAlphaBlending: boolean;
  15688. /**
  15689. * Does the material work in alpha test mode
  15690. */
  15691. needAlphaTesting: boolean;
  15692. /**
  15693. * The list of attribute names used in the shader
  15694. */
  15695. attributes: string[];
  15696. /**
  15697. * The list of unifrom names used in the shader
  15698. */
  15699. uniforms: string[];
  15700. /**
  15701. * The list of UBO names used in the shader
  15702. */
  15703. uniformBuffers: string[];
  15704. /**
  15705. * The list of sampler names used in the shader
  15706. */
  15707. samplers: string[];
  15708. /**
  15709. * The list of defines used in the shader
  15710. */
  15711. defines: string[];
  15712. }
  15713. /**
  15714. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15715. *
  15716. * This returned material effects how the mesh will look based on the code in the shaders.
  15717. *
  15718. * @see http://doc.babylonjs.com/how_to/shader_material
  15719. */
  15720. export class ShaderMaterial extends Material {
  15721. private _shaderPath;
  15722. private _options;
  15723. private _textures;
  15724. private _textureArrays;
  15725. private _floats;
  15726. private _ints;
  15727. private _floatsArrays;
  15728. private _colors3;
  15729. private _colors3Arrays;
  15730. private _colors4;
  15731. private _colors4Arrays;
  15732. private _vectors2;
  15733. private _vectors3;
  15734. private _vectors4;
  15735. private _matrices;
  15736. private _matrixArrays;
  15737. private _matrices3x3;
  15738. private _matrices2x2;
  15739. private _vectors2Arrays;
  15740. private _vectors3Arrays;
  15741. private _vectors4Arrays;
  15742. private _cachedWorldViewMatrix;
  15743. private _cachedWorldViewProjectionMatrix;
  15744. private _renderId;
  15745. private _multiview;
  15746. /**
  15747. * Instantiate a new shader material.
  15748. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15749. * This returned material effects how the mesh will look based on the code in the shaders.
  15750. * @see http://doc.babylonjs.com/how_to/shader_material
  15751. * @param name Define the name of the material in the scene
  15752. * @param scene Define the scene the material belongs to
  15753. * @param shaderPath Defines the route to the shader code in one of three ways:
  15754. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15755. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15756. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15757. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15758. * @param options Define the options used to create the shader
  15759. */
  15760. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15761. /**
  15762. * Gets the shader path used to define the shader code
  15763. * It can be modified to trigger a new compilation
  15764. */
  15765. get shaderPath(): any;
  15766. /**
  15767. * Sets the shader path used to define the shader code
  15768. * It can be modified to trigger a new compilation
  15769. */
  15770. set shaderPath(shaderPath: any);
  15771. /**
  15772. * Gets the options used to compile the shader.
  15773. * They can be modified to trigger a new compilation
  15774. */
  15775. get options(): IShaderMaterialOptions;
  15776. /**
  15777. * Gets the current class name of the material e.g. "ShaderMaterial"
  15778. * Mainly use in serialization.
  15779. * @returns the class name
  15780. */
  15781. getClassName(): string;
  15782. /**
  15783. * Specifies if the material will require alpha blending
  15784. * @returns a boolean specifying if alpha blending is needed
  15785. */
  15786. needAlphaBlending(): boolean;
  15787. /**
  15788. * Specifies if this material should be rendered in alpha test mode
  15789. * @returns a boolean specifying if an alpha test is needed.
  15790. */
  15791. needAlphaTesting(): boolean;
  15792. private _checkUniform;
  15793. /**
  15794. * Set a texture in the shader.
  15795. * @param name Define the name of the uniform samplers as defined in the shader
  15796. * @param texture Define the texture to bind to this sampler
  15797. * @return the material itself allowing "fluent" like uniform updates
  15798. */
  15799. setTexture(name: string, texture: Texture): ShaderMaterial;
  15800. /**
  15801. * Set a texture array in the shader.
  15802. * @param name Define the name of the uniform sampler array as defined in the shader
  15803. * @param textures Define the list of textures to bind to this sampler
  15804. * @return the material itself allowing "fluent" like uniform updates
  15805. */
  15806. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15807. /**
  15808. * Set a float in the shader.
  15809. * @param name Define the name of the uniform as defined in the shader
  15810. * @param value Define the value to give to the uniform
  15811. * @return the material itself allowing "fluent" like uniform updates
  15812. */
  15813. setFloat(name: string, value: number): ShaderMaterial;
  15814. /**
  15815. * Set a int in the shader.
  15816. * @param name Define the name of the uniform as defined in the shader
  15817. * @param value Define the value to give to the uniform
  15818. * @return the material itself allowing "fluent" like uniform updates
  15819. */
  15820. setInt(name: string, value: number): ShaderMaterial;
  15821. /**
  15822. * Set an array of floats in the shader.
  15823. * @param name Define the name of the uniform as defined in the shader
  15824. * @param value Define the value to give to the uniform
  15825. * @return the material itself allowing "fluent" like uniform updates
  15826. */
  15827. setFloats(name: string, value: number[]): ShaderMaterial;
  15828. /**
  15829. * Set a vec3 in the shader from a Color3.
  15830. * @param name Define the name of the uniform as defined in the shader
  15831. * @param value Define the value to give to the uniform
  15832. * @return the material itself allowing "fluent" like uniform updates
  15833. */
  15834. setColor3(name: string, value: Color3): ShaderMaterial;
  15835. /**
  15836. * Set a vec3 array in the shader from a Color3 array.
  15837. * @param name Define the name of the uniform as defined in the shader
  15838. * @param value Define the value to give to the uniform
  15839. * @return the material itself allowing "fluent" like uniform updates
  15840. */
  15841. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15842. /**
  15843. * Set a vec4 in the shader from a Color4.
  15844. * @param name Define the name of the uniform as defined in the shader
  15845. * @param value Define the value to give to the uniform
  15846. * @return the material itself allowing "fluent" like uniform updates
  15847. */
  15848. setColor4(name: string, value: Color4): ShaderMaterial;
  15849. /**
  15850. * Set a vec4 array in the shader from a Color4 array.
  15851. * @param name Define the name of the uniform as defined in the shader
  15852. * @param value Define the value to give to the uniform
  15853. * @return the material itself allowing "fluent" like uniform updates
  15854. */
  15855. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15856. /**
  15857. * Set a vec2 in the shader from a Vector2.
  15858. * @param name Define the name of the uniform as defined in the shader
  15859. * @param value Define the value to give to the uniform
  15860. * @return the material itself allowing "fluent" like uniform updates
  15861. */
  15862. setVector2(name: string, value: Vector2): ShaderMaterial;
  15863. /**
  15864. * Set a vec3 in the shader from a Vector3.
  15865. * @param name Define the name of the uniform as defined in the shader
  15866. * @param value Define the value to give to the uniform
  15867. * @return the material itself allowing "fluent" like uniform updates
  15868. */
  15869. setVector3(name: string, value: Vector3): ShaderMaterial;
  15870. /**
  15871. * Set a vec4 in the shader from a Vector4.
  15872. * @param name Define the name of the uniform as defined in the shader
  15873. * @param value Define the value to give to the uniform
  15874. * @return the material itself allowing "fluent" like uniform updates
  15875. */
  15876. setVector4(name: string, value: Vector4): ShaderMaterial;
  15877. /**
  15878. * Set a mat4 in the shader from a Matrix.
  15879. * @param name Define the name of the uniform as defined in the shader
  15880. * @param value Define the value to give to the uniform
  15881. * @return the material itself allowing "fluent" like uniform updates
  15882. */
  15883. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15884. /**
  15885. * Set a float32Array in the shader from a matrix array.
  15886. * @param name Define the name of the uniform as defined in the shader
  15887. * @param value Define the value to give to the uniform
  15888. * @return the material itself allowing "fluent" like uniform updates
  15889. */
  15890. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15891. /**
  15892. * Set a mat3 in the shader from a Float32Array.
  15893. * @param name Define the name of the uniform as defined in the shader
  15894. * @param value Define the value to give to the uniform
  15895. * @return the material itself allowing "fluent" like uniform updates
  15896. */
  15897. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15898. /**
  15899. * Set a mat2 in the shader from a Float32Array.
  15900. * @param name Define the name of the uniform as defined in the shader
  15901. * @param value Define the value to give to the uniform
  15902. * @return the material itself allowing "fluent" like uniform updates
  15903. */
  15904. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15905. /**
  15906. * Set a vec2 array in the shader from a number array.
  15907. * @param name Define the name of the uniform as defined in the shader
  15908. * @param value Define the value to give to the uniform
  15909. * @return the material itself allowing "fluent" like uniform updates
  15910. */
  15911. setArray2(name: string, value: number[]): ShaderMaterial;
  15912. /**
  15913. * Set a vec3 array in the shader from a number array.
  15914. * @param name Define the name of the uniform as defined in the shader
  15915. * @param value Define the value to give to the uniform
  15916. * @return the material itself allowing "fluent" like uniform updates
  15917. */
  15918. setArray3(name: string, value: number[]): ShaderMaterial;
  15919. /**
  15920. * Set a vec4 array in the shader from a number array.
  15921. * @param name Define the name of the uniform as defined in the shader
  15922. * @param value Define the value to give to the uniform
  15923. * @return the material itself allowing "fluent" like uniform updates
  15924. */
  15925. setArray4(name: string, value: number[]): ShaderMaterial;
  15926. private _checkCache;
  15927. /**
  15928. * Specifies that the submesh is ready to be used
  15929. * @param mesh defines the mesh to check
  15930. * @param subMesh defines which submesh to check
  15931. * @param useInstances specifies that instances should be used
  15932. * @returns a boolean indicating that the submesh is ready or not
  15933. */
  15934. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15935. /**
  15936. * Checks if the material is ready to render the requested mesh
  15937. * @param mesh Define the mesh to render
  15938. * @param useInstances Define whether or not the material is used with instances
  15939. * @returns true if ready, otherwise false
  15940. */
  15941. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15942. /**
  15943. * Binds the world matrix to the material
  15944. * @param world defines the world transformation matrix
  15945. */
  15946. bindOnlyWorldMatrix(world: Matrix): void;
  15947. /**
  15948. * Binds the material to the mesh
  15949. * @param world defines the world transformation matrix
  15950. * @param mesh defines the mesh to bind the material to
  15951. */
  15952. bind(world: Matrix, mesh?: Mesh): void;
  15953. /**
  15954. * Gets the active textures from the material
  15955. * @returns an array of textures
  15956. */
  15957. getActiveTextures(): BaseTexture[];
  15958. /**
  15959. * Specifies if the material uses a texture
  15960. * @param texture defines the texture to check against the material
  15961. * @returns a boolean specifying if the material uses the texture
  15962. */
  15963. hasTexture(texture: BaseTexture): boolean;
  15964. /**
  15965. * Makes a duplicate of the material, and gives it a new name
  15966. * @param name defines the new name for the duplicated material
  15967. * @returns the cloned material
  15968. */
  15969. clone(name: string): ShaderMaterial;
  15970. /**
  15971. * Disposes the material
  15972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15974. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15975. */
  15976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15977. /**
  15978. * Serializes this material in a JSON representation
  15979. * @returns the serialized material object
  15980. */
  15981. serialize(): any;
  15982. /**
  15983. * Creates a shader material from parsed shader material data
  15984. * @param source defines the JSON represnetation of the material
  15985. * @param scene defines the hosting scene
  15986. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15987. * @returns a new material
  15988. */
  15989. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15990. }
  15991. }
  15992. declare module "babylonjs/Shaders/color.fragment" {
  15993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15995. /** @hidden */
  15996. export var colorPixelShader: {
  15997. name: string;
  15998. shader: string;
  15999. };
  16000. }
  16001. declare module "babylonjs/Shaders/color.vertex" {
  16002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16003. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16008. /** @hidden */
  16009. export var colorVertexShader: {
  16010. name: string;
  16011. shader: string;
  16012. };
  16013. }
  16014. declare module "babylonjs/Meshes/linesMesh" {
  16015. import { Nullable } from "babylonjs/types";
  16016. import { Scene } from "babylonjs/scene";
  16017. import { Color3 } from "babylonjs/Maths/math.color";
  16018. import { Node } from "babylonjs/node";
  16019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16020. import { Mesh } from "babylonjs/Meshes/mesh";
  16021. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16022. import { Effect } from "babylonjs/Materials/effect";
  16023. import { Material } from "babylonjs/Materials/material";
  16024. import "babylonjs/Shaders/color.fragment";
  16025. import "babylonjs/Shaders/color.vertex";
  16026. /**
  16027. * Line mesh
  16028. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16029. */
  16030. export class LinesMesh extends Mesh {
  16031. /**
  16032. * If vertex color should be applied to the mesh
  16033. */
  16034. readonly useVertexColor?: boolean | undefined;
  16035. /**
  16036. * If vertex alpha should be applied to the mesh
  16037. */
  16038. readonly useVertexAlpha?: boolean | undefined;
  16039. /**
  16040. * Color of the line (Default: White)
  16041. */
  16042. color: Color3;
  16043. /**
  16044. * Alpha of the line (Default: 1)
  16045. */
  16046. alpha: number;
  16047. /**
  16048. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16049. * This margin is expressed in world space coordinates, so its value may vary.
  16050. * Default value is 0.1
  16051. */
  16052. intersectionThreshold: number;
  16053. private _colorShader;
  16054. private color4;
  16055. /**
  16056. * Creates a new LinesMesh
  16057. * @param name defines the name
  16058. * @param scene defines the hosting scene
  16059. * @param parent defines the parent mesh if any
  16060. * @param source defines the optional source LinesMesh used to clone data from
  16061. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16062. * When false, achieved by calling a clone(), also passing False.
  16063. * This will make creation of children, recursive.
  16064. * @param useVertexColor defines if this LinesMesh supports vertex color
  16065. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16066. */
  16067. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16068. /**
  16069. * If vertex color should be applied to the mesh
  16070. */
  16071. useVertexColor?: boolean | undefined,
  16072. /**
  16073. * If vertex alpha should be applied to the mesh
  16074. */
  16075. useVertexAlpha?: boolean | undefined);
  16076. private _addClipPlaneDefine;
  16077. private _removeClipPlaneDefine;
  16078. isReady(): boolean;
  16079. /**
  16080. * Returns the string "LineMesh"
  16081. */
  16082. getClassName(): string;
  16083. /**
  16084. * @hidden
  16085. */
  16086. get material(): Material;
  16087. /**
  16088. * @hidden
  16089. */
  16090. set material(value: Material);
  16091. /**
  16092. * @hidden
  16093. */
  16094. get checkCollisions(): boolean;
  16095. /** @hidden */
  16096. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16097. /** @hidden */
  16098. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16099. /**
  16100. * Disposes of the line mesh
  16101. * @param doNotRecurse If children should be disposed
  16102. */
  16103. dispose(doNotRecurse?: boolean): void;
  16104. /**
  16105. * Returns a new LineMesh object cloned from the current one.
  16106. */
  16107. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16108. /**
  16109. * Creates a new InstancedLinesMesh object from the mesh model.
  16110. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16111. * @param name defines the name of the new instance
  16112. * @returns a new InstancedLinesMesh
  16113. */
  16114. createInstance(name: string): InstancedLinesMesh;
  16115. }
  16116. /**
  16117. * Creates an instance based on a source LinesMesh
  16118. */
  16119. export class InstancedLinesMesh extends InstancedMesh {
  16120. /**
  16121. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16122. * This margin is expressed in world space coordinates, so its value may vary.
  16123. * Initilized with the intersectionThreshold value of the source LinesMesh
  16124. */
  16125. intersectionThreshold: number;
  16126. constructor(name: string, source: LinesMesh);
  16127. /**
  16128. * Returns the string "InstancedLinesMesh".
  16129. */
  16130. getClassName(): string;
  16131. }
  16132. }
  16133. declare module "babylonjs/Shaders/line.fragment" {
  16134. /** @hidden */
  16135. export var linePixelShader: {
  16136. name: string;
  16137. shader: string;
  16138. };
  16139. }
  16140. declare module "babylonjs/Shaders/line.vertex" {
  16141. /** @hidden */
  16142. export var lineVertexShader: {
  16143. name: string;
  16144. shader: string;
  16145. };
  16146. }
  16147. declare module "babylonjs/Rendering/edgesRenderer" {
  16148. import { Nullable } from "babylonjs/types";
  16149. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16151. import { Vector3 } from "babylonjs/Maths/math.vector";
  16152. import { IDisposable } from "babylonjs/scene";
  16153. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16154. import "babylonjs/Shaders/line.fragment";
  16155. import "babylonjs/Shaders/line.vertex";
  16156. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16157. module "babylonjs/Meshes/abstractMesh" {
  16158. interface AbstractMesh {
  16159. /**
  16160. * Gets the edgesRenderer associated with the mesh
  16161. */
  16162. edgesRenderer: Nullable<EdgesRenderer>;
  16163. }
  16164. }
  16165. module "babylonjs/Meshes/linesMesh" {
  16166. interface LinesMesh {
  16167. /**
  16168. * Enables the edge rendering mode on the mesh.
  16169. * This mode makes the mesh edges visible
  16170. * @param epsilon defines the maximal distance between two angles to detect a face
  16171. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16172. * @returns the currentAbstractMesh
  16173. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16174. */
  16175. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16176. }
  16177. }
  16178. module "babylonjs/Meshes/linesMesh" {
  16179. interface InstancedLinesMesh {
  16180. /**
  16181. * Enables the edge rendering mode on the mesh.
  16182. * This mode makes the mesh edges visible
  16183. * @param epsilon defines the maximal distance between two angles to detect a face
  16184. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16185. * @returns the current InstancedLinesMesh
  16186. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16187. */
  16188. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16189. }
  16190. }
  16191. /**
  16192. * Defines the minimum contract an Edges renderer should follow.
  16193. */
  16194. export interface IEdgesRenderer extends IDisposable {
  16195. /**
  16196. * Gets or sets a boolean indicating if the edgesRenderer is active
  16197. */
  16198. isEnabled: boolean;
  16199. /**
  16200. * Renders the edges of the attached mesh,
  16201. */
  16202. render(): void;
  16203. /**
  16204. * Checks wether or not the edges renderer is ready to render.
  16205. * @return true if ready, otherwise false.
  16206. */
  16207. isReady(): boolean;
  16208. }
  16209. /**
  16210. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16211. */
  16212. export class EdgesRenderer implements IEdgesRenderer {
  16213. /**
  16214. * Define the size of the edges with an orthographic camera
  16215. */
  16216. edgesWidthScalerForOrthographic: number;
  16217. /**
  16218. * Define the size of the edges with a perspective camera
  16219. */
  16220. edgesWidthScalerForPerspective: number;
  16221. protected _source: AbstractMesh;
  16222. protected _linesPositions: number[];
  16223. protected _linesNormals: number[];
  16224. protected _linesIndices: number[];
  16225. protected _epsilon: number;
  16226. protected _indicesCount: number;
  16227. protected _lineShader: ShaderMaterial;
  16228. protected _ib: DataBuffer;
  16229. protected _buffers: {
  16230. [key: string]: Nullable<VertexBuffer>;
  16231. };
  16232. protected _checkVerticesInsteadOfIndices: boolean;
  16233. private _meshRebuildObserver;
  16234. private _meshDisposeObserver;
  16235. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16236. isEnabled: boolean;
  16237. /**
  16238. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16239. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16240. * @param source Mesh used to create edges
  16241. * @param epsilon sum of angles in adjacency to check for edge
  16242. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16243. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16244. */
  16245. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16246. protected _prepareRessources(): void;
  16247. /** @hidden */
  16248. _rebuild(): void;
  16249. /**
  16250. * Releases the required resources for the edges renderer
  16251. */
  16252. dispose(): void;
  16253. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16254. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16255. /**
  16256. * Checks if the pair of p0 and p1 is en edge
  16257. * @param faceIndex
  16258. * @param edge
  16259. * @param faceNormals
  16260. * @param p0
  16261. * @param p1
  16262. * @private
  16263. */
  16264. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16265. /**
  16266. * push line into the position, normal and index buffer
  16267. * @protected
  16268. */
  16269. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16270. /**
  16271. * Generates lines edges from adjacencjes
  16272. * @private
  16273. */
  16274. _generateEdgesLines(): void;
  16275. /**
  16276. * Checks wether or not the edges renderer is ready to render.
  16277. * @return true if ready, otherwise false.
  16278. */
  16279. isReady(): boolean;
  16280. /**
  16281. * Renders the edges of the attached mesh,
  16282. */
  16283. render(): void;
  16284. }
  16285. /**
  16286. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16287. */
  16288. export class LineEdgesRenderer extends EdgesRenderer {
  16289. /**
  16290. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16291. * @param source LineMesh used to generate edges
  16292. * @param epsilon not important (specified angle for edge detection)
  16293. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16294. */
  16295. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16296. /**
  16297. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16298. */
  16299. _generateEdgesLines(): void;
  16300. }
  16301. }
  16302. declare module "babylonjs/Rendering/renderingGroup" {
  16303. import { SmartArray } from "babylonjs/Misc/smartArray";
  16304. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16306. import { Nullable } from "babylonjs/types";
  16307. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16308. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16309. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16310. import { Material } from "babylonjs/Materials/material";
  16311. import { Scene } from "babylonjs/scene";
  16312. /**
  16313. * This represents the object necessary to create a rendering group.
  16314. * This is exclusively used and created by the rendering manager.
  16315. * To modify the behavior, you use the available helpers in your scene or meshes.
  16316. * @hidden
  16317. */
  16318. export class RenderingGroup {
  16319. index: number;
  16320. private static _zeroVector;
  16321. private _scene;
  16322. private _opaqueSubMeshes;
  16323. private _transparentSubMeshes;
  16324. private _alphaTestSubMeshes;
  16325. private _depthOnlySubMeshes;
  16326. private _particleSystems;
  16327. private _spriteManagers;
  16328. private _opaqueSortCompareFn;
  16329. private _alphaTestSortCompareFn;
  16330. private _transparentSortCompareFn;
  16331. private _renderOpaque;
  16332. private _renderAlphaTest;
  16333. private _renderTransparent;
  16334. /** @hidden */
  16335. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16336. onBeforeTransparentRendering: () => void;
  16337. /**
  16338. * Set the opaque sort comparison function.
  16339. * If null the sub meshes will be render in the order they were created
  16340. */
  16341. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16342. /**
  16343. * Set the alpha test sort comparison function.
  16344. * If null the sub meshes will be render in the order they were created
  16345. */
  16346. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16347. /**
  16348. * Set the transparent sort comparison function.
  16349. * If null the sub meshes will be render in the order they were created
  16350. */
  16351. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16352. /**
  16353. * Creates a new rendering group.
  16354. * @param index The rendering group index
  16355. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16356. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16357. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16358. */
  16359. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16360. /**
  16361. * Render all the sub meshes contained in the group.
  16362. * @param customRenderFunction Used to override the default render behaviour of the group.
  16363. * @returns true if rendered some submeshes.
  16364. */
  16365. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16366. /**
  16367. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16368. * @param subMeshes The submeshes to render
  16369. */
  16370. private renderOpaqueSorted;
  16371. /**
  16372. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16373. * @param subMeshes The submeshes to render
  16374. */
  16375. private renderAlphaTestSorted;
  16376. /**
  16377. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16378. * @param subMeshes The submeshes to render
  16379. */
  16380. private renderTransparentSorted;
  16381. /**
  16382. * Renders the submeshes in a specified order.
  16383. * @param subMeshes The submeshes to sort before render
  16384. * @param sortCompareFn The comparison function use to sort
  16385. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16386. * @param transparent Specifies to activate blending if true
  16387. */
  16388. private static renderSorted;
  16389. /**
  16390. * Renders the submeshes in the order they were dispatched (no sort applied).
  16391. * @param subMeshes The submeshes to render
  16392. */
  16393. private static renderUnsorted;
  16394. /**
  16395. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16396. * are rendered back to front if in the same alpha index.
  16397. *
  16398. * @param a The first submesh
  16399. * @param b The second submesh
  16400. * @returns The result of the comparison
  16401. */
  16402. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16403. /**
  16404. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16405. * are rendered back to front.
  16406. *
  16407. * @param a The first submesh
  16408. * @param b The second submesh
  16409. * @returns The result of the comparison
  16410. */
  16411. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16412. /**
  16413. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16414. * are rendered front to back (prevent overdraw).
  16415. *
  16416. * @param a The first submesh
  16417. * @param b The second submesh
  16418. * @returns The result of the comparison
  16419. */
  16420. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16421. /**
  16422. * Resets the different lists of submeshes to prepare a new frame.
  16423. */
  16424. prepare(): void;
  16425. dispose(): void;
  16426. /**
  16427. * Inserts the submesh in its correct queue depending on its material.
  16428. * @param subMesh The submesh to dispatch
  16429. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16430. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16431. */
  16432. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16433. dispatchSprites(spriteManager: ISpriteManager): void;
  16434. dispatchParticles(particleSystem: IParticleSystem): void;
  16435. private _renderParticles;
  16436. private _renderSprites;
  16437. }
  16438. }
  16439. declare module "babylonjs/Rendering/renderingManager" {
  16440. import { Nullable } from "babylonjs/types";
  16441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16443. import { SmartArray } from "babylonjs/Misc/smartArray";
  16444. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16445. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16446. import { Material } from "babylonjs/Materials/material";
  16447. import { Scene } from "babylonjs/scene";
  16448. import { Camera } from "babylonjs/Cameras/camera";
  16449. /**
  16450. * Interface describing the different options available in the rendering manager
  16451. * regarding Auto Clear between groups.
  16452. */
  16453. export interface IRenderingManagerAutoClearSetup {
  16454. /**
  16455. * Defines whether or not autoclear is enable.
  16456. */
  16457. autoClear: boolean;
  16458. /**
  16459. * Defines whether or not to autoclear the depth buffer.
  16460. */
  16461. depth: boolean;
  16462. /**
  16463. * Defines whether or not to autoclear the stencil buffer.
  16464. */
  16465. stencil: boolean;
  16466. }
  16467. /**
  16468. * This class is used by the onRenderingGroupObservable
  16469. */
  16470. export class RenderingGroupInfo {
  16471. /**
  16472. * The Scene that being rendered
  16473. */
  16474. scene: Scene;
  16475. /**
  16476. * The camera currently used for the rendering pass
  16477. */
  16478. camera: Nullable<Camera>;
  16479. /**
  16480. * The ID of the renderingGroup being processed
  16481. */
  16482. renderingGroupId: number;
  16483. }
  16484. /**
  16485. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16486. * It is enable to manage the different groups as well as the different necessary sort functions.
  16487. * This should not be used directly aside of the few static configurations
  16488. */
  16489. export class RenderingManager {
  16490. /**
  16491. * The max id used for rendering groups (not included)
  16492. */
  16493. static MAX_RENDERINGGROUPS: number;
  16494. /**
  16495. * The min id used for rendering groups (included)
  16496. */
  16497. static MIN_RENDERINGGROUPS: number;
  16498. /**
  16499. * Used to globally prevent autoclearing scenes.
  16500. */
  16501. static AUTOCLEAR: boolean;
  16502. /**
  16503. * @hidden
  16504. */
  16505. _useSceneAutoClearSetup: boolean;
  16506. private _scene;
  16507. private _renderingGroups;
  16508. private _depthStencilBufferAlreadyCleaned;
  16509. private _autoClearDepthStencil;
  16510. private _customOpaqueSortCompareFn;
  16511. private _customAlphaTestSortCompareFn;
  16512. private _customTransparentSortCompareFn;
  16513. private _renderingGroupInfo;
  16514. /**
  16515. * Instantiates a new rendering group for a particular scene
  16516. * @param scene Defines the scene the groups belongs to
  16517. */
  16518. constructor(scene: Scene);
  16519. private _clearDepthStencilBuffer;
  16520. /**
  16521. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16522. * @hidden
  16523. */
  16524. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16525. /**
  16526. * Resets the different information of the group to prepare a new frame
  16527. * @hidden
  16528. */
  16529. reset(): void;
  16530. /**
  16531. * Dispose and release the group and its associated resources.
  16532. * @hidden
  16533. */
  16534. dispose(): void;
  16535. /**
  16536. * Clear the info related to rendering groups preventing retention points during dispose.
  16537. */
  16538. freeRenderingGroups(): void;
  16539. private _prepareRenderingGroup;
  16540. /**
  16541. * Add a sprite manager to the rendering manager in order to render it this frame.
  16542. * @param spriteManager Define the sprite manager to render
  16543. */
  16544. dispatchSprites(spriteManager: ISpriteManager): void;
  16545. /**
  16546. * Add a particle system to the rendering manager in order to render it this frame.
  16547. * @param particleSystem Define the particle system to render
  16548. */
  16549. dispatchParticles(particleSystem: IParticleSystem): void;
  16550. /**
  16551. * Add a submesh to the manager in order to render it this frame
  16552. * @param subMesh The submesh to dispatch
  16553. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16554. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16555. */
  16556. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16557. /**
  16558. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16559. * This allowed control for front to back rendering or reversly depending of the special needs.
  16560. *
  16561. * @param renderingGroupId The rendering group id corresponding to its index
  16562. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16563. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16564. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16565. */
  16566. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  16567. /**
  16568. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16569. *
  16570. * @param renderingGroupId The rendering group id corresponding to its index
  16571. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16572. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16573. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16574. */
  16575. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16576. /**
  16577. * Gets the current auto clear configuration for one rendering group of the rendering
  16578. * manager.
  16579. * @param index the rendering group index to get the information for
  16580. * @returns The auto clear setup for the requested rendering group
  16581. */
  16582. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16583. }
  16584. }
  16585. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16586. import { SmartArray } from "babylonjs/Misc/smartArray";
  16587. import { Nullable } from "babylonjs/types";
  16588. import { Scene } from "babylonjs/scene";
  16589. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16592. import { Mesh } from "babylonjs/Meshes/mesh";
  16593. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16594. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16595. import { Effect } from "babylonjs/Materials/effect";
  16596. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16597. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16598. import "babylonjs/Shaders/shadowMap.fragment";
  16599. import "babylonjs/Shaders/shadowMap.vertex";
  16600. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16601. import { Observable } from "babylonjs/Misc/observable";
  16602. /**
  16603. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16604. */
  16605. export interface ICustomShaderOptions {
  16606. /**
  16607. * Gets or sets the custom shader name to use
  16608. */
  16609. shaderName: string;
  16610. /**
  16611. * The list of attribute names used in the shader
  16612. */
  16613. attributes?: string[];
  16614. /**
  16615. * The list of unifrom names used in the shader
  16616. */
  16617. uniforms?: string[];
  16618. /**
  16619. * The list of sampler names used in the shader
  16620. */
  16621. samplers?: string[];
  16622. /**
  16623. * The list of defines used in the shader
  16624. */
  16625. defines?: string[];
  16626. }
  16627. /**
  16628. * Interface to implement to create a shadow generator compatible with BJS.
  16629. */
  16630. export interface IShadowGenerator {
  16631. /**
  16632. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16633. * @returns The render target texture if present otherwise, null
  16634. */
  16635. getShadowMap(): Nullable<RenderTargetTexture>;
  16636. /**
  16637. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16638. * @param subMesh The submesh we want to render in the shadow map
  16639. * @param useInstances Defines wether will draw in the map using instances
  16640. * @returns true if ready otherwise, false
  16641. */
  16642. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16643. /**
  16644. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16645. * @param defines Defines of the material we want to update
  16646. * @param lightIndex Index of the light in the enabled light list of the material
  16647. */
  16648. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16649. /**
  16650. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16651. * defined in the generator but impacting the effect).
  16652. * It implies the unifroms available on the materials are the standard BJS ones.
  16653. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16654. * @param effect The effect we are binfing the information for
  16655. */
  16656. bindShadowLight(lightIndex: string, effect: Effect): void;
  16657. /**
  16658. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16659. * (eq to shadow prjection matrix * light transform matrix)
  16660. * @returns The transform matrix used to create the shadow map
  16661. */
  16662. getTransformMatrix(): Matrix;
  16663. /**
  16664. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16665. * Cube and 2D textures for instance.
  16666. */
  16667. recreateShadowMap(): void;
  16668. /**
  16669. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16670. * @param onCompiled Callback triggered at the and of the effects compilation
  16671. * @param options Sets of optional options forcing the compilation with different modes
  16672. */
  16673. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16674. useInstances: boolean;
  16675. }>): void;
  16676. /**
  16677. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16678. * @param options Sets of optional options forcing the compilation with different modes
  16679. * @returns A promise that resolves when the compilation completes
  16680. */
  16681. forceCompilationAsync(options?: Partial<{
  16682. useInstances: boolean;
  16683. }>): Promise<void>;
  16684. /**
  16685. * Serializes the shadow generator setup to a json object.
  16686. * @returns The serialized JSON object
  16687. */
  16688. serialize(): any;
  16689. /**
  16690. * Disposes the Shadow map and related Textures and effects.
  16691. */
  16692. dispose(): void;
  16693. }
  16694. /**
  16695. * Default implementation IShadowGenerator.
  16696. * This is the main object responsible of generating shadows in the framework.
  16697. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16698. */
  16699. export class ShadowGenerator implements IShadowGenerator {
  16700. /**
  16701. * Name of the shadow generator class
  16702. */
  16703. static CLASSNAME: string;
  16704. /**
  16705. * Shadow generator mode None: no filtering applied.
  16706. */
  16707. static readonly FILTER_NONE: number;
  16708. /**
  16709. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16710. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16711. */
  16712. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16713. /**
  16714. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16715. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16716. */
  16717. static readonly FILTER_POISSONSAMPLING: number;
  16718. /**
  16719. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16720. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16721. */
  16722. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16723. /**
  16724. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16725. * edge artifacts on steep falloff.
  16726. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16727. */
  16728. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16729. /**
  16730. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16731. * edge artifacts on steep falloff.
  16732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16733. */
  16734. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16735. /**
  16736. * Shadow generator mode PCF: Percentage Closer Filtering
  16737. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16738. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16739. */
  16740. static readonly FILTER_PCF: number;
  16741. /**
  16742. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16743. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16744. * Contact Hardening
  16745. */
  16746. static readonly FILTER_PCSS: number;
  16747. /**
  16748. * Reserved for PCF and PCSS
  16749. * Highest Quality.
  16750. *
  16751. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16752. *
  16753. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16754. */
  16755. static readonly QUALITY_HIGH: number;
  16756. /**
  16757. * Reserved for PCF and PCSS
  16758. * Good tradeoff for quality/perf cross devices
  16759. *
  16760. * Execute PCF on a 3*3 kernel.
  16761. *
  16762. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16763. */
  16764. static readonly QUALITY_MEDIUM: number;
  16765. /**
  16766. * Reserved for PCF and PCSS
  16767. * The lowest quality but the fastest.
  16768. *
  16769. * Execute PCF on a 1*1 kernel.
  16770. *
  16771. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16772. */
  16773. static readonly QUALITY_LOW: number;
  16774. /** Gets or sets the custom shader name to use */
  16775. customShaderOptions: ICustomShaderOptions;
  16776. /**
  16777. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16778. */
  16779. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16780. /**
  16781. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16782. */
  16783. onAfterShadowMapRenderObservable: Observable<Effect>;
  16784. /**
  16785. * Observable triggered before a mesh is rendered in the shadow map.
  16786. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16787. */
  16788. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16789. /**
  16790. * Observable triggered after a mesh is rendered in the shadow map.
  16791. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16792. */
  16793. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16794. protected _bias: number;
  16795. /**
  16796. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16797. */
  16798. get bias(): number;
  16799. /**
  16800. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16801. */
  16802. set bias(bias: number);
  16803. protected _normalBias: number;
  16804. /**
  16805. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16806. */
  16807. get normalBias(): number;
  16808. /**
  16809. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16810. */
  16811. set normalBias(normalBias: number);
  16812. protected _blurBoxOffset: number;
  16813. /**
  16814. * Gets the blur box offset: offset applied during the blur pass.
  16815. * Only useful if useKernelBlur = false
  16816. */
  16817. get blurBoxOffset(): number;
  16818. /**
  16819. * Sets the blur box offset: offset applied during the blur pass.
  16820. * Only useful if useKernelBlur = false
  16821. */
  16822. set blurBoxOffset(value: number);
  16823. protected _blurScale: number;
  16824. /**
  16825. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16826. * 2 means half of the size.
  16827. */
  16828. get blurScale(): number;
  16829. /**
  16830. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16831. * 2 means half of the size.
  16832. */
  16833. set blurScale(value: number);
  16834. protected _blurKernel: number;
  16835. /**
  16836. * Gets the blur kernel: kernel size of the blur pass.
  16837. * Only useful if useKernelBlur = true
  16838. */
  16839. get blurKernel(): number;
  16840. /**
  16841. * Sets the blur kernel: kernel size of the blur pass.
  16842. * Only useful if useKernelBlur = true
  16843. */
  16844. set blurKernel(value: number);
  16845. protected _useKernelBlur: boolean;
  16846. /**
  16847. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16848. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16849. */
  16850. get useKernelBlur(): boolean;
  16851. /**
  16852. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16853. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16854. */
  16855. set useKernelBlur(value: boolean);
  16856. protected _depthScale: number;
  16857. /**
  16858. * Gets the depth scale used in ESM mode.
  16859. */
  16860. get depthScale(): number;
  16861. /**
  16862. * Sets the depth scale used in ESM mode.
  16863. * This can override the scale stored on the light.
  16864. */
  16865. set depthScale(value: number);
  16866. protected _validateFilter(filter: number): number;
  16867. protected _filter: number;
  16868. /**
  16869. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16870. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16871. */
  16872. get filter(): number;
  16873. /**
  16874. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16875. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16876. */
  16877. set filter(value: number);
  16878. /**
  16879. * Gets if the current filter is set to Poisson Sampling.
  16880. */
  16881. get usePoissonSampling(): boolean;
  16882. /**
  16883. * Sets the current filter to Poisson Sampling.
  16884. */
  16885. set usePoissonSampling(value: boolean);
  16886. /**
  16887. * Gets if the current filter is set to ESM.
  16888. */
  16889. get useExponentialShadowMap(): boolean;
  16890. /**
  16891. * Sets the current filter is to ESM.
  16892. */
  16893. set useExponentialShadowMap(value: boolean);
  16894. /**
  16895. * Gets if the current filter is set to filtered ESM.
  16896. */
  16897. get useBlurExponentialShadowMap(): boolean;
  16898. /**
  16899. * Gets if the current filter is set to filtered ESM.
  16900. */
  16901. set useBlurExponentialShadowMap(value: boolean);
  16902. /**
  16903. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16904. * exponential to prevent steep falloff artifacts).
  16905. */
  16906. get useCloseExponentialShadowMap(): boolean;
  16907. /**
  16908. * Sets the current filter to "close ESM" (using the inverse of the
  16909. * exponential to prevent steep falloff artifacts).
  16910. */
  16911. set useCloseExponentialShadowMap(value: boolean);
  16912. /**
  16913. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16914. * exponential to prevent steep falloff artifacts).
  16915. */
  16916. get useBlurCloseExponentialShadowMap(): boolean;
  16917. /**
  16918. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16919. * exponential to prevent steep falloff artifacts).
  16920. */
  16921. set useBlurCloseExponentialShadowMap(value: boolean);
  16922. /**
  16923. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16924. */
  16925. get usePercentageCloserFiltering(): boolean;
  16926. /**
  16927. * Sets the current filter to "PCF" (percentage closer filtering).
  16928. */
  16929. set usePercentageCloserFiltering(value: boolean);
  16930. protected _filteringQuality: number;
  16931. /**
  16932. * Gets the PCF or PCSS Quality.
  16933. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16934. */
  16935. get filteringQuality(): number;
  16936. /**
  16937. * Sets the PCF or PCSS Quality.
  16938. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16939. */
  16940. set filteringQuality(filteringQuality: number);
  16941. /**
  16942. * Gets if the current filter is set to "PCSS" (contact hardening).
  16943. */
  16944. get useContactHardeningShadow(): boolean;
  16945. /**
  16946. * Sets the current filter to "PCSS" (contact hardening).
  16947. */
  16948. set useContactHardeningShadow(value: boolean);
  16949. protected _contactHardeningLightSizeUVRatio: number;
  16950. /**
  16951. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16952. * Using a ratio helps keeping shape stability independently of the map size.
  16953. *
  16954. * It does not account for the light projection as it was having too much
  16955. * instability during the light setup or during light position changes.
  16956. *
  16957. * Only valid if useContactHardeningShadow is true.
  16958. */
  16959. get contactHardeningLightSizeUVRatio(): number;
  16960. /**
  16961. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16962. * Using a ratio helps keeping shape stability independently of the map size.
  16963. *
  16964. * It does not account for the light projection as it was having too much
  16965. * instability during the light setup or during light position changes.
  16966. *
  16967. * Only valid if useContactHardeningShadow is true.
  16968. */
  16969. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16970. protected _darkness: number;
  16971. /** Gets or sets the actual darkness of a shadow */
  16972. get darkness(): number;
  16973. set darkness(value: number);
  16974. /**
  16975. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16976. * 0 means strongest and 1 would means no shadow.
  16977. * @returns the darkness.
  16978. */
  16979. getDarkness(): number;
  16980. /**
  16981. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16982. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16983. * @returns the shadow generator allowing fluent coding.
  16984. */
  16985. setDarkness(darkness: number): ShadowGenerator;
  16986. protected _transparencyShadow: boolean;
  16987. /** Gets or sets the ability to have transparent shadow */
  16988. get transparencyShadow(): boolean;
  16989. set transparencyShadow(value: boolean);
  16990. /**
  16991. * Sets the ability to have transparent shadow (boolean).
  16992. * @param transparent True if transparent else False
  16993. * @returns the shadow generator allowing fluent coding
  16994. */
  16995. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16996. protected _shadowMap: Nullable<RenderTargetTexture>;
  16997. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16998. /**
  16999. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17000. * @returns The render target texture if present otherwise, null
  17001. */
  17002. getShadowMap(): Nullable<RenderTargetTexture>;
  17003. /**
  17004. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17005. * @returns The render target texture if the shadow map is present otherwise, null
  17006. */
  17007. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17008. /**
  17009. * Gets the class name of that object
  17010. * @returns "ShadowGenerator"
  17011. */
  17012. getClassName(): string;
  17013. /**
  17014. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17015. * @param mesh Mesh to add
  17016. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17017. * @returns the Shadow Generator itself
  17018. */
  17019. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17020. /**
  17021. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17022. * @param mesh Mesh to remove
  17023. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17024. * @returns the Shadow Generator itself
  17025. */
  17026. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17027. /**
  17028. * Controls the extent to which the shadows fade out at the edge of the frustum
  17029. */
  17030. frustumEdgeFalloff: number;
  17031. protected _light: IShadowLight;
  17032. /**
  17033. * Returns the associated light object.
  17034. * @returns the light generating the shadow
  17035. */
  17036. getLight(): IShadowLight;
  17037. /**
  17038. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17039. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17040. * It might on the other hand introduce peter panning.
  17041. */
  17042. forceBackFacesOnly: boolean;
  17043. protected _scene: Scene;
  17044. protected _lightDirection: Vector3;
  17045. protected _effect: Effect;
  17046. protected _viewMatrix: Matrix;
  17047. protected _projectionMatrix: Matrix;
  17048. protected _transformMatrix: Matrix;
  17049. protected _cachedPosition: Vector3;
  17050. protected _cachedDirection: Vector3;
  17051. protected _cachedDefines: string;
  17052. protected _currentRenderID: number;
  17053. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17054. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17055. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17056. protected _blurPostProcesses: PostProcess[];
  17057. protected _mapSize: number;
  17058. protected _currentFaceIndex: number;
  17059. protected _currentFaceIndexCache: number;
  17060. protected _textureType: number;
  17061. protected _defaultTextureMatrix: Matrix;
  17062. protected _storedUniqueId: Nullable<number>;
  17063. /** @hidden */
  17064. static _SceneComponentInitialization: (scene: Scene) => void;
  17065. /**
  17066. * Creates a ShadowGenerator object.
  17067. * A ShadowGenerator is the required tool to use the shadows.
  17068. * Each light casting shadows needs to use its own ShadowGenerator.
  17069. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17070. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17071. * @param light The light object generating the shadows.
  17072. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  17073. */
  17074. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17075. protected _initializeGenerator(): void;
  17076. protected _createTargetRenderTexture(): void;
  17077. protected _initializeShadowMap(): void;
  17078. protected _initializeBlurRTTAndPostProcesses(): void;
  17079. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17080. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17081. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17082. protected _applyFilterValues(): void;
  17083. /**
  17084. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17085. * @param onCompiled Callback triggered at the and of the effects compilation
  17086. * @param options Sets of optional options forcing the compilation with different modes
  17087. */
  17088. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17089. useInstances: boolean;
  17090. }>): void;
  17091. /**
  17092. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17093. * @param options Sets of optional options forcing the compilation with different modes
  17094. * @returns A promise that resolves when the compilation completes
  17095. */
  17096. forceCompilationAsync(options?: Partial<{
  17097. useInstances: boolean;
  17098. }>): Promise<void>;
  17099. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17100. /**
  17101. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17102. * @param subMesh The submesh we want to render in the shadow map
  17103. * @param useInstances Defines wether will draw in the map using instances
  17104. * @returns true if ready otherwise, false
  17105. */
  17106. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17107. /**
  17108. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17109. * @param defines Defines of the material we want to update
  17110. * @param lightIndex Index of the light in the enabled light list of the material
  17111. */
  17112. prepareDefines(defines: any, lightIndex: number): void;
  17113. /**
  17114. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17115. * defined in the generator but impacting the effect).
  17116. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17117. * @param effect The effect we are binfing the information for
  17118. */
  17119. bindShadowLight(lightIndex: string, effect: Effect): void;
  17120. /**
  17121. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17122. * (eq to shadow prjection matrix * light transform matrix)
  17123. * @returns The transform matrix used to create the shadow map
  17124. */
  17125. getTransformMatrix(): Matrix;
  17126. /**
  17127. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17128. * Cube and 2D textures for instance.
  17129. */
  17130. recreateShadowMap(): void;
  17131. protected _disposeBlurPostProcesses(): void;
  17132. protected _disposeRTTandPostProcesses(): void;
  17133. /**
  17134. * Disposes the ShadowGenerator.
  17135. * Returns nothing.
  17136. */
  17137. dispose(): void;
  17138. /**
  17139. * Serializes the shadow generator setup to a json object.
  17140. * @returns The serialized JSON object
  17141. */
  17142. serialize(): any;
  17143. /**
  17144. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17145. * @param parsedShadowGenerator The JSON object to parse
  17146. * @param scene The scene to create the shadow map for
  17147. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17148. * @returns The parsed shadow generator
  17149. */
  17150. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17151. }
  17152. }
  17153. declare module "babylonjs/Lights/light" {
  17154. import { Nullable } from "babylonjs/types";
  17155. import { Scene } from "babylonjs/scene";
  17156. import { Vector3 } from "babylonjs/Maths/math.vector";
  17157. import { Color3 } from "babylonjs/Maths/math.color";
  17158. import { Node } from "babylonjs/node";
  17159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17160. import { Effect } from "babylonjs/Materials/effect";
  17161. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17162. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17163. /**
  17164. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17165. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17166. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  17167. */
  17168. export abstract class Light extends Node {
  17169. /**
  17170. * Falloff Default: light is falling off following the material specification:
  17171. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17172. */
  17173. static readonly FALLOFF_DEFAULT: number;
  17174. /**
  17175. * Falloff Physical: light is falling off following the inverse squared distance law.
  17176. */
  17177. static readonly FALLOFF_PHYSICAL: number;
  17178. /**
  17179. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17180. * to enhance interoperability with other engines.
  17181. */
  17182. static readonly FALLOFF_GLTF: number;
  17183. /**
  17184. * Falloff Standard: light is falling off like in the standard material
  17185. * to enhance interoperability with other materials.
  17186. */
  17187. static readonly FALLOFF_STANDARD: number;
  17188. /**
  17189. * If every light affecting the material is in this lightmapMode,
  17190. * material.lightmapTexture adds or multiplies
  17191. * (depends on material.useLightmapAsShadowmap)
  17192. * after every other light calculations.
  17193. */
  17194. static readonly LIGHTMAP_DEFAULT: number;
  17195. /**
  17196. * material.lightmapTexture as only diffuse lighting from this light
  17197. * adds only specular lighting from this light
  17198. * adds dynamic shadows
  17199. */
  17200. static readonly LIGHTMAP_SPECULAR: number;
  17201. /**
  17202. * material.lightmapTexture as only lighting
  17203. * no light calculation from this light
  17204. * only adds dynamic shadows from this light
  17205. */
  17206. static readonly LIGHTMAP_SHADOWSONLY: number;
  17207. /**
  17208. * Each light type uses the default quantity according to its type:
  17209. * point/spot lights use luminous intensity
  17210. * directional lights use illuminance
  17211. */
  17212. static readonly INTENSITYMODE_AUTOMATIC: number;
  17213. /**
  17214. * lumen (lm)
  17215. */
  17216. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17217. /**
  17218. * candela (lm/sr)
  17219. */
  17220. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17221. /**
  17222. * lux (lm/m^2)
  17223. */
  17224. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17225. /**
  17226. * nit (cd/m^2)
  17227. */
  17228. static readonly INTENSITYMODE_LUMINANCE: number;
  17229. /**
  17230. * Light type const id of the point light.
  17231. */
  17232. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17233. /**
  17234. * Light type const id of the directional light.
  17235. */
  17236. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17237. /**
  17238. * Light type const id of the spot light.
  17239. */
  17240. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17241. /**
  17242. * Light type const id of the hemispheric light.
  17243. */
  17244. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17245. /**
  17246. * Diffuse gives the basic color to an object.
  17247. */
  17248. diffuse: Color3;
  17249. /**
  17250. * Specular produces a highlight color on an object.
  17251. * Note: This is note affecting PBR materials.
  17252. */
  17253. specular: Color3;
  17254. /**
  17255. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17256. * falling off base on range or angle.
  17257. * This can be set to any values in Light.FALLOFF_x.
  17258. *
  17259. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17260. * other types of materials.
  17261. */
  17262. falloffType: number;
  17263. /**
  17264. * Strength of the light.
  17265. * Note: By default it is define in the framework own unit.
  17266. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17267. */
  17268. intensity: number;
  17269. private _range;
  17270. protected _inverseSquaredRange: number;
  17271. /**
  17272. * Defines how far from the source the light is impacting in scene units.
  17273. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17274. */
  17275. get range(): number;
  17276. /**
  17277. * Defines how far from the source the light is impacting in scene units.
  17278. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17279. */
  17280. set range(value: number);
  17281. /**
  17282. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17283. * of light.
  17284. */
  17285. private _photometricScale;
  17286. private _intensityMode;
  17287. /**
  17288. * Gets the photometric scale used to interpret the intensity.
  17289. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17290. */
  17291. get intensityMode(): number;
  17292. /**
  17293. * Sets the photometric scale used to interpret the intensity.
  17294. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17295. */
  17296. set intensityMode(value: number);
  17297. private _radius;
  17298. /**
  17299. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17300. */
  17301. get radius(): number;
  17302. /**
  17303. * sets the light radius used by PBR Materials to simulate soft area lights.
  17304. */
  17305. set radius(value: number);
  17306. private _renderPriority;
  17307. /**
  17308. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17309. * exceeding the number allowed of the materials.
  17310. */
  17311. renderPriority: number;
  17312. private _shadowEnabled;
  17313. /**
  17314. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17315. * the current shadow generator.
  17316. */
  17317. get shadowEnabled(): boolean;
  17318. /**
  17319. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17320. * the current shadow generator.
  17321. */
  17322. set shadowEnabled(value: boolean);
  17323. private _includedOnlyMeshes;
  17324. /**
  17325. * Gets the only meshes impacted by this light.
  17326. */
  17327. get includedOnlyMeshes(): AbstractMesh[];
  17328. /**
  17329. * Sets the only meshes impacted by this light.
  17330. */
  17331. set includedOnlyMeshes(value: AbstractMesh[]);
  17332. private _excludedMeshes;
  17333. /**
  17334. * Gets the meshes not impacted by this light.
  17335. */
  17336. get excludedMeshes(): AbstractMesh[];
  17337. /**
  17338. * Sets the meshes not impacted by this light.
  17339. */
  17340. set excludedMeshes(value: AbstractMesh[]);
  17341. private _excludeWithLayerMask;
  17342. /**
  17343. * Gets the layer id use to find what meshes are not impacted by the light.
  17344. * Inactive if 0
  17345. */
  17346. get excludeWithLayerMask(): number;
  17347. /**
  17348. * Sets the layer id use to find what meshes are not impacted by the light.
  17349. * Inactive if 0
  17350. */
  17351. set excludeWithLayerMask(value: number);
  17352. private _includeOnlyWithLayerMask;
  17353. /**
  17354. * Gets the layer id use to find what meshes are impacted by the light.
  17355. * Inactive if 0
  17356. */
  17357. get includeOnlyWithLayerMask(): number;
  17358. /**
  17359. * Sets the layer id use to find what meshes are impacted by the light.
  17360. * Inactive if 0
  17361. */
  17362. set includeOnlyWithLayerMask(value: number);
  17363. private _lightmapMode;
  17364. /**
  17365. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17366. */
  17367. get lightmapMode(): number;
  17368. /**
  17369. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17370. */
  17371. set lightmapMode(value: number);
  17372. /**
  17373. * Shadow generator associted to the light.
  17374. * @hidden Internal use only.
  17375. */
  17376. _shadowGenerator: Nullable<IShadowGenerator>;
  17377. /**
  17378. * @hidden Internal use only.
  17379. */
  17380. _excludedMeshesIds: string[];
  17381. /**
  17382. * @hidden Internal use only.
  17383. */
  17384. _includedOnlyMeshesIds: string[];
  17385. /**
  17386. * The current light unifom buffer.
  17387. * @hidden Internal use only.
  17388. */
  17389. _uniformBuffer: UniformBuffer;
  17390. /** @hidden */
  17391. _renderId: number;
  17392. /**
  17393. * Creates a Light object in the scene.
  17394. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17395. * @param name The firendly name of the light
  17396. * @param scene The scene the light belongs too
  17397. */
  17398. constructor(name: string, scene: Scene);
  17399. protected abstract _buildUniformLayout(): void;
  17400. /**
  17401. * Sets the passed Effect "effect" with the Light information.
  17402. * @param effect The effect to update
  17403. * @param lightIndex The index of the light in the effect to update
  17404. * @returns The light
  17405. */
  17406. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17407. /**
  17408. * Sets the passed Effect "effect" with the Light textures.
  17409. * @param effect The effect to update
  17410. * @param lightIndex The index of the light in the effect to update
  17411. * @returns The light
  17412. */
  17413. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17414. /**
  17415. * Binds the lights information from the scene to the effect for the given mesh.
  17416. * @param lightIndex Light index
  17417. * @param scene The scene where the light belongs to
  17418. * @param effect The effect we are binding the data to
  17419. * @param useSpecular Defines if specular is supported
  17420. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17421. */
  17422. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17423. /**
  17424. * Sets the passed Effect "effect" with the Light information.
  17425. * @param effect The effect to update
  17426. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17427. * @returns The light
  17428. */
  17429. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17430. /**
  17431. * Returns the string "Light".
  17432. * @returns the class name
  17433. */
  17434. getClassName(): string;
  17435. /** @hidden */
  17436. readonly _isLight: boolean;
  17437. /**
  17438. * Converts the light information to a readable string for debug purpose.
  17439. * @param fullDetails Supports for multiple levels of logging within scene loading
  17440. * @returns the human readable light info
  17441. */
  17442. toString(fullDetails?: boolean): string;
  17443. /** @hidden */
  17444. protected _syncParentEnabledState(): void;
  17445. /**
  17446. * Set the enabled state of this node.
  17447. * @param value - the new enabled state
  17448. */
  17449. setEnabled(value: boolean): void;
  17450. /**
  17451. * Returns the Light associated shadow generator if any.
  17452. * @return the associated shadow generator.
  17453. */
  17454. getShadowGenerator(): Nullable<IShadowGenerator>;
  17455. /**
  17456. * Returns a Vector3, the absolute light position in the World.
  17457. * @returns the world space position of the light
  17458. */
  17459. getAbsolutePosition(): Vector3;
  17460. /**
  17461. * Specifies if the light will affect the passed mesh.
  17462. * @param mesh The mesh to test against the light
  17463. * @return true the mesh is affected otherwise, false.
  17464. */
  17465. canAffectMesh(mesh: AbstractMesh): boolean;
  17466. /**
  17467. * Sort function to order lights for rendering.
  17468. * @param a First Light object to compare to second.
  17469. * @param b Second Light object to compare first.
  17470. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17471. */
  17472. static CompareLightsPriority(a: Light, b: Light): number;
  17473. /**
  17474. * Releases resources associated with this node.
  17475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17477. */
  17478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17479. /**
  17480. * Returns the light type ID (integer).
  17481. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17482. */
  17483. getTypeID(): number;
  17484. /**
  17485. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17486. * @returns the scaled intensity in intensity mode unit
  17487. */
  17488. getScaledIntensity(): number;
  17489. /**
  17490. * Returns a new Light object, named "name", from the current one.
  17491. * @param name The name of the cloned light
  17492. * @returns the new created light
  17493. */
  17494. clone(name: string): Nullable<Light>;
  17495. /**
  17496. * Serializes the current light into a Serialization object.
  17497. * @returns the serialized object.
  17498. */
  17499. serialize(): any;
  17500. /**
  17501. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17502. * This new light is named "name" and added to the passed scene.
  17503. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17504. * @param name The friendly name of the light
  17505. * @param scene The scene the new light will belong to
  17506. * @returns the constructor function
  17507. */
  17508. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17509. /**
  17510. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17511. * @param parsedLight The JSON representation of the light
  17512. * @param scene The scene to create the parsed light in
  17513. * @returns the created light after parsing
  17514. */
  17515. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17516. private _hookArrayForExcluded;
  17517. private _hookArrayForIncludedOnly;
  17518. private _resyncMeshes;
  17519. /**
  17520. * Forces the meshes to update their light related information in their rendering used effects
  17521. * @hidden Internal Use Only
  17522. */
  17523. _markMeshesAsLightDirty(): void;
  17524. /**
  17525. * Recomputes the cached photometric scale if needed.
  17526. */
  17527. private _computePhotometricScale;
  17528. /**
  17529. * Returns the Photometric Scale according to the light type and intensity mode.
  17530. */
  17531. private _getPhotometricScale;
  17532. /**
  17533. * Reorder the light in the scene according to their defined priority.
  17534. * @hidden Internal Use Only
  17535. */
  17536. _reorderLightsInScene(): void;
  17537. /**
  17538. * Prepares the list of defines specific to the light type.
  17539. * @param defines the list of defines
  17540. * @param lightIndex defines the index of the light for the effect
  17541. */
  17542. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17543. }
  17544. }
  17545. declare module "babylonjs/Actions/action" {
  17546. import { Observable } from "babylonjs/Misc/observable";
  17547. import { Condition } from "babylonjs/Actions/condition";
  17548. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17549. import { ActionManager } from "babylonjs/Actions/actionManager";
  17550. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17551. /**
  17552. * Interface used to define Action
  17553. */
  17554. export interface IAction {
  17555. /**
  17556. * Trigger for the action
  17557. */
  17558. trigger: number;
  17559. /** Options of the trigger */
  17560. triggerOptions: any;
  17561. /**
  17562. * Gets the trigger parameters
  17563. * @returns the trigger parameters
  17564. */
  17565. getTriggerParameter(): any;
  17566. /**
  17567. * Internal only - executes current action event
  17568. * @hidden
  17569. */
  17570. _executeCurrent(evt?: ActionEvent): void;
  17571. /**
  17572. * Serialize placeholder for child classes
  17573. * @param parent of child
  17574. * @returns the serialized object
  17575. */
  17576. serialize(parent: any): any;
  17577. /**
  17578. * Internal only
  17579. * @hidden
  17580. */
  17581. _prepare(): void;
  17582. /**
  17583. * Internal only - manager for action
  17584. * @hidden
  17585. */
  17586. _actionManager: AbstractActionManager;
  17587. /**
  17588. * Adds action to chain of actions, may be a DoNothingAction
  17589. * @param action defines the next action to execute
  17590. * @returns The action passed in
  17591. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17592. */
  17593. then(action: IAction): IAction;
  17594. }
  17595. /**
  17596. * The action to be carried out following a trigger
  17597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17598. */
  17599. export class Action implements IAction {
  17600. /** the trigger, with or without parameters, for the action */
  17601. triggerOptions: any;
  17602. /**
  17603. * Trigger for the action
  17604. */
  17605. trigger: number;
  17606. /**
  17607. * Internal only - manager for action
  17608. * @hidden
  17609. */
  17610. _actionManager: ActionManager;
  17611. private _nextActiveAction;
  17612. private _child;
  17613. private _condition?;
  17614. private _triggerParameter;
  17615. /**
  17616. * An event triggered prior to action being executed.
  17617. */
  17618. onBeforeExecuteObservable: Observable<Action>;
  17619. /**
  17620. * Creates a new Action
  17621. * @param triggerOptions the trigger, with or without parameters, for the action
  17622. * @param condition an optional determinant of action
  17623. */
  17624. constructor(
  17625. /** the trigger, with or without parameters, for the action */
  17626. triggerOptions: any, condition?: Condition);
  17627. /**
  17628. * Internal only
  17629. * @hidden
  17630. */
  17631. _prepare(): void;
  17632. /**
  17633. * Gets the trigger parameters
  17634. * @returns the trigger parameters
  17635. */
  17636. getTriggerParameter(): any;
  17637. /**
  17638. * Internal only - executes current action event
  17639. * @hidden
  17640. */
  17641. _executeCurrent(evt?: ActionEvent): void;
  17642. /**
  17643. * Execute placeholder for child classes
  17644. * @param evt optional action event
  17645. */
  17646. execute(evt?: ActionEvent): void;
  17647. /**
  17648. * Skips to next active action
  17649. */
  17650. skipToNextActiveAction(): void;
  17651. /**
  17652. * Adds action to chain of actions, may be a DoNothingAction
  17653. * @param action defines the next action to execute
  17654. * @returns The action passed in
  17655. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17656. */
  17657. then(action: Action): Action;
  17658. /**
  17659. * Internal only
  17660. * @hidden
  17661. */
  17662. _getProperty(propertyPath: string): string;
  17663. /**
  17664. * Internal only
  17665. * @hidden
  17666. */
  17667. _getEffectiveTarget(target: any, propertyPath: string): any;
  17668. /**
  17669. * Serialize placeholder for child classes
  17670. * @param parent of child
  17671. * @returns the serialized object
  17672. */
  17673. serialize(parent: any): any;
  17674. /**
  17675. * Internal only called by serialize
  17676. * @hidden
  17677. */
  17678. protected _serialize(serializedAction: any, parent?: any): any;
  17679. /**
  17680. * Internal only
  17681. * @hidden
  17682. */
  17683. static _SerializeValueAsString: (value: any) => string;
  17684. /**
  17685. * Internal only
  17686. * @hidden
  17687. */
  17688. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17689. name: string;
  17690. targetType: string;
  17691. value: string;
  17692. };
  17693. }
  17694. }
  17695. declare module "babylonjs/Actions/condition" {
  17696. import { ActionManager } from "babylonjs/Actions/actionManager";
  17697. /**
  17698. * A Condition applied to an Action
  17699. */
  17700. export class Condition {
  17701. /**
  17702. * Internal only - manager for action
  17703. * @hidden
  17704. */
  17705. _actionManager: ActionManager;
  17706. /**
  17707. * Internal only
  17708. * @hidden
  17709. */
  17710. _evaluationId: number;
  17711. /**
  17712. * Internal only
  17713. * @hidden
  17714. */
  17715. _currentResult: boolean;
  17716. /**
  17717. * Creates a new Condition
  17718. * @param actionManager the manager of the action the condition is applied to
  17719. */
  17720. constructor(actionManager: ActionManager);
  17721. /**
  17722. * Check if the current condition is valid
  17723. * @returns a boolean
  17724. */
  17725. isValid(): boolean;
  17726. /**
  17727. * Internal only
  17728. * @hidden
  17729. */
  17730. _getProperty(propertyPath: string): string;
  17731. /**
  17732. * Internal only
  17733. * @hidden
  17734. */
  17735. _getEffectiveTarget(target: any, propertyPath: string): any;
  17736. /**
  17737. * Serialize placeholder for child classes
  17738. * @returns the serialized object
  17739. */
  17740. serialize(): any;
  17741. /**
  17742. * Internal only
  17743. * @hidden
  17744. */
  17745. protected _serialize(serializedCondition: any): any;
  17746. }
  17747. /**
  17748. * Defines specific conditional operators as extensions of Condition
  17749. */
  17750. export class ValueCondition extends Condition {
  17751. /** path to specify the property of the target the conditional operator uses */
  17752. propertyPath: string;
  17753. /** the value compared by the conditional operator against the current value of the property */
  17754. value: any;
  17755. /** the conditional operator, default ValueCondition.IsEqual */
  17756. operator: number;
  17757. /**
  17758. * Internal only
  17759. * @hidden
  17760. */
  17761. private static _IsEqual;
  17762. /**
  17763. * Internal only
  17764. * @hidden
  17765. */
  17766. private static _IsDifferent;
  17767. /**
  17768. * Internal only
  17769. * @hidden
  17770. */
  17771. private static _IsGreater;
  17772. /**
  17773. * Internal only
  17774. * @hidden
  17775. */
  17776. private static _IsLesser;
  17777. /**
  17778. * returns the number for IsEqual
  17779. */
  17780. static get IsEqual(): number;
  17781. /**
  17782. * Returns the number for IsDifferent
  17783. */
  17784. static get IsDifferent(): number;
  17785. /**
  17786. * Returns the number for IsGreater
  17787. */
  17788. static get IsGreater(): number;
  17789. /**
  17790. * Returns the number for IsLesser
  17791. */
  17792. static get IsLesser(): number;
  17793. /**
  17794. * Internal only The action manager for the condition
  17795. * @hidden
  17796. */
  17797. _actionManager: ActionManager;
  17798. /**
  17799. * Internal only
  17800. * @hidden
  17801. */
  17802. private _target;
  17803. /**
  17804. * Internal only
  17805. * @hidden
  17806. */
  17807. private _effectiveTarget;
  17808. /**
  17809. * Internal only
  17810. * @hidden
  17811. */
  17812. private _property;
  17813. /**
  17814. * Creates a new ValueCondition
  17815. * @param actionManager manager for the action the condition applies to
  17816. * @param target for the action
  17817. * @param propertyPath path to specify the property of the target the conditional operator uses
  17818. * @param value the value compared by the conditional operator against the current value of the property
  17819. * @param operator the conditional operator, default ValueCondition.IsEqual
  17820. */
  17821. constructor(actionManager: ActionManager, target: any,
  17822. /** path to specify the property of the target the conditional operator uses */
  17823. propertyPath: string,
  17824. /** the value compared by the conditional operator against the current value of the property */
  17825. value: any,
  17826. /** the conditional operator, default ValueCondition.IsEqual */
  17827. operator?: number);
  17828. /**
  17829. * Compares the given value with the property value for the specified conditional operator
  17830. * @returns the result of the comparison
  17831. */
  17832. isValid(): boolean;
  17833. /**
  17834. * Serialize the ValueCondition into a JSON compatible object
  17835. * @returns serialization object
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * Gets the name of the conditional operator for the ValueCondition
  17840. * @param operator the conditional operator
  17841. * @returns the name
  17842. */
  17843. static GetOperatorName(operator: number): string;
  17844. }
  17845. /**
  17846. * Defines a predicate condition as an extension of Condition
  17847. */
  17848. export class PredicateCondition extends Condition {
  17849. /** defines the predicate function used to validate the condition */
  17850. predicate: () => boolean;
  17851. /**
  17852. * Internal only - manager for action
  17853. * @hidden
  17854. */
  17855. _actionManager: ActionManager;
  17856. /**
  17857. * Creates a new PredicateCondition
  17858. * @param actionManager manager for the action the condition applies to
  17859. * @param predicate defines the predicate function used to validate the condition
  17860. */
  17861. constructor(actionManager: ActionManager,
  17862. /** defines the predicate function used to validate the condition */
  17863. predicate: () => boolean);
  17864. /**
  17865. * @returns the validity of the predicate condition
  17866. */
  17867. isValid(): boolean;
  17868. }
  17869. /**
  17870. * Defines a state condition as an extension of Condition
  17871. */
  17872. export class StateCondition extends Condition {
  17873. /** Value to compare with target state */
  17874. value: string;
  17875. /**
  17876. * Internal only - manager for action
  17877. * @hidden
  17878. */
  17879. _actionManager: ActionManager;
  17880. /**
  17881. * Internal only
  17882. * @hidden
  17883. */
  17884. private _target;
  17885. /**
  17886. * Creates a new StateCondition
  17887. * @param actionManager manager for the action the condition applies to
  17888. * @param target of the condition
  17889. * @param value to compare with target state
  17890. */
  17891. constructor(actionManager: ActionManager, target: any,
  17892. /** Value to compare with target state */
  17893. value: string);
  17894. /**
  17895. * Gets a boolean indicating if the current condition is met
  17896. * @returns the validity of the state
  17897. */
  17898. isValid(): boolean;
  17899. /**
  17900. * Serialize the StateCondition into a JSON compatible object
  17901. * @returns serialization object
  17902. */
  17903. serialize(): any;
  17904. }
  17905. }
  17906. declare module "babylonjs/Actions/directActions" {
  17907. import { Action } from "babylonjs/Actions/action";
  17908. import { Condition } from "babylonjs/Actions/condition";
  17909. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17910. /**
  17911. * This defines an action responsible to toggle a boolean once triggered.
  17912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17913. */
  17914. export class SwitchBooleanAction extends Action {
  17915. /**
  17916. * The path to the boolean property in the target object
  17917. */
  17918. propertyPath: string;
  17919. private _target;
  17920. private _effectiveTarget;
  17921. private _property;
  17922. /**
  17923. * Instantiate the action
  17924. * @param triggerOptions defines the trigger options
  17925. * @param target defines the object containing the boolean
  17926. * @param propertyPath defines the path to the boolean property in the target object
  17927. * @param condition defines the trigger related conditions
  17928. */
  17929. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17930. /** @hidden */
  17931. _prepare(): void;
  17932. /**
  17933. * Execute the action toggle the boolean value.
  17934. */
  17935. execute(): void;
  17936. /**
  17937. * Serializes the actions and its related information.
  17938. * @param parent defines the object to serialize in
  17939. * @returns the serialized object
  17940. */
  17941. serialize(parent: any): any;
  17942. }
  17943. /**
  17944. * This defines an action responsible to set a the state field of the target
  17945. * to a desired value once triggered.
  17946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17947. */
  17948. export class SetStateAction extends Action {
  17949. /**
  17950. * The value to store in the state field.
  17951. */
  17952. value: string;
  17953. private _target;
  17954. /**
  17955. * Instantiate the action
  17956. * @param triggerOptions defines the trigger options
  17957. * @param target defines the object containing the state property
  17958. * @param value defines the value to store in the state field
  17959. * @param condition defines the trigger related conditions
  17960. */
  17961. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17962. /**
  17963. * Execute the action and store the value on the target state property.
  17964. */
  17965. execute(): void;
  17966. /**
  17967. * Serializes the actions and its related information.
  17968. * @param parent defines the object to serialize in
  17969. * @returns the serialized object
  17970. */
  17971. serialize(parent: any): any;
  17972. }
  17973. /**
  17974. * This defines an action responsible to set a property of the target
  17975. * to a desired value once triggered.
  17976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17977. */
  17978. export class SetValueAction extends Action {
  17979. /**
  17980. * The path of the property to set in the target.
  17981. */
  17982. propertyPath: string;
  17983. /**
  17984. * The value to set in the property
  17985. */
  17986. value: any;
  17987. private _target;
  17988. private _effectiveTarget;
  17989. private _property;
  17990. /**
  17991. * Instantiate the action
  17992. * @param triggerOptions defines the trigger options
  17993. * @param target defines the object containing the property
  17994. * @param propertyPath defines the path of the property to set in the target
  17995. * @param value defines the value to set in the property
  17996. * @param condition defines the trigger related conditions
  17997. */
  17998. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17999. /** @hidden */
  18000. _prepare(): void;
  18001. /**
  18002. * Execute the action and set the targetted property to the desired value.
  18003. */
  18004. execute(): void;
  18005. /**
  18006. * Serializes the actions and its related information.
  18007. * @param parent defines the object to serialize in
  18008. * @returns the serialized object
  18009. */
  18010. serialize(parent: any): any;
  18011. }
  18012. /**
  18013. * This defines an action responsible to increment the target value
  18014. * to a desired value once triggered.
  18015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18016. */
  18017. export class IncrementValueAction extends Action {
  18018. /**
  18019. * The path of the property to increment in the target.
  18020. */
  18021. propertyPath: string;
  18022. /**
  18023. * The value we should increment the property by.
  18024. */
  18025. value: any;
  18026. private _target;
  18027. private _effectiveTarget;
  18028. private _property;
  18029. /**
  18030. * Instantiate the action
  18031. * @param triggerOptions defines the trigger options
  18032. * @param target defines the object containing the property
  18033. * @param propertyPath defines the path of the property to increment in the target
  18034. * @param value defines the value value we should increment the property by
  18035. * @param condition defines the trigger related conditions
  18036. */
  18037. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18038. /** @hidden */
  18039. _prepare(): void;
  18040. /**
  18041. * Execute the action and increment the target of the value amount.
  18042. */
  18043. execute(): void;
  18044. /**
  18045. * Serializes the actions and its related information.
  18046. * @param parent defines the object to serialize in
  18047. * @returns the serialized object
  18048. */
  18049. serialize(parent: any): any;
  18050. }
  18051. /**
  18052. * This defines an action responsible to start an animation once triggered.
  18053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18054. */
  18055. export class PlayAnimationAction extends Action {
  18056. /**
  18057. * Where the animation should start (animation frame)
  18058. */
  18059. from: number;
  18060. /**
  18061. * Where the animation should stop (animation frame)
  18062. */
  18063. to: number;
  18064. /**
  18065. * Define if the animation should loop or stop after the first play.
  18066. */
  18067. loop?: boolean;
  18068. private _target;
  18069. /**
  18070. * Instantiate the action
  18071. * @param triggerOptions defines the trigger options
  18072. * @param target defines the target animation or animation name
  18073. * @param from defines from where the animation should start (animation frame)
  18074. * @param end defines where the animation should stop (animation frame)
  18075. * @param loop defines if the animation should loop or stop after the first play
  18076. * @param condition defines the trigger related conditions
  18077. */
  18078. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18079. /** @hidden */
  18080. _prepare(): void;
  18081. /**
  18082. * Execute the action and play the animation.
  18083. */
  18084. execute(): void;
  18085. /**
  18086. * Serializes the actions and its related information.
  18087. * @param parent defines the object to serialize in
  18088. * @returns the serialized object
  18089. */
  18090. serialize(parent: any): any;
  18091. }
  18092. /**
  18093. * This defines an action responsible to stop an animation once triggered.
  18094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18095. */
  18096. export class StopAnimationAction extends Action {
  18097. private _target;
  18098. /**
  18099. * Instantiate the action
  18100. * @param triggerOptions defines the trigger options
  18101. * @param target defines the target animation or animation name
  18102. * @param condition defines the trigger related conditions
  18103. */
  18104. constructor(triggerOptions: any, target: any, condition?: Condition);
  18105. /** @hidden */
  18106. _prepare(): void;
  18107. /**
  18108. * Execute the action and stop the animation.
  18109. */
  18110. execute(): void;
  18111. /**
  18112. * Serializes the actions and its related information.
  18113. * @param parent defines the object to serialize in
  18114. * @returns the serialized object
  18115. */
  18116. serialize(parent: any): any;
  18117. }
  18118. /**
  18119. * This defines an action responsible that does nothing once triggered.
  18120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18121. */
  18122. export class DoNothingAction extends Action {
  18123. /**
  18124. * Instantiate the action
  18125. * @param triggerOptions defines the trigger options
  18126. * @param condition defines the trigger related conditions
  18127. */
  18128. constructor(triggerOptions?: any, condition?: Condition);
  18129. /**
  18130. * Execute the action and do nothing.
  18131. */
  18132. execute(): void;
  18133. /**
  18134. * Serializes the actions and its related information.
  18135. * @param parent defines the object to serialize in
  18136. * @returns the serialized object
  18137. */
  18138. serialize(parent: any): any;
  18139. }
  18140. /**
  18141. * This defines an action responsible to trigger several actions once triggered.
  18142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18143. */
  18144. export class CombineAction extends Action {
  18145. /**
  18146. * The list of aggregated animations to run.
  18147. */
  18148. children: Action[];
  18149. /**
  18150. * Instantiate the action
  18151. * @param triggerOptions defines the trigger options
  18152. * @param children defines the list of aggregated animations to run
  18153. * @param condition defines the trigger related conditions
  18154. */
  18155. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18156. /** @hidden */
  18157. _prepare(): void;
  18158. /**
  18159. * Execute the action and executes all the aggregated actions.
  18160. */
  18161. execute(evt: ActionEvent): void;
  18162. /**
  18163. * Serializes the actions and its related information.
  18164. * @param parent defines the object to serialize in
  18165. * @returns the serialized object
  18166. */
  18167. serialize(parent: any): any;
  18168. }
  18169. /**
  18170. * This defines an action responsible to run code (external event) once triggered.
  18171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18172. */
  18173. export class ExecuteCodeAction extends Action {
  18174. /**
  18175. * The callback function to run.
  18176. */
  18177. func: (evt: ActionEvent) => void;
  18178. /**
  18179. * Instantiate the action
  18180. * @param triggerOptions defines the trigger options
  18181. * @param func defines the callback function to run
  18182. * @param condition defines the trigger related conditions
  18183. */
  18184. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18185. /**
  18186. * Execute the action and run the attached code.
  18187. */
  18188. execute(evt: ActionEvent): void;
  18189. }
  18190. /**
  18191. * This defines an action responsible to set the parent property of the target once triggered.
  18192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18193. */
  18194. export class SetParentAction extends Action {
  18195. private _parent;
  18196. private _target;
  18197. /**
  18198. * Instantiate the action
  18199. * @param triggerOptions defines the trigger options
  18200. * @param target defines the target containing the parent property
  18201. * @param parent defines from where the animation should start (animation frame)
  18202. * @param condition defines the trigger related conditions
  18203. */
  18204. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18205. /** @hidden */
  18206. _prepare(): void;
  18207. /**
  18208. * Execute the action and set the parent property.
  18209. */
  18210. execute(): void;
  18211. /**
  18212. * Serializes the actions and its related information.
  18213. * @param parent defines the object to serialize in
  18214. * @returns the serialized object
  18215. */
  18216. serialize(parent: any): any;
  18217. }
  18218. }
  18219. declare module "babylonjs/Actions/actionManager" {
  18220. import { Nullable } from "babylonjs/types";
  18221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18222. import { Scene } from "babylonjs/scene";
  18223. import { IAction } from "babylonjs/Actions/action";
  18224. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18225. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18226. /**
  18227. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18228. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18230. */
  18231. export class ActionManager extends AbstractActionManager {
  18232. /**
  18233. * Nothing
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly NothingTrigger: number;
  18237. /**
  18238. * On pick
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnPickTrigger: number;
  18242. /**
  18243. * On left pick
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnLeftPickTrigger: number;
  18247. /**
  18248. * On right pick
  18249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18250. */
  18251. static readonly OnRightPickTrigger: number;
  18252. /**
  18253. * On center pick
  18254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18255. */
  18256. static readonly OnCenterPickTrigger: number;
  18257. /**
  18258. * On pick down
  18259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18260. */
  18261. static readonly OnPickDownTrigger: number;
  18262. /**
  18263. * On double pick
  18264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18265. */
  18266. static readonly OnDoublePickTrigger: number;
  18267. /**
  18268. * On pick up
  18269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18270. */
  18271. static readonly OnPickUpTrigger: number;
  18272. /**
  18273. * On pick out.
  18274. * This trigger will only be raised if you also declared a OnPickDown
  18275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18276. */
  18277. static readonly OnPickOutTrigger: number;
  18278. /**
  18279. * On long press
  18280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18281. */
  18282. static readonly OnLongPressTrigger: number;
  18283. /**
  18284. * On pointer over
  18285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18286. */
  18287. static readonly OnPointerOverTrigger: number;
  18288. /**
  18289. * On pointer out
  18290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18291. */
  18292. static readonly OnPointerOutTrigger: number;
  18293. /**
  18294. * On every frame
  18295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18296. */
  18297. static readonly OnEveryFrameTrigger: number;
  18298. /**
  18299. * On intersection enter
  18300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18301. */
  18302. static readonly OnIntersectionEnterTrigger: number;
  18303. /**
  18304. * On intersection exit
  18305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18306. */
  18307. static readonly OnIntersectionExitTrigger: number;
  18308. /**
  18309. * On key down
  18310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18311. */
  18312. static readonly OnKeyDownTrigger: number;
  18313. /**
  18314. * On key up
  18315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18316. */
  18317. static readonly OnKeyUpTrigger: number;
  18318. private _scene;
  18319. /**
  18320. * Creates a new action manager
  18321. * @param scene defines the hosting scene
  18322. */
  18323. constructor(scene: Scene);
  18324. /**
  18325. * Releases all associated resources
  18326. */
  18327. dispose(): void;
  18328. /**
  18329. * Gets hosting scene
  18330. * @returns the hosting scene
  18331. */
  18332. getScene(): Scene;
  18333. /**
  18334. * Does this action manager handles actions of any of the given triggers
  18335. * @param triggers defines the triggers to be tested
  18336. * @return a boolean indicating whether one (or more) of the triggers is handled
  18337. */
  18338. hasSpecificTriggers(triggers: number[]): boolean;
  18339. /**
  18340. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18341. * speed.
  18342. * @param triggerA defines the trigger to be tested
  18343. * @param triggerB defines the trigger to be tested
  18344. * @return a boolean indicating whether one (or more) of the triggers is handled
  18345. */
  18346. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18347. /**
  18348. * Does this action manager handles actions of a given trigger
  18349. * @param trigger defines the trigger to be tested
  18350. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18351. * @return whether the trigger is handled
  18352. */
  18353. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18354. /**
  18355. * Does this action manager has pointer triggers
  18356. */
  18357. get hasPointerTriggers(): boolean;
  18358. /**
  18359. * Does this action manager has pick triggers
  18360. */
  18361. get hasPickTriggers(): boolean;
  18362. /**
  18363. * Registers an action to this action manager
  18364. * @param action defines the action to be registered
  18365. * @return the action amended (prepared) after registration
  18366. */
  18367. registerAction(action: IAction): Nullable<IAction>;
  18368. /**
  18369. * Unregisters an action to this action manager
  18370. * @param action defines the action to be unregistered
  18371. * @return a boolean indicating whether the action has been unregistered
  18372. */
  18373. unregisterAction(action: IAction): Boolean;
  18374. /**
  18375. * Process a specific trigger
  18376. * @param trigger defines the trigger to process
  18377. * @param evt defines the event details to be processed
  18378. */
  18379. processTrigger(trigger: number, evt?: IActionEvent): void;
  18380. /** @hidden */
  18381. _getEffectiveTarget(target: any, propertyPath: string): any;
  18382. /** @hidden */
  18383. _getProperty(propertyPath: string): string;
  18384. /**
  18385. * Serialize this manager to a JSON object
  18386. * @param name defines the property name to store this manager
  18387. * @returns a JSON representation of this manager
  18388. */
  18389. serialize(name: string): any;
  18390. /**
  18391. * Creates a new ActionManager from a JSON data
  18392. * @param parsedActions defines the JSON data to read from
  18393. * @param object defines the hosting mesh
  18394. * @param scene defines the hosting scene
  18395. */
  18396. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18397. /**
  18398. * Get a trigger name by index
  18399. * @param trigger defines the trigger index
  18400. * @returns a trigger name
  18401. */
  18402. static GetTriggerName(trigger: number): string;
  18403. }
  18404. }
  18405. declare module "babylonjs/Sprites/sprite" {
  18406. import { Vector3 } from "babylonjs/Maths/math.vector";
  18407. import { Nullable } from "babylonjs/types";
  18408. import { ActionManager } from "babylonjs/Actions/actionManager";
  18409. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18410. import { Color4 } from "babylonjs/Maths/math.color";
  18411. /**
  18412. * Class used to represent a sprite
  18413. * @see http://doc.babylonjs.com/babylon101/sprites
  18414. */
  18415. export class Sprite {
  18416. /** defines the name */
  18417. name: string;
  18418. /** Gets or sets the current world position */
  18419. position: Vector3;
  18420. /** Gets or sets the main color */
  18421. color: Color4;
  18422. /** Gets or sets the width */
  18423. width: number;
  18424. /** Gets or sets the height */
  18425. height: number;
  18426. /** Gets or sets rotation angle */
  18427. angle: number;
  18428. /** Gets or sets the cell index in the sprite sheet */
  18429. cellIndex: number;
  18430. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18431. cellRef: string;
  18432. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18433. invertU: number;
  18434. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18435. invertV: number;
  18436. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18437. disposeWhenFinishedAnimating: boolean;
  18438. /** Gets the list of attached animations */
  18439. animations: Animation[];
  18440. /** Gets or sets a boolean indicating if the sprite can be picked */
  18441. isPickable: boolean;
  18442. /**
  18443. * Gets or sets the associated action manager
  18444. */
  18445. actionManager: Nullable<ActionManager>;
  18446. private _animationStarted;
  18447. private _loopAnimation;
  18448. private _fromIndex;
  18449. private _toIndex;
  18450. private _delay;
  18451. private _direction;
  18452. private _manager;
  18453. private _time;
  18454. private _onAnimationEnd;
  18455. /**
  18456. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18457. */
  18458. isVisible: boolean;
  18459. /**
  18460. * Gets or sets the sprite size
  18461. */
  18462. get size(): number;
  18463. set size(value: number);
  18464. /**
  18465. * Creates a new Sprite
  18466. * @param name defines the name
  18467. * @param manager defines the manager
  18468. */
  18469. constructor(
  18470. /** defines the name */
  18471. name: string, manager: ISpriteManager);
  18472. /**
  18473. * Starts an animation
  18474. * @param from defines the initial key
  18475. * @param to defines the end key
  18476. * @param loop defines if the animation must loop
  18477. * @param delay defines the start delay (in ms)
  18478. * @param onAnimationEnd defines a callback to call when animation ends
  18479. */
  18480. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18481. /** Stops current animation (if any) */
  18482. stopAnimation(): void;
  18483. /** @hidden */
  18484. _animate(deltaTime: number): void;
  18485. /** Release associated resources */
  18486. dispose(): void;
  18487. }
  18488. }
  18489. declare module "babylonjs/Collisions/pickingInfo" {
  18490. import { Nullable } from "babylonjs/types";
  18491. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18493. import { Sprite } from "babylonjs/Sprites/sprite";
  18494. import { Ray } from "babylonjs/Culling/ray";
  18495. /**
  18496. * Information about the result of picking within a scene
  18497. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18498. */
  18499. export class PickingInfo {
  18500. /** @hidden */
  18501. _pickingUnavailable: boolean;
  18502. /**
  18503. * If the pick collided with an object
  18504. */
  18505. hit: boolean;
  18506. /**
  18507. * Distance away where the pick collided
  18508. */
  18509. distance: number;
  18510. /**
  18511. * The location of pick collision
  18512. */
  18513. pickedPoint: Nullable<Vector3>;
  18514. /**
  18515. * The mesh corresponding the the pick collision
  18516. */
  18517. pickedMesh: Nullable<AbstractMesh>;
  18518. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18519. bu: number;
  18520. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18521. bv: number;
  18522. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18523. faceId: number;
  18524. /** Id of the the submesh that was picked */
  18525. subMeshId: number;
  18526. /** If a sprite was picked, this will be the sprite the pick collided with */
  18527. pickedSprite: Nullable<Sprite>;
  18528. /**
  18529. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18530. */
  18531. originMesh: Nullable<AbstractMesh>;
  18532. /**
  18533. * The ray that was used to perform the picking.
  18534. */
  18535. ray: Nullable<Ray>;
  18536. /**
  18537. * Gets the normal correspodning to the face the pick collided with
  18538. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18539. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18540. * @returns The normal correspodning to the face the pick collided with
  18541. */
  18542. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18543. /**
  18544. * Gets the texture coordinates of where the pick occured
  18545. * @returns the vector containing the coordnates of the texture
  18546. */
  18547. getTextureCoordinates(): Nullable<Vector2>;
  18548. }
  18549. }
  18550. declare module "babylonjs/Events/pointerEvents" {
  18551. import { Nullable } from "babylonjs/types";
  18552. import { Vector2 } from "babylonjs/Maths/math.vector";
  18553. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18554. import { Ray } from "babylonjs/Culling/ray";
  18555. /**
  18556. * Gather the list of pointer event types as constants.
  18557. */
  18558. export class PointerEventTypes {
  18559. /**
  18560. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18561. */
  18562. static readonly POINTERDOWN: number;
  18563. /**
  18564. * The pointerup event is fired when a pointer is no longer active.
  18565. */
  18566. static readonly POINTERUP: number;
  18567. /**
  18568. * The pointermove event is fired when a pointer changes coordinates.
  18569. */
  18570. static readonly POINTERMOVE: number;
  18571. /**
  18572. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18573. */
  18574. static readonly POINTERWHEEL: number;
  18575. /**
  18576. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18577. */
  18578. static readonly POINTERPICK: number;
  18579. /**
  18580. * The pointertap event is fired when a the object has been touched and released without drag.
  18581. */
  18582. static readonly POINTERTAP: number;
  18583. /**
  18584. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18585. */
  18586. static readonly POINTERDOUBLETAP: number;
  18587. }
  18588. /**
  18589. * Base class of pointer info types.
  18590. */
  18591. export class PointerInfoBase {
  18592. /**
  18593. * Defines the type of event (PointerEventTypes)
  18594. */
  18595. type: number;
  18596. /**
  18597. * Defines the related dom event
  18598. */
  18599. event: PointerEvent | MouseWheelEvent;
  18600. /**
  18601. * Instantiates the base class of pointers info.
  18602. * @param type Defines the type of event (PointerEventTypes)
  18603. * @param event Defines the related dom event
  18604. */
  18605. constructor(
  18606. /**
  18607. * Defines the type of event (PointerEventTypes)
  18608. */
  18609. type: number,
  18610. /**
  18611. * Defines the related dom event
  18612. */
  18613. event: PointerEvent | MouseWheelEvent);
  18614. }
  18615. /**
  18616. * This class is used to store pointer related info for the onPrePointerObservable event.
  18617. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18618. */
  18619. export class PointerInfoPre extends PointerInfoBase {
  18620. /**
  18621. * Ray from a pointer if availible (eg. 6dof controller)
  18622. */
  18623. ray: Nullable<Ray>;
  18624. /**
  18625. * Defines the local position of the pointer on the canvas.
  18626. */
  18627. localPosition: Vector2;
  18628. /**
  18629. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18630. */
  18631. skipOnPointerObservable: boolean;
  18632. /**
  18633. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18634. * @param type Defines the type of event (PointerEventTypes)
  18635. * @param event Defines the related dom event
  18636. * @param localX Defines the local x coordinates of the pointer when the event occured
  18637. * @param localY Defines the local y coordinates of the pointer when the event occured
  18638. */
  18639. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18640. }
  18641. /**
  18642. * This type contains all the data related to a pointer event in Babylon.js.
  18643. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18644. */
  18645. export class PointerInfo extends PointerInfoBase {
  18646. /**
  18647. * Defines the picking info associated to the info (if any)\
  18648. */
  18649. pickInfo: Nullable<PickingInfo>;
  18650. /**
  18651. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18652. * @param type Defines the type of event (PointerEventTypes)
  18653. * @param event Defines the related dom event
  18654. * @param pickInfo Defines the picking info associated to the info (if any)\
  18655. */
  18656. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18657. /**
  18658. * Defines the picking info associated to the info (if any)\
  18659. */
  18660. pickInfo: Nullable<PickingInfo>);
  18661. }
  18662. /**
  18663. * Data relating to a touch event on the screen.
  18664. */
  18665. export interface PointerTouch {
  18666. /**
  18667. * X coordinate of touch.
  18668. */
  18669. x: number;
  18670. /**
  18671. * Y coordinate of touch.
  18672. */
  18673. y: number;
  18674. /**
  18675. * Id of touch. Unique for each finger.
  18676. */
  18677. pointerId: number;
  18678. /**
  18679. * Event type passed from DOM.
  18680. */
  18681. type: any;
  18682. }
  18683. }
  18684. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18685. import { Observable } from "babylonjs/Misc/observable";
  18686. import { Nullable } from "babylonjs/types";
  18687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18688. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18689. /**
  18690. * Manage the mouse inputs to control the movement of a free camera.
  18691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18692. */
  18693. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18694. /**
  18695. * Define if touch is enabled in the mouse input
  18696. */
  18697. touchEnabled: boolean;
  18698. /**
  18699. * Defines the camera the input is attached to.
  18700. */
  18701. camera: FreeCamera;
  18702. /**
  18703. * Defines the buttons associated with the input to handle camera move.
  18704. */
  18705. buttons: number[];
  18706. /**
  18707. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18708. */
  18709. angularSensibility: number;
  18710. private _pointerInput;
  18711. private _onMouseMove;
  18712. private _observer;
  18713. private previousPosition;
  18714. /**
  18715. * Observable for when a pointer move event occurs containing the move offset
  18716. */
  18717. onPointerMovedObservable: Observable<{
  18718. offsetX: number;
  18719. offsetY: number;
  18720. }>;
  18721. /**
  18722. * @hidden
  18723. * If the camera should be rotated automatically based on pointer movement
  18724. */
  18725. _allowCameraRotation: boolean;
  18726. /**
  18727. * Manage the mouse inputs to control the movement of a free camera.
  18728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18729. * @param touchEnabled Defines if touch is enabled or not
  18730. */
  18731. constructor(
  18732. /**
  18733. * Define if touch is enabled in the mouse input
  18734. */
  18735. touchEnabled?: boolean);
  18736. /**
  18737. * Attach the input controls to a specific dom element to get the input from.
  18738. * @param element Defines the element the controls should be listened from
  18739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18740. */
  18741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18742. /**
  18743. * Called on JS contextmenu event.
  18744. * Override this method to provide functionality.
  18745. */
  18746. protected onContextMenu(evt: PointerEvent): void;
  18747. /**
  18748. * Detach the current controls from the specified dom element.
  18749. * @param element Defines the element to stop listening the inputs from
  18750. */
  18751. detachControl(element: Nullable<HTMLElement>): void;
  18752. /**
  18753. * Gets the class name of the current intput.
  18754. * @returns the class name
  18755. */
  18756. getClassName(): string;
  18757. /**
  18758. * Get the friendly name associated with the input class.
  18759. * @returns the input friendly name
  18760. */
  18761. getSimpleName(): string;
  18762. }
  18763. }
  18764. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18765. import { Nullable } from "babylonjs/types";
  18766. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18767. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18768. /**
  18769. * Manage the touch inputs to control the movement of a free camera.
  18770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18771. */
  18772. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18773. /**
  18774. * Defines the camera the input is attached to.
  18775. */
  18776. camera: FreeCamera;
  18777. /**
  18778. * Defines the touch sensibility for rotation.
  18779. * The higher the faster.
  18780. */
  18781. touchAngularSensibility: number;
  18782. /**
  18783. * Defines the touch sensibility for move.
  18784. * The higher the faster.
  18785. */
  18786. touchMoveSensibility: number;
  18787. private _offsetX;
  18788. private _offsetY;
  18789. private _pointerPressed;
  18790. private _pointerInput;
  18791. private _observer;
  18792. private _onLostFocus;
  18793. /**
  18794. * Attach the input controls to a specific dom element to get the input from.
  18795. * @param element Defines the element the controls should be listened from
  18796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18797. */
  18798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18799. /**
  18800. * Detach the current controls from the specified dom element.
  18801. * @param element Defines the element to stop listening the inputs from
  18802. */
  18803. detachControl(element: Nullable<HTMLElement>): void;
  18804. /**
  18805. * Update the current camera state depending on the inputs that have been used this frame.
  18806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18807. */
  18808. checkInputs(): void;
  18809. /**
  18810. * Gets the class name of the current intput.
  18811. * @returns the class name
  18812. */
  18813. getClassName(): string;
  18814. /**
  18815. * Get the friendly name associated with the input class.
  18816. * @returns the input friendly name
  18817. */
  18818. getSimpleName(): string;
  18819. }
  18820. }
  18821. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18822. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18823. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18824. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18825. import { Nullable } from "babylonjs/types";
  18826. /**
  18827. * Default Inputs manager for the FreeCamera.
  18828. * It groups all the default supported inputs for ease of use.
  18829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18830. */
  18831. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18832. /**
  18833. * @hidden
  18834. */
  18835. _mouseInput: Nullable<FreeCameraMouseInput>;
  18836. /**
  18837. * Instantiates a new FreeCameraInputsManager.
  18838. * @param camera Defines the camera the inputs belong to
  18839. */
  18840. constructor(camera: FreeCamera);
  18841. /**
  18842. * Add keyboard input support to the input manager.
  18843. * @returns the current input manager
  18844. */
  18845. addKeyboard(): FreeCameraInputsManager;
  18846. /**
  18847. * Add mouse input support to the input manager.
  18848. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18849. * @returns the current input manager
  18850. */
  18851. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18852. /**
  18853. * Removes the mouse input support from the manager
  18854. * @returns the current input manager
  18855. */
  18856. removeMouse(): FreeCameraInputsManager;
  18857. /**
  18858. * Add touch input support to the input manager.
  18859. * @returns the current input manager
  18860. */
  18861. addTouch(): FreeCameraInputsManager;
  18862. /**
  18863. * Remove all attached input methods from a camera
  18864. */
  18865. clear(): void;
  18866. }
  18867. }
  18868. declare module "babylonjs/Cameras/freeCamera" {
  18869. import { Vector3 } from "babylonjs/Maths/math.vector";
  18870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18871. import { Scene } from "babylonjs/scene";
  18872. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18873. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18874. /**
  18875. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18876. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18878. */
  18879. export class FreeCamera extends TargetCamera {
  18880. /**
  18881. * Define the collision ellipsoid of the camera.
  18882. * This is helpful to simulate a camera body like the player body around the camera
  18883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18884. */
  18885. ellipsoid: Vector3;
  18886. /**
  18887. * Define an offset for the position of the ellipsoid around the camera.
  18888. * This can be helpful to determine the center of the body near the gravity center of the body
  18889. * instead of its head.
  18890. */
  18891. ellipsoidOffset: Vector3;
  18892. /**
  18893. * Enable or disable collisions of the camera with the rest of the scene objects.
  18894. */
  18895. checkCollisions: boolean;
  18896. /**
  18897. * Enable or disable gravity on the camera.
  18898. */
  18899. applyGravity: boolean;
  18900. /**
  18901. * Define the input manager associated to the camera.
  18902. */
  18903. inputs: FreeCameraInputsManager;
  18904. /**
  18905. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18906. * Higher values reduce sensitivity.
  18907. */
  18908. get angularSensibility(): number;
  18909. /**
  18910. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18911. * Higher values reduce sensitivity.
  18912. */
  18913. set angularSensibility(value: number);
  18914. /**
  18915. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18916. */
  18917. get keysUp(): number[];
  18918. set keysUp(value: number[]);
  18919. /**
  18920. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18921. */
  18922. get keysUpward(): number[];
  18923. set keysUpward(value: number[]);
  18924. /**
  18925. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18926. */
  18927. get keysDown(): number[];
  18928. set keysDown(value: number[]);
  18929. /**
  18930. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18931. */
  18932. get keysDownward(): number[];
  18933. set keysDownward(value: number[]);
  18934. /**
  18935. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18936. */
  18937. get keysLeft(): number[];
  18938. set keysLeft(value: number[]);
  18939. /**
  18940. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18941. */
  18942. get keysRight(): number[];
  18943. set keysRight(value: number[]);
  18944. /**
  18945. * Event raised when the camera collide with a mesh in the scene.
  18946. */
  18947. onCollide: (collidedMesh: AbstractMesh) => void;
  18948. private _collider;
  18949. private _needMoveForGravity;
  18950. private _oldPosition;
  18951. private _diffPosition;
  18952. private _newPosition;
  18953. /** @hidden */
  18954. _localDirection: Vector3;
  18955. /** @hidden */
  18956. _transformedDirection: Vector3;
  18957. /**
  18958. * Instantiates a Free Camera.
  18959. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18960. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18962. * @param name Define the name of the camera in the scene
  18963. * @param position Define the start position of the camera in the scene
  18964. * @param scene Define the scene the camera belongs to
  18965. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18966. */
  18967. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18968. /**
  18969. * Attached controls to the current camera.
  18970. * @param element Defines the element the controls should be listened from
  18971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18972. */
  18973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18974. /**
  18975. * Detach the current controls from the camera.
  18976. * The camera will stop reacting to inputs.
  18977. * @param element Defines the element to stop listening the inputs from
  18978. */
  18979. detachControl(element: HTMLElement): void;
  18980. private _collisionMask;
  18981. /**
  18982. * Define a collision mask to limit the list of object the camera can collide with
  18983. */
  18984. get collisionMask(): number;
  18985. set collisionMask(mask: number);
  18986. /** @hidden */
  18987. _collideWithWorld(displacement: Vector3): void;
  18988. private _onCollisionPositionChange;
  18989. /** @hidden */
  18990. _checkInputs(): void;
  18991. /** @hidden */
  18992. _decideIfNeedsToMove(): boolean;
  18993. /** @hidden */
  18994. _updatePosition(): void;
  18995. /**
  18996. * Destroy the camera and release the current resources hold by it.
  18997. */
  18998. dispose(): void;
  18999. /**
  19000. * Gets the current object class name.
  19001. * @return the class name
  19002. */
  19003. getClassName(): string;
  19004. }
  19005. }
  19006. declare module "babylonjs/Gamepads/gamepad" {
  19007. import { Observable } from "babylonjs/Misc/observable";
  19008. /**
  19009. * Represents a gamepad control stick position
  19010. */
  19011. export class StickValues {
  19012. /**
  19013. * The x component of the control stick
  19014. */
  19015. x: number;
  19016. /**
  19017. * The y component of the control stick
  19018. */
  19019. y: number;
  19020. /**
  19021. * Initializes the gamepad x and y control stick values
  19022. * @param x The x component of the gamepad control stick value
  19023. * @param y The y component of the gamepad control stick value
  19024. */
  19025. constructor(
  19026. /**
  19027. * The x component of the control stick
  19028. */
  19029. x: number,
  19030. /**
  19031. * The y component of the control stick
  19032. */
  19033. y: number);
  19034. }
  19035. /**
  19036. * An interface which manages callbacks for gamepad button changes
  19037. */
  19038. export interface GamepadButtonChanges {
  19039. /**
  19040. * Called when a gamepad has been changed
  19041. */
  19042. changed: boolean;
  19043. /**
  19044. * Called when a gamepad press event has been triggered
  19045. */
  19046. pressChanged: boolean;
  19047. /**
  19048. * Called when a touch event has been triggered
  19049. */
  19050. touchChanged: boolean;
  19051. /**
  19052. * Called when a value has changed
  19053. */
  19054. valueChanged: boolean;
  19055. }
  19056. /**
  19057. * Represents a gamepad
  19058. */
  19059. export class Gamepad {
  19060. /**
  19061. * The id of the gamepad
  19062. */
  19063. id: string;
  19064. /**
  19065. * The index of the gamepad
  19066. */
  19067. index: number;
  19068. /**
  19069. * The browser gamepad
  19070. */
  19071. browserGamepad: any;
  19072. /**
  19073. * Specifies what type of gamepad this represents
  19074. */
  19075. type: number;
  19076. private _leftStick;
  19077. private _rightStick;
  19078. /** @hidden */
  19079. _isConnected: boolean;
  19080. private _leftStickAxisX;
  19081. private _leftStickAxisY;
  19082. private _rightStickAxisX;
  19083. private _rightStickAxisY;
  19084. /**
  19085. * Triggered when the left control stick has been changed
  19086. */
  19087. private _onleftstickchanged;
  19088. /**
  19089. * Triggered when the right control stick has been changed
  19090. */
  19091. private _onrightstickchanged;
  19092. /**
  19093. * Represents a gamepad controller
  19094. */
  19095. static GAMEPAD: number;
  19096. /**
  19097. * Represents a generic controller
  19098. */
  19099. static GENERIC: number;
  19100. /**
  19101. * Represents an XBox controller
  19102. */
  19103. static XBOX: number;
  19104. /**
  19105. * Represents a pose-enabled controller
  19106. */
  19107. static POSE_ENABLED: number;
  19108. /**
  19109. * Represents an Dual Shock controller
  19110. */
  19111. static DUALSHOCK: number;
  19112. /**
  19113. * Specifies whether the left control stick should be Y-inverted
  19114. */
  19115. protected _invertLeftStickY: boolean;
  19116. /**
  19117. * Specifies if the gamepad has been connected
  19118. */
  19119. get isConnected(): boolean;
  19120. /**
  19121. * Initializes the gamepad
  19122. * @param id The id of the gamepad
  19123. * @param index The index of the gamepad
  19124. * @param browserGamepad The browser gamepad
  19125. * @param leftStickX The x component of the left joystick
  19126. * @param leftStickY The y component of the left joystick
  19127. * @param rightStickX The x component of the right joystick
  19128. * @param rightStickY The y component of the right joystick
  19129. */
  19130. constructor(
  19131. /**
  19132. * The id of the gamepad
  19133. */
  19134. id: string,
  19135. /**
  19136. * The index of the gamepad
  19137. */
  19138. index: number,
  19139. /**
  19140. * The browser gamepad
  19141. */
  19142. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19143. /**
  19144. * Callback triggered when the left joystick has changed
  19145. * @param callback
  19146. */
  19147. onleftstickchanged(callback: (values: StickValues) => void): void;
  19148. /**
  19149. * Callback triggered when the right joystick has changed
  19150. * @param callback
  19151. */
  19152. onrightstickchanged(callback: (values: StickValues) => void): void;
  19153. /**
  19154. * Gets the left joystick
  19155. */
  19156. get leftStick(): StickValues;
  19157. /**
  19158. * Sets the left joystick values
  19159. */
  19160. set leftStick(newValues: StickValues);
  19161. /**
  19162. * Gets the right joystick
  19163. */
  19164. get rightStick(): StickValues;
  19165. /**
  19166. * Sets the right joystick value
  19167. */
  19168. set rightStick(newValues: StickValues);
  19169. /**
  19170. * Updates the gamepad joystick positions
  19171. */
  19172. update(): void;
  19173. /**
  19174. * Disposes the gamepad
  19175. */
  19176. dispose(): void;
  19177. }
  19178. /**
  19179. * Represents a generic gamepad
  19180. */
  19181. export class GenericPad extends Gamepad {
  19182. private _buttons;
  19183. private _onbuttondown;
  19184. private _onbuttonup;
  19185. /**
  19186. * Observable triggered when a button has been pressed
  19187. */
  19188. onButtonDownObservable: Observable<number>;
  19189. /**
  19190. * Observable triggered when a button has been released
  19191. */
  19192. onButtonUpObservable: Observable<number>;
  19193. /**
  19194. * Callback triggered when a button has been pressed
  19195. * @param callback Called when a button has been pressed
  19196. */
  19197. onbuttondown(callback: (buttonPressed: number) => void): void;
  19198. /**
  19199. * Callback triggered when a button has been released
  19200. * @param callback Called when a button has been released
  19201. */
  19202. onbuttonup(callback: (buttonReleased: number) => void): void;
  19203. /**
  19204. * Initializes the generic gamepad
  19205. * @param id The id of the generic gamepad
  19206. * @param index The index of the generic gamepad
  19207. * @param browserGamepad The browser gamepad
  19208. */
  19209. constructor(id: string, index: number, browserGamepad: any);
  19210. private _setButtonValue;
  19211. /**
  19212. * Updates the generic gamepad
  19213. */
  19214. update(): void;
  19215. /**
  19216. * Disposes the generic gamepad
  19217. */
  19218. dispose(): void;
  19219. }
  19220. }
  19221. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19222. import { Observable } from "babylonjs/Misc/observable";
  19223. import { Nullable } from "babylonjs/types";
  19224. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19227. import { Ray } from "babylonjs/Culling/ray";
  19228. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19229. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19230. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19231. /**
  19232. * Defines the types of pose enabled controllers that are supported
  19233. */
  19234. export enum PoseEnabledControllerType {
  19235. /**
  19236. * HTC Vive
  19237. */
  19238. VIVE = 0,
  19239. /**
  19240. * Oculus Rift
  19241. */
  19242. OCULUS = 1,
  19243. /**
  19244. * Windows mixed reality
  19245. */
  19246. WINDOWS = 2,
  19247. /**
  19248. * Samsung gear VR
  19249. */
  19250. GEAR_VR = 3,
  19251. /**
  19252. * Google Daydream
  19253. */
  19254. DAYDREAM = 4,
  19255. /**
  19256. * Generic
  19257. */
  19258. GENERIC = 5
  19259. }
  19260. /**
  19261. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19262. */
  19263. export interface MutableGamepadButton {
  19264. /**
  19265. * Value of the button/trigger
  19266. */
  19267. value: number;
  19268. /**
  19269. * If the button/trigger is currently touched
  19270. */
  19271. touched: boolean;
  19272. /**
  19273. * If the button/trigger is currently pressed
  19274. */
  19275. pressed: boolean;
  19276. }
  19277. /**
  19278. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19279. * @hidden
  19280. */
  19281. export interface ExtendedGamepadButton extends GamepadButton {
  19282. /**
  19283. * If the button/trigger is currently pressed
  19284. */
  19285. readonly pressed: boolean;
  19286. /**
  19287. * If the button/trigger is currently touched
  19288. */
  19289. readonly touched: boolean;
  19290. /**
  19291. * Value of the button/trigger
  19292. */
  19293. readonly value: number;
  19294. }
  19295. /** @hidden */
  19296. export interface _GamePadFactory {
  19297. /**
  19298. * Returns whether or not the current gamepad can be created for this type of controller.
  19299. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19300. * @returns true if it can be created, otherwise false
  19301. */
  19302. canCreate(gamepadInfo: any): boolean;
  19303. /**
  19304. * Creates a new instance of the Gamepad.
  19305. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19306. * @returns the new gamepad instance
  19307. */
  19308. create(gamepadInfo: any): Gamepad;
  19309. }
  19310. /**
  19311. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19312. */
  19313. export class PoseEnabledControllerHelper {
  19314. /** @hidden */
  19315. static _ControllerFactories: _GamePadFactory[];
  19316. /** @hidden */
  19317. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19318. /**
  19319. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19320. * @param vrGamepad the gamepad to initialized
  19321. * @returns a vr controller of the type the gamepad identified as
  19322. */
  19323. static InitiateController(vrGamepad: any): Gamepad;
  19324. }
  19325. /**
  19326. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19327. */
  19328. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19329. /**
  19330. * If the controller is used in a webXR session
  19331. */
  19332. isXR: boolean;
  19333. private _deviceRoomPosition;
  19334. private _deviceRoomRotationQuaternion;
  19335. /**
  19336. * The device position in babylon space
  19337. */
  19338. devicePosition: Vector3;
  19339. /**
  19340. * The device rotation in babylon space
  19341. */
  19342. deviceRotationQuaternion: Quaternion;
  19343. /**
  19344. * The scale factor of the device in babylon space
  19345. */
  19346. deviceScaleFactor: number;
  19347. /**
  19348. * (Likely devicePosition should be used instead) The device position in its room space
  19349. */
  19350. position: Vector3;
  19351. /**
  19352. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19353. */
  19354. rotationQuaternion: Quaternion;
  19355. /**
  19356. * The type of controller (Eg. Windows mixed reality)
  19357. */
  19358. controllerType: PoseEnabledControllerType;
  19359. protected _calculatedPosition: Vector3;
  19360. private _calculatedRotation;
  19361. /**
  19362. * The raw pose from the device
  19363. */
  19364. rawPose: DevicePose;
  19365. private _trackPosition;
  19366. private _maxRotationDistFromHeadset;
  19367. private _draggedRoomRotation;
  19368. /**
  19369. * @hidden
  19370. */
  19371. _disableTrackPosition(fixedPosition: Vector3): void;
  19372. /**
  19373. * Internal, the mesh attached to the controller
  19374. * @hidden
  19375. */
  19376. _mesh: Nullable<AbstractMesh>;
  19377. private _poseControlledCamera;
  19378. private _leftHandSystemQuaternion;
  19379. /**
  19380. * Internal, matrix used to convert room space to babylon space
  19381. * @hidden
  19382. */
  19383. _deviceToWorld: Matrix;
  19384. /**
  19385. * Node to be used when casting a ray from the controller
  19386. * @hidden
  19387. */
  19388. _pointingPoseNode: Nullable<TransformNode>;
  19389. /**
  19390. * Name of the child mesh that can be used to cast a ray from the controller
  19391. */
  19392. static readonly POINTING_POSE: string;
  19393. /**
  19394. * Creates a new PoseEnabledController from a gamepad
  19395. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19396. */
  19397. constructor(browserGamepad: any);
  19398. private _workingMatrix;
  19399. /**
  19400. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19401. */
  19402. update(): void;
  19403. /**
  19404. * Updates only the pose device and mesh without doing any button event checking
  19405. */
  19406. protected _updatePoseAndMesh(): void;
  19407. /**
  19408. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19409. * @param poseData raw pose fromthe device
  19410. */
  19411. updateFromDevice(poseData: DevicePose): void;
  19412. /**
  19413. * @hidden
  19414. */
  19415. _meshAttachedObservable: Observable<AbstractMesh>;
  19416. /**
  19417. * Attaches a mesh to the controller
  19418. * @param mesh the mesh to be attached
  19419. */
  19420. attachToMesh(mesh: AbstractMesh): void;
  19421. /**
  19422. * Attaches the controllers mesh to a camera
  19423. * @param camera the camera the mesh should be attached to
  19424. */
  19425. attachToPoseControlledCamera(camera: TargetCamera): void;
  19426. /**
  19427. * Disposes of the controller
  19428. */
  19429. dispose(): void;
  19430. /**
  19431. * The mesh that is attached to the controller
  19432. */
  19433. get mesh(): Nullable<AbstractMesh>;
  19434. /**
  19435. * Gets the ray of the controller in the direction the controller is pointing
  19436. * @param length the length the resulting ray should be
  19437. * @returns a ray in the direction the controller is pointing
  19438. */
  19439. getForwardRay(length?: number): Ray;
  19440. }
  19441. }
  19442. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19443. import { Observable } from "babylonjs/Misc/observable";
  19444. import { Scene } from "babylonjs/scene";
  19445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19446. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19447. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19448. import { Nullable } from "babylonjs/types";
  19449. /**
  19450. * Defines the WebVRController object that represents controllers tracked in 3D space
  19451. */
  19452. export abstract class WebVRController extends PoseEnabledController {
  19453. /**
  19454. * Internal, the default controller model for the controller
  19455. */
  19456. protected _defaultModel: Nullable<AbstractMesh>;
  19457. /**
  19458. * Fired when the trigger state has changed
  19459. */
  19460. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19461. /**
  19462. * Fired when the main button state has changed
  19463. */
  19464. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19465. /**
  19466. * Fired when the secondary button state has changed
  19467. */
  19468. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19469. /**
  19470. * Fired when the pad state has changed
  19471. */
  19472. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19473. /**
  19474. * Fired when controllers stick values have changed
  19475. */
  19476. onPadValuesChangedObservable: Observable<StickValues>;
  19477. /**
  19478. * Array of button availible on the controller
  19479. */
  19480. protected _buttons: Array<MutableGamepadButton>;
  19481. private _onButtonStateChange;
  19482. /**
  19483. * Fired when a controller button's state has changed
  19484. * @param callback the callback containing the button that was modified
  19485. */
  19486. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19487. /**
  19488. * X and Y axis corresponding to the controllers joystick
  19489. */
  19490. pad: StickValues;
  19491. /**
  19492. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19493. */
  19494. hand: string;
  19495. /**
  19496. * The default controller model for the controller
  19497. */
  19498. get defaultModel(): Nullable<AbstractMesh>;
  19499. /**
  19500. * Creates a new WebVRController from a gamepad
  19501. * @param vrGamepad the gamepad that the WebVRController should be created from
  19502. */
  19503. constructor(vrGamepad: any);
  19504. /**
  19505. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19506. */
  19507. update(): void;
  19508. /**
  19509. * Function to be called when a button is modified
  19510. */
  19511. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19512. /**
  19513. * Loads a mesh and attaches it to the controller
  19514. * @param scene the scene the mesh should be added to
  19515. * @param meshLoaded callback for when the mesh has been loaded
  19516. */
  19517. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19518. private _setButtonValue;
  19519. private _changes;
  19520. private _checkChanges;
  19521. /**
  19522. * Disposes of th webVRCOntroller
  19523. */
  19524. dispose(): void;
  19525. }
  19526. }
  19527. declare module "babylonjs/Lights/hemisphericLight" {
  19528. import { Nullable } from "babylonjs/types";
  19529. import { Scene } from "babylonjs/scene";
  19530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19531. import { Color3 } from "babylonjs/Maths/math.color";
  19532. import { Effect } from "babylonjs/Materials/effect";
  19533. import { Light } from "babylonjs/Lights/light";
  19534. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19535. /**
  19536. * The HemisphericLight simulates the ambient environment light,
  19537. * so the passed direction is the light reflection direction, not the incoming direction.
  19538. */
  19539. export class HemisphericLight extends Light {
  19540. /**
  19541. * The groundColor is the light in the opposite direction to the one specified during creation.
  19542. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19543. */
  19544. groundColor: Color3;
  19545. /**
  19546. * The light reflection direction, not the incoming direction.
  19547. */
  19548. direction: Vector3;
  19549. /**
  19550. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19551. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19552. * The HemisphericLight can't cast shadows.
  19553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19554. * @param name The friendly name of the light
  19555. * @param direction The direction of the light reflection
  19556. * @param scene The scene the light belongs to
  19557. */
  19558. constructor(name: string, direction: Vector3, scene: Scene);
  19559. protected _buildUniformLayout(): void;
  19560. /**
  19561. * Returns the string "HemisphericLight".
  19562. * @return The class name
  19563. */
  19564. getClassName(): string;
  19565. /**
  19566. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19567. * Returns the updated direction.
  19568. * @param target The target the direction should point to
  19569. * @return The computed direction
  19570. */
  19571. setDirectionToTarget(target: Vector3): Vector3;
  19572. /**
  19573. * Returns the shadow generator associated to the light.
  19574. * @returns Always null for hemispheric lights because it does not support shadows.
  19575. */
  19576. getShadowGenerator(): Nullable<IShadowGenerator>;
  19577. /**
  19578. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19579. * @param effect The effect to update
  19580. * @param lightIndex The index of the light in the effect to update
  19581. * @returns The hemispheric light
  19582. */
  19583. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19584. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19585. /**
  19586. * Computes the world matrix of the node
  19587. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19588. * @param useWasUpdatedFlag defines a reserved property
  19589. * @returns the world matrix
  19590. */
  19591. computeWorldMatrix(): Matrix;
  19592. /**
  19593. * Returns the integer 3.
  19594. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19595. */
  19596. getTypeID(): number;
  19597. /**
  19598. * Prepares the list of defines specific to the light type.
  19599. * @param defines the list of defines
  19600. * @param lightIndex defines the index of the light for the effect
  19601. */
  19602. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19603. }
  19604. }
  19605. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19606. /** @hidden */
  19607. export var vrMultiviewToSingleviewPixelShader: {
  19608. name: string;
  19609. shader: string;
  19610. };
  19611. }
  19612. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19614. import { Scene } from "babylonjs/scene";
  19615. /**
  19616. * Renders to multiple views with a single draw call
  19617. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19618. */
  19619. export class MultiviewRenderTarget extends RenderTargetTexture {
  19620. /**
  19621. * Creates a multiview render target
  19622. * @param scene scene used with the render target
  19623. * @param size the size of the render target (used for each view)
  19624. */
  19625. constructor(scene: Scene, size?: number | {
  19626. width: number;
  19627. height: number;
  19628. } | {
  19629. ratio: number;
  19630. });
  19631. /**
  19632. * @hidden
  19633. * @param faceIndex the face index, if its a cube texture
  19634. */
  19635. _bindFrameBuffer(faceIndex?: number): void;
  19636. /**
  19637. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19638. * @returns the view count
  19639. */
  19640. getViewCount(): number;
  19641. }
  19642. }
  19643. declare module "babylonjs/Maths/math.frustum" {
  19644. import { Matrix } from "babylonjs/Maths/math.vector";
  19645. import { DeepImmutable } from "babylonjs/types";
  19646. import { Plane } from "babylonjs/Maths/math.plane";
  19647. /**
  19648. * Represents a camera frustum
  19649. */
  19650. export class Frustum {
  19651. /**
  19652. * Gets the planes representing the frustum
  19653. * @param transform matrix to be applied to the returned planes
  19654. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19655. */
  19656. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19657. /**
  19658. * Gets the near frustum plane transformed by the transform matrix
  19659. * @param transform transformation matrix to be applied to the resulting frustum plane
  19660. * @param frustumPlane the resuling frustum plane
  19661. */
  19662. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19663. /**
  19664. * Gets the far frustum plane transformed by the transform matrix
  19665. * @param transform transformation matrix to be applied to the resulting frustum plane
  19666. * @param frustumPlane the resuling frustum plane
  19667. */
  19668. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19669. /**
  19670. * Gets the left frustum plane transformed by the transform matrix
  19671. * @param transform transformation matrix to be applied to the resulting frustum plane
  19672. * @param frustumPlane the resuling frustum plane
  19673. */
  19674. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19675. /**
  19676. * Gets the right frustum plane transformed by the transform matrix
  19677. * @param transform transformation matrix to be applied to the resulting frustum plane
  19678. * @param frustumPlane the resuling frustum plane
  19679. */
  19680. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19681. /**
  19682. * Gets the top frustum plane transformed by the transform matrix
  19683. * @param transform transformation matrix to be applied to the resulting frustum plane
  19684. * @param frustumPlane the resuling frustum plane
  19685. */
  19686. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19687. /**
  19688. * Gets the bottom frustum plane transformed by the transform matrix
  19689. * @param transform transformation matrix to be applied to the resulting frustum plane
  19690. * @param frustumPlane the resuling frustum plane
  19691. */
  19692. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19693. /**
  19694. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19695. * @param transform transformation matrix to be applied to the resulting frustum planes
  19696. * @param frustumPlanes the resuling frustum planes
  19697. */
  19698. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19699. }
  19700. }
  19701. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19702. import { Camera } from "babylonjs/Cameras/camera";
  19703. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19704. import { Nullable } from "babylonjs/types";
  19705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19706. import { Matrix } from "babylonjs/Maths/math.vector";
  19707. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19708. module "babylonjs/Engines/engine" {
  19709. interface Engine {
  19710. /**
  19711. * Creates a new multiview render target
  19712. * @param width defines the width of the texture
  19713. * @param height defines the height of the texture
  19714. * @returns the created multiview texture
  19715. */
  19716. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19717. /**
  19718. * Binds a multiview framebuffer to be drawn to
  19719. * @param multiviewTexture texture to bind
  19720. */
  19721. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19722. }
  19723. }
  19724. module "babylonjs/Cameras/camera" {
  19725. interface Camera {
  19726. /**
  19727. * @hidden
  19728. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19729. */
  19730. _useMultiviewToSingleView: boolean;
  19731. /**
  19732. * @hidden
  19733. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19734. */
  19735. _multiviewTexture: Nullable<RenderTargetTexture>;
  19736. /**
  19737. * @hidden
  19738. * ensures the multiview texture of the camera exists and has the specified width/height
  19739. * @param width height to set on the multiview texture
  19740. * @param height width to set on the multiview texture
  19741. */
  19742. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19743. }
  19744. }
  19745. module "babylonjs/scene" {
  19746. interface Scene {
  19747. /** @hidden */
  19748. _transformMatrixR: Matrix;
  19749. /** @hidden */
  19750. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19751. /** @hidden */
  19752. _createMultiviewUbo(): void;
  19753. /** @hidden */
  19754. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19755. /** @hidden */
  19756. _renderMultiviewToSingleView(camera: Camera): void;
  19757. }
  19758. }
  19759. }
  19760. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19761. import { Camera } from "babylonjs/Cameras/camera";
  19762. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19763. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19764. import "babylonjs/Engines/Extensions/engine.multiview";
  19765. /**
  19766. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19767. * This will not be used for webXR as it supports displaying texture arrays directly
  19768. */
  19769. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19770. /**
  19771. * Initializes a VRMultiviewToSingleview
  19772. * @param name name of the post process
  19773. * @param camera camera to be applied to
  19774. * @param scaleFactor scaling factor to the size of the output texture
  19775. */
  19776. constructor(name: string, camera: Camera, scaleFactor: number);
  19777. }
  19778. }
  19779. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19780. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19781. import { Nullable } from "babylonjs/types";
  19782. import { Size } from "babylonjs/Maths/math.size";
  19783. import { Observable } from "babylonjs/Misc/observable";
  19784. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19785. /**
  19786. * Interface used to define additional presentation attributes
  19787. */
  19788. export interface IVRPresentationAttributes {
  19789. /**
  19790. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19791. */
  19792. highRefreshRate: boolean;
  19793. /**
  19794. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19795. */
  19796. foveationLevel: number;
  19797. }
  19798. module "babylonjs/Engines/engine" {
  19799. interface Engine {
  19800. /** @hidden */
  19801. _vrDisplay: any;
  19802. /** @hidden */
  19803. _vrSupported: boolean;
  19804. /** @hidden */
  19805. _oldSize: Size;
  19806. /** @hidden */
  19807. _oldHardwareScaleFactor: number;
  19808. /** @hidden */
  19809. _vrExclusivePointerMode: boolean;
  19810. /** @hidden */
  19811. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19812. /** @hidden */
  19813. _onVRDisplayPointerRestricted: () => void;
  19814. /** @hidden */
  19815. _onVRDisplayPointerUnrestricted: () => void;
  19816. /** @hidden */
  19817. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19818. /** @hidden */
  19819. _onVrDisplayDisconnect: Nullable<() => void>;
  19820. /** @hidden */
  19821. _onVrDisplayPresentChange: Nullable<() => void>;
  19822. /**
  19823. * Observable signaled when VR display mode changes
  19824. */
  19825. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19826. /**
  19827. * Observable signaled when VR request present is complete
  19828. */
  19829. onVRRequestPresentComplete: Observable<boolean>;
  19830. /**
  19831. * Observable signaled when VR request present starts
  19832. */
  19833. onVRRequestPresentStart: Observable<Engine>;
  19834. /**
  19835. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19836. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19837. */
  19838. isInVRExclusivePointerMode: boolean;
  19839. /**
  19840. * Gets a boolean indicating if a webVR device was detected
  19841. * @returns true if a webVR device was detected
  19842. */
  19843. isVRDevicePresent(): boolean;
  19844. /**
  19845. * Gets the current webVR device
  19846. * @returns the current webVR device (or null)
  19847. */
  19848. getVRDevice(): any;
  19849. /**
  19850. * Initializes a webVR display and starts listening to display change events
  19851. * The onVRDisplayChangedObservable will be notified upon these changes
  19852. * @returns A promise containing a VRDisplay and if vr is supported
  19853. */
  19854. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19855. /** @hidden */
  19856. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19857. /**
  19858. * Gets or sets the presentation attributes used to configure VR rendering
  19859. */
  19860. vrPresentationAttributes?: IVRPresentationAttributes;
  19861. /**
  19862. * Call this function to switch to webVR mode
  19863. * Will do nothing if webVR is not supported or if there is no webVR device
  19864. * @param options the webvr options provided to the camera. mainly used for multiview
  19865. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19866. */
  19867. enableVR(options: WebVROptions): void;
  19868. /** @hidden */
  19869. _onVRFullScreenTriggered(): void;
  19870. }
  19871. }
  19872. }
  19873. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Observable } from "babylonjs/Misc/observable";
  19876. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19877. import { Scene } from "babylonjs/scene";
  19878. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19879. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19880. import { Node } from "babylonjs/node";
  19881. import { Ray } from "babylonjs/Culling/ray";
  19882. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19883. import "babylonjs/Engines/Extensions/engine.webVR";
  19884. /**
  19885. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19886. * IMPORTANT!! The data is right-hand data.
  19887. * @export
  19888. * @interface DevicePose
  19889. */
  19890. export interface DevicePose {
  19891. /**
  19892. * The position of the device, values in array are [x,y,z].
  19893. */
  19894. readonly position: Nullable<Float32Array>;
  19895. /**
  19896. * The linearVelocity of the device, values in array are [x,y,z].
  19897. */
  19898. readonly linearVelocity: Nullable<Float32Array>;
  19899. /**
  19900. * The linearAcceleration of the device, values in array are [x,y,z].
  19901. */
  19902. readonly linearAcceleration: Nullable<Float32Array>;
  19903. /**
  19904. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19905. */
  19906. readonly orientation: Nullable<Float32Array>;
  19907. /**
  19908. * The angularVelocity of the device, values in array are [x,y,z].
  19909. */
  19910. readonly angularVelocity: Nullable<Float32Array>;
  19911. /**
  19912. * The angularAcceleration of the device, values in array are [x,y,z].
  19913. */
  19914. readonly angularAcceleration: Nullable<Float32Array>;
  19915. }
  19916. /**
  19917. * Interface representing a pose controlled object in Babylon.
  19918. * A pose controlled object has both regular pose values as well as pose values
  19919. * from an external device such as a VR head mounted display
  19920. */
  19921. export interface PoseControlled {
  19922. /**
  19923. * The position of the object in babylon space.
  19924. */
  19925. position: Vector3;
  19926. /**
  19927. * The rotation quaternion of the object in babylon space.
  19928. */
  19929. rotationQuaternion: Quaternion;
  19930. /**
  19931. * The position of the device in babylon space.
  19932. */
  19933. devicePosition?: Vector3;
  19934. /**
  19935. * The rotation quaternion of the device in babylon space.
  19936. */
  19937. deviceRotationQuaternion: Quaternion;
  19938. /**
  19939. * The raw pose coming from the device.
  19940. */
  19941. rawPose: Nullable<DevicePose>;
  19942. /**
  19943. * The scale of the device to be used when translating from device space to babylon space.
  19944. */
  19945. deviceScaleFactor: number;
  19946. /**
  19947. * Updates the poseControlled values based on the input device pose.
  19948. * @param poseData the pose data to update the object with
  19949. */
  19950. updateFromDevice(poseData: DevicePose): void;
  19951. }
  19952. /**
  19953. * Set of options to customize the webVRCamera
  19954. */
  19955. export interface WebVROptions {
  19956. /**
  19957. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19958. */
  19959. trackPosition?: boolean;
  19960. /**
  19961. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19962. */
  19963. positionScale?: number;
  19964. /**
  19965. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19966. */
  19967. displayName?: string;
  19968. /**
  19969. * Should the native controller meshes be initialized. (default: true)
  19970. */
  19971. controllerMeshes?: boolean;
  19972. /**
  19973. * Creating a default HemiLight only on controllers. (default: true)
  19974. */
  19975. defaultLightingOnControllers?: boolean;
  19976. /**
  19977. * If you don't want to use the default VR button of the helper. (default: false)
  19978. */
  19979. useCustomVRButton?: boolean;
  19980. /**
  19981. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19982. */
  19983. customVRButton?: HTMLButtonElement;
  19984. /**
  19985. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19986. */
  19987. rayLength?: number;
  19988. /**
  19989. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19990. */
  19991. defaultHeight?: number;
  19992. /**
  19993. * If multiview should be used if availible (default: false)
  19994. */
  19995. useMultiview?: boolean;
  19996. }
  19997. /**
  19998. * This represents a WebVR camera.
  19999. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20000. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20001. */
  20002. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20003. private webVROptions;
  20004. /**
  20005. * @hidden
  20006. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20007. */
  20008. _vrDevice: any;
  20009. /**
  20010. * The rawPose of the vrDevice.
  20011. */
  20012. rawPose: Nullable<DevicePose>;
  20013. private _onVREnabled;
  20014. private _specsVersion;
  20015. private _attached;
  20016. private _frameData;
  20017. protected _descendants: Array<Node>;
  20018. private _deviceRoomPosition;
  20019. /** @hidden */
  20020. _deviceRoomRotationQuaternion: Quaternion;
  20021. private _standingMatrix;
  20022. /**
  20023. * Represents device position in babylon space.
  20024. */
  20025. devicePosition: Vector3;
  20026. /**
  20027. * Represents device rotation in babylon space.
  20028. */
  20029. deviceRotationQuaternion: Quaternion;
  20030. /**
  20031. * The scale of the device to be used when translating from device space to babylon space.
  20032. */
  20033. deviceScaleFactor: number;
  20034. private _deviceToWorld;
  20035. private _worldToDevice;
  20036. /**
  20037. * References to the webVR controllers for the vrDevice.
  20038. */
  20039. controllers: Array<WebVRController>;
  20040. /**
  20041. * Emits an event when a controller is attached.
  20042. */
  20043. onControllersAttachedObservable: Observable<WebVRController[]>;
  20044. /**
  20045. * Emits an event when a controller's mesh has been loaded;
  20046. */
  20047. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20048. /**
  20049. * Emits an event when the HMD's pose has been updated.
  20050. */
  20051. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20052. private _poseSet;
  20053. /**
  20054. * If the rig cameras be used as parent instead of this camera.
  20055. */
  20056. rigParenting: boolean;
  20057. private _lightOnControllers;
  20058. private _defaultHeight?;
  20059. /**
  20060. * Instantiates a WebVRFreeCamera.
  20061. * @param name The name of the WebVRFreeCamera
  20062. * @param position The starting anchor position for the camera
  20063. * @param scene The scene the camera belongs to
  20064. * @param webVROptions a set of customizable options for the webVRCamera
  20065. */
  20066. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20067. /**
  20068. * Gets the device distance from the ground in meters.
  20069. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20070. */
  20071. deviceDistanceToRoomGround(): number;
  20072. /**
  20073. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20074. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20075. */
  20076. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20077. /**
  20078. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20079. * @returns A promise with a boolean set to if the standing matrix is supported.
  20080. */
  20081. useStandingMatrixAsync(): Promise<boolean>;
  20082. /**
  20083. * Disposes the camera
  20084. */
  20085. dispose(): void;
  20086. /**
  20087. * Gets a vrController by name.
  20088. * @param name The name of the controller to retreive
  20089. * @returns the controller matching the name specified or null if not found
  20090. */
  20091. getControllerByName(name: string): Nullable<WebVRController>;
  20092. private _leftController;
  20093. /**
  20094. * The controller corresponding to the users left hand.
  20095. */
  20096. get leftController(): Nullable<WebVRController>;
  20097. private _rightController;
  20098. /**
  20099. * The controller corresponding to the users right hand.
  20100. */
  20101. get rightController(): Nullable<WebVRController>;
  20102. /**
  20103. * Casts a ray forward from the vrCamera's gaze.
  20104. * @param length Length of the ray (default: 100)
  20105. * @returns the ray corresponding to the gaze
  20106. */
  20107. getForwardRay(length?: number): Ray;
  20108. /**
  20109. * @hidden
  20110. * Updates the camera based on device's frame data
  20111. */
  20112. _checkInputs(): void;
  20113. /**
  20114. * Updates the poseControlled values based on the input device pose.
  20115. * @param poseData Pose coming from the device
  20116. */
  20117. updateFromDevice(poseData: DevicePose): void;
  20118. private _htmlElementAttached;
  20119. private _detachIfAttached;
  20120. /**
  20121. * WebVR's attach control will start broadcasting frames to the device.
  20122. * Note that in certain browsers (chrome for example) this function must be called
  20123. * within a user-interaction callback. Example:
  20124. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20125. *
  20126. * @param element html element to attach the vrDevice to
  20127. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20128. */
  20129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20130. /**
  20131. * Detaches the camera from the html element and disables VR
  20132. *
  20133. * @param element html element to detach from
  20134. */
  20135. detachControl(element: HTMLElement): void;
  20136. /**
  20137. * @returns the name of this class
  20138. */
  20139. getClassName(): string;
  20140. /**
  20141. * Calls resetPose on the vrDisplay
  20142. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20143. */
  20144. resetToCurrentRotation(): void;
  20145. /**
  20146. * @hidden
  20147. * Updates the rig cameras (left and right eye)
  20148. */
  20149. _updateRigCameras(): void;
  20150. private _workingVector;
  20151. private _oneVector;
  20152. private _workingMatrix;
  20153. private updateCacheCalled;
  20154. private _correctPositionIfNotTrackPosition;
  20155. /**
  20156. * @hidden
  20157. * Updates the cached values of the camera
  20158. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20159. */
  20160. _updateCache(ignoreParentClass?: boolean): void;
  20161. /**
  20162. * @hidden
  20163. * Get current device position in babylon world
  20164. */
  20165. _computeDevicePosition(): void;
  20166. /**
  20167. * Updates the current device position and rotation in the babylon world
  20168. */
  20169. update(): void;
  20170. /**
  20171. * @hidden
  20172. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20173. * @returns an identity matrix
  20174. */
  20175. _getViewMatrix(): Matrix;
  20176. private _tmpMatrix;
  20177. /**
  20178. * This function is called by the two RIG cameras.
  20179. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20180. * @hidden
  20181. */
  20182. _getWebVRViewMatrix(): Matrix;
  20183. /** @hidden */
  20184. _getWebVRProjectionMatrix(): Matrix;
  20185. private _onGamepadConnectedObserver;
  20186. private _onGamepadDisconnectedObserver;
  20187. private _updateCacheWhenTrackingDisabledObserver;
  20188. /**
  20189. * Initializes the controllers and their meshes
  20190. */
  20191. initControllers(): void;
  20192. }
  20193. }
  20194. declare module "babylonjs/PostProcesses/postProcess" {
  20195. import { Nullable } from "babylonjs/types";
  20196. import { SmartArray } from "babylonjs/Misc/smartArray";
  20197. import { Observable } from "babylonjs/Misc/observable";
  20198. import { Vector2 } from "babylonjs/Maths/math.vector";
  20199. import { Camera } from "babylonjs/Cameras/camera";
  20200. import { Effect } from "babylonjs/Materials/effect";
  20201. import "babylonjs/Shaders/postprocess.vertex";
  20202. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20203. import { Engine } from "babylonjs/Engines/engine";
  20204. import { Color4 } from "babylonjs/Maths/math.color";
  20205. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20207. /**
  20208. * Size options for a post process
  20209. */
  20210. export type PostProcessOptions = {
  20211. width: number;
  20212. height: number;
  20213. };
  20214. /**
  20215. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20217. */
  20218. export class PostProcess {
  20219. /** Name of the PostProcess. */
  20220. name: string;
  20221. /**
  20222. * Gets or sets the unique id of the post process
  20223. */
  20224. uniqueId: number;
  20225. /**
  20226. * Width of the texture to apply the post process on
  20227. */
  20228. width: number;
  20229. /**
  20230. * Height of the texture to apply the post process on
  20231. */
  20232. height: number;
  20233. /**
  20234. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20235. * @hidden
  20236. */
  20237. _outputTexture: Nullable<InternalTexture>;
  20238. /**
  20239. * Sampling mode used by the shader
  20240. * See https://doc.babylonjs.com/classes/3.1/texture
  20241. */
  20242. renderTargetSamplingMode: number;
  20243. /**
  20244. * Clear color to use when screen clearing
  20245. */
  20246. clearColor: Color4;
  20247. /**
  20248. * If the buffer needs to be cleared before applying the post process. (default: true)
  20249. * Should be set to false if shader will overwrite all previous pixels.
  20250. */
  20251. autoClear: boolean;
  20252. /**
  20253. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20254. */
  20255. alphaMode: number;
  20256. /**
  20257. * Sets the setAlphaBlendConstants of the babylon engine
  20258. */
  20259. alphaConstants: Color4;
  20260. /**
  20261. * Animations to be used for the post processing
  20262. */
  20263. animations: import("babylonjs/Animations/animation").Animation[];
  20264. /**
  20265. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20266. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20267. */
  20268. enablePixelPerfectMode: boolean;
  20269. /**
  20270. * Force the postprocess to be applied without taking in account viewport
  20271. */
  20272. forceFullscreenViewport: boolean;
  20273. /**
  20274. * List of inspectable custom properties (used by the Inspector)
  20275. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20276. */
  20277. inspectableCustomProperties: IInspectable[];
  20278. /**
  20279. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20280. *
  20281. * | Value | Type | Description |
  20282. * | ----- | ----------------------------------- | ----------- |
  20283. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20284. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20285. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20286. *
  20287. */
  20288. scaleMode: number;
  20289. /**
  20290. * Force textures to be a power of two (default: false)
  20291. */
  20292. alwaysForcePOT: boolean;
  20293. private _samples;
  20294. /**
  20295. * Number of sample textures (default: 1)
  20296. */
  20297. get samples(): number;
  20298. set samples(n: number);
  20299. /**
  20300. * Modify the scale of the post process to be the same as the viewport (default: false)
  20301. */
  20302. adaptScaleToCurrentViewport: boolean;
  20303. private _camera;
  20304. private _scene;
  20305. private _engine;
  20306. private _options;
  20307. private _reusable;
  20308. private _textureType;
  20309. private _textureFormat;
  20310. /**
  20311. * Smart array of input and output textures for the post process.
  20312. * @hidden
  20313. */
  20314. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20315. /**
  20316. * The index in _textures that corresponds to the output texture.
  20317. * @hidden
  20318. */
  20319. _currentRenderTextureInd: number;
  20320. private _effect;
  20321. private _samplers;
  20322. private _fragmentUrl;
  20323. private _vertexUrl;
  20324. private _parameters;
  20325. private _scaleRatio;
  20326. protected _indexParameters: any;
  20327. private _shareOutputWithPostProcess;
  20328. private _texelSize;
  20329. private _forcedOutputTexture;
  20330. /**
  20331. * Returns the fragment url or shader name used in the post process.
  20332. * @returns the fragment url or name in the shader store.
  20333. */
  20334. getEffectName(): string;
  20335. /**
  20336. * An event triggered when the postprocess is activated.
  20337. */
  20338. onActivateObservable: Observable<Camera>;
  20339. private _onActivateObserver;
  20340. /**
  20341. * A function that is added to the onActivateObservable
  20342. */
  20343. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20344. /**
  20345. * An event triggered when the postprocess changes its size.
  20346. */
  20347. onSizeChangedObservable: Observable<PostProcess>;
  20348. private _onSizeChangedObserver;
  20349. /**
  20350. * A function that is added to the onSizeChangedObservable
  20351. */
  20352. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20353. /**
  20354. * An event triggered when the postprocess applies its effect.
  20355. */
  20356. onApplyObservable: Observable<Effect>;
  20357. private _onApplyObserver;
  20358. /**
  20359. * A function that is added to the onApplyObservable
  20360. */
  20361. set onApply(callback: (effect: Effect) => void);
  20362. /**
  20363. * An event triggered before rendering the postprocess
  20364. */
  20365. onBeforeRenderObservable: Observable<Effect>;
  20366. private _onBeforeRenderObserver;
  20367. /**
  20368. * A function that is added to the onBeforeRenderObservable
  20369. */
  20370. set onBeforeRender(callback: (effect: Effect) => void);
  20371. /**
  20372. * An event triggered after rendering the postprocess
  20373. */
  20374. onAfterRenderObservable: Observable<Effect>;
  20375. private _onAfterRenderObserver;
  20376. /**
  20377. * A function that is added to the onAfterRenderObservable
  20378. */
  20379. set onAfterRender(callback: (efect: Effect) => void);
  20380. /**
  20381. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  20382. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20383. */
  20384. get inputTexture(): InternalTexture;
  20385. set inputTexture(value: InternalTexture);
  20386. /**
  20387. * Gets the camera which post process is applied to.
  20388. * @returns The camera the post process is applied to.
  20389. */
  20390. getCamera(): Camera;
  20391. /**
  20392. * Gets the texel size of the postprocess.
  20393. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20394. */
  20395. get texelSize(): Vector2;
  20396. /**
  20397. * Creates a new instance PostProcess
  20398. * @param name The name of the PostProcess.
  20399. * @param fragmentUrl The url of the fragment shader to be used.
  20400. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20401. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20402. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20403. * @param camera The camera to apply the render pass to.
  20404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20405. * @param engine The engine which the post process will be applied. (default: current engine)
  20406. * @param reusable If the post process can be reused on the same frame. (default: false)
  20407. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20408. * @param textureType Type of textures used when performing the post process. (default: 0)
  20409. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20410. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20411. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20412. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20413. */
  20414. constructor(
  20415. /** Name of the PostProcess. */
  20416. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  20417. /**
  20418. * Gets a string idenfifying the name of the class
  20419. * @returns "PostProcess" string
  20420. */
  20421. getClassName(): string;
  20422. /**
  20423. * Gets the engine which this post process belongs to.
  20424. * @returns The engine the post process was enabled with.
  20425. */
  20426. getEngine(): Engine;
  20427. /**
  20428. * The effect that is created when initializing the post process.
  20429. * @returns The created effect corresponding the the postprocess.
  20430. */
  20431. getEffect(): Effect;
  20432. /**
  20433. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20434. * @param postProcess The post process to share the output with.
  20435. * @returns This post process.
  20436. */
  20437. shareOutputWith(postProcess: PostProcess): PostProcess;
  20438. /**
  20439. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20440. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20441. */
  20442. useOwnOutput(): void;
  20443. /**
  20444. * Updates the effect with the current post process compile time values and recompiles the shader.
  20445. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20446. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20447. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20448. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20449. * @param onCompiled Called when the shader has been compiled.
  20450. * @param onError Called if there is an error when compiling a shader.
  20451. */
  20452. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20453. /**
  20454. * The post process is reusable if it can be used multiple times within one frame.
  20455. * @returns If the post process is reusable
  20456. */
  20457. isReusable(): boolean;
  20458. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20459. markTextureDirty(): void;
  20460. /**
  20461. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20462. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  20463. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20464. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20465. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20466. * @returns The target texture that was bound to be written to.
  20467. */
  20468. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20469. /**
  20470. * If the post process is supported.
  20471. */
  20472. get isSupported(): boolean;
  20473. /**
  20474. * The aspect ratio of the output texture.
  20475. */
  20476. get aspectRatio(): number;
  20477. /**
  20478. * Get a value indicating if the post-process is ready to be used
  20479. * @returns true if the post-process is ready (shader is compiled)
  20480. */
  20481. isReady(): boolean;
  20482. /**
  20483. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20484. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20485. */
  20486. apply(): Nullable<Effect>;
  20487. private _disposeTextures;
  20488. /**
  20489. * Disposes the post process.
  20490. * @param camera The camera to dispose the post process on.
  20491. */
  20492. dispose(camera?: Camera): void;
  20493. }
  20494. }
  20495. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20496. /** @hidden */
  20497. export var kernelBlurVaryingDeclaration: {
  20498. name: string;
  20499. shader: string;
  20500. };
  20501. }
  20502. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20503. /** @hidden */
  20504. export var kernelBlurFragment: {
  20505. name: string;
  20506. shader: string;
  20507. };
  20508. }
  20509. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20510. /** @hidden */
  20511. export var kernelBlurFragment2: {
  20512. name: string;
  20513. shader: string;
  20514. };
  20515. }
  20516. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20517. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20518. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20519. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20520. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20521. /** @hidden */
  20522. export var kernelBlurPixelShader: {
  20523. name: string;
  20524. shader: string;
  20525. };
  20526. }
  20527. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20528. /** @hidden */
  20529. export var kernelBlurVertex: {
  20530. name: string;
  20531. shader: string;
  20532. };
  20533. }
  20534. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20535. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20536. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20537. /** @hidden */
  20538. export var kernelBlurVertexShader: {
  20539. name: string;
  20540. shader: string;
  20541. };
  20542. }
  20543. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20544. import { Vector2 } from "babylonjs/Maths/math.vector";
  20545. import { Nullable } from "babylonjs/types";
  20546. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20547. import { Camera } from "babylonjs/Cameras/camera";
  20548. import { Effect } from "babylonjs/Materials/effect";
  20549. import { Engine } from "babylonjs/Engines/engine";
  20550. import "babylonjs/Shaders/kernelBlur.fragment";
  20551. import "babylonjs/Shaders/kernelBlur.vertex";
  20552. /**
  20553. * The Blur Post Process which blurs an image based on a kernel and direction.
  20554. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20555. */
  20556. export class BlurPostProcess extends PostProcess {
  20557. /** The direction in which to blur the image. */
  20558. direction: Vector2;
  20559. private blockCompilation;
  20560. protected _kernel: number;
  20561. protected _idealKernel: number;
  20562. protected _packedFloat: boolean;
  20563. private _staticDefines;
  20564. /**
  20565. * Sets the length in pixels of the blur sample region
  20566. */
  20567. set kernel(v: number);
  20568. /**
  20569. * Gets the length in pixels of the blur sample region
  20570. */
  20571. get kernel(): number;
  20572. /**
  20573. * Sets wether or not the blur needs to unpack/repack floats
  20574. */
  20575. set packedFloat(v: boolean);
  20576. /**
  20577. * Gets wether or not the blur is unpacking/repacking floats
  20578. */
  20579. get packedFloat(): boolean;
  20580. /**
  20581. * Creates a new instance BlurPostProcess
  20582. * @param name The name of the effect.
  20583. * @param direction The direction in which to blur the image.
  20584. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  20585. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20586. * @param camera The camera to apply the render pass to.
  20587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20588. * @param engine The engine which the post process will be applied. (default: current engine)
  20589. * @param reusable If the post process can be reused on the same frame. (default: false)
  20590. * @param textureType Type of textures used when performing the post process. (default: 0)
  20591. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20592. */
  20593. constructor(name: string,
  20594. /** The direction in which to blur the image. */
  20595. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20596. /**
  20597. * Updates the effect with the current post process compile time values and recompiles the shader.
  20598. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20599. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20600. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20601. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20602. * @param onCompiled Called when the shader has been compiled.
  20603. * @param onError Called if there is an error when compiling a shader.
  20604. */
  20605. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20606. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20607. /**
  20608. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20609. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20610. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20611. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20612. * The gaps between physical kernels are compensated for in the weighting of the samples
  20613. * @param idealKernel Ideal blur kernel.
  20614. * @return Nearest best kernel.
  20615. */
  20616. protected _nearestBestKernel(idealKernel: number): number;
  20617. /**
  20618. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20619. * @param x The point on the Gaussian distribution to sample.
  20620. * @return the value of the Gaussian function at x.
  20621. */
  20622. protected _gaussianWeight(x: number): number;
  20623. /**
  20624. * Generates a string that can be used as a floating point number in GLSL.
  20625. * @param x Value to print.
  20626. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20627. * @return GLSL float string.
  20628. */
  20629. protected _glslFloat(x: number, decimalFigures?: number): string;
  20630. }
  20631. }
  20632. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20633. import { Scene } from "babylonjs/scene";
  20634. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20635. import { Plane } from "babylonjs/Maths/math.plane";
  20636. /**
  20637. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20638. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20639. * You can then easily use it as a reflectionTexture on a flat surface.
  20640. * In case the surface is not a plane, please consider relying on reflection probes.
  20641. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20642. */
  20643. export class MirrorTexture extends RenderTargetTexture {
  20644. private scene;
  20645. /**
  20646. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20647. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  20648. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20649. */
  20650. mirrorPlane: Plane;
  20651. /**
  20652. * Define the blur ratio used to blur the reflection if needed.
  20653. */
  20654. set blurRatio(value: number);
  20655. get blurRatio(): number;
  20656. /**
  20657. * Define the adaptive blur kernel used to blur the reflection if needed.
  20658. * This will autocompute the closest best match for the `blurKernel`
  20659. */
  20660. set adaptiveBlurKernel(value: number);
  20661. /**
  20662. * Define the blur kernel used to blur the reflection if needed.
  20663. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20664. */
  20665. set blurKernel(value: number);
  20666. /**
  20667. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20668. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20669. */
  20670. set blurKernelX(value: number);
  20671. get blurKernelX(): number;
  20672. /**
  20673. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20674. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20675. */
  20676. set blurKernelY(value: number);
  20677. get blurKernelY(): number;
  20678. private _autoComputeBlurKernel;
  20679. protected _onRatioRescale(): void;
  20680. private _updateGammaSpace;
  20681. private _imageProcessingConfigChangeObserver;
  20682. private _transformMatrix;
  20683. private _mirrorMatrix;
  20684. private _savedViewMatrix;
  20685. private _blurX;
  20686. private _blurY;
  20687. private _adaptiveBlurKernel;
  20688. private _blurKernelX;
  20689. private _blurKernelY;
  20690. private _blurRatio;
  20691. /**
  20692. * Instantiates a Mirror Texture.
  20693. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20694. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20695. * You can then easily use it as a reflectionTexture on a flat surface.
  20696. * In case the surface is not a plane, please consider relying on reflection probes.
  20697. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20698. * @param name
  20699. * @param size
  20700. * @param scene
  20701. * @param generateMipMaps
  20702. * @param type
  20703. * @param samplingMode
  20704. * @param generateDepthBuffer
  20705. */
  20706. constructor(name: string, size: number | {
  20707. width: number;
  20708. height: number;
  20709. } | {
  20710. ratio: number;
  20711. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20712. private _preparePostProcesses;
  20713. /**
  20714. * Clone the mirror texture.
  20715. * @returns the cloned texture
  20716. */
  20717. clone(): MirrorTexture;
  20718. /**
  20719. * Serialize the texture to a JSON representation you could use in Parse later on
  20720. * @returns the serialized JSON representation
  20721. */
  20722. serialize(): any;
  20723. /**
  20724. * Dispose the texture and release its associated resources.
  20725. */
  20726. dispose(): void;
  20727. }
  20728. }
  20729. declare module "babylonjs/Materials/Textures/texture" {
  20730. import { Observable } from "babylonjs/Misc/observable";
  20731. import { Nullable } from "babylonjs/types";
  20732. import { Matrix } from "babylonjs/Maths/math.vector";
  20733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20734. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20735. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20736. import { Scene } from "babylonjs/scene";
  20737. /**
  20738. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20739. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20740. */
  20741. export class Texture extends BaseTexture {
  20742. /**
  20743. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20744. */
  20745. static SerializeBuffers: boolean;
  20746. /** @hidden */
  20747. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20748. /** @hidden */
  20749. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20750. /** @hidden */
  20751. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20752. /** nearest is mag = nearest and min = nearest and mip = linear */
  20753. static readonly NEAREST_SAMPLINGMODE: number;
  20754. /** nearest is mag = nearest and min = nearest and mip = linear */
  20755. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20756. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20757. static readonly BILINEAR_SAMPLINGMODE: number;
  20758. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20759. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20760. /** Trilinear is mag = linear and min = linear and mip = linear */
  20761. static readonly TRILINEAR_SAMPLINGMODE: number;
  20762. /** Trilinear is mag = linear and min = linear and mip = linear */
  20763. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20764. /** mag = nearest and min = nearest and mip = nearest */
  20765. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20766. /** mag = nearest and min = linear and mip = nearest */
  20767. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20768. /** mag = nearest and min = linear and mip = linear */
  20769. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20770. /** mag = nearest and min = linear and mip = none */
  20771. static readonly NEAREST_LINEAR: number;
  20772. /** mag = nearest and min = nearest and mip = none */
  20773. static readonly NEAREST_NEAREST: number;
  20774. /** mag = linear and min = nearest and mip = nearest */
  20775. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20776. /** mag = linear and min = nearest and mip = linear */
  20777. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20778. /** mag = linear and min = linear and mip = none */
  20779. static readonly LINEAR_LINEAR: number;
  20780. /** mag = linear and min = nearest and mip = none */
  20781. static readonly LINEAR_NEAREST: number;
  20782. /** Explicit coordinates mode */
  20783. static readonly EXPLICIT_MODE: number;
  20784. /** Spherical coordinates mode */
  20785. static readonly SPHERICAL_MODE: number;
  20786. /** Planar coordinates mode */
  20787. static readonly PLANAR_MODE: number;
  20788. /** Cubic coordinates mode */
  20789. static readonly CUBIC_MODE: number;
  20790. /** Projection coordinates mode */
  20791. static readonly PROJECTION_MODE: number;
  20792. /** Inverse Cubic coordinates mode */
  20793. static readonly SKYBOX_MODE: number;
  20794. /** Inverse Cubic coordinates mode */
  20795. static readonly INVCUBIC_MODE: number;
  20796. /** Equirectangular coordinates mode */
  20797. static readonly EQUIRECTANGULAR_MODE: number;
  20798. /** Equirectangular Fixed coordinates mode */
  20799. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20800. /** Equirectangular Fixed Mirrored coordinates mode */
  20801. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20802. /** Texture is not repeating outside of 0..1 UVs */
  20803. static readonly CLAMP_ADDRESSMODE: number;
  20804. /** Texture is repeating outside of 0..1 UVs */
  20805. static readonly WRAP_ADDRESSMODE: number;
  20806. /** Texture is repeating and mirrored */
  20807. static readonly MIRROR_ADDRESSMODE: number;
  20808. /**
  20809. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  20810. */
  20811. static UseSerializedUrlIfAny: boolean;
  20812. /**
  20813. * Define the url of the texture.
  20814. */
  20815. url: Nullable<string>;
  20816. /**
  20817. * Define an offset on the texture to offset the u coordinates of the UVs
  20818. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20819. */
  20820. uOffset: number;
  20821. /**
  20822. * Define an offset on the texture to offset the v coordinates of the UVs
  20823. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20824. */
  20825. vOffset: number;
  20826. /**
  20827. * Define an offset on the texture to scale the u coordinates of the UVs
  20828. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20829. */
  20830. uScale: number;
  20831. /**
  20832. * Define an offset on the texture to scale the v coordinates of the UVs
  20833. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20834. */
  20835. vScale: number;
  20836. /**
  20837. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20838. * @see http://doc.babylonjs.com/how_to/more_materials
  20839. */
  20840. uAng: number;
  20841. /**
  20842. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20843. * @see http://doc.babylonjs.com/how_to/more_materials
  20844. */
  20845. vAng: number;
  20846. /**
  20847. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20848. * @see http://doc.babylonjs.com/how_to/more_materials
  20849. */
  20850. wAng: number;
  20851. /**
  20852. * Defines the center of rotation (U)
  20853. */
  20854. uRotationCenter: number;
  20855. /**
  20856. * Defines the center of rotation (V)
  20857. */
  20858. vRotationCenter: number;
  20859. /**
  20860. * Defines the center of rotation (W)
  20861. */
  20862. wRotationCenter: number;
  20863. /**
  20864. * Are mip maps generated for this texture or not.
  20865. */
  20866. get noMipmap(): boolean;
  20867. /**
  20868. * List of inspectable custom properties (used by the Inspector)
  20869. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20870. */
  20871. inspectableCustomProperties: Nullable<IInspectable[]>;
  20872. private _noMipmap;
  20873. /** @hidden */
  20874. _invertY: boolean;
  20875. private _rowGenerationMatrix;
  20876. private _cachedTextureMatrix;
  20877. private _projectionModeMatrix;
  20878. private _t0;
  20879. private _t1;
  20880. private _t2;
  20881. private _cachedUOffset;
  20882. private _cachedVOffset;
  20883. private _cachedUScale;
  20884. private _cachedVScale;
  20885. private _cachedUAng;
  20886. private _cachedVAng;
  20887. private _cachedWAng;
  20888. private _cachedProjectionMatrixId;
  20889. private _cachedCoordinatesMode;
  20890. /** @hidden */
  20891. protected _initialSamplingMode: number;
  20892. /** @hidden */
  20893. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20894. private _deleteBuffer;
  20895. protected _format: Nullable<number>;
  20896. private _delayedOnLoad;
  20897. private _delayedOnError;
  20898. private _mimeType?;
  20899. /**
  20900. * Observable triggered once the texture has been loaded.
  20901. */
  20902. onLoadObservable: Observable<Texture>;
  20903. protected _isBlocking: boolean;
  20904. /**
  20905. * Is the texture preventing material to render while loading.
  20906. * If false, a default texture will be used instead of the loading one during the preparation step.
  20907. */
  20908. set isBlocking(value: boolean);
  20909. get isBlocking(): boolean;
  20910. /**
  20911. * Get the current sampling mode associated with the texture.
  20912. */
  20913. get samplingMode(): number;
  20914. /**
  20915. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20916. */
  20917. get invertY(): boolean;
  20918. /**
  20919. * Instantiates a new texture.
  20920. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20921. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20922. * @param url defines the url of the picture to load as a texture
  20923. * @param scene defines the scene or engine the texture will belong to
  20924. * @param noMipmap defines if the texture will require mip maps or not
  20925. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20926. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20927. * @param onLoad defines a callback triggered when the texture has been loaded
  20928. * @param onError defines a callback triggered when an error occurred during the loading session
  20929. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20930. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20931. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20932. * @param mimeType defines an optional mime type information
  20933. */
  20934. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20935. /**
  20936. * Update the url (and optional buffer) of this texture if url was null during construction.
  20937. * @param url the url of the texture
  20938. * @param buffer the buffer of the texture (defaults to null)
  20939. * @param onLoad callback called when the texture is loaded (defaults to null)
  20940. */
  20941. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20942. /**
  20943. * Finish the loading sequence of a texture flagged as delayed load.
  20944. * @hidden
  20945. */
  20946. delayLoad(): void;
  20947. private _prepareRowForTextureGeneration;
  20948. /**
  20949. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20950. * @returns the transform matrix of the texture.
  20951. */
  20952. getTextureMatrix(uBase?: number): Matrix;
  20953. /**
  20954. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20955. * @returns The reflection texture transform
  20956. */
  20957. getReflectionTextureMatrix(): Matrix;
  20958. /**
  20959. * Clones the texture.
  20960. * @returns the cloned texture
  20961. */
  20962. clone(): Texture;
  20963. /**
  20964. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20965. * @returns The JSON representation of the texture
  20966. */
  20967. serialize(): any;
  20968. /**
  20969. * Get the current class name of the texture useful for serialization or dynamic coding.
  20970. * @returns "Texture"
  20971. */
  20972. getClassName(): string;
  20973. /**
  20974. * Dispose the texture and release its associated resources.
  20975. */
  20976. dispose(): void;
  20977. /**
  20978. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20979. * @param parsedTexture Define the JSON representation of the texture
  20980. * @param scene Define the scene the parsed texture should be instantiated in
  20981. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20982. * @returns The parsed texture if successful
  20983. */
  20984. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20985. /**
  20986. * Creates a texture from its base 64 representation.
  20987. * @param data Define the base64 payload without the data: prefix
  20988. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20989. * @param scene Define the scene the texture should belong to
  20990. * @param noMipmap Forces the texture to not create mip map information if true
  20991. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20992. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20993. * @param onLoad define a callback triggered when the texture has been loaded
  20994. * @param onError define a callback triggered when an error occurred during the loading session
  20995. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20996. * @returns the created texture
  20997. */
  20998. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20999. /**
  21000. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21001. * @param data Define the base64 payload without the data: prefix
  21002. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21003. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21004. * @param scene Define the scene the texture should belong to
  21005. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21006. * @param noMipmap Forces the texture to not create mip map information if true
  21007. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21008. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21009. * @param onLoad define a callback triggered when the texture has been loaded
  21010. * @param onError define a callback triggered when an error occurred during the loading session
  21011. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21012. * @returns the created texture
  21013. */
  21014. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  21015. }
  21016. }
  21017. declare module "babylonjs/PostProcesses/postProcessManager" {
  21018. import { Nullable } from "babylonjs/types";
  21019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21020. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21021. import { Scene } from "babylonjs/scene";
  21022. /**
  21023. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21024. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21025. */
  21026. export class PostProcessManager {
  21027. private _scene;
  21028. private _indexBuffer;
  21029. private _vertexBuffers;
  21030. /**
  21031. * Creates a new instance PostProcess
  21032. * @param scene The scene that the post process is associated with.
  21033. */
  21034. constructor(scene: Scene);
  21035. private _prepareBuffers;
  21036. private _buildIndexBuffer;
  21037. /**
  21038. * Rebuilds the vertex buffers of the manager.
  21039. * @hidden
  21040. */
  21041. _rebuild(): void;
  21042. /**
  21043. * Prepares a frame to be run through a post process.
  21044. * @param sourceTexture The input texture to the post procesess. (default: null)
  21045. * @param postProcesses An array of post processes to be run. (default: null)
  21046. * @returns True if the post processes were able to be run.
  21047. * @hidden
  21048. */
  21049. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21050. /**
  21051. * Manually render a set of post processes to a texture.
  21052. * @param postProcesses An array of post processes to be run.
  21053. * @param targetTexture The target texture to render to.
  21054. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21055. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21056. * @param lodLevel defines which lod of the texture to render to
  21057. */
  21058. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21059. /**
  21060. * Finalize the result of the output of the postprocesses.
  21061. * @param doNotPresent If true the result will not be displayed to the screen.
  21062. * @param targetTexture The target texture to render to.
  21063. * @param faceIndex The index of the face to bind the target texture to.
  21064. * @param postProcesses The array of post processes to render.
  21065. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21066. * @hidden
  21067. */
  21068. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21069. /**
  21070. * Disposes of the post process manager.
  21071. */
  21072. dispose(): void;
  21073. }
  21074. }
  21075. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21076. import { Observable } from "babylonjs/Misc/observable";
  21077. import { SmartArray } from "babylonjs/Misc/smartArray";
  21078. import { Nullable, Immutable } from "babylonjs/types";
  21079. import { Camera } from "babylonjs/Cameras/camera";
  21080. import { Scene } from "babylonjs/scene";
  21081. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21082. import { Color4 } from "babylonjs/Maths/math.color";
  21083. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21085. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21087. import { Texture } from "babylonjs/Materials/Textures/texture";
  21088. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21089. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21090. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21091. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21092. import { Engine } from "babylonjs/Engines/engine";
  21093. /**
  21094. * This Helps creating a texture that will be created from a camera in your scene.
  21095. * It is basically a dynamic texture that could be used to create special effects for instance.
  21096. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21097. */
  21098. export class RenderTargetTexture extends Texture {
  21099. isCube: boolean;
  21100. /**
  21101. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21102. */
  21103. static readonly REFRESHRATE_RENDER_ONCE: number;
  21104. /**
  21105. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21106. */
  21107. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21108. /**
  21109. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21110. * the central point of your effect and can save a lot of performances.
  21111. */
  21112. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21113. /**
  21114. * Use this predicate to dynamically define the list of mesh you want to render.
  21115. * If set, the renderList property will be overwritten.
  21116. */
  21117. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21118. private _renderList;
  21119. /**
  21120. * Use this list to define the list of mesh you want to render.
  21121. */
  21122. get renderList(): Nullable<Array<AbstractMesh>>;
  21123. set renderList(value: Nullable<Array<AbstractMesh>>);
  21124. /**
  21125. * Use this function to overload the renderList array at rendering time.
  21126. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21127. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21128. * the cube (if the RTT is a cube, else layerOrFace=0).
  21129. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21130. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21131. * hold dummy elements!
  21132. */
  21133. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21134. private _hookArray;
  21135. /**
  21136. * Define if particles should be rendered in your texture.
  21137. */
  21138. renderParticles: boolean;
  21139. /**
  21140. * Define if sprites should be rendered in your texture.
  21141. */
  21142. renderSprites: boolean;
  21143. /**
  21144. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21145. */
  21146. coordinatesMode: number;
  21147. /**
  21148. * Define the camera used to render the texture.
  21149. */
  21150. activeCamera: Nullable<Camera>;
  21151. /**
  21152. * Override the render function of the texture with your own one.
  21153. */
  21154. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21155. /**
  21156. * Define if camera post processes should be use while rendering the texture.
  21157. */
  21158. useCameraPostProcesses: boolean;
  21159. /**
  21160. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21161. */
  21162. ignoreCameraViewport: boolean;
  21163. private _postProcessManager;
  21164. private _postProcesses;
  21165. private _resizeObserver;
  21166. /**
  21167. * An event triggered when the texture is unbind.
  21168. */
  21169. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21170. /**
  21171. * An event triggered when the texture is unbind.
  21172. */
  21173. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21174. private _onAfterUnbindObserver;
  21175. /**
  21176. * Set a after unbind callback in the texture.
  21177. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21178. */
  21179. set onAfterUnbind(callback: () => void);
  21180. /**
  21181. * An event triggered before rendering the texture
  21182. */
  21183. onBeforeRenderObservable: Observable<number>;
  21184. private _onBeforeRenderObserver;
  21185. /**
  21186. * Set a before render callback in the texture.
  21187. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21188. */
  21189. set onBeforeRender(callback: (faceIndex: number) => void);
  21190. /**
  21191. * An event triggered after rendering the texture
  21192. */
  21193. onAfterRenderObservable: Observable<number>;
  21194. private _onAfterRenderObserver;
  21195. /**
  21196. * Set a after render callback in the texture.
  21197. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21198. */
  21199. set onAfterRender(callback: (faceIndex: number) => void);
  21200. /**
  21201. * An event triggered after the texture clear
  21202. */
  21203. onClearObservable: Observable<Engine>;
  21204. private _onClearObserver;
  21205. /**
  21206. * Set a clear callback in the texture.
  21207. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21208. */
  21209. set onClear(callback: (Engine: Engine) => void);
  21210. /**
  21211. * An event triggered when the texture is resized.
  21212. */
  21213. onResizeObservable: Observable<RenderTargetTexture>;
  21214. /**
  21215. * Define the clear color of the Render Target if it should be different from the scene.
  21216. */
  21217. clearColor: Color4;
  21218. protected _size: number | {
  21219. width: number;
  21220. height: number;
  21221. layers?: number;
  21222. };
  21223. protected _initialSizeParameter: number | {
  21224. width: number;
  21225. height: number;
  21226. } | {
  21227. ratio: number;
  21228. };
  21229. protected _sizeRatio: Nullable<number>;
  21230. /** @hidden */
  21231. _generateMipMaps: boolean;
  21232. protected _renderingManager: RenderingManager;
  21233. /** @hidden */
  21234. _waitingRenderList: string[];
  21235. protected _doNotChangeAspectRatio: boolean;
  21236. protected _currentRefreshId: number;
  21237. protected _refreshRate: number;
  21238. protected _textureMatrix: Matrix;
  21239. protected _samples: number;
  21240. protected _renderTargetOptions: RenderTargetCreationOptions;
  21241. /**
  21242. * Gets render target creation options that were used.
  21243. */
  21244. get renderTargetOptions(): RenderTargetCreationOptions;
  21245. protected _engine: Engine;
  21246. protected _onRatioRescale(): void;
  21247. /**
  21248. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21249. * It must define where the camera used to render the texture is set
  21250. */
  21251. boundingBoxPosition: Vector3;
  21252. private _boundingBoxSize;
  21253. /**
  21254. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21255. * When defined, the cubemap will switch to local mode
  21256. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21257. * @example https://www.babylonjs-playground.com/#RNASML
  21258. */
  21259. set boundingBoxSize(value: Vector3);
  21260. get boundingBoxSize(): Vector3;
  21261. /**
  21262. * In case the RTT has been created with a depth texture, get the associated
  21263. * depth texture.
  21264. * Otherwise, return null.
  21265. */
  21266. get depthStencilTexture(): Nullable<InternalTexture>;
  21267. /**
  21268. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21269. * or used a shadow, depth texture...
  21270. * @param name The friendly name of the texture
  21271. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  21272. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21273. * @param generateMipMaps True if mip maps need to be generated after render.
  21274. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21275. * @param type The type of the buffer in the RTT (int, half float, float...)
  21276. * @param isCube True if a cube texture needs to be created
  21277. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21278. * @param generateDepthBuffer True to generate a depth buffer
  21279. * @param generateStencilBuffer True to generate a stencil buffer
  21280. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21281. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21282. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21283. */
  21284. constructor(name: string, size: number | {
  21285. width: number;
  21286. height: number;
  21287. layers?: number;
  21288. } | {
  21289. ratio: number;
  21290. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21291. /**
  21292. * Creates a depth stencil texture.
  21293. * This is only available in WebGL 2 or with the depth texture extension available.
  21294. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21295. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21296. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21297. */
  21298. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21299. private _processSizeParameter;
  21300. /**
  21301. * Define the number of samples to use in case of MSAA.
  21302. * It defaults to one meaning no MSAA has been enabled.
  21303. */
  21304. get samples(): number;
  21305. set samples(value: number);
  21306. /**
  21307. * Resets the refresh counter of the texture and start bak from scratch.
  21308. * Could be useful to regenerate the texture if it is setup to render only once.
  21309. */
  21310. resetRefreshCounter(): void;
  21311. /**
  21312. * Define the refresh rate of the texture or the rendering frequency.
  21313. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21314. */
  21315. get refreshRate(): number;
  21316. set refreshRate(value: number);
  21317. /**
  21318. * Adds a post process to the render target rendering passes.
  21319. * @param postProcess define the post process to add
  21320. */
  21321. addPostProcess(postProcess: PostProcess): void;
  21322. /**
  21323. * Clear all the post processes attached to the render target
  21324. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21325. */
  21326. clearPostProcesses(dispose?: boolean): void;
  21327. /**
  21328. * Remove one of the post process from the list of attached post processes to the texture
  21329. * @param postProcess define the post process to remove from the list
  21330. */
  21331. removePostProcess(postProcess: PostProcess): void;
  21332. /** @hidden */
  21333. _shouldRender(): boolean;
  21334. /**
  21335. * Gets the actual render size of the texture.
  21336. * @returns the width of the render size
  21337. */
  21338. getRenderSize(): number;
  21339. /**
  21340. * Gets the actual render width of the texture.
  21341. * @returns the width of the render size
  21342. */
  21343. getRenderWidth(): number;
  21344. /**
  21345. * Gets the actual render height of the texture.
  21346. * @returns the height of the render size
  21347. */
  21348. getRenderHeight(): number;
  21349. /**
  21350. * Gets the actual number of layers of the texture.
  21351. * @returns the number of layers
  21352. */
  21353. getRenderLayers(): number;
  21354. /**
  21355. * Get if the texture can be rescaled or not.
  21356. */
  21357. get canRescale(): boolean;
  21358. /**
  21359. * Resize the texture using a ratio.
  21360. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21361. */
  21362. scale(ratio: number): void;
  21363. /**
  21364. * Get the texture reflection matrix used to rotate/transform the reflection.
  21365. * @returns the reflection matrix
  21366. */
  21367. getReflectionTextureMatrix(): Matrix;
  21368. /**
  21369. * Resize the texture to a new desired size.
  21370. * Be carrefull as it will recreate all the data in the new texture.
  21371. * @param size Define the new size. It can be:
  21372. * - a number for squared texture,
  21373. * - an object containing { width: number, height: number }
  21374. * - or an object containing a ratio { ratio: number }
  21375. */
  21376. resize(size: number | {
  21377. width: number;
  21378. height: number;
  21379. } | {
  21380. ratio: number;
  21381. }): void;
  21382. private _defaultRenderListPrepared;
  21383. /**
  21384. * Renders all the objects from the render list into the texture.
  21385. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21386. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21387. */
  21388. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21389. private _bestReflectionRenderTargetDimension;
  21390. private _prepareRenderingManager;
  21391. /**
  21392. * @hidden
  21393. * @param faceIndex face index to bind to if this is a cubetexture
  21394. * @param layer defines the index of the texture to bind in the array
  21395. */
  21396. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21397. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21398. private renderToTarget;
  21399. /**
  21400. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21401. * This allowed control for front to back rendering or reversly depending of the special needs.
  21402. *
  21403. * @param renderingGroupId The rendering group id corresponding to its index
  21404. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21405. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21406. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21407. */
  21408. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  21409. /**
  21410. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21411. *
  21412. * @param renderingGroupId The rendering group id corresponding to its index
  21413. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21414. */
  21415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21416. /**
  21417. * Clones the texture.
  21418. * @returns the cloned texture
  21419. */
  21420. clone(): RenderTargetTexture;
  21421. /**
  21422. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21423. * @returns The JSON representation of the texture
  21424. */
  21425. serialize(): any;
  21426. /**
  21427. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21428. */
  21429. disposeFramebufferObjects(): void;
  21430. /**
  21431. * Dispose the texture and release its associated resources.
  21432. */
  21433. dispose(): void;
  21434. /** @hidden */
  21435. _rebuild(): void;
  21436. /**
  21437. * Clear the info related to rendering groups preventing retention point in material dispose.
  21438. */
  21439. freeRenderingGroups(): void;
  21440. /**
  21441. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21442. * @returns the view count
  21443. */
  21444. getViewCount(): number;
  21445. }
  21446. }
  21447. declare module "babylonjs/Materials/material" {
  21448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21449. import { SmartArray } from "babylonjs/Misc/smartArray";
  21450. import { Observable } from "babylonjs/Misc/observable";
  21451. import { Nullable } from "babylonjs/types";
  21452. import { Scene } from "babylonjs/scene";
  21453. import { Matrix } from "babylonjs/Maths/math.vector";
  21454. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21456. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21457. import { Effect } from "babylonjs/Materials/effect";
  21458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21460. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21461. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21462. import { Mesh } from "babylonjs/Meshes/mesh";
  21463. import { Animation } from "babylonjs/Animations/animation";
  21464. /**
  21465. * Options for compiling materials.
  21466. */
  21467. export interface IMaterialCompilationOptions {
  21468. /**
  21469. * Defines whether clip planes are enabled.
  21470. */
  21471. clipPlane: boolean;
  21472. /**
  21473. * Defines whether instances are enabled.
  21474. */
  21475. useInstances: boolean;
  21476. }
  21477. /**
  21478. * Base class for the main features of a material in Babylon.js
  21479. */
  21480. export class Material implements IAnimatable {
  21481. /**
  21482. * Returns the triangle fill mode
  21483. */
  21484. static readonly TriangleFillMode: number;
  21485. /**
  21486. * Returns the wireframe mode
  21487. */
  21488. static readonly WireFrameFillMode: number;
  21489. /**
  21490. * Returns the point fill mode
  21491. */
  21492. static readonly PointFillMode: number;
  21493. /**
  21494. * Returns the point list draw mode
  21495. */
  21496. static readonly PointListDrawMode: number;
  21497. /**
  21498. * Returns the line list draw mode
  21499. */
  21500. static readonly LineListDrawMode: number;
  21501. /**
  21502. * Returns the line loop draw mode
  21503. */
  21504. static readonly LineLoopDrawMode: number;
  21505. /**
  21506. * Returns the line strip draw mode
  21507. */
  21508. static readonly LineStripDrawMode: number;
  21509. /**
  21510. * Returns the triangle strip draw mode
  21511. */
  21512. static readonly TriangleStripDrawMode: number;
  21513. /**
  21514. * Returns the triangle fan draw mode
  21515. */
  21516. static readonly TriangleFanDrawMode: number;
  21517. /**
  21518. * Stores the clock-wise side orientation
  21519. */
  21520. static readonly ClockWiseSideOrientation: number;
  21521. /**
  21522. * Stores the counter clock-wise side orientation
  21523. */
  21524. static readonly CounterClockWiseSideOrientation: number;
  21525. /**
  21526. * The dirty texture flag value
  21527. */
  21528. static readonly TextureDirtyFlag: number;
  21529. /**
  21530. * The dirty light flag value
  21531. */
  21532. static readonly LightDirtyFlag: number;
  21533. /**
  21534. * The dirty fresnel flag value
  21535. */
  21536. static readonly FresnelDirtyFlag: number;
  21537. /**
  21538. * The dirty attribute flag value
  21539. */
  21540. static readonly AttributesDirtyFlag: number;
  21541. /**
  21542. * The dirty misc flag value
  21543. */
  21544. static readonly MiscDirtyFlag: number;
  21545. /**
  21546. * The all dirty flag value
  21547. */
  21548. static readonly AllDirtyFlag: number;
  21549. /**
  21550. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21551. */
  21552. static readonly MATERIAL_OPAQUE: number;
  21553. /**
  21554. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21555. */
  21556. static readonly MATERIAL_ALPHATEST: number;
  21557. /**
  21558. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21559. */
  21560. static readonly MATERIAL_ALPHABLEND: number;
  21561. /**
  21562. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21563. * They are also discarded below the alpha cutoff threshold to improve performances.
  21564. */
  21565. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21566. /**
  21567. * The ID of the material
  21568. */
  21569. id: string;
  21570. /**
  21571. * Gets or sets the unique id of the material
  21572. */
  21573. uniqueId: number;
  21574. /**
  21575. * The name of the material
  21576. */
  21577. name: string;
  21578. /**
  21579. * Gets or sets user defined metadata
  21580. */
  21581. metadata: any;
  21582. /**
  21583. * For internal use only. Please do not use.
  21584. */
  21585. reservedDataStore: any;
  21586. /**
  21587. * Specifies if the ready state should be checked on each call
  21588. */
  21589. checkReadyOnEveryCall: boolean;
  21590. /**
  21591. * Specifies if the ready state should be checked once
  21592. */
  21593. checkReadyOnlyOnce: boolean;
  21594. /**
  21595. * The state of the material
  21596. */
  21597. state: string;
  21598. /**
  21599. * The alpha value of the material
  21600. */
  21601. protected _alpha: number;
  21602. /**
  21603. * List of inspectable custom properties (used by the Inspector)
  21604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21605. */
  21606. inspectableCustomProperties: IInspectable[];
  21607. /**
  21608. * Sets the alpha value of the material
  21609. */
  21610. set alpha(value: number);
  21611. /**
  21612. * Gets the alpha value of the material
  21613. */
  21614. get alpha(): number;
  21615. /**
  21616. * Specifies if back face culling is enabled
  21617. */
  21618. protected _backFaceCulling: boolean;
  21619. /**
  21620. * Sets the back-face culling state
  21621. */
  21622. set backFaceCulling(value: boolean);
  21623. /**
  21624. * Gets the back-face culling state
  21625. */
  21626. get backFaceCulling(): boolean;
  21627. /**
  21628. * Stores the value for side orientation
  21629. */
  21630. sideOrientation: number;
  21631. /**
  21632. * Callback triggered when the material is compiled
  21633. */
  21634. onCompiled: Nullable<(effect: Effect) => void>;
  21635. /**
  21636. * Callback triggered when an error occurs
  21637. */
  21638. onError: Nullable<(effect: Effect, errors: string) => void>;
  21639. /**
  21640. * Callback triggered to get the render target textures
  21641. */
  21642. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21643. /**
  21644. * Gets a boolean indicating that current material needs to register RTT
  21645. */
  21646. get hasRenderTargetTextures(): boolean;
  21647. /**
  21648. * Specifies if the material should be serialized
  21649. */
  21650. doNotSerialize: boolean;
  21651. /**
  21652. * @hidden
  21653. */
  21654. _storeEffectOnSubMeshes: boolean;
  21655. /**
  21656. * Stores the animations for the material
  21657. */
  21658. animations: Nullable<Array<Animation>>;
  21659. /**
  21660. * An event triggered when the material is disposed
  21661. */
  21662. onDisposeObservable: Observable<Material>;
  21663. /**
  21664. * An observer which watches for dispose events
  21665. */
  21666. private _onDisposeObserver;
  21667. private _onUnBindObservable;
  21668. /**
  21669. * Called during a dispose event
  21670. */
  21671. set onDispose(callback: () => void);
  21672. private _onBindObservable;
  21673. /**
  21674. * An event triggered when the material is bound
  21675. */
  21676. get onBindObservable(): Observable<AbstractMesh>;
  21677. /**
  21678. * An observer which watches for bind events
  21679. */
  21680. private _onBindObserver;
  21681. /**
  21682. * Called during a bind event
  21683. */
  21684. set onBind(callback: (Mesh: AbstractMesh) => void);
  21685. /**
  21686. * An event triggered when the material is unbound
  21687. */
  21688. get onUnBindObservable(): Observable<Material>;
  21689. /**
  21690. * Stores the value of the alpha mode
  21691. */
  21692. private _alphaMode;
  21693. /**
  21694. * Sets the value of the alpha mode.
  21695. *
  21696. * | Value | Type | Description |
  21697. * | --- | --- | --- |
  21698. * | 0 | ALPHA_DISABLE | |
  21699. * | 1 | ALPHA_ADD | |
  21700. * | 2 | ALPHA_COMBINE | |
  21701. * | 3 | ALPHA_SUBTRACT | |
  21702. * | 4 | ALPHA_MULTIPLY | |
  21703. * | 5 | ALPHA_MAXIMIZED | |
  21704. * | 6 | ALPHA_ONEONE | |
  21705. * | 7 | ALPHA_PREMULTIPLIED | |
  21706. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21707. * | 9 | ALPHA_INTERPOLATE | |
  21708. * | 10 | ALPHA_SCREENMODE | |
  21709. *
  21710. */
  21711. set alphaMode(value: number);
  21712. /**
  21713. * Gets the value of the alpha mode
  21714. */
  21715. get alphaMode(): number;
  21716. /**
  21717. * Stores the state of the need depth pre-pass value
  21718. */
  21719. private _needDepthPrePass;
  21720. /**
  21721. * Sets the need depth pre-pass value
  21722. */
  21723. set needDepthPrePass(value: boolean);
  21724. /**
  21725. * Gets the depth pre-pass value
  21726. */
  21727. get needDepthPrePass(): boolean;
  21728. /**
  21729. * Specifies if depth writing should be disabled
  21730. */
  21731. disableDepthWrite: boolean;
  21732. /**
  21733. * Specifies if depth writing should be forced
  21734. */
  21735. forceDepthWrite: boolean;
  21736. /**
  21737. * Specifies the depth function that should be used. 0 means the default engine function
  21738. */
  21739. depthFunction: number;
  21740. /**
  21741. * Specifies if there should be a separate pass for culling
  21742. */
  21743. separateCullingPass: boolean;
  21744. /**
  21745. * Stores the state specifing if fog should be enabled
  21746. */
  21747. private _fogEnabled;
  21748. /**
  21749. * Sets the state for enabling fog
  21750. */
  21751. set fogEnabled(value: boolean);
  21752. /**
  21753. * Gets the value of the fog enabled state
  21754. */
  21755. get fogEnabled(): boolean;
  21756. /**
  21757. * Stores the size of points
  21758. */
  21759. pointSize: number;
  21760. /**
  21761. * Stores the z offset value
  21762. */
  21763. zOffset: number;
  21764. /**
  21765. * Gets a value specifying if wireframe mode is enabled
  21766. */
  21767. get wireframe(): boolean;
  21768. /**
  21769. * Sets the state of wireframe mode
  21770. */
  21771. set wireframe(value: boolean);
  21772. /**
  21773. * Gets the value specifying if point clouds are enabled
  21774. */
  21775. get pointsCloud(): boolean;
  21776. /**
  21777. * Sets the state of point cloud mode
  21778. */
  21779. set pointsCloud(value: boolean);
  21780. /**
  21781. * Gets the material fill mode
  21782. */
  21783. get fillMode(): number;
  21784. /**
  21785. * Sets the material fill mode
  21786. */
  21787. set fillMode(value: number);
  21788. /**
  21789. * @hidden
  21790. * Stores the effects for the material
  21791. */
  21792. _effect: Nullable<Effect>;
  21793. /**
  21794. * Specifies if uniform buffers should be used
  21795. */
  21796. private _useUBO;
  21797. /**
  21798. * Stores a reference to the scene
  21799. */
  21800. private _scene;
  21801. /**
  21802. * Stores the fill mode state
  21803. */
  21804. private _fillMode;
  21805. /**
  21806. * Specifies if the depth write state should be cached
  21807. */
  21808. private _cachedDepthWriteState;
  21809. /**
  21810. * Specifies if the depth function state should be cached
  21811. */
  21812. private _cachedDepthFunctionState;
  21813. /**
  21814. * Stores the uniform buffer
  21815. */
  21816. protected _uniformBuffer: UniformBuffer;
  21817. /** @hidden */
  21818. _indexInSceneMaterialArray: number;
  21819. /** @hidden */
  21820. meshMap: Nullable<{
  21821. [id: string]: AbstractMesh | undefined;
  21822. }>;
  21823. /**
  21824. * Creates a material instance
  21825. * @param name defines the name of the material
  21826. * @param scene defines the scene to reference
  21827. * @param doNotAdd specifies if the material should be added to the scene
  21828. */
  21829. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21830. /**
  21831. * Returns a string representation of the current material
  21832. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21833. * @returns a string with material information
  21834. */
  21835. toString(fullDetails?: boolean): string;
  21836. /**
  21837. * Gets the class name of the material
  21838. * @returns a string with the class name of the material
  21839. */
  21840. getClassName(): string;
  21841. /**
  21842. * Specifies if updates for the material been locked
  21843. */
  21844. get isFrozen(): boolean;
  21845. /**
  21846. * Locks updates for the material
  21847. */
  21848. freeze(): void;
  21849. /**
  21850. * Unlocks updates for the material
  21851. */
  21852. unfreeze(): void;
  21853. /**
  21854. * Specifies if the material is ready to be used
  21855. * @param mesh defines the mesh to check
  21856. * @param useInstances specifies if instances should be used
  21857. * @returns a boolean indicating if the material is ready to be used
  21858. */
  21859. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21860. /**
  21861. * Specifies that the submesh is ready to be used
  21862. * @param mesh defines the mesh to check
  21863. * @param subMesh defines which submesh to check
  21864. * @param useInstances specifies that instances should be used
  21865. * @returns a boolean indicating that the submesh is ready or not
  21866. */
  21867. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21868. /**
  21869. * Returns the material effect
  21870. * @returns the effect associated with the material
  21871. */
  21872. getEffect(): Nullable<Effect>;
  21873. /**
  21874. * Returns the current scene
  21875. * @returns a Scene
  21876. */
  21877. getScene(): Scene;
  21878. /**
  21879. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21880. */
  21881. protected _forceAlphaTest: boolean;
  21882. /**
  21883. * The transparency mode of the material.
  21884. */
  21885. protected _transparencyMode: Nullable<number>;
  21886. /**
  21887. * Gets the current transparency mode.
  21888. */
  21889. get transparencyMode(): Nullable<number>;
  21890. /**
  21891. * Sets the transparency mode of the material.
  21892. *
  21893. * | Value | Type | Description |
  21894. * | ----- | ----------------------------------- | ----------- |
  21895. * | 0 | OPAQUE | |
  21896. * | 1 | ALPHATEST | |
  21897. * | 2 | ALPHABLEND | |
  21898. * | 3 | ALPHATESTANDBLEND | |
  21899. *
  21900. */
  21901. set transparencyMode(value: Nullable<number>);
  21902. /**
  21903. * Returns true if alpha blending should be disabled.
  21904. */
  21905. protected get _disableAlphaBlending(): boolean;
  21906. /**
  21907. * Specifies whether or not this material should be rendered in alpha blend mode.
  21908. * @returns a boolean specifying if alpha blending is needed
  21909. */
  21910. needAlphaBlending(): boolean;
  21911. /**
  21912. * Specifies if the mesh will require alpha blending
  21913. * @param mesh defines the mesh to check
  21914. * @returns a boolean specifying if alpha blending is needed for the mesh
  21915. */
  21916. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21917. /**
  21918. * Specifies whether or not this material should be rendered in alpha test mode.
  21919. * @returns a boolean specifying if an alpha test is needed.
  21920. */
  21921. needAlphaTesting(): boolean;
  21922. /**
  21923. * Specifies if material alpha testing should be turned on for the mesh
  21924. * @param mesh defines the mesh to check
  21925. */
  21926. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21927. /**
  21928. * Gets the texture used for the alpha test
  21929. * @returns the texture to use for alpha testing
  21930. */
  21931. getAlphaTestTexture(): Nullable<BaseTexture>;
  21932. /**
  21933. * Marks the material to indicate that it needs to be re-calculated
  21934. */
  21935. markDirty(): void;
  21936. /** @hidden */
  21937. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21938. /**
  21939. * Binds the material to the mesh
  21940. * @param world defines the world transformation matrix
  21941. * @param mesh defines the mesh to bind the material to
  21942. */
  21943. bind(world: Matrix, mesh?: Mesh): void;
  21944. /**
  21945. * Binds the submesh to the material
  21946. * @param world defines the world transformation matrix
  21947. * @param mesh defines the mesh containing the submesh
  21948. * @param subMesh defines the submesh to bind the material to
  21949. */
  21950. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21951. /**
  21952. * Binds the world matrix to the material
  21953. * @param world defines the world transformation matrix
  21954. */
  21955. bindOnlyWorldMatrix(world: Matrix): void;
  21956. /**
  21957. * Binds the scene's uniform buffer to the effect.
  21958. * @param effect defines the effect to bind to the scene uniform buffer
  21959. * @param sceneUbo defines the uniform buffer storing scene data
  21960. */
  21961. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21962. /**
  21963. * Binds the view matrix to the effect
  21964. * @param effect defines the effect to bind the view matrix to
  21965. */
  21966. bindView(effect: Effect): void;
  21967. /**
  21968. * Binds the view projection matrix to the effect
  21969. * @param effect defines the effect to bind the view projection matrix to
  21970. */
  21971. bindViewProjection(effect: Effect): void;
  21972. /**
  21973. * Processes to execute after binding the material to a mesh
  21974. * @param mesh defines the rendered mesh
  21975. */
  21976. protected _afterBind(mesh?: Mesh): void;
  21977. /**
  21978. * Unbinds the material from the mesh
  21979. */
  21980. unbind(): void;
  21981. /**
  21982. * Gets the active textures from the material
  21983. * @returns an array of textures
  21984. */
  21985. getActiveTextures(): BaseTexture[];
  21986. /**
  21987. * Specifies if the material uses a texture
  21988. * @param texture defines the texture to check against the material
  21989. * @returns a boolean specifying if the material uses the texture
  21990. */
  21991. hasTexture(texture: BaseTexture): boolean;
  21992. /**
  21993. * Makes a duplicate of the material, and gives it a new name
  21994. * @param name defines the new name for the duplicated material
  21995. * @returns the cloned material
  21996. */
  21997. clone(name: string): Nullable<Material>;
  21998. /**
  21999. * Gets the meshes bound to the material
  22000. * @returns an array of meshes bound to the material
  22001. */
  22002. getBindedMeshes(): AbstractMesh[];
  22003. /**
  22004. * Force shader compilation
  22005. * @param mesh defines the mesh associated with this material
  22006. * @param onCompiled defines a function to execute once the material is compiled
  22007. * @param options defines the options to configure the compilation
  22008. * @param onError defines a function to execute if the material fails compiling
  22009. */
  22010. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22011. /**
  22012. * Force shader compilation
  22013. * @param mesh defines the mesh that will use this material
  22014. * @param options defines additional options for compiling the shaders
  22015. * @returns a promise that resolves when the compilation completes
  22016. */
  22017. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22018. private static readonly _AllDirtyCallBack;
  22019. private static readonly _ImageProcessingDirtyCallBack;
  22020. private static readonly _TextureDirtyCallBack;
  22021. private static readonly _FresnelDirtyCallBack;
  22022. private static readonly _MiscDirtyCallBack;
  22023. private static readonly _LightsDirtyCallBack;
  22024. private static readonly _AttributeDirtyCallBack;
  22025. private static _FresnelAndMiscDirtyCallBack;
  22026. private static _TextureAndMiscDirtyCallBack;
  22027. private static readonly _DirtyCallbackArray;
  22028. private static readonly _RunDirtyCallBacks;
  22029. /**
  22030. * Marks a define in the material to indicate that it needs to be re-computed
  22031. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22032. */
  22033. markAsDirty(flag: number): void;
  22034. /**
  22035. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22036. * @param func defines a function which checks material defines against the submeshes
  22037. */
  22038. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22039. /**
  22040. * Indicates that we need to re-calculated for all submeshes
  22041. */
  22042. protected _markAllSubMeshesAsAllDirty(): void;
  22043. /**
  22044. * Indicates that image processing needs to be re-calculated for all submeshes
  22045. */
  22046. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22047. /**
  22048. * Indicates that textures need to be re-calculated for all submeshes
  22049. */
  22050. protected _markAllSubMeshesAsTexturesDirty(): void;
  22051. /**
  22052. * Indicates that fresnel needs to be re-calculated for all submeshes
  22053. */
  22054. protected _markAllSubMeshesAsFresnelDirty(): void;
  22055. /**
  22056. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22057. */
  22058. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22059. /**
  22060. * Indicates that lights need to be re-calculated for all submeshes
  22061. */
  22062. protected _markAllSubMeshesAsLightsDirty(): void;
  22063. /**
  22064. * Indicates that attributes need to be re-calculated for all submeshes
  22065. */
  22066. protected _markAllSubMeshesAsAttributesDirty(): void;
  22067. /**
  22068. * Indicates that misc needs to be re-calculated for all submeshes
  22069. */
  22070. protected _markAllSubMeshesAsMiscDirty(): void;
  22071. /**
  22072. * Indicates that textures and misc need to be re-calculated for all submeshes
  22073. */
  22074. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22075. /**
  22076. * Disposes the material
  22077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22079. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22080. */
  22081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22082. /** @hidden */
  22083. private releaseVertexArrayObject;
  22084. /**
  22085. * Serializes this material
  22086. * @returns the serialized material object
  22087. */
  22088. serialize(): any;
  22089. /**
  22090. * Creates a material from parsed material data
  22091. * @param parsedMaterial defines parsed material data
  22092. * @param scene defines the hosting scene
  22093. * @param rootUrl defines the root URL to use to load textures
  22094. * @returns a new material
  22095. */
  22096. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22097. }
  22098. }
  22099. declare module "babylonjs/Materials/multiMaterial" {
  22100. import { Nullable } from "babylonjs/types";
  22101. import { Scene } from "babylonjs/scene";
  22102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22103. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22105. import { Material } from "babylonjs/Materials/material";
  22106. /**
  22107. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22108. * separate meshes. This can be use to improve performances.
  22109. * @see http://doc.babylonjs.com/how_to/multi_materials
  22110. */
  22111. export class MultiMaterial extends Material {
  22112. private _subMaterials;
  22113. /**
  22114. * Gets or Sets the list of Materials used within the multi material.
  22115. * They need to be ordered according to the submeshes order in the associated mesh
  22116. */
  22117. get subMaterials(): Nullable<Material>[];
  22118. set subMaterials(value: Nullable<Material>[]);
  22119. /**
  22120. * Function used to align with Node.getChildren()
  22121. * @returns the list of Materials used within the multi material
  22122. */
  22123. getChildren(): Nullable<Material>[];
  22124. /**
  22125. * Instantiates a new Multi Material
  22126. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22127. * separate meshes. This can be use to improve performances.
  22128. * @see http://doc.babylonjs.com/how_to/multi_materials
  22129. * @param name Define the name in the scene
  22130. * @param scene Define the scene the material belongs to
  22131. */
  22132. constructor(name: string, scene: Scene);
  22133. private _hookArray;
  22134. /**
  22135. * Get one of the submaterial by its index in the submaterials array
  22136. * @param index The index to look the sub material at
  22137. * @returns The Material if the index has been defined
  22138. */
  22139. getSubMaterial(index: number): Nullable<Material>;
  22140. /**
  22141. * Get the list of active textures for the whole sub materials list.
  22142. * @returns All the textures that will be used during the rendering
  22143. */
  22144. getActiveTextures(): BaseTexture[];
  22145. /**
  22146. * Gets the current class name of the material e.g. "MultiMaterial"
  22147. * Mainly use in serialization.
  22148. * @returns the class name
  22149. */
  22150. getClassName(): string;
  22151. /**
  22152. * Checks if the material is ready to render the requested sub mesh
  22153. * @param mesh Define the mesh the submesh belongs to
  22154. * @param subMesh Define the sub mesh to look readyness for
  22155. * @param useInstances Define whether or not the material is used with instances
  22156. * @returns true if ready, otherwise false
  22157. */
  22158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22159. /**
  22160. * Clones the current material and its related sub materials
  22161. * @param name Define the name of the newly cloned material
  22162. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22163. * @returns the cloned material
  22164. */
  22165. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22166. /**
  22167. * Serializes the materials into a JSON representation.
  22168. * @returns the JSON representation
  22169. */
  22170. serialize(): any;
  22171. /**
  22172. * Dispose the material and release its associated resources
  22173. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  22174. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  22175. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  22176. */
  22177. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22178. /**
  22179. * Creates a MultiMaterial from parsed MultiMaterial data.
  22180. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22181. * @param scene defines the hosting scene
  22182. * @returns a new MultiMaterial
  22183. */
  22184. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22185. }
  22186. }
  22187. declare module "babylonjs/Meshes/subMesh" {
  22188. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22190. import { Engine } from "babylonjs/Engines/engine";
  22191. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22192. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22193. import { Effect } from "babylonjs/Materials/effect";
  22194. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22195. import { Plane } from "babylonjs/Maths/math.plane";
  22196. import { Collider } from "babylonjs/Collisions/collider";
  22197. import { Material } from "babylonjs/Materials/material";
  22198. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22200. import { Mesh } from "babylonjs/Meshes/mesh";
  22201. import { Ray } from "babylonjs/Culling/ray";
  22202. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22203. /**
  22204. * Base class for submeshes
  22205. */
  22206. export class BaseSubMesh {
  22207. /** @hidden */
  22208. _materialDefines: Nullable<MaterialDefines>;
  22209. /** @hidden */
  22210. _materialEffect: Nullable<Effect>;
  22211. /**
  22212. * Gets material defines used by the effect associated to the sub mesh
  22213. */
  22214. get materialDefines(): Nullable<MaterialDefines>;
  22215. /**
  22216. * Sets material defines used by the effect associated to the sub mesh
  22217. */
  22218. set materialDefines(defines: Nullable<MaterialDefines>);
  22219. /**
  22220. * Gets associated effect
  22221. */
  22222. get effect(): Nullable<Effect>;
  22223. /**
  22224. * Sets associated effect (effect used to render this submesh)
  22225. * @param effect defines the effect to associate with
  22226. * @param defines defines the set of defines used to compile this effect
  22227. */
  22228. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22229. }
  22230. /**
  22231. * Defines a subdivision inside a mesh
  22232. */
  22233. export class SubMesh extends BaseSubMesh implements ICullable {
  22234. /** the material index to use */
  22235. materialIndex: number;
  22236. /** vertex index start */
  22237. verticesStart: number;
  22238. /** vertices count */
  22239. verticesCount: number;
  22240. /** index start */
  22241. indexStart: number;
  22242. /** indices count */
  22243. indexCount: number;
  22244. /** @hidden */
  22245. _linesIndexCount: number;
  22246. private _mesh;
  22247. private _renderingMesh;
  22248. private _boundingInfo;
  22249. private _linesIndexBuffer;
  22250. /** @hidden */
  22251. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22252. /** @hidden */
  22253. _trianglePlanes: Plane[];
  22254. /** @hidden */
  22255. _lastColliderTransformMatrix: Nullable<Matrix>;
  22256. /** @hidden */
  22257. _renderId: number;
  22258. /** @hidden */
  22259. _alphaIndex: number;
  22260. /** @hidden */
  22261. _distanceToCamera: number;
  22262. /** @hidden */
  22263. _id: number;
  22264. private _currentMaterial;
  22265. /**
  22266. * Add a new submesh to a mesh
  22267. * @param materialIndex defines the material index to use
  22268. * @param verticesStart defines vertex index start
  22269. * @param verticesCount defines vertices count
  22270. * @param indexStart defines index start
  22271. * @param indexCount defines indices count
  22272. * @param mesh defines the parent mesh
  22273. * @param renderingMesh defines an optional rendering mesh
  22274. * @param createBoundingBox defines if bounding box should be created for this submesh
  22275. * @returns the new submesh
  22276. */
  22277. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22278. /**
  22279. * Creates a new submesh
  22280. * @param materialIndex defines the material index to use
  22281. * @param verticesStart defines vertex index start
  22282. * @param verticesCount defines vertices count
  22283. * @param indexStart defines index start
  22284. * @param indexCount defines indices count
  22285. * @param mesh defines the parent mesh
  22286. * @param renderingMesh defines an optional rendering mesh
  22287. * @param createBoundingBox defines if bounding box should be created for this submesh
  22288. */
  22289. constructor(
  22290. /** the material index to use */
  22291. materialIndex: number,
  22292. /** vertex index start */
  22293. verticesStart: number,
  22294. /** vertices count */
  22295. verticesCount: number,
  22296. /** index start */
  22297. indexStart: number,
  22298. /** indices count */
  22299. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22300. /**
  22301. * Returns true if this submesh covers the entire parent mesh
  22302. * @ignorenaming
  22303. */
  22304. get IsGlobal(): boolean;
  22305. /**
  22306. * Returns the submesh BoudingInfo object
  22307. * @returns current bounding info (or mesh's one if the submesh is global)
  22308. */
  22309. getBoundingInfo(): BoundingInfo;
  22310. /**
  22311. * Sets the submesh BoundingInfo
  22312. * @param boundingInfo defines the new bounding info to use
  22313. * @returns the SubMesh
  22314. */
  22315. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22316. /**
  22317. * Returns the mesh of the current submesh
  22318. * @return the parent mesh
  22319. */
  22320. getMesh(): AbstractMesh;
  22321. /**
  22322. * Returns the rendering mesh of the submesh
  22323. * @returns the rendering mesh (could be different from parent mesh)
  22324. */
  22325. getRenderingMesh(): Mesh;
  22326. /**
  22327. * Returns the submesh material
  22328. * @returns null or the current material
  22329. */
  22330. getMaterial(): Nullable<Material>;
  22331. /**
  22332. * Sets a new updated BoundingInfo object to the submesh
  22333. * @param data defines an optional position array to use to determine the bounding info
  22334. * @returns the SubMesh
  22335. */
  22336. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22337. /** @hidden */
  22338. _checkCollision(collider: Collider): boolean;
  22339. /**
  22340. * Updates the submesh BoundingInfo
  22341. * @param world defines the world matrix to use to update the bounding info
  22342. * @returns the submesh
  22343. */
  22344. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22345. /**
  22346. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22347. * @param frustumPlanes defines the frustum planes
  22348. * @returns true if the submesh is intersecting with the frustum
  22349. */
  22350. isInFrustum(frustumPlanes: Plane[]): boolean;
  22351. /**
  22352. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22353. * @param frustumPlanes defines the frustum planes
  22354. * @returns true if the submesh is inside the frustum
  22355. */
  22356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22357. /**
  22358. * Renders the submesh
  22359. * @param enableAlphaMode defines if alpha needs to be used
  22360. * @returns the submesh
  22361. */
  22362. render(enableAlphaMode: boolean): SubMesh;
  22363. /**
  22364. * @hidden
  22365. */
  22366. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22367. /**
  22368. * Checks if the submesh intersects with a ray
  22369. * @param ray defines the ray to test
  22370. * @returns true is the passed ray intersects the submesh bounding box
  22371. */
  22372. canIntersects(ray: Ray): boolean;
  22373. /**
  22374. * Intersects current submesh with a ray
  22375. * @param ray defines the ray to test
  22376. * @param positions defines mesh's positions array
  22377. * @param indices defines mesh's indices array
  22378. * @param fastCheck defines if only bounding info should be used
  22379. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22380. * @returns intersection info or null if no intersection
  22381. */
  22382. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22383. /** @hidden */
  22384. private _intersectLines;
  22385. /** @hidden */
  22386. private _intersectUnIndexedLines;
  22387. /** @hidden */
  22388. private _intersectTriangles;
  22389. /** @hidden */
  22390. private _intersectUnIndexedTriangles;
  22391. /** @hidden */
  22392. _rebuild(): void;
  22393. /**
  22394. * Creates a new submesh from the passed mesh
  22395. * @param newMesh defines the new hosting mesh
  22396. * @param newRenderingMesh defines an optional rendering mesh
  22397. * @returns the new submesh
  22398. */
  22399. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22400. /**
  22401. * Release associated resources
  22402. */
  22403. dispose(): void;
  22404. /**
  22405. * Gets the class name
  22406. * @returns the string "SubMesh".
  22407. */
  22408. getClassName(): string;
  22409. /**
  22410. * Creates a new submesh from indices data
  22411. * @param materialIndex the index of the main mesh material
  22412. * @param startIndex the index where to start the copy in the mesh indices array
  22413. * @param indexCount the number of indices to copy then from the startIndex
  22414. * @param mesh the main mesh to create the submesh from
  22415. * @param renderingMesh the optional rendering mesh
  22416. * @returns a new submesh
  22417. */
  22418. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22419. }
  22420. }
  22421. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22422. /**
  22423. * Class used to represent data loading progression
  22424. */
  22425. export class SceneLoaderFlags {
  22426. private static _ForceFullSceneLoadingForIncremental;
  22427. private static _ShowLoadingScreen;
  22428. private static _CleanBoneMatrixWeights;
  22429. private static _loggingLevel;
  22430. /**
  22431. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22432. */
  22433. static get ForceFullSceneLoadingForIncremental(): boolean;
  22434. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22435. /**
  22436. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22437. */
  22438. static get ShowLoadingScreen(): boolean;
  22439. static set ShowLoadingScreen(value: boolean);
  22440. /**
  22441. * Defines the current logging level (while loading the scene)
  22442. * @ignorenaming
  22443. */
  22444. static get loggingLevel(): number;
  22445. static set loggingLevel(value: number);
  22446. /**
  22447. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22448. */
  22449. static get CleanBoneMatrixWeights(): boolean;
  22450. static set CleanBoneMatrixWeights(value: boolean);
  22451. }
  22452. }
  22453. declare module "babylonjs/Meshes/geometry" {
  22454. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22455. import { Scene } from "babylonjs/scene";
  22456. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22457. import { Engine } from "babylonjs/Engines/engine";
  22458. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22459. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22460. import { Effect } from "babylonjs/Materials/effect";
  22461. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22462. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22463. import { Mesh } from "babylonjs/Meshes/mesh";
  22464. /**
  22465. * Class used to store geometry data (vertex buffers + index buffer)
  22466. */
  22467. export class Geometry implements IGetSetVerticesData {
  22468. /**
  22469. * Gets or sets the ID of the geometry
  22470. */
  22471. id: string;
  22472. /**
  22473. * Gets or sets the unique ID of the geometry
  22474. */
  22475. uniqueId: number;
  22476. /**
  22477. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22478. */
  22479. delayLoadState: number;
  22480. /**
  22481. * Gets the file containing the data to load when running in delay load state
  22482. */
  22483. delayLoadingFile: Nullable<string>;
  22484. /**
  22485. * Callback called when the geometry is updated
  22486. */
  22487. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22488. private _scene;
  22489. private _engine;
  22490. private _meshes;
  22491. private _totalVertices;
  22492. /** @hidden */
  22493. _indices: IndicesArray;
  22494. /** @hidden */
  22495. _vertexBuffers: {
  22496. [key: string]: VertexBuffer;
  22497. };
  22498. private _isDisposed;
  22499. private _extend;
  22500. private _boundingBias;
  22501. /** @hidden */
  22502. _delayInfo: Array<string>;
  22503. private _indexBuffer;
  22504. private _indexBufferIsUpdatable;
  22505. /** @hidden */
  22506. _boundingInfo: Nullable<BoundingInfo>;
  22507. /** @hidden */
  22508. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22509. /** @hidden */
  22510. _softwareSkinningFrameId: number;
  22511. private _vertexArrayObjects;
  22512. private _updatable;
  22513. /** @hidden */
  22514. _positions: Nullable<Vector3[]>;
  22515. /**
  22516. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22517. */
  22518. get boundingBias(): Vector2;
  22519. /**
  22520. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22521. */
  22522. set boundingBias(value: Vector2);
  22523. /**
  22524. * Static function used to attach a new empty geometry to a mesh
  22525. * @param mesh defines the mesh to attach the geometry to
  22526. * @returns the new Geometry
  22527. */
  22528. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22529. /**
  22530. * Creates a new geometry
  22531. * @param id defines the unique ID
  22532. * @param scene defines the hosting scene
  22533. * @param vertexData defines the VertexData used to get geometry data
  22534. * @param updatable defines if geometry must be updatable (false by default)
  22535. * @param mesh defines the mesh that will be associated with the geometry
  22536. */
  22537. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22538. /**
  22539. * Gets the current extend of the geometry
  22540. */
  22541. get extend(): {
  22542. minimum: Vector3;
  22543. maximum: Vector3;
  22544. };
  22545. /**
  22546. * Gets the hosting scene
  22547. * @returns the hosting Scene
  22548. */
  22549. getScene(): Scene;
  22550. /**
  22551. * Gets the hosting engine
  22552. * @returns the hosting Engine
  22553. */
  22554. getEngine(): Engine;
  22555. /**
  22556. * Defines if the geometry is ready to use
  22557. * @returns true if the geometry is ready to be used
  22558. */
  22559. isReady(): boolean;
  22560. /**
  22561. * Gets a value indicating that the geometry should not be serialized
  22562. */
  22563. get doNotSerialize(): boolean;
  22564. /** @hidden */
  22565. _rebuild(): void;
  22566. /**
  22567. * Affects all geometry data in one call
  22568. * @param vertexData defines the geometry data
  22569. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22570. */
  22571. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22572. /**
  22573. * Set specific vertex data
  22574. * @param kind defines the data kind (Position, normal, etc...)
  22575. * @param data defines the vertex data to use
  22576. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22577. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22578. */
  22579. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22580. /**
  22581. * Removes a specific vertex data
  22582. * @param kind defines the data kind (Position, normal, etc...)
  22583. */
  22584. removeVerticesData(kind: string): void;
  22585. /**
  22586. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22587. * @param buffer defines the vertex buffer to use
  22588. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22589. */
  22590. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22591. /**
  22592. * Update a specific vertex buffer
  22593. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22594. * It will do nothing if the buffer is not updatable
  22595. * @param kind defines the data kind (Position, normal, etc...)
  22596. * @param data defines the data to use
  22597. * @param offset defines the offset in the target buffer where to store the data
  22598. * @param useBytes set to true if the offset is in bytes
  22599. */
  22600. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22601. /**
  22602. * Update a specific vertex buffer
  22603. * This function will create a new buffer if the current one is not updatable
  22604. * @param kind defines the data kind (Position, normal, etc...)
  22605. * @param data defines the data to use
  22606. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22607. */
  22608. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22609. private _updateBoundingInfo;
  22610. /** @hidden */
  22611. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22612. /**
  22613. * Gets total number of vertices
  22614. * @returns the total number of vertices
  22615. */
  22616. getTotalVertices(): number;
  22617. /**
  22618. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22619. * @param kind defines the data kind (Position, normal, etc...)
  22620. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22621. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22622. * @returns a float array containing vertex data
  22623. */
  22624. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22625. /**
  22626. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22627. * @param kind defines the data kind (Position, normal, etc...)
  22628. * @returns true if the vertex buffer with the specified kind is updatable
  22629. */
  22630. isVertexBufferUpdatable(kind: string): boolean;
  22631. /**
  22632. * Gets a specific vertex buffer
  22633. * @param kind defines the data kind (Position, normal, etc...)
  22634. * @returns a VertexBuffer
  22635. */
  22636. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22637. /**
  22638. * Returns all vertex buffers
  22639. * @return an object holding all vertex buffers indexed by kind
  22640. */
  22641. getVertexBuffers(): Nullable<{
  22642. [key: string]: VertexBuffer;
  22643. }>;
  22644. /**
  22645. * Gets a boolean indicating if specific vertex buffer is present
  22646. * @param kind defines the data kind (Position, normal, etc...)
  22647. * @returns true if data is present
  22648. */
  22649. isVerticesDataPresent(kind: string): boolean;
  22650. /**
  22651. * Gets a list of all attached data kinds (Position, normal, etc...)
  22652. * @returns a list of string containing all kinds
  22653. */
  22654. getVerticesDataKinds(): string[];
  22655. /**
  22656. * Update index buffer
  22657. * @param indices defines the indices to store in the index buffer
  22658. * @param offset defines the offset in the target buffer where to store the data
  22659. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22660. */
  22661. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22662. /**
  22663. * Creates a new index buffer
  22664. * @param indices defines the indices to store in the index buffer
  22665. * @param totalVertices defines the total number of vertices (could be null)
  22666. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22667. */
  22668. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22669. /**
  22670. * Return the total number of indices
  22671. * @returns the total number of indices
  22672. */
  22673. getTotalIndices(): number;
  22674. /**
  22675. * Gets the index buffer array
  22676. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22678. * @returns the index buffer array
  22679. */
  22680. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22681. /**
  22682. * Gets the index buffer
  22683. * @return the index buffer
  22684. */
  22685. getIndexBuffer(): Nullable<DataBuffer>;
  22686. /** @hidden */
  22687. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22688. /**
  22689. * Release the associated resources for a specific mesh
  22690. * @param mesh defines the source mesh
  22691. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22692. */
  22693. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22694. /**
  22695. * Apply current geometry to a given mesh
  22696. * @param mesh defines the mesh to apply geometry to
  22697. */
  22698. applyToMesh(mesh: Mesh): void;
  22699. private _updateExtend;
  22700. private _applyToMesh;
  22701. private notifyUpdate;
  22702. /**
  22703. * Load the geometry if it was flagged as delay loaded
  22704. * @param scene defines the hosting scene
  22705. * @param onLoaded defines a callback called when the geometry is loaded
  22706. */
  22707. load(scene: Scene, onLoaded?: () => void): void;
  22708. private _queueLoad;
  22709. /**
  22710. * Invert the geometry to move from a right handed system to a left handed one.
  22711. */
  22712. toLeftHanded(): void;
  22713. /** @hidden */
  22714. _resetPointsArrayCache(): void;
  22715. /** @hidden */
  22716. _generatePointsArray(): boolean;
  22717. /**
  22718. * Gets a value indicating if the geometry is disposed
  22719. * @returns true if the geometry was disposed
  22720. */
  22721. isDisposed(): boolean;
  22722. private _disposeVertexArrayObjects;
  22723. /**
  22724. * Free all associated resources
  22725. */
  22726. dispose(): void;
  22727. /**
  22728. * Clone the current geometry into a new geometry
  22729. * @param id defines the unique ID of the new geometry
  22730. * @returns a new geometry object
  22731. */
  22732. copy(id: string): Geometry;
  22733. /**
  22734. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22735. * @return a JSON representation of the current geometry data (without the vertices data)
  22736. */
  22737. serialize(): any;
  22738. private toNumberArray;
  22739. /**
  22740. * Serialize all vertices data into a JSON oject
  22741. * @returns a JSON representation of the current geometry data
  22742. */
  22743. serializeVerticeData(): any;
  22744. /**
  22745. * Extracts a clone of a mesh geometry
  22746. * @param mesh defines the source mesh
  22747. * @param id defines the unique ID of the new geometry object
  22748. * @returns the new geometry object
  22749. */
  22750. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22751. /**
  22752. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22753. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22754. * Be aware Math.random() could cause collisions, but:
  22755. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  22756. * @returns a string containing a new GUID
  22757. */
  22758. static RandomId(): string;
  22759. /** @hidden */
  22760. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22761. private static _CleanMatricesWeights;
  22762. /**
  22763. * Create a new geometry from persisted data (Using .babylon file format)
  22764. * @param parsedVertexData defines the persisted data
  22765. * @param scene defines the hosting scene
  22766. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22767. * @returns the new geometry object
  22768. */
  22769. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22770. }
  22771. }
  22772. declare module "babylonjs/Meshes/mesh.vertexData" {
  22773. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22774. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22775. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22776. import { Geometry } from "babylonjs/Meshes/geometry";
  22777. import { Mesh } from "babylonjs/Meshes/mesh";
  22778. /**
  22779. * Define an interface for all classes that will get and set the data on vertices
  22780. */
  22781. export interface IGetSetVerticesData {
  22782. /**
  22783. * Gets a boolean indicating if specific vertex data is present
  22784. * @param kind defines the vertex data kind to use
  22785. * @returns true is data kind is present
  22786. */
  22787. isVerticesDataPresent(kind: string): boolean;
  22788. /**
  22789. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22790. * @param kind defines the data kind (Position, normal, etc...)
  22791. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22792. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22793. * @returns a float array containing vertex data
  22794. */
  22795. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22796. /**
  22797. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22798. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22799. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22800. * @returns the indices array or an empty array if the mesh has no geometry
  22801. */
  22802. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22803. /**
  22804. * Set specific vertex data
  22805. * @param kind defines the data kind (Position, normal, etc...)
  22806. * @param data defines the vertex data to use
  22807. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22808. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22809. */
  22810. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22811. /**
  22812. * Update a specific associated vertex buffer
  22813. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22814. * - VertexBuffer.PositionKind
  22815. * - VertexBuffer.UVKind
  22816. * - VertexBuffer.UV2Kind
  22817. * - VertexBuffer.UV3Kind
  22818. * - VertexBuffer.UV4Kind
  22819. * - VertexBuffer.UV5Kind
  22820. * - VertexBuffer.UV6Kind
  22821. * - VertexBuffer.ColorKind
  22822. * - VertexBuffer.MatricesIndicesKind
  22823. * - VertexBuffer.MatricesIndicesExtraKind
  22824. * - VertexBuffer.MatricesWeightsKind
  22825. * - VertexBuffer.MatricesWeightsExtraKind
  22826. * @param data defines the data source
  22827. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22828. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  22829. */
  22830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22831. /**
  22832. * Creates a new index buffer
  22833. * @param indices defines the indices to store in the index buffer
  22834. * @param totalVertices defines the total number of vertices (could be null)
  22835. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22836. */
  22837. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22838. }
  22839. /**
  22840. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22841. */
  22842. export class VertexData {
  22843. /**
  22844. * Mesh side orientation : usually the external or front surface
  22845. */
  22846. static readonly FRONTSIDE: number;
  22847. /**
  22848. * Mesh side orientation : usually the internal or back surface
  22849. */
  22850. static readonly BACKSIDE: number;
  22851. /**
  22852. * Mesh side orientation : both internal and external or front and back surfaces
  22853. */
  22854. static readonly DOUBLESIDE: number;
  22855. /**
  22856. * Mesh side orientation : by default, `FRONTSIDE`
  22857. */
  22858. static readonly DEFAULTSIDE: number;
  22859. /**
  22860. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22861. */
  22862. positions: Nullable<FloatArray>;
  22863. /**
  22864. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22865. */
  22866. normals: Nullable<FloatArray>;
  22867. /**
  22868. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22869. */
  22870. tangents: Nullable<FloatArray>;
  22871. /**
  22872. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22873. */
  22874. uvs: Nullable<FloatArray>;
  22875. /**
  22876. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22877. */
  22878. uvs2: Nullable<FloatArray>;
  22879. /**
  22880. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22881. */
  22882. uvs3: Nullable<FloatArray>;
  22883. /**
  22884. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22885. */
  22886. uvs4: Nullable<FloatArray>;
  22887. /**
  22888. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22889. */
  22890. uvs5: Nullable<FloatArray>;
  22891. /**
  22892. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22893. */
  22894. uvs6: Nullable<FloatArray>;
  22895. /**
  22896. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22897. */
  22898. colors: Nullable<FloatArray>;
  22899. /**
  22900. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  22901. */
  22902. matricesIndices: Nullable<FloatArray>;
  22903. /**
  22904. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22905. */
  22906. matricesWeights: Nullable<FloatArray>;
  22907. /**
  22908. * An array extending the number of possible indices
  22909. */
  22910. matricesIndicesExtra: Nullable<FloatArray>;
  22911. /**
  22912. * An array extending the number of possible weights when the number of indices is extended
  22913. */
  22914. matricesWeightsExtra: Nullable<FloatArray>;
  22915. /**
  22916. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22917. */
  22918. indices: Nullable<IndicesArray>;
  22919. /**
  22920. * Uses the passed data array to set the set the values for the specified kind of data
  22921. * @param data a linear array of floating numbers
  22922. * @param kind the type of data that is being set, eg positions, colors etc
  22923. */
  22924. set(data: FloatArray, kind: string): void;
  22925. /**
  22926. * Associates the vertexData to the passed Mesh.
  22927. * Sets it as updatable or not (default `false`)
  22928. * @param mesh the mesh the vertexData is applied to
  22929. * @param updatable when used and having the value true allows new data to update the vertexData
  22930. * @returns the VertexData
  22931. */
  22932. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22933. /**
  22934. * Associates the vertexData to the passed Geometry.
  22935. * Sets it as updatable or not (default `false`)
  22936. * @param geometry the geometry the vertexData is applied to
  22937. * @param updatable when used and having the value true allows new data to update the vertexData
  22938. * @returns VertexData
  22939. */
  22940. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22941. /**
  22942. * Updates the associated mesh
  22943. * @param mesh the mesh to be updated
  22944. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22945. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22946. * @returns VertexData
  22947. */
  22948. updateMesh(mesh: Mesh): VertexData;
  22949. /**
  22950. * Updates the associated geometry
  22951. * @param geometry the geometry to be updated
  22952. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22953. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22954. * @returns VertexData.
  22955. */
  22956. updateGeometry(geometry: Geometry): VertexData;
  22957. private _applyTo;
  22958. private _update;
  22959. /**
  22960. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22961. * @param matrix the transforming matrix
  22962. * @returns the VertexData
  22963. */
  22964. transform(matrix: Matrix): VertexData;
  22965. /**
  22966. * Merges the passed VertexData into the current one
  22967. * @param other the VertexData to be merged into the current one
  22968. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22969. * @returns the modified VertexData
  22970. */
  22971. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22972. private _mergeElement;
  22973. private _validate;
  22974. /**
  22975. * Serializes the VertexData
  22976. * @returns a serialized object
  22977. */
  22978. serialize(): any;
  22979. /**
  22980. * Extracts the vertexData from a mesh
  22981. * @param mesh the mesh from which to extract the VertexData
  22982. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22983. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22984. * @returns the object VertexData associated to the passed mesh
  22985. */
  22986. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22987. /**
  22988. * Extracts the vertexData from the geometry
  22989. * @param geometry the geometry from which to extract the VertexData
  22990. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22991. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22992. * @returns the object VertexData associated to the passed mesh
  22993. */
  22994. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22995. private static _ExtractFrom;
  22996. /**
  22997. * Creates the VertexData for a Ribbon
  22998. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22999. * * pathArray array of paths, each of which an array of successive Vector3
  23000. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23001. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23002. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  23003. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23004. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23005. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23006. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23007. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23008. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23009. * @returns the VertexData of the ribbon
  23010. */
  23011. static CreateRibbon(options: {
  23012. pathArray: Vector3[][];
  23013. closeArray?: boolean;
  23014. closePath?: boolean;
  23015. offset?: number;
  23016. sideOrientation?: number;
  23017. frontUVs?: Vector4;
  23018. backUVs?: Vector4;
  23019. invertUV?: boolean;
  23020. uvs?: Vector2[];
  23021. colors?: Color4[];
  23022. }): VertexData;
  23023. /**
  23024. * Creates the VertexData for a box
  23025. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23026. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23027. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23028. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23029. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23030. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23031. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23033. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23034. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23035. * @returns the VertexData of the box
  23036. */
  23037. static CreateBox(options: {
  23038. size?: number;
  23039. width?: number;
  23040. height?: number;
  23041. depth?: number;
  23042. faceUV?: Vector4[];
  23043. faceColors?: Color4[];
  23044. sideOrientation?: number;
  23045. frontUVs?: Vector4;
  23046. backUVs?: Vector4;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData for a tiled box
  23050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23051. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23052. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23053. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23055. * @returns the VertexData of the box
  23056. */
  23057. static CreateTiledBox(options: {
  23058. pattern?: number;
  23059. width?: number;
  23060. height?: number;
  23061. depth?: number;
  23062. tileSize?: number;
  23063. tileWidth?: number;
  23064. tileHeight?: number;
  23065. alignHorizontal?: number;
  23066. alignVertical?: number;
  23067. faceUV?: Vector4[];
  23068. faceColors?: Color4[];
  23069. sideOrientation?: number;
  23070. }): VertexData;
  23071. /**
  23072. * Creates the VertexData for a tiled plane
  23073. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23074. * * pattern a limited pattern arrangement depending on the number
  23075. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23076. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23077. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23079. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23080. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23081. * @returns the VertexData of the tiled plane
  23082. */
  23083. static CreateTiledPlane(options: {
  23084. pattern?: number;
  23085. tileSize?: number;
  23086. tileWidth?: number;
  23087. tileHeight?: number;
  23088. size?: number;
  23089. width?: number;
  23090. height?: number;
  23091. alignHorizontal?: number;
  23092. alignVertical?: number;
  23093. sideOrientation?: number;
  23094. frontUVs?: Vector4;
  23095. backUVs?: Vector4;
  23096. }): VertexData;
  23097. /**
  23098. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23100. * * segments sets the number of horizontal strips optional, default 32
  23101. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23102. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23103. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23104. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23105. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  23106. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  23107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23108. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23109. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23110. * @returns the VertexData of the ellipsoid
  23111. */
  23112. static CreateSphere(options: {
  23113. segments?: number;
  23114. diameter?: number;
  23115. diameterX?: number;
  23116. diameterY?: number;
  23117. diameterZ?: number;
  23118. arc?: number;
  23119. slice?: number;
  23120. sideOrientation?: number;
  23121. frontUVs?: Vector4;
  23122. backUVs?: Vector4;
  23123. }): VertexData;
  23124. /**
  23125. * Creates the VertexData for a cylinder, cone or prism
  23126. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23127. * * height sets the height (y direction) of the cylinder, optional, default 2
  23128. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23129. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23130. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23131. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23132. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23133. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  23134. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23135. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23136. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23137. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23139. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23140. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23141. * @returns the VertexData of the cylinder, cone or prism
  23142. */
  23143. static CreateCylinder(options: {
  23144. height?: number;
  23145. diameterTop?: number;
  23146. diameterBottom?: number;
  23147. diameter?: number;
  23148. tessellation?: number;
  23149. subdivisions?: number;
  23150. arc?: number;
  23151. faceColors?: Color4[];
  23152. faceUV?: Vector4[];
  23153. hasRings?: boolean;
  23154. enclose?: boolean;
  23155. sideOrientation?: number;
  23156. frontUVs?: Vector4;
  23157. backUVs?: Vector4;
  23158. }): VertexData;
  23159. /**
  23160. * Creates the VertexData for a torus
  23161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23162. * * diameter the diameter of the torus, optional default 1
  23163. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23164. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23166. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23167. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23168. * @returns the VertexData of the torus
  23169. */
  23170. static CreateTorus(options: {
  23171. diameter?: number;
  23172. thickness?: number;
  23173. tessellation?: number;
  23174. sideOrientation?: number;
  23175. frontUVs?: Vector4;
  23176. backUVs?: Vector4;
  23177. }): VertexData;
  23178. /**
  23179. * Creates the VertexData of the LineSystem
  23180. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23181. * - lines an array of lines, each line being an array of successive Vector3
  23182. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23183. * @returns the VertexData of the LineSystem
  23184. */
  23185. static CreateLineSystem(options: {
  23186. lines: Vector3[][];
  23187. colors?: Nullable<Color4[][]>;
  23188. }): VertexData;
  23189. /**
  23190. * Create the VertexData for a DashedLines
  23191. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23192. * - points an array successive Vector3
  23193. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23194. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23195. * - dashNb the intended total number of dashes, optional, default 200
  23196. * @returns the VertexData for the DashedLines
  23197. */
  23198. static CreateDashedLines(options: {
  23199. points: Vector3[];
  23200. dashSize?: number;
  23201. gapSize?: number;
  23202. dashNb?: number;
  23203. }): VertexData;
  23204. /**
  23205. * Creates the VertexData for a Ground
  23206. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23207. * - width the width (x direction) of the ground, optional, default 1
  23208. * - height the height (z direction) of the ground, optional, default 1
  23209. * - subdivisions the number of subdivisions per side, optional, default 1
  23210. * @returns the VertexData of the Ground
  23211. */
  23212. static CreateGround(options: {
  23213. width?: number;
  23214. height?: number;
  23215. subdivisions?: number;
  23216. subdivisionsX?: number;
  23217. subdivisionsY?: number;
  23218. }): VertexData;
  23219. /**
  23220. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23221. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23222. * * xmin the ground minimum X coordinate, optional, default -1
  23223. * * zmin the ground minimum Z coordinate, optional, default -1
  23224. * * xmax the ground maximum X coordinate, optional, default 1
  23225. * * zmax the ground maximum Z coordinate, optional, default 1
  23226. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  23227. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  23228. * @returns the VertexData of the TiledGround
  23229. */
  23230. static CreateTiledGround(options: {
  23231. xmin: number;
  23232. zmin: number;
  23233. xmax: number;
  23234. zmax: number;
  23235. subdivisions?: {
  23236. w: number;
  23237. h: number;
  23238. };
  23239. precision?: {
  23240. w: number;
  23241. h: number;
  23242. };
  23243. }): VertexData;
  23244. /**
  23245. * Creates the VertexData of the Ground designed from a heightmap
  23246. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23247. * * width the width (x direction) of the ground
  23248. * * height the height (z direction) of the ground
  23249. * * subdivisions the number of subdivisions per side
  23250. * * minHeight the minimum altitude on the ground, optional, default 0
  23251. * * maxHeight the maximum altitude on the ground, optional default 1
  23252. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23253. * * buffer the array holding the image color data
  23254. * * bufferWidth the width of image
  23255. * * bufferHeight the height of image
  23256. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23257. * @returns the VertexData of the Ground designed from a heightmap
  23258. */
  23259. static CreateGroundFromHeightMap(options: {
  23260. width: number;
  23261. height: number;
  23262. subdivisions: number;
  23263. minHeight: number;
  23264. maxHeight: number;
  23265. colorFilter: Color3;
  23266. buffer: Uint8Array;
  23267. bufferWidth: number;
  23268. bufferHeight: number;
  23269. alphaFilter: number;
  23270. }): VertexData;
  23271. /**
  23272. * Creates the VertexData for a Plane
  23273. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23274. * * size sets the width and height of the plane to the value of size, optional default 1
  23275. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23276. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23278. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23279. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23280. * @returns the VertexData of the box
  23281. */
  23282. static CreatePlane(options: {
  23283. size?: number;
  23284. width?: number;
  23285. height?: number;
  23286. sideOrientation?: number;
  23287. frontUVs?: Vector4;
  23288. backUVs?: Vector4;
  23289. }): VertexData;
  23290. /**
  23291. * Creates the VertexData of the Disc or regular Polygon
  23292. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23293. * * radius the radius of the disc, optional default 0.5
  23294. * * tessellation the number of polygon sides, optional, default 64
  23295. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  23296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23297. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23298. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23299. * @returns the VertexData of the box
  23300. */
  23301. static CreateDisc(options: {
  23302. radius?: number;
  23303. tessellation?: number;
  23304. arc?: number;
  23305. sideOrientation?: number;
  23306. frontUVs?: Vector4;
  23307. backUVs?: Vector4;
  23308. }): VertexData;
  23309. /**
  23310. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23311. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23312. * @param polygon a mesh built from polygonTriangulation.build()
  23313. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23314. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23315. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23316. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23317. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23318. * @returns the VertexData of the Polygon
  23319. */
  23320. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23321. /**
  23322. * Creates the VertexData of the IcoSphere
  23323. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23324. * * radius the radius of the IcoSphere, optional default 1
  23325. * * radiusX allows stretching in the x direction, optional, default radius
  23326. * * radiusY allows stretching in the y direction, optional, default radius
  23327. * * radiusZ allows stretching in the z direction, optional, default radius
  23328. * * flat when true creates a flat shaded mesh, optional, default true
  23329. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23331. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23332. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23333. * @returns the VertexData of the IcoSphere
  23334. */
  23335. static CreateIcoSphere(options: {
  23336. radius?: number;
  23337. radiusX?: number;
  23338. radiusY?: number;
  23339. radiusZ?: number;
  23340. flat?: boolean;
  23341. subdivisions?: number;
  23342. sideOrientation?: number;
  23343. frontUVs?: Vector4;
  23344. backUVs?: Vector4;
  23345. }): VertexData;
  23346. /**
  23347. * Creates the VertexData for a Polyhedron
  23348. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23349. * * type provided types are:
  23350. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23351. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  23352. * * size the size of the IcoSphere, optional default 1
  23353. * * sizeX allows stretching in the x direction, optional, default size
  23354. * * sizeY allows stretching in the y direction, optional, default size
  23355. * * sizeZ allows stretching in the z direction, optional, default size
  23356. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  23357. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23358. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23359. * * flat when true creates a flat shaded mesh, optional, default true
  23360. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23362. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23363. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23364. * @returns the VertexData of the Polyhedron
  23365. */
  23366. static CreatePolyhedron(options: {
  23367. type?: number;
  23368. size?: number;
  23369. sizeX?: number;
  23370. sizeY?: number;
  23371. sizeZ?: number;
  23372. custom?: any;
  23373. faceUV?: Vector4[];
  23374. faceColors?: Color4[];
  23375. flat?: boolean;
  23376. sideOrientation?: number;
  23377. frontUVs?: Vector4;
  23378. backUVs?: Vector4;
  23379. }): VertexData;
  23380. /**
  23381. * Creates the VertexData for a TorusKnot
  23382. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23383. * * radius the radius of the torus knot, optional, default 2
  23384. * * tube the thickness of the tube, optional, default 0.5
  23385. * * radialSegments the number of sides on each tube segments, optional, default 32
  23386. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23387. * * p the number of windings around the z axis, optional, default 2
  23388. * * q the number of windings around the x axis, optional, default 3
  23389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23390. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23391. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23392. * @returns the VertexData of the Torus Knot
  23393. */
  23394. static CreateTorusKnot(options: {
  23395. radius?: number;
  23396. tube?: number;
  23397. radialSegments?: number;
  23398. tubularSegments?: number;
  23399. p?: number;
  23400. q?: number;
  23401. sideOrientation?: number;
  23402. frontUVs?: Vector4;
  23403. backUVs?: Vector4;
  23404. }): VertexData;
  23405. /**
  23406. * Compute normals for given positions and indices
  23407. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23408. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23409. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23410. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23411. * * facetNormals : optional array of facet normals (vector3)
  23412. * * facetPositions : optional array of facet positions (vector3)
  23413. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23414. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23415. * * bInfo : optional bounding info, required for facetPartitioning computation
  23416. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23417. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23418. * * useRightHandedSystem: optional boolean to for right handed system computation
  23419. * * depthSort : optional boolean to enable the facet depth sort computation
  23420. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23421. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23422. */
  23423. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23424. facetNormals?: any;
  23425. facetPositions?: any;
  23426. facetPartitioning?: any;
  23427. ratio?: number;
  23428. bInfo?: any;
  23429. bbSize?: Vector3;
  23430. subDiv?: any;
  23431. useRightHandedSystem?: boolean;
  23432. depthSort?: boolean;
  23433. distanceTo?: Vector3;
  23434. depthSortedFacets?: any;
  23435. }): void;
  23436. /** @hidden */
  23437. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23438. /**
  23439. * Applies VertexData created from the imported parameters to the geometry
  23440. * @param parsedVertexData the parsed data from an imported file
  23441. * @param geometry the geometry to apply the VertexData to
  23442. */
  23443. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23444. }
  23445. }
  23446. declare module "babylonjs/Morph/morphTarget" {
  23447. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23448. import { Observable } from "babylonjs/Misc/observable";
  23449. import { Nullable, FloatArray } from "babylonjs/types";
  23450. import { Scene } from "babylonjs/scene";
  23451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23452. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23453. /**
  23454. * Defines a target to use with MorphTargetManager
  23455. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23456. */
  23457. export class MorphTarget implements IAnimatable {
  23458. /** defines the name of the target */
  23459. name: string;
  23460. /**
  23461. * Gets or sets the list of animations
  23462. */
  23463. animations: import("babylonjs/Animations/animation").Animation[];
  23464. private _scene;
  23465. private _positions;
  23466. private _normals;
  23467. private _tangents;
  23468. private _uvs;
  23469. private _influence;
  23470. private _uniqueId;
  23471. /**
  23472. * Observable raised when the influence changes
  23473. */
  23474. onInfluenceChanged: Observable<boolean>;
  23475. /** @hidden */
  23476. _onDataLayoutChanged: Observable<void>;
  23477. /**
  23478. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23479. */
  23480. get influence(): number;
  23481. set influence(influence: number);
  23482. /**
  23483. * Gets or sets the id of the morph Target
  23484. */
  23485. id: string;
  23486. private _animationPropertiesOverride;
  23487. /**
  23488. * Gets or sets the animation properties override
  23489. */
  23490. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23491. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23492. /**
  23493. * Creates a new MorphTarget
  23494. * @param name defines the name of the target
  23495. * @param influence defines the influence to use
  23496. * @param scene defines the scene the morphtarget belongs to
  23497. */
  23498. constructor(
  23499. /** defines the name of the target */
  23500. name: string, influence?: number, scene?: Nullable<Scene>);
  23501. /**
  23502. * Gets the unique ID of this manager
  23503. */
  23504. get uniqueId(): number;
  23505. /**
  23506. * Gets a boolean defining if the target contains position data
  23507. */
  23508. get hasPositions(): boolean;
  23509. /**
  23510. * Gets a boolean defining if the target contains normal data
  23511. */
  23512. get hasNormals(): boolean;
  23513. /**
  23514. * Gets a boolean defining if the target contains tangent data
  23515. */
  23516. get hasTangents(): boolean;
  23517. /**
  23518. * Gets a boolean defining if the target contains texture coordinates data
  23519. */
  23520. get hasUVs(): boolean;
  23521. /**
  23522. * Affects position data to this target
  23523. * @param data defines the position data to use
  23524. */
  23525. setPositions(data: Nullable<FloatArray>): void;
  23526. /**
  23527. * Gets the position data stored in this target
  23528. * @returns a FloatArray containing the position data (or null if not present)
  23529. */
  23530. getPositions(): Nullable<FloatArray>;
  23531. /**
  23532. * Affects normal data to this target
  23533. * @param data defines the normal data to use
  23534. */
  23535. setNormals(data: Nullable<FloatArray>): void;
  23536. /**
  23537. * Gets the normal data stored in this target
  23538. * @returns a FloatArray containing the normal data (or null if not present)
  23539. */
  23540. getNormals(): Nullable<FloatArray>;
  23541. /**
  23542. * Affects tangent data to this target
  23543. * @param data defines the tangent data to use
  23544. */
  23545. setTangents(data: Nullable<FloatArray>): void;
  23546. /**
  23547. * Gets the tangent data stored in this target
  23548. * @returns a FloatArray containing the tangent data (or null if not present)
  23549. */
  23550. getTangents(): Nullable<FloatArray>;
  23551. /**
  23552. * Affects texture coordinates data to this target
  23553. * @param data defines the texture coordinates data to use
  23554. */
  23555. setUVs(data: Nullable<FloatArray>): void;
  23556. /**
  23557. * Gets the texture coordinates data stored in this target
  23558. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23559. */
  23560. getUVs(): Nullable<FloatArray>;
  23561. /**
  23562. * Clone the current target
  23563. * @returns a new MorphTarget
  23564. */
  23565. clone(): MorphTarget;
  23566. /**
  23567. * Serializes the current target into a Serialization object
  23568. * @returns the serialized object
  23569. */
  23570. serialize(): any;
  23571. /**
  23572. * Returns the string "MorphTarget"
  23573. * @returns "MorphTarget"
  23574. */
  23575. getClassName(): string;
  23576. /**
  23577. * Creates a new target from serialized data
  23578. * @param serializationObject defines the serialized data to use
  23579. * @returns a new MorphTarget
  23580. */
  23581. static Parse(serializationObject: any): MorphTarget;
  23582. /**
  23583. * Creates a MorphTarget from mesh data
  23584. * @param mesh defines the source mesh
  23585. * @param name defines the name to use for the new target
  23586. * @param influence defines the influence to attach to the target
  23587. * @returns a new MorphTarget
  23588. */
  23589. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23590. }
  23591. }
  23592. declare module "babylonjs/Morph/morphTargetManager" {
  23593. import { Nullable } from "babylonjs/types";
  23594. import { Scene } from "babylonjs/scene";
  23595. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23596. /**
  23597. * This class is used to deform meshes using morphing between different targets
  23598. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23599. */
  23600. export class MorphTargetManager {
  23601. private _targets;
  23602. private _targetInfluenceChangedObservers;
  23603. private _targetDataLayoutChangedObservers;
  23604. private _activeTargets;
  23605. private _scene;
  23606. private _influences;
  23607. private _supportsNormals;
  23608. private _supportsTangents;
  23609. private _supportsUVs;
  23610. private _vertexCount;
  23611. private _uniqueId;
  23612. private _tempInfluences;
  23613. /**
  23614. * Gets or sets a boolean indicating if normals must be morphed
  23615. */
  23616. enableNormalMorphing: boolean;
  23617. /**
  23618. * Gets or sets a boolean indicating if tangents must be morphed
  23619. */
  23620. enableTangentMorphing: boolean;
  23621. /**
  23622. * Gets or sets a boolean indicating if UV must be morphed
  23623. */
  23624. enableUVMorphing: boolean;
  23625. /**
  23626. * Creates a new MorphTargetManager
  23627. * @param scene defines the current scene
  23628. */
  23629. constructor(scene?: Nullable<Scene>);
  23630. /**
  23631. * Gets the unique ID of this manager
  23632. */
  23633. get uniqueId(): number;
  23634. /**
  23635. * Gets the number of vertices handled by this manager
  23636. */
  23637. get vertexCount(): number;
  23638. /**
  23639. * Gets a boolean indicating if this manager supports morphing of normals
  23640. */
  23641. get supportsNormals(): boolean;
  23642. /**
  23643. * Gets a boolean indicating if this manager supports morphing of tangents
  23644. */
  23645. get supportsTangents(): boolean;
  23646. /**
  23647. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23648. */
  23649. get supportsUVs(): boolean;
  23650. /**
  23651. * Gets the number of targets stored in this manager
  23652. */
  23653. get numTargets(): number;
  23654. /**
  23655. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23656. */
  23657. get numInfluencers(): number;
  23658. /**
  23659. * Gets the list of influences (one per target)
  23660. */
  23661. get influences(): Float32Array;
  23662. /**
  23663. * Gets the active target at specified index. An active target is a target with an influence > 0
  23664. * @param index defines the index to check
  23665. * @returns the requested target
  23666. */
  23667. getActiveTarget(index: number): MorphTarget;
  23668. /**
  23669. * Gets the target at specified index
  23670. * @param index defines the index to check
  23671. * @returns the requested target
  23672. */
  23673. getTarget(index: number): MorphTarget;
  23674. /**
  23675. * Add a new target to this manager
  23676. * @param target defines the target to add
  23677. */
  23678. addTarget(target: MorphTarget): void;
  23679. /**
  23680. * Removes a target from the manager
  23681. * @param target defines the target to remove
  23682. */
  23683. removeTarget(target: MorphTarget): void;
  23684. /**
  23685. * Clone the current manager
  23686. * @returns a new MorphTargetManager
  23687. */
  23688. clone(): MorphTargetManager;
  23689. /**
  23690. * Serializes the current manager into a Serialization object
  23691. * @returns the serialized object
  23692. */
  23693. serialize(): any;
  23694. private _syncActiveTargets;
  23695. /**
  23696. * Syncrhonize the targets with all the meshes using this morph target manager
  23697. */
  23698. synchronize(): void;
  23699. /**
  23700. * Creates a new MorphTargetManager from serialized data
  23701. * @param serializationObject defines the serialized data
  23702. * @param scene defines the hosting scene
  23703. * @returns the new MorphTargetManager
  23704. */
  23705. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23706. }
  23707. }
  23708. declare module "babylonjs/Meshes/meshLODLevel" {
  23709. import { Mesh } from "babylonjs/Meshes/mesh";
  23710. import { Nullable } from "babylonjs/types";
  23711. /**
  23712. * Class used to represent a specific level of detail of a mesh
  23713. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23714. */
  23715. export class MeshLODLevel {
  23716. /** Defines the distance where this level should start being displayed */
  23717. distance: number;
  23718. /** Defines the mesh to use to render this level */
  23719. mesh: Nullable<Mesh>;
  23720. /**
  23721. * Creates a new LOD level
  23722. * @param distance defines the distance where this level should star being displayed
  23723. * @param mesh defines the mesh to use to render this level
  23724. */
  23725. constructor(
  23726. /** Defines the distance where this level should start being displayed */
  23727. distance: number,
  23728. /** Defines the mesh to use to render this level */
  23729. mesh: Nullable<Mesh>);
  23730. }
  23731. }
  23732. declare module "babylonjs/Meshes/groundMesh" {
  23733. import { Scene } from "babylonjs/scene";
  23734. import { Vector3 } from "babylonjs/Maths/math.vector";
  23735. import { Mesh } from "babylonjs/Meshes/mesh";
  23736. /**
  23737. * Mesh representing the gorund
  23738. */
  23739. export class GroundMesh extends Mesh {
  23740. /** If octree should be generated */
  23741. generateOctree: boolean;
  23742. private _heightQuads;
  23743. /** @hidden */
  23744. _subdivisionsX: number;
  23745. /** @hidden */
  23746. _subdivisionsY: number;
  23747. /** @hidden */
  23748. _width: number;
  23749. /** @hidden */
  23750. _height: number;
  23751. /** @hidden */
  23752. _minX: number;
  23753. /** @hidden */
  23754. _maxX: number;
  23755. /** @hidden */
  23756. _minZ: number;
  23757. /** @hidden */
  23758. _maxZ: number;
  23759. constructor(name: string, scene: Scene);
  23760. /**
  23761. * "GroundMesh"
  23762. * @returns "GroundMesh"
  23763. */
  23764. getClassName(): string;
  23765. /**
  23766. * The minimum of x and y subdivisions
  23767. */
  23768. get subdivisions(): number;
  23769. /**
  23770. * X subdivisions
  23771. */
  23772. get subdivisionsX(): number;
  23773. /**
  23774. * Y subdivisions
  23775. */
  23776. get subdivisionsY(): number;
  23777. /**
  23778. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23779. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23780. * @param chunksCount the number of subdivisions for x and y
  23781. * @param octreeBlocksSize (Default: 32)
  23782. */
  23783. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23784. /**
  23785. * Returns a height (y) value in the Worl system :
  23786. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23787. * @param x x coordinate
  23788. * @param z z coordinate
  23789. * @returns the ground y position if (x, z) are outside the ground surface.
  23790. */
  23791. getHeightAtCoordinates(x: number, z: number): number;
  23792. /**
  23793. * Returns a normalized vector (Vector3) orthogonal to the ground
  23794. * at the ground coordinates (x, z) expressed in the World system.
  23795. * @param x x coordinate
  23796. * @param z z coordinate
  23797. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23798. */
  23799. getNormalAtCoordinates(x: number, z: number): Vector3;
  23800. /**
  23801. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23802. * at the ground coordinates (x, z) expressed in the World system.
  23803. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23804. * @param x x coordinate
  23805. * @param z z coordinate
  23806. * @param ref vector to store the result
  23807. * @returns the GroundMesh.
  23808. */
  23809. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23810. /**
  23811. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23812. * if the ground has been updated.
  23813. * This can be used in the render loop.
  23814. * @returns the GroundMesh.
  23815. */
  23816. updateCoordinateHeights(): GroundMesh;
  23817. private _getFacetAt;
  23818. private _initHeightQuads;
  23819. private _computeHeightQuads;
  23820. /**
  23821. * Serializes this ground mesh
  23822. * @param serializationObject object to write serialization to
  23823. */
  23824. serialize(serializationObject: any): void;
  23825. /**
  23826. * Parses a serialized ground mesh
  23827. * @param parsedMesh the serialized mesh
  23828. * @param scene the scene to create the ground mesh in
  23829. * @returns the created ground mesh
  23830. */
  23831. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23832. }
  23833. }
  23834. declare module "babylonjs/Physics/physicsJoint" {
  23835. import { Vector3 } from "babylonjs/Maths/math.vector";
  23836. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23837. /**
  23838. * Interface for Physics-Joint data
  23839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23840. */
  23841. export interface PhysicsJointData {
  23842. /**
  23843. * The main pivot of the joint
  23844. */
  23845. mainPivot?: Vector3;
  23846. /**
  23847. * The connected pivot of the joint
  23848. */
  23849. connectedPivot?: Vector3;
  23850. /**
  23851. * The main axis of the joint
  23852. */
  23853. mainAxis?: Vector3;
  23854. /**
  23855. * The connected axis of the joint
  23856. */
  23857. connectedAxis?: Vector3;
  23858. /**
  23859. * The collision of the joint
  23860. */
  23861. collision?: boolean;
  23862. /**
  23863. * Native Oimo/Cannon/Energy data
  23864. */
  23865. nativeParams?: any;
  23866. }
  23867. /**
  23868. * This is a holder class for the physics joint created by the physics plugin
  23869. * It holds a set of functions to control the underlying joint
  23870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23871. */
  23872. export class PhysicsJoint {
  23873. /**
  23874. * The type of the physics joint
  23875. */
  23876. type: number;
  23877. /**
  23878. * The data for the physics joint
  23879. */
  23880. jointData: PhysicsJointData;
  23881. private _physicsJoint;
  23882. protected _physicsPlugin: IPhysicsEnginePlugin;
  23883. /**
  23884. * Initializes the physics joint
  23885. * @param type The type of the physics joint
  23886. * @param jointData The data for the physics joint
  23887. */
  23888. constructor(
  23889. /**
  23890. * The type of the physics joint
  23891. */
  23892. type: number,
  23893. /**
  23894. * The data for the physics joint
  23895. */
  23896. jointData: PhysicsJointData);
  23897. /**
  23898. * Gets the physics joint
  23899. */
  23900. get physicsJoint(): any;
  23901. /**
  23902. * Sets the physics joint
  23903. */
  23904. set physicsJoint(newJoint: any);
  23905. /**
  23906. * Sets the physics plugin
  23907. */
  23908. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23909. /**
  23910. * Execute a function that is physics-plugin specific.
  23911. * @param {Function} func the function that will be executed.
  23912. * It accepts two parameters: the physics world and the physics joint
  23913. */
  23914. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23915. /**
  23916. * Distance-Joint type
  23917. */
  23918. static DistanceJoint: number;
  23919. /**
  23920. * Hinge-Joint type
  23921. */
  23922. static HingeJoint: number;
  23923. /**
  23924. * Ball-and-Socket joint type
  23925. */
  23926. static BallAndSocketJoint: number;
  23927. /**
  23928. * Wheel-Joint type
  23929. */
  23930. static WheelJoint: number;
  23931. /**
  23932. * Slider-Joint type
  23933. */
  23934. static SliderJoint: number;
  23935. /**
  23936. * Prismatic-Joint type
  23937. */
  23938. static PrismaticJoint: number;
  23939. /**
  23940. * Universal-Joint type
  23941. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23942. */
  23943. static UniversalJoint: number;
  23944. /**
  23945. * Hinge-Joint 2 type
  23946. */
  23947. static Hinge2Joint: number;
  23948. /**
  23949. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23950. */
  23951. static PointToPointJoint: number;
  23952. /**
  23953. * Spring-Joint type
  23954. */
  23955. static SpringJoint: number;
  23956. /**
  23957. * Lock-Joint type
  23958. */
  23959. static LockJoint: number;
  23960. }
  23961. /**
  23962. * A class representing a physics distance joint
  23963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23964. */
  23965. export class DistanceJoint extends PhysicsJoint {
  23966. /**
  23967. *
  23968. * @param jointData The data for the Distance-Joint
  23969. */
  23970. constructor(jointData: DistanceJointData);
  23971. /**
  23972. * Update the predefined distance.
  23973. * @param maxDistance The maximum preferred distance
  23974. * @param minDistance The minimum preferred distance
  23975. */
  23976. updateDistance(maxDistance: number, minDistance?: number): void;
  23977. }
  23978. /**
  23979. * Represents a Motor-Enabled Joint
  23980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23981. */
  23982. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23983. /**
  23984. * Initializes the Motor-Enabled Joint
  23985. * @param type The type of the joint
  23986. * @param jointData The physica joint data for the joint
  23987. */
  23988. constructor(type: number, jointData: PhysicsJointData);
  23989. /**
  23990. * Set the motor values.
  23991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23992. * @param force the force to apply
  23993. * @param maxForce max force for this motor.
  23994. */
  23995. setMotor(force?: number, maxForce?: number): void;
  23996. /**
  23997. * Set the motor's limits.
  23998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23999. * @param upperLimit The upper limit of the motor
  24000. * @param lowerLimit The lower limit of the motor
  24001. */
  24002. setLimit(upperLimit: number, lowerLimit?: number): void;
  24003. }
  24004. /**
  24005. * This class represents a single physics Hinge-Joint
  24006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24007. */
  24008. export class HingeJoint extends MotorEnabledJoint {
  24009. /**
  24010. * Initializes the Hinge-Joint
  24011. * @param jointData The joint data for the Hinge-Joint
  24012. */
  24013. constructor(jointData: PhysicsJointData);
  24014. /**
  24015. * Set the motor values.
  24016. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24017. * @param {number} force the force to apply
  24018. * @param {number} maxForce max force for this motor.
  24019. */
  24020. setMotor(force?: number, maxForce?: number): void;
  24021. /**
  24022. * Set the motor's limits.
  24023. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24024. * @param upperLimit The upper limit of the motor
  24025. * @param lowerLimit The lower limit of the motor
  24026. */
  24027. setLimit(upperLimit: number, lowerLimit?: number): void;
  24028. }
  24029. /**
  24030. * This class represents a dual hinge physics joint (same as wheel joint)
  24031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24032. */
  24033. export class Hinge2Joint extends MotorEnabledJoint {
  24034. /**
  24035. * Initializes the Hinge2-Joint
  24036. * @param jointData The joint data for the Hinge2-Joint
  24037. */
  24038. constructor(jointData: PhysicsJointData);
  24039. /**
  24040. * Set the motor values.
  24041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24042. * @param {number} targetSpeed the speed the motor is to reach
  24043. * @param {number} maxForce max force for this motor.
  24044. * @param {motorIndex} the motor's index, 0 or 1.
  24045. */
  24046. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24047. /**
  24048. * Set the motor limits.
  24049. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24050. * @param {number} upperLimit the upper limit
  24051. * @param {number} lowerLimit lower limit
  24052. * @param {motorIndex} the motor's index, 0 or 1.
  24053. */
  24054. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24055. }
  24056. /**
  24057. * Interface for a motor enabled joint
  24058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24059. */
  24060. export interface IMotorEnabledJoint {
  24061. /**
  24062. * Physics joint
  24063. */
  24064. physicsJoint: any;
  24065. /**
  24066. * Sets the motor of the motor-enabled joint
  24067. * @param force The force of the motor
  24068. * @param maxForce The maximum force of the motor
  24069. * @param motorIndex The index of the motor
  24070. */
  24071. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24072. /**
  24073. * Sets the limit of the motor
  24074. * @param upperLimit The upper limit of the motor
  24075. * @param lowerLimit The lower limit of the motor
  24076. * @param motorIndex The index of the motor
  24077. */
  24078. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24079. }
  24080. /**
  24081. * Joint data for a Distance-Joint
  24082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24083. */
  24084. export interface DistanceJointData extends PhysicsJointData {
  24085. /**
  24086. * Max distance the 2 joint objects can be apart
  24087. */
  24088. maxDistance: number;
  24089. }
  24090. /**
  24091. * Joint data from a spring joint
  24092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24093. */
  24094. export interface SpringJointData extends PhysicsJointData {
  24095. /**
  24096. * Length of the spring
  24097. */
  24098. length: number;
  24099. /**
  24100. * Stiffness of the spring
  24101. */
  24102. stiffness: number;
  24103. /**
  24104. * Damping of the spring
  24105. */
  24106. damping: number;
  24107. /** this callback will be called when applying the force to the impostors. */
  24108. forceApplicationCallback: () => void;
  24109. }
  24110. }
  24111. declare module "babylonjs/Physics/physicsRaycastResult" {
  24112. import { Vector3 } from "babylonjs/Maths/math.vector";
  24113. /**
  24114. * Holds the data for the raycast result
  24115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24116. */
  24117. export class PhysicsRaycastResult {
  24118. private _hasHit;
  24119. private _hitDistance;
  24120. private _hitNormalWorld;
  24121. private _hitPointWorld;
  24122. private _rayFromWorld;
  24123. private _rayToWorld;
  24124. /**
  24125. * Gets if there was a hit
  24126. */
  24127. get hasHit(): boolean;
  24128. /**
  24129. * Gets the distance from the hit
  24130. */
  24131. get hitDistance(): number;
  24132. /**
  24133. * Gets the hit normal/direction in the world
  24134. */
  24135. get hitNormalWorld(): Vector3;
  24136. /**
  24137. * Gets the hit point in the world
  24138. */
  24139. get hitPointWorld(): Vector3;
  24140. /**
  24141. * Gets the ray "start point" of the ray in the world
  24142. */
  24143. get rayFromWorld(): Vector3;
  24144. /**
  24145. * Gets the ray "end point" of the ray in the world
  24146. */
  24147. get rayToWorld(): Vector3;
  24148. /**
  24149. * Sets the hit data (normal & point in world space)
  24150. * @param hitNormalWorld defines the normal in world space
  24151. * @param hitPointWorld defines the point in world space
  24152. */
  24153. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24154. /**
  24155. * Sets the distance from the start point to the hit point
  24156. * @param distance
  24157. */
  24158. setHitDistance(distance: number): void;
  24159. /**
  24160. * Calculates the distance manually
  24161. */
  24162. calculateHitDistance(): void;
  24163. /**
  24164. * Resets all the values to default
  24165. * @param from The from point on world space
  24166. * @param to The to point on world space
  24167. */
  24168. reset(from?: Vector3, to?: Vector3): void;
  24169. }
  24170. /**
  24171. * Interface for the size containing width and height
  24172. */
  24173. interface IXYZ {
  24174. /**
  24175. * X
  24176. */
  24177. x: number;
  24178. /**
  24179. * Y
  24180. */
  24181. y: number;
  24182. /**
  24183. * Z
  24184. */
  24185. z: number;
  24186. }
  24187. }
  24188. declare module "babylonjs/Physics/IPhysicsEngine" {
  24189. import { Nullable } from "babylonjs/types";
  24190. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24192. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24193. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24194. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24195. /**
  24196. * Interface used to describe a physics joint
  24197. */
  24198. export interface PhysicsImpostorJoint {
  24199. /** Defines the main impostor to which the joint is linked */
  24200. mainImpostor: PhysicsImpostor;
  24201. /** Defines the impostor that is connected to the main impostor using this joint */
  24202. connectedImpostor: PhysicsImpostor;
  24203. /** Defines the joint itself */
  24204. joint: PhysicsJoint;
  24205. }
  24206. /** @hidden */
  24207. export interface IPhysicsEnginePlugin {
  24208. world: any;
  24209. name: string;
  24210. setGravity(gravity: Vector3): void;
  24211. setTimeStep(timeStep: number): void;
  24212. getTimeStep(): number;
  24213. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24214. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24215. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24216. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24217. removePhysicsBody(impostor: PhysicsImpostor): void;
  24218. generateJoint(joint: PhysicsImpostorJoint): void;
  24219. removeJoint(joint: PhysicsImpostorJoint): void;
  24220. isSupported(): boolean;
  24221. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24222. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24223. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24224. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24225. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24226. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24227. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24228. getBodyMass(impostor: PhysicsImpostor): number;
  24229. getBodyFriction(impostor: PhysicsImpostor): number;
  24230. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24231. getBodyRestitution(impostor: PhysicsImpostor): number;
  24232. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24233. getBodyPressure?(impostor: PhysicsImpostor): number;
  24234. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24235. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24236. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24237. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24238. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24239. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24240. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24241. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24242. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24243. sleepBody(impostor: PhysicsImpostor): void;
  24244. wakeUpBody(impostor: PhysicsImpostor): void;
  24245. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24246. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24247. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24248. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24249. getRadius(impostor: PhysicsImpostor): number;
  24250. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24251. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24252. dispose(): void;
  24253. }
  24254. /**
  24255. * Interface used to define a physics engine
  24256. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24257. */
  24258. export interface IPhysicsEngine {
  24259. /**
  24260. * Gets the gravity vector used by the simulation
  24261. */
  24262. gravity: Vector3;
  24263. /**
  24264. * Sets the gravity vector used by the simulation
  24265. * @param gravity defines the gravity vector to use
  24266. */
  24267. setGravity(gravity: Vector3): void;
  24268. /**
  24269. * Set the time step of the physics engine.
  24270. * Default is 1/60.
  24271. * To slow it down, enter 1/600 for example.
  24272. * To speed it up, 1/30
  24273. * @param newTimeStep the new timestep to apply to this world.
  24274. */
  24275. setTimeStep(newTimeStep: number): void;
  24276. /**
  24277. * Get the time step of the physics engine.
  24278. * @returns the current time step
  24279. */
  24280. getTimeStep(): number;
  24281. /**
  24282. * Set the sub time step of the physics engine.
  24283. * Default is 0 meaning there is no sub steps
  24284. * To increase physics resolution precision, set a small value (like 1 ms)
  24285. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24286. */
  24287. setSubTimeStep(subTimeStep: number): void;
  24288. /**
  24289. * Get the sub time step of the physics engine.
  24290. * @returns the current sub time step
  24291. */
  24292. getSubTimeStep(): number;
  24293. /**
  24294. * Release all resources
  24295. */
  24296. dispose(): void;
  24297. /**
  24298. * Gets the name of the current physics plugin
  24299. * @returns the name of the plugin
  24300. */
  24301. getPhysicsPluginName(): string;
  24302. /**
  24303. * Adding a new impostor for the impostor tracking.
  24304. * This will be done by the impostor itself.
  24305. * @param impostor the impostor to add
  24306. */
  24307. addImpostor(impostor: PhysicsImpostor): void;
  24308. /**
  24309. * Remove an impostor from the engine.
  24310. * This impostor and its mesh will not longer be updated by the physics engine.
  24311. * @param impostor the impostor to remove
  24312. */
  24313. removeImpostor(impostor: PhysicsImpostor): void;
  24314. /**
  24315. * Add a joint to the physics engine
  24316. * @param mainImpostor defines the main impostor to which the joint is added.
  24317. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24318. * @param joint defines the joint that will connect both impostors.
  24319. */
  24320. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24321. /**
  24322. * Removes a joint from the simulation
  24323. * @param mainImpostor defines the impostor used with the joint
  24324. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24325. * @param joint defines the joint to remove
  24326. */
  24327. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24328. /**
  24329. * Gets the current plugin used to run the simulation
  24330. * @returns current plugin
  24331. */
  24332. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24333. /**
  24334. * Gets the list of physic impostors
  24335. * @returns an array of PhysicsImpostor
  24336. */
  24337. getImpostors(): Array<PhysicsImpostor>;
  24338. /**
  24339. * Gets the impostor for a physics enabled object
  24340. * @param object defines the object impersonated by the impostor
  24341. * @returns the PhysicsImpostor or null if not found
  24342. */
  24343. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24344. /**
  24345. * Gets the impostor for a physics body object
  24346. * @param body defines physics body used by the impostor
  24347. * @returns the PhysicsImpostor or null if not found
  24348. */
  24349. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24350. /**
  24351. * Does a raycast in the physics world
  24352. * @param from when should the ray start?
  24353. * @param to when should the ray end?
  24354. * @returns PhysicsRaycastResult
  24355. */
  24356. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24357. /**
  24358. * Called by the scene. No need to call it.
  24359. * @param delta defines the timespam between frames
  24360. */
  24361. _step(delta: number): void;
  24362. }
  24363. }
  24364. declare module "babylonjs/Physics/physicsImpostor" {
  24365. import { Nullable, IndicesArray } from "babylonjs/types";
  24366. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24367. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24369. import { Scene } from "babylonjs/scene";
  24370. import { Bone } from "babylonjs/Bones/bone";
  24371. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24372. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24373. import { Space } from "babylonjs/Maths/math.axis";
  24374. /**
  24375. * The interface for the physics imposter parameters
  24376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24377. */
  24378. export interface PhysicsImpostorParameters {
  24379. /**
  24380. * The mass of the physics imposter
  24381. */
  24382. mass: number;
  24383. /**
  24384. * The friction of the physics imposter
  24385. */
  24386. friction?: number;
  24387. /**
  24388. * The coefficient of restitution of the physics imposter
  24389. */
  24390. restitution?: number;
  24391. /**
  24392. * The native options of the physics imposter
  24393. */
  24394. nativeOptions?: any;
  24395. /**
  24396. * Specifies if the parent should be ignored
  24397. */
  24398. ignoreParent?: boolean;
  24399. /**
  24400. * Specifies if bi-directional transformations should be disabled
  24401. */
  24402. disableBidirectionalTransformation?: boolean;
  24403. /**
  24404. * The pressure inside the physics imposter, soft object only
  24405. */
  24406. pressure?: number;
  24407. /**
  24408. * The stiffness the physics imposter, soft object only
  24409. */
  24410. stiffness?: number;
  24411. /**
  24412. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24413. */
  24414. velocityIterations?: number;
  24415. /**
  24416. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24417. */
  24418. positionIterations?: number;
  24419. /**
  24420. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24421. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24422. * Add to fix multiple points
  24423. */
  24424. fixedPoints?: number;
  24425. /**
  24426. * The collision margin around a soft object
  24427. */
  24428. margin?: number;
  24429. /**
  24430. * The collision margin around a soft object
  24431. */
  24432. damping?: number;
  24433. /**
  24434. * The path for a rope based on an extrusion
  24435. */
  24436. path?: any;
  24437. /**
  24438. * The shape of an extrusion used for a rope based on an extrusion
  24439. */
  24440. shape?: any;
  24441. }
  24442. /**
  24443. * Interface for a physics-enabled object
  24444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24445. */
  24446. export interface IPhysicsEnabledObject {
  24447. /**
  24448. * The position of the physics-enabled object
  24449. */
  24450. position: Vector3;
  24451. /**
  24452. * The rotation of the physics-enabled object
  24453. */
  24454. rotationQuaternion: Nullable<Quaternion>;
  24455. /**
  24456. * The scale of the physics-enabled object
  24457. */
  24458. scaling: Vector3;
  24459. /**
  24460. * The rotation of the physics-enabled object
  24461. */
  24462. rotation?: Vector3;
  24463. /**
  24464. * The parent of the physics-enabled object
  24465. */
  24466. parent?: any;
  24467. /**
  24468. * The bounding info of the physics-enabled object
  24469. * @returns The bounding info of the physics-enabled object
  24470. */
  24471. getBoundingInfo(): BoundingInfo;
  24472. /**
  24473. * Computes the world matrix
  24474. * @param force Specifies if the world matrix should be computed by force
  24475. * @returns A world matrix
  24476. */
  24477. computeWorldMatrix(force: boolean): Matrix;
  24478. /**
  24479. * Gets the world matrix
  24480. * @returns A world matrix
  24481. */
  24482. getWorldMatrix?(): Matrix;
  24483. /**
  24484. * Gets the child meshes
  24485. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24486. * @returns An array of abstract meshes
  24487. */
  24488. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24489. /**
  24490. * Gets the vertex data
  24491. * @param kind The type of vertex data
  24492. * @returns A nullable array of numbers, or a float32 array
  24493. */
  24494. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24495. /**
  24496. * Gets the indices from the mesh
  24497. * @returns A nullable array of index arrays
  24498. */
  24499. getIndices?(): Nullable<IndicesArray>;
  24500. /**
  24501. * Gets the scene from the mesh
  24502. * @returns the indices array or null
  24503. */
  24504. getScene?(): Scene;
  24505. /**
  24506. * Gets the absolute position from the mesh
  24507. * @returns the absolute position
  24508. */
  24509. getAbsolutePosition(): Vector3;
  24510. /**
  24511. * Gets the absolute pivot point from the mesh
  24512. * @returns the absolute pivot point
  24513. */
  24514. getAbsolutePivotPoint(): Vector3;
  24515. /**
  24516. * Rotates the mesh
  24517. * @param axis The axis of rotation
  24518. * @param amount The amount of rotation
  24519. * @param space The space of the rotation
  24520. * @returns The rotation transform node
  24521. */
  24522. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24523. /**
  24524. * Translates the mesh
  24525. * @param axis The axis of translation
  24526. * @param distance The distance of translation
  24527. * @param space The space of the translation
  24528. * @returns The transform node
  24529. */
  24530. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24531. /**
  24532. * Sets the absolute position of the mesh
  24533. * @param absolutePosition The absolute position of the mesh
  24534. * @returns The transform node
  24535. */
  24536. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24537. /**
  24538. * Gets the class name of the mesh
  24539. * @returns The class name
  24540. */
  24541. getClassName(): string;
  24542. }
  24543. /**
  24544. * Represents a physics imposter
  24545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24546. */
  24547. export class PhysicsImpostor {
  24548. /**
  24549. * The physics-enabled object used as the physics imposter
  24550. */
  24551. object: IPhysicsEnabledObject;
  24552. /**
  24553. * The type of the physics imposter
  24554. */
  24555. type: number;
  24556. private _options;
  24557. private _scene?;
  24558. /**
  24559. * The default object size of the imposter
  24560. */
  24561. static DEFAULT_OBJECT_SIZE: Vector3;
  24562. /**
  24563. * The identity quaternion of the imposter
  24564. */
  24565. static IDENTITY_QUATERNION: Quaternion;
  24566. /** @hidden */
  24567. _pluginData: any;
  24568. private _physicsEngine;
  24569. private _physicsBody;
  24570. private _bodyUpdateRequired;
  24571. private _onBeforePhysicsStepCallbacks;
  24572. private _onAfterPhysicsStepCallbacks;
  24573. /** @hidden */
  24574. _onPhysicsCollideCallbacks: Array<{
  24575. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24576. otherImpostors: Array<PhysicsImpostor>;
  24577. }>;
  24578. private _deltaPosition;
  24579. private _deltaRotation;
  24580. private _deltaRotationConjugated;
  24581. /** @hidden */
  24582. _isFromLine: boolean;
  24583. private _parent;
  24584. private _isDisposed;
  24585. private static _tmpVecs;
  24586. private static _tmpQuat;
  24587. /**
  24588. * Specifies if the physics imposter is disposed
  24589. */
  24590. get isDisposed(): boolean;
  24591. /**
  24592. * Gets the mass of the physics imposter
  24593. */
  24594. get mass(): number;
  24595. set mass(value: number);
  24596. /**
  24597. * Gets the coefficient of friction
  24598. */
  24599. get friction(): number;
  24600. /**
  24601. * Sets the coefficient of friction
  24602. */
  24603. set friction(value: number);
  24604. /**
  24605. * Gets the coefficient of restitution
  24606. */
  24607. get restitution(): number;
  24608. /**
  24609. * Sets the coefficient of restitution
  24610. */
  24611. set restitution(value: number);
  24612. /**
  24613. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24614. */
  24615. get pressure(): number;
  24616. /**
  24617. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24618. */
  24619. set pressure(value: number);
  24620. /**
  24621. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24622. */
  24623. get stiffness(): number;
  24624. /**
  24625. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24626. */
  24627. set stiffness(value: number);
  24628. /**
  24629. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24630. */
  24631. get velocityIterations(): number;
  24632. /**
  24633. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24634. */
  24635. set velocityIterations(value: number);
  24636. /**
  24637. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24638. */
  24639. get positionIterations(): number;
  24640. /**
  24641. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24642. */
  24643. set positionIterations(value: number);
  24644. /**
  24645. * The unique id of the physics imposter
  24646. * set by the physics engine when adding this impostor to the array
  24647. */
  24648. uniqueId: number;
  24649. /**
  24650. * @hidden
  24651. */
  24652. soft: boolean;
  24653. /**
  24654. * @hidden
  24655. */
  24656. segments: number;
  24657. private _joints;
  24658. /**
  24659. * Initializes the physics imposter
  24660. * @param object The physics-enabled object used as the physics imposter
  24661. * @param type The type of the physics imposter
  24662. * @param _options The options for the physics imposter
  24663. * @param _scene The Babylon scene
  24664. */
  24665. constructor(
  24666. /**
  24667. * The physics-enabled object used as the physics imposter
  24668. */
  24669. object: IPhysicsEnabledObject,
  24670. /**
  24671. * The type of the physics imposter
  24672. */
  24673. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24674. /**
  24675. * This function will completly initialize this impostor.
  24676. * It will create a new body - but only if this mesh has no parent.
  24677. * If it has, this impostor will not be used other than to define the impostor
  24678. * of the child mesh.
  24679. * @hidden
  24680. */
  24681. _init(): void;
  24682. private _getPhysicsParent;
  24683. /**
  24684. * Should a new body be generated.
  24685. * @returns boolean specifying if body initialization is required
  24686. */
  24687. isBodyInitRequired(): boolean;
  24688. /**
  24689. * Sets the updated scaling
  24690. * @param updated Specifies if the scaling is updated
  24691. */
  24692. setScalingUpdated(): void;
  24693. /**
  24694. * Force a regeneration of this or the parent's impostor's body.
  24695. * Use under cautious - This will remove all joints already implemented.
  24696. */
  24697. forceUpdate(): void;
  24698. /**
  24699. * Gets the body that holds this impostor. Either its own, or its parent.
  24700. */
  24701. get physicsBody(): any;
  24702. /**
  24703. * Get the parent of the physics imposter
  24704. * @returns Physics imposter or null
  24705. */
  24706. get parent(): Nullable<PhysicsImpostor>;
  24707. /**
  24708. * Sets the parent of the physics imposter
  24709. */
  24710. set parent(value: Nullable<PhysicsImpostor>);
  24711. /**
  24712. * Set the physics body. Used mainly by the physics engine/plugin
  24713. */
  24714. set physicsBody(physicsBody: any);
  24715. /**
  24716. * Resets the update flags
  24717. */
  24718. resetUpdateFlags(): void;
  24719. /**
  24720. * Gets the object extend size
  24721. * @returns the object extend size
  24722. */
  24723. getObjectExtendSize(): Vector3;
  24724. /**
  24725. * Gets the object center
  24726. * @returns The object center
  24727. */
  24728. getObjectCenter(): Vector3;
  24729. /**
  24730. * Get a specific parameter from the options parameters
  24731. * @param paramName The object parameter name
  24732. * @returns The object parameter
  24733. */
  24734. getParam(paramName: string): any;
  24735. /**
  24736. * Sets a specific parameter in the options given to the physics plugin
  24737. * @param paramName The parameter name
  24738. * @param value The value of the parameter
  24739. */
  24740. setParam(paramName: string, value: number): void;
  24741. /**
  24742. * Specifically change the body's mass option. Won't recreate the physics body object
  24743. * @param mass The mass of the physics imposter
  24744. */
  24745. setMass(mass: number): void;
  24746. /**
  24747. * Gets the linear velocity
  24748. * @returns linear velocity or null
  24749. */
  24750. getLinearVelocity(): Nullable<Vector3>;
  24751. /**
  24752. * Sets the linear velocity
  24753. * @param velocity linear velocity or null
  24754. */
  24755. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24756. /**
  24757. * Gets the angular velocity
  24758. * @returns angular velocity or null
  24759. */
  24760. getAngularVelocity(): Nullable<Vector3>;
  24761. /**
  24762. * Sets the angular velocity
  24763. * @param velocity The velocity or null
  24764. */
  24765. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24766. /**
  24767. * Execute a function with the physics plugin native code
  24768. * Provide a function the will have two variables - the world object and the physics body object
  24769. * @param func The function to execute with the physics plugin native code
  24770. */
  24771. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24772. /**
  24773. * Register a function that will be executed before the physics world is stepping forward
  24774. * @param func The function to execute before the physics world is stepped forward
  24775. */
  24776. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24777. /**
  24778. * Unregister a function that will be executed before the physics world is stepping forward
  24779. * @param func The function to execute before the physics world is stepped forward
  24780. */
  24781. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24782. /**
  24783. * Register a function that will be executed after the physics step
  24784. * @param func The function to execute after physics step
  24785. */
  24786. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24787. /**
  24788. * Unregisters a function that will be executed after the physics step
  24789. * @param func The function to execute after physics step
  24790. */
  24791. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24792. /**
  24793. * register a function that will be executed when this impostor collides against a different body
  24794. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24795. * @param func Callback that is executed on collision
  24796. */
  24797. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24798. /**
  24799. * Unregisters the physics imposter on contact
  24800. * @param collideAgainst The physics object to collide against
  24801. * @param func Callback to execute on collision
  24802. */
  24803. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24804. private _tmpQuat;
  24805. private _tmpQuat2;
  24806. /**
  24807. * Get the parent rotation
  24808. * @returns The parent rotation
  24809. */
  24810. getParentsRotation(): Quaternion;
  24811. /**
  24812. * this function is executed by the physics engine.
  24813. */
  24814. beforeStep: () => void;
  24815. /**
  24816. * this function is executed by the physics engine
  24817. */
  24818. afterStep: () => void;
  24819. /**
  24820. * Legacy collision detection event support
  24821. */
  24822. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24823. /**
  24824. * event and body object due to cannon's event-based architecture.
  24825. */
  24826. onCollide: (e: {
  24827. body: any;
  24828. }) => void;
  24829. /**
  24830. * Apply a force
  24831. * @param force The force to apply
  24832. * @param contactPoint The contact point for the force
  24833. * @returns The physics imposter
  24834. */
  24835. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24836. /**
  24837. * Apply an impulse
  24838. * @param force The impulse force
  24839. * @param contactPoint The contact point for the impulse force
  24840. * @returns The physics imposter
  24841. */
  24842. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24843. /**
  24844. * A help function to create a joint
  24845. * @param otherImpostor A physics imposter used to create a joint
  24846. * @param jointType The type of joint
  24847. * @param jointData The data for the joint
  24848. * @returns The physics imposter
  24849. */
  24850. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24851. /**
  24852. * Add a joint to this impostor with a different impostor
  24853. * @param otherImpostor A physics imposter used to add a joint
  24854. * @param joint The joint to add
  24855. * @returns The physics imposter
  24856. */
  24857. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24858. /**
  24859. * Add an anchor to a cloth impostor
  24860. * @param otherImpostor rigid impostor to anchor to
  24861. * @param width ratio across width from 0 to 1
  24862. * @param height ratio up height from 0 to 1
  24863. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24864. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24865. * @returns impostor the soft imposter
  24866. */
  24867. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24868. /**
  24869. * Add a hook to a rope impostor
  24870. * @param otherImpostor rigid impostor to anchor to
  24871. * @param length ratio across rope from 0 to 1
  24872. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24873. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24874. * @returns impostor the rope imposter
  24875. */
  24876. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24877. /**
  24878. * Will keep this body still, in a sleep mode.
  24879. * @returns the physics imposter
  24880. */
  24881. sleep(): PhysicsImpostor;
  24882. /**
  24883. * Wake the body up.
  24884. * @returns The physics imposter
  24885. */
  24886. wakeUp(): PhysicsImpostor;
  24887. /**
  24888. * Clones the physics imposter
  24889. * @param newObject The physics imposter clones to this physics-enabled object
  24890. * @returns A nullable physics imposter
  24891. */
  24892. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24893. /**
  24894. * Disposes the physics imposter
  24895. */
  24896. dispose(): void;
  24897. /**
  24898. * Sets the delta position
  24899. * @param position The delta position amount
  24900. */
  24901. setDeltaPosition(position: Vector3): void;
  24902. /**
  24903. * Sets the delta rotation
  24904. * @param rotation The delta rotation amount
  24905. */
  24906. setDeltaRotation(rotation: Quaternion): void;
  24907. /**
  24908. * Gets the box size of the physics imposter and stores the result in the input parameter
  24909. * @param result Stores the box size
  24910. * @returns The physics imposter
  24911. */
  24912. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24913. /**
  24914. * Gets the radius of the physics imposter
  24915. * @returns Radius of the physics imposter
  24916. */
  24917. getRadius(): number;
  24918. /**
  24919. * Sync a bone with this impostor
  24920. * @param bone The bone to sync to the impostor.
  24921. * @param boneMesh The mesh that the bone is influencing.
  24922. * @param jointPivot The pivot of the joint / bone in local space.
  24923. * @param distToJoint Optional distance from the impostor to the joint.
  24924. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24925. */
  24926. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24927. /**
  24928. * Sync impostor to a bone
  24929. * @param bone The bone that the impostor will be synced to.
  24930. * @param boneMesh The mesh that the bone is influencing.
  24931. * @param jointPivot The pivot of the joint / bone in local space.
  24932. * @param distToJoint Optional distance from the impostor to the joint.
  24933. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24934. * @param boneAxis Optional vector3 axis the bone is aligned with
  24935. */
  24936. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24937. /**
  24938. * No-Imposter type
  24939. */
  24940. static NoImpostor: number;
  24941. /**
  24942. * Sphere-Imposter type
  24943. */
  24944. static SphereImpostor: number;
  24945. /**
  24946. * Box-Imposter type
  24947. */
  24948. static BoxImpostor: number;
  24949. /**
  24950. * Plane-Imposter type
  24951. */
  24952. static PlaneImpostor: number;
  24953. /**
  24954. * Mesh-imposter type
  24955. */
  24956. static MeshImpostor: number;
  24957. /**
  24958. * Capsule-Impostor type (Ammo.js plugin only)
  24959. */
  24960. static CapsuleImpostor: number;
  24961. /**
  24962. * Cylinder-Imposter type
  24963. */
  24964. static CylinderImpostor: number;
  24965. /**
  24966. * Particle-Imposter type
  24967. */
  24968. static ParticleImpostor: number;
  24969. /**
  24970. * Heightmap-Imposter type
  24971. */
  24972. static HeightmapImpostor: number;
  24973. /**
  24974. * ConvexHull-Impostor type (Ammo.js plugin only)
  24975. */
  24976. static ConvexHullImpostor: number;
  24977. /**
  24978. * Custom-Imposter type (Ammo.js plugin only)
  24979. */
  24980. static CustomImpostor: number;
  24981. /**
  24982. * Rope-Imposter type
  24983. */
  24984. static RopeImpostor: number;
  24985. /**
  24986. * Cloth-Imposter type
  24987. */
  24988. static ClothImpostor: number;
  24989. /**
  24990. * Softbody-Imposter type
  24991. */
  24992. static SoftbodyImpostor: number;
  24993. }
  24994. }
  24995. declare module "babylonjs/Meshes/mesh" {
  24996. import { Observable } from "babylonjs/Misc/observable";
  24997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24998. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24999. import { Camera } from "babylonjs/Cameras/camera";
  25000. import { Scene } from "babylonjs/scene";
  25001. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25002. import { Color4 } from "babylonjs/Maths/math.color";
  25003. import { Engine } from "babylonjs/Engines/engine";
  25004. import { Node } from "babylonjs/node";
  25005. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25006. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25007. import { Buffer } from "babylonjs/Meshes/buffer";
  25008. import { Geometry } from "babylonjs/Meshes/geometry";
  25009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25011. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25012. import { Effect } from "babylonjs/Materials/effect";
  25013. import { Material } from "babylonjs/Materials/material";
  25014. import { Skeleton } from "babylonjs/Bones/skeleton";
  25015. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25016. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25017. import { Path3D } from "babylonjs/Maths/math.path";
  25018. import { Plane } from "babylonjs/Maths/math.plane";
  25019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25020. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25021. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25022. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25023. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25024. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25025. /**
  25026. * @hidden
  25027. **/
  25028. export class _CreationDataStorage {
  25029. closePath?: boolean;
  25030. closeArray?: boolean;
  25031. idx: number[];
  25032. dashSize: number;
  25033. gapSize: number;
  25034. path3D: Path3D;
  25035. pathArray: Vector3[][];
  25036. arc: number;
  25037. radius: number;
  25038. cap: number;
  25039. tessellation: number;
  25040. }
  25041. /**
  25042. * @hidden
  25043. **/
  25044. class _InstanceDataStorage {
  25045. visibleInstances: any;
  25046. batchCache: _InstancesBatch;
  25047. instancesBufferSize: number;
  25048. instancesBuffer: Nullable<Buffer>;
  25049. instancesData: Float32Array;
  25050. overridenInstanceCount: number;
  25051. isFrozen: boolean;
  25052. previousBatch: Nullable<_InstancesBatch>;
  25053. hardwareInstancedRendering: boolean;
  25054. sideOrientation: number;
  25055. manualUpdate: boolean;
  25056. }
  25057. /**
  25058. * @hidden
  25059. **/
  25060. export class _InstancesBatch {
  25061. mustReturn: boolean;
  25062. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25063. renderSelf: boolean[];
  25064. hardwareInstancedRendering: boolean[];
  25065. }
  25066. /**
  25067. * Class used to represent renderable models
  25068. */
  25069. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25070. /**
  25071. * Mesh side orientation : usually the external or front surface
  25072. */
  25073. static readonly FRONTSIDE: number;
  25074. /**
  25075. * Mesh side orientation : usually the internal or back surface
  25076. */
  25077. static readonly BACKSIDE: number;
  25078. /**
  25079. * Mesh side orientation : both internal and external or front and back surfaces
  25080. */
  25081. static readonly DOUBLESIDE: number;
  25082. /**
  25083. * Mesh side orientation : by default, `FRONTSIDE`
  25084. */
  25085. static readonly DEFAULTSIDE: number;
  25086. /**
  25087. * Mesh cap setting : no cap
  25088. */
  25089. static readonly NO_CAP: number;
  25090. /**
  25091. * Mesh cap setting : one cap at the beginning of the mesh
  25092. */
  25093. static readonly CAP_START: number;
  25094. /**
  25095. * Mesh cap setting : one cap at the end of the mesh
  25096. */
  25097. static readonly CAP_END: number;
  25098. /**
  25099. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25100. */
  25101. static readonly CAP_ALL: number;
  25102. /**
  25103. * Mesh pattern setting : no flip or rotate
  25104. */
  25105. static readonly NO_FLIP: number;
  25106. /**
  25107. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25108. */
  25109. static readonly FLIP_TILE: number;
  25110. /**
  25111. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25112. */
  25113. static readonly ROTATE_TILE: number;
  25114. /**
  25115. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25116. */
  25117. static readonly FLIP_ROW: number;
  25118. /**
  25119. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25120. */
  25121. static readonly ROTATE_ROW: number;
  25122. /**
  25123. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25124. */
  25125. static readonly FLIP_N_ROTATE_TILE: number;
  25126. /**
  25127. * Mesh pattern setting : rotate pattern and rotate
  25128. */
  25129. static readonly FLIP_N_ROTATE_ROW: number;
  25130. /**
  25131. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25132. */
  25133. static readonly CENTER: number;
  25134. /**
  25135. * Mesh tile positioning : part tiles on left
  25136. */
  25137. static readonly LEFT: number;
  25138. /**
  25139. * Mesh tile positioning : part tiles on right
  25140. */
  25141. static readonly RIGHT: number;
  25142. /**
  25143. * Mesh tile positioning : part tiles on top
  25144. */
  25145. static readonly TOP: number;
  25146. /**
  25147. * Mesh tile positioning : part tiles on bottom
  25148. */
  25149. static readonly BOTTOM: number;
  25150. /**
  25151. * Gets the default side orientation.
  25152. * @param orientation the orientation to value to attempt to get
  25153. * @returns the default orientation
  25154. * @hidden
  25155. */
  25156. static _GetDefaultSideOrientation(orientation?: number): number;
  25157. private _internalMeshDataInfo;
  25158. /**
  25159. * An event triggered before rendering the mesh
  25160. */
  25161. get onBeforeRenderObservable(): Observable<Mesh>;
  25162. /**
  25163. * An event triggered before binding the mesh
  25164. */
  25165. get onBeforeBindObservable(): Observable<Mesh>;
  25166. /**
  25167. * An event triggered after rendering the mesh
  25168. */
  25169. get onAfterRenderObservable(): Observable<Mesh>;
  25170. /**
  25171. * An event triggered before drawing the mesh
  25172. */
  25173. get onBeforeDrawObservable(): Observable<Mesh>;
  25174. private _onBeforeDrawObserver;
  25175. /**
  25176. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25177. */
  25178. set onBeforeDraw(callback: () => void);
  25179. get hasInstances(): boolean;
  25180. /**
  25181. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25182. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25183. */
  25184. delayLoadState: number;
  25185. /**
  25186. * Gets the list of instances created from this mesh
  25187. * it is not supposed to be modified manually.
  25188. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25189. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25190. */
  25191. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25192. /**
  25193. * Gets the file containing delay loading data for this mesh
  25194. */
  25195. delayLoadingFile: string;
  25196. /** @hidden */
  25197. _binaryInfo: any;
  25198. /**
  25199. * User defined function used to change how LOD level selection is done
  25200. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25201. */
  25202. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25203. /**
  25204. * Gets or sets the morph target manager
  25205. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25206. */
  25207. get morphTargetManager(): Nullable<MorphTargetManager>;
  25208. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25209. /** @hidden */
  25210. _creationDataStorage: Nullable<_CreationDataStorage>;
  25211. /** @hidden */
  25212. _geometry: Nullable<Geometry>;
  25213. /** @hidden */
  25214. _delayInfo: Array<string>;
  25215. /** @hidden */
  25216. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25217. /** @hidden */
  25218. _instanceDataStorage: _InstanceDataStorage;
  25219. private _effectiveMaterial;
  25220. /** @hidden */
  25221. _shouldGenerateFlatShading: boolean;
  25222. /** @hidden */
  25223. _originalBuilderSideOrientation: number;
  25224. /**
  25225. * Use this property to change the original side orientation defined at construction time
  25226. */
  25227. overrideMaterialSideOrientation: Nullable<number>;
  25228. /**
  25229. * Gets the source mesh (the one used to clone this one from)
  25230. */
  25231. get source(): Nullable<Mesh>;
  25232. /**
  25233. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25234. */
  25235. get isUnIndexed(): boolean;
  25236. set isUnIndexed(value: boolean);
  25237. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25238. get worldMatrixInstancedBuffer(): Float32Array;
  25239. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25240. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25241. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25242. /**
  25243. * @constructor
  25244. * @param name The value used by scene.getMeshByName() to do a lookup.
  25245. * @param scene The scene to add this mesh to.
  25246. * @param parent The parent of this mesh, if it has one
  25247. * @param source An optional Mesh from which geometry is shared, cloned.
  25248. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25249. * When false, achieved by calling a clone(), also passing False.
  25250. * This will make creation of children, recursive.
  25251. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25252. */
  25253. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25254. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25255. doNotInstantiate: boolean;
  25256. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25257. /**
  25258. * Gets the class name
  25259. * @returns the string "Mesh".
  25260. */
  25261. getClassName(): string;
  25262. /** @hidden */
  25263. get _isMesh(): boolean;
  25264. /**
  25265. * Returns a description of this mesh
  25266. * @param fullDetails define if full details about this mesh must be used
  25267. * @returns a descriptive string representing this mesh
  25268. */
  25269. toString(fullDetails?: boolean): string;
  25270. /** @hidden */
  25271. _unBindEffect(): void;
  25272. /**
  25273. * Gets a boolean indicating if this mesh has LOD
  25274. */
  25275. get hasLODLevels(): boolean;
  25276. /**
  25277. * Gets the list of MeshLODLevel associated with the current mesh
  25278. * @returns an array of MeshLODLevel
  25279. */
  25280. getLODLevels(): MeshLODLevel[];
  25281. private _sortLODLevels;
  25282. /**
  25283. * Add a mesh as LOD level triggered at the given distance.
  25284. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25285. * @param distance The distance from the center of the object to show this level
  25286. * @param mesh The mesh to be added as LOD level (can be null)
  25287. * @return This mesh (for chaining)
  25288. */
  25289. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25290. /**
  25291. * Returns the LOD level mesh at the passed distance or null if not found.
  25292. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25293. * @param distance The distance from the center of the object to show this level
  25294. * @returns a Mesh or `null`
  25295. */
  25296. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25297. /**
  25298. * Remove a mesh from the LOD array
  25299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25300. * @param mesh defines the mesh to be removed
  25301. * @return This mesh (for chaining)
  25302. */
  25303. removeLODLevel(mesh: Mesh): Mesh;
  25304. /**
  25305. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25306. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25307. * @param camera defines the camera to use to compute distance
  25308. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25309. * @return This mesh (for chaining)
  25310. */
  25311. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25312. /**
  25313. * Gets the mesh internal Geometry object
  25314. */
  25315. get geometry(): Nullable<Geometry>;
  25316. /**
  25317. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25318. * @returns the total number of vertices
  25319. */
  25320. getTotalVertices(): number;
  25321. /**
  25322. * Returns the content of an associated vertex buffer
  25323. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25324. * - VertexBuffer.PositionKind
  25325. * - VertexBuffer.UVKind
  25326. * - VertexBuffer.UV2Kind
  25327. * - VertexBuffer.UV3Kind
  25328. * - VertexBuffer.UV4Kind
  25329. * - VertexBuffer.UV5Kind
  25330. * - VertexBuffer.UV6Kind
  25331. * - VertexBuffer.ColorKind
  25332. * - VertexBuffer.MatricesIndicesKind
  25333. * - VertexBuffer.MatricesIndicesExtraKind
  25334. * - VertexBuffer.MatricesWeightsKind
  25335. * - VertexBuffer.MatricesWeightsExtraKind
  25336. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  25337. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25338. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25339. */
  25340. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25341. /**
  25342. * Returns the mesh VertexBuffer object from the requested `kind`
  25343. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25344. * - VertexBuffer.PositionKind
  25345. * - VertexBuffer.NormalKind
  25346. * - VertexBuffer.UVKind
  25347. * - VertexBuffer.UV2Kind
  25348. * - VertexBuffer.UV3Kind
  25349. * - VertexBuffer.UV4Kind
  25350. * - VertexBuffer.UV5Kind
  25351. * - VertexBuffer.UV6Kind
  25352. * - VertexBuffer.ColorKind
  25353. * - VertexBuffer.MatricesIndicesKind
  25354. * - VertexBuffer.MatricesIndicesExtraKind
  25355. * - VertexBuffer.MatricesWeightsKind
  25356. * - VertexBuffer.MatricesWeightsExtraKind
  25357. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25358. */
  25359. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25360. /**
  25361. * Tests if a specific vertex buffer is associated with this mesh
  25362. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25363. * - VertexBuffer.PositionKind
  25364. * - VertexBuffer.NormalKind
  25365. * - VertexBuffer.UVKind
  25366. * - VertexBuffer.UV2Kind
  25367. * - VertexBuffer.UV3Kind
  25368. * - VertexBuffer.UV4Kind
  25369. * - VertexBuffer.UV5Kind
  25370. * - VertexBuffer.UV6Kind
  25371. * - VertexBuffer.ColorKind
  25372. * - VertexBuffer.MatricesIndicesKind
  25373. * - VertexBuffer.MatricesIndicesExtraKind
  25374. * - VertexBuffer.MatricesWeightsKind
  25375. * - VertexBuffer.MatricesWeightsExtraKind
  25376. * @returns a boolean
  25377. */
  25378. isVerticesDataPresent(kind: string): boolean;
  25379. /**
  25380. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25381. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25382. * - VertexBuffer.PositionKind
  25383. * - VertexBuffer.UVKind
  25384. * - VertexBuffer.UV2Kind
  25385. * - VertexBuffer.UV3Kind
  25386. * - VertexBuffer.UV4Kind
  25387. * - VertexBuffer.UV5Kind
  25388. * - VertexBuffer.UV6Kind
  25389. * - VertexBuffer.ColorKind
  25390. * - VertexBuffer.MatricesIndicesKind
  25391. * - VertexBuffer.MatricesIndicesExtraKind
  25392. * - VertexBuffer.MatricesWeightsKind
  25393. * - VertexBuffer.MatricesWeightsExtraKind
  25394. * @returns a boolean
  25395. */
  25396. isVertexBufferUpdatable(kind: string): boolean;
  25397. /**
  25398. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25399. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25400. * - VertexBuffer.PositionKind
  25401. * - VertexBuffer.NormalKind
  25402. * - VertexBuffer.UVKind
  25403. * - VertexBuffer.UV2Kind
  25404. * - VertexBuffer.UV3Kind
  25405. * - VertexBuffer.UV4Kind
  25406. * - VertexBuffer.UV5Kind
  25407. * - VertexBuffer.UV6Kind
  25408. * - VertexBuffer.ColorKind
  25409. * - VertexBuffer.MatricesIndicesKind
  25410. * - VertexBuffer.MatricesIndicesExtraKind
  25411. * - VertexBuffer.MatricesWeightsKind
  25412. * - VertexBuffer.MatricesWeightsExtraKind
  25413. * @returns an array of strings
  25414. */
  25415. getVerticesDataKinds(): string[];
  25416. /**
  25417. * Returns a positive integer : the total number of indices in this mesh geometry.
  25418. * @returns the numner of indices or zero if the mesh has no geometry.
  25419. */
  25420. getTotalIndices(): number;
  25421. /**
  25422. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25423. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  25424. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25425. * @returns the indices array or an empty array if the mesh has no geometry
  25426. */
  25427. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25428. get isBlocked(): boolean;
  25429. /**
  25430. * Determine if the current mesh is ready to be rendered
  25431. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25432. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25433. * @returns true if all associated assets are ready (material, textures, shaders)
  25434. */
  25435. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25436. /**
  25437. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  25438. */
  25439. get areNormalsFrozen(): boolean;
  25440. /**
  25441. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  25442. * @returns the current mesh
  25443. */
  25444. freezeNormals(): Mesh;
  25445. /**
  25446. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  25447. * @returns the current mesh
  25448. */
  25449. unfreezeNormals(): Mesh;
  25450. /**
  25451. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25452. */
  25453. set overridenInstanceCount(count: number);
  25454. /** @hidden */
  25455. _preActivate(): Mesh;
  25456. /** @hidden */
  25457. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25458. /** @hidden */
  25459. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25460. /**
  25461. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25462. * This means the mesh underlying bounding box and sphere are recomputed.
  25463. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25464. * @returns the current mesh
  25465. */
  25466. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25467. /** @hidden */
  25468. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25469. /**
  25470. * This function will subdivide the mesh into multiple submeshes
  25471. * @param count defines the expected number of submeshes
  25472. */
  25473. subdivide(count: number): void;
  25474. /**
  25475. * Copy a FloatArray into a specific associated vertex buffer
  25476. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25477. * - VertexBuffer.PositionKind
  25478. * - VertexBuffer.UVKind
  25479. * - VertexBuffer.UV2Kind
  25480. * - VertexBuffer.UV3Kind
  25481. * - VertexBuffer.UV4Kind
  25482. * - VertexBuffer.UV5Kind
  25483. * - VertexBuffer.UV6Kind
  25484. * - VertexBuffer.ColorKind
  25485. * - VertexBuffer.MatricesIndicesKind
  25486. * - VertexBuffer.MatricesIndicesExtraKind
  25487. * - VertexBuffer.MatricesWeightsKind
  25488. * - VertexBuffer.MatricesWeightsExtraKind
  25489. * @param data defines the data source
  25490. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25491. * @param stride defines the data stride size (can be null)
  25492. * @returns the current mesh
  25493. */
  25494. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25495. /**
  25496. * Delete a vertex buffer associated with this mesh
  25497. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25498. * - VertexBuffer.PositionKind
  25499. * - VertexBuffer.UVKind
  25500. * - VertexBuffer.UV2Kind
  25501. * - VertexBuffer.UV3Kind
  25502. * - VertexBuffer.UV4Kind
  25503. * - VertexBuffer.UV5Kind
  25504. * - VertexBuffer.UV6Kind
  25505. * - VertexBuffer.ColorKind
  25506. * - VertexBuffer.MatricesIndicesKind
  25507. * - VertexBuffer.MatricesIndicesExtraKind
  25508. * - VertexBuffer.MatricesWeightsKind
  25509. * - VertexBuffer.MatricesWeightsExtraKind
  25510. */
  25511. removeVerticesData(kind: string): void;
  25512. /**
  25513. * Flags an associated vertex buffer as updatable
  25514. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25515. * - VertexBuffer.PositionKind
  25516. * - VertexBuffer.UVKind
  25517. * - VertexBuffer.UV2Kind
  25518. * - VertexBuffer.UV3Kind
  25519. * - VertexBuffer.UV4Kind
  25520. * - VertexBuffer.UV5Kind
  25521. * - VertexBuffer.UV6Kind
  25522. * - VertexBuffer.ColorKind
  25523. * - VertexBuffer.MatricesIndicesKind
  25524. * - VertexBuffer.MatricesIndicesExtraKind
  25525. * - VertexBuffer.MatricesWeightsKind
  25526. * - VertexBuffer.MatricesWeightsExtraKind
  25527. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25528. */
  25529. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25530. /**
  25531. * Sets the mesh global Vertex Buffer
  25532. * @param buffer defines the buffer to use
  25533. * @returns the current mesh
  25534. */
  25535. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25536. /**
  25537. * Update a specific associated vertex buffer
  25538. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25539. * - VertexBuffer.PositionKind
  25540. * - VertexBuffer.UVKind
  25541. * - VertexBuffer.UV2Kind
  25542. * - VertexBuffer.UV3Kind
  25543. * - VertexBuffer.UV4Kind
  25544. * - VertexBuffer.UV5Kind
  25545. * - VertexBuffer.UV6Kind
  25546. * - VertexBuffer.ColorKind
  25547. * - VertexBuffer.MatricesIndicesKind
  25548. * - VertexBuffer.MatricesIndicesExtraKind
  25549. * - VertexBuffer.MatricesWeightsKind
  25550. * - VertexBuffer.MatricesWeightsExtraKind
  25551. * @param data defines the data source
  25552. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25553. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  25554. * @returns the current mesh
  25555. */
  25556. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25557. /**
  25558. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25559. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25560. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25561. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25562. * @returns the current mesh
  25563. */
  25564. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25565. /**
  25566. * Creates a un-shared specific occurence of the geometry for the mesh.
  25567. * @returns the current mesh
  25568. */
  25569. makeGeometryUnique(): Mesh;
  25570. /**
  25571. * Set the index buffer of this mesh
  25572. * @param indices defines the source data
  25573. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25574. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25575. * @returns the current mesh
  25576. */
  25577. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25578. /**
  25579. * Update the current index buffer
  25580. * @param indices defines the source data
  25581. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25582. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25583. * @returns the current mesh
  25584. */
  25585. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25586. /**
  25587. * Invert the geometry to move from a right handed system to a left handed one.
  25588. * @returns the current mesh
  25589. */
  25590. toLeftHanded(): Mesh;
  25591. /** @hidden */
  25592. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25593. /** @hidden */
  25594. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25595. /**
  25596. * Registers for this mesh a javascript function called just before the rendering process
  25597. * @param func defines the function to call before rendering this mesh
  25598. * @returns the current mesh
  25599. */
  25600. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25601. /**
  25602. * Disposes a previously registered javascript function called before the rendering
  25603. * @param func defines the function to remove
  25604. * @returns the current mesh
  25605. */
  25606. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25607. /**
  25608. * Registers for this mesh a javascript function called just after the rendering is complete
  25609. * @param func defines the function to call after rendering this mesh
  25610. * @returns the current mesh
  25611. */
  25612. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25613. /**
  25614. * Disposes a previously registered javascript function called after the rendering.
  25615. * @param func defines the function to remove
  25616. * @returns the current mesh
  25617. */
  25618. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25619. /** @hidden */
  25620. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25621. /** @hidden */
  25622. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25623. /** @hidden */
  25624. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25625. /** @hidden */
  25626. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25627. /** @hidden */
  25628. _rebuild(): void;
  25629. /** @hidden */
  25630. _freeze(): void;
  25631. /** @hidden */
  25632. _unFreeze(): void;
  25633. /**
  25634. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  25635. * @param subMesh defines the subMesh to render
  25636. * @param enableAlphaMode defines if alpha mode can be changed
  25637. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25638. * @returns the current mesh
  25639. */
  25640. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25641. private _onBeforeDraw;
  25642. /**
  25643. * Renormalize the mesh and patch it up if there are no weights
  25644. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25645. * However in the case of zero weights then we set just a single influence to 1.
  25646. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25647. */
  25648. cleanMatrixWeights(): void;
  25649. private normalizeSkinFourWeights;
  25650. private normalizeSkinWeightsAndExtra;
  25651. /**
  25652. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25653. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25654. * the user know there was an issue with importing the mesh
  25655. * @returns a validation object with skinned, valid and report string
  25656. */
  25657. validateSkinning(): {
  25658. skinned: boolean;
  25659. valid: boolean;
  25660. report: string;
  25661. };
  25662. /** @hidden */
  25663. _checkDelayState(): Mesh;
  25664. private _queueLoad;
  25665. /**
  25666. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25667. * A mesh is in the frustum if its bounding box intersects the frustum
  25668. * @param frustumPlanes defines the frustum to test
  25669. * @returns true if the mesh is in the frustum planes
  25670. */
  25671. isInFrustum(frustumPlanes: Plane[]): boolean;
  25672. /**
  25673. * Sets the mesh material by the material or multiMaterial `id` property
  25674. * @param id is a string identifying the material or the multiMaterial
  25675. * @returns the current mesh
  25676. */
  25677. setMaterialByID(id: string): Mesh;
  25678. /**
  25679. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25680. * @returns an array of IAnimatable
  25681. */
  25682. getAnimatables(): IAnimatable[];
  25683. /**
  25684. * Modifies the mesh geometry according to the passed transformation matrix.
  25685. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25686. * The mesh normals are modified using the same transformation.
  25687. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25688. * @param transform defines the transform matrix to use
  25689. * @see http://doc.babylonjs.com/resources/baking_transformations
  25690. * @returns the current mesh
  25691. */
  25692. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25693. /**
  25694. * Modifies the mesh geometry according to its own current World Matrix.
  25695. * The mesh World Matrix is then reset.
  25696. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25697. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25698. * @see http://doc.babylonjs.com/resources/baking_transformations
  25699. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25700. * @returns the current mesh
  25701. */
  25702. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25703. /** @hidden */
  25704. get _positions(): Nullable<Vector3[]>;
  25705. /** @hidden */
  25706. _resetPointsArrayCache(): Mesh;
  25707. /** @hidden */
  25708. _generatePointsArray(): boolean;
  25709. /**
  25710. * Returns a new Mesh object generated from the current mesh properties.
  25711. * This method must not get confused with createInstance()
  25712. * @param name is a string, the name given to the new mesh
  25713. * @param newParent can be any Node object (default `null`)
  25714. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25715. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25716. * @returns a new mesh
  25717. */
  25718. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25719. /**
  25720. * Releases resources associated with this mesh.
  25721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25723. */
  25724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25725. /** @hidden */
  25726. _disposeInstanceSpecificData(): void;
  25727. /**
  25728. * Modifies the mesh geometry according to a displacement map.
  25729. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25730. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25731. * @param url is a string, the URL from the image file is to be downloaded.
  25732. * @param minHeight is the lower limit of the displacement.
  25733. * @param maxHeight is the upper limit of the displacement.
  25734. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25735. * @param uvOffset is an optional vector2 used to offset UV.
  25736. * @param uvScale is an optional vector2 used to scale UV.
  25737. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25738. * @returns the Mesh.
  25739. */
  25740. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25741. /**
  25742. * Modifies the mesh geometry according to a displacementMap buffer.
  25743. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25744. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25745. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25746. * @param heightMapWidth is the width of the buffer image.
  25747. * @param heightMapHeight is the height of the buffer image.
  25748. * @param minHeight is the lower limit of the displacement.
  25749. * @param maxHeight is the upper limit of the displacement.
  25750. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25751. * @param uvOffset is an optional vector2 used to offset UV.
  25752. * @param uvScale is an optional vector2 used to scale UV.
  25753. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25754. * @returns the Mesh.
  25755. */
  25756. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25757. /**
  25758. * Modify the mesh to get a flat shading rendering.
  25759. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25760. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25761. * @returns current mesh
  25762. */
  25763. convertToFlatShadedMesh(): Mesh;
  25764. /**
  25765. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25766. * In other words, more vertices, no more indices and a single bigger VBO.
  25767. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25768. * @returns current mesh
  25769. */
  25770. convertToUnIndexedMesh(): Mesh;
  25771. /**
  25772. * Inverses facet orientations.
  25773. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25774. * @param flipNormals will also inverts the normals
  25775. * @returns current mesh
  25776. */
  25777. flipFaces(flipNormals?: boolean): Mesh;
  25778. /**
  25779. * Increase the number of facets and hence vertices in a mesh
  25780. * Vertex normals are interpolated from existing vertex normals
  25781. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25782. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25783. */
  25784. increaseVertices(numberPerEdge: number): void;
  25785. /**
  25786. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25787. * This will undo any application of covertToFlatShadedMesh
  25788. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25789. */
  25790. forceSharedVertices(): void;
  25791. /** @hidden */
  25792. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25793. /** @hidden */
  25794. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25795. /**
  25796. * Creates a new InstancedMesh object from the mesh model.
  25797. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25798. * @param name defines the name of the new instance
  25799. * @returns a new InstancedMesh
  25800. */
  25801. createInstance(name: string): InstancedMesh;
  25802. /**
  25803. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25804. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25805. * @returns the current mesh
  25806. */
  25807. synchronizeInstances(): Mesh;
  25808. /**
  25809. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25810. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25811. * This should be used together with the simplification to avoid disappearing triangles.
  25812. * @param successCallback an optional success callback to be called after the optimization finished.
  25813. * @returns the current mesh
  25814. */
  25815. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25816. /**
  25817. * Serialize current mesh
  25818. * @param serializationObject defines the object which will receive the serialization data
  25819. */
  25820. serialize(serializationObject: any): void;
  25821. /** @hidden */
  25822. _syncGeometryWithMorphTargetManager(): void;
  25823. /** @hidden */
  25824. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25825. /**
  25826. * Returns a new Mesh object parsed from the source provided.
  25827. * @param parsedMesh is the source
  25828. * @param scene defines the hosting scene
  25829. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25830. * @returns a new Mesh
  25831. */
  25832. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25833. /**
  25834. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25835. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25836. * @param name defines the name of the mesh to create
  25837. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25838. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25839. * @param closePath creates a seam between the first and the last points of each path of the path array
  25840. * @param offset is taken in account only if the `pathArray` is containing a single path
  25841. * @param scene defines the hosting scene
  25842. * @param updatable defines if the mesh must be flagged as updatable
  25843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25844. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  25845. * @returns a new Mesh
  25846. */
  25847. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25848. /**
  25849. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25850. * @param name defines the name of the mesh to create
  25851. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25852. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25853. * @param scene defines the hosting scene
  25854. * @param updatable defines if the mesh must be flagged as updatable
  25855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25856. * @returns a new Mesh
  25857. */
  25858. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25859. /**
  25860. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25861. * @param name defines the name of the mesh to create
  25862. * @param size sets the size (float) of each box side (default 1)
  25863. * @param scene defines the hosting scene
  25864. * @param updatable defines if the mesh must be flagged as updatable
  25865. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25866. * @returns a new Mesh
  25867. */
  25868. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25869. /**
  25870. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25871. * @param name defines the name of the mesh to create
  25872. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25873. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25874. * @param scene defines the hosting scene
  25875. * @param updatable defines if the mesh must be flagged as updatable
  25876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25877. * @returns a new Mesh
  25878. */
  25879. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25880. /**
  25881. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25882. * @param name defines the name of the mesh to create
  25883. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25884. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25885. * @param scene defines the hosting scene
  25886. * @returns a new Mesh
  25887. */
  25888. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25889. /**
  25890. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25891. * @param name defines the name of the mesh to create
  25892. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25893. * @param diameterTop set the top cap diameter (floats, default 1)
  25894. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25895. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25896. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25897. * @param scene defines the hosting scene
  25898. * @param updatable defines if the mesh must be flagged as updatable
  25899. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25900. * @returns a new Mesh
  25901. */
  25902. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25903. /**
  25904. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25905. * @param name defines the name of the mesh to create
  25906. * @param diameter sets the diameter size (float) of the torus (default 1)
  25907. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25908. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25909. * @param scene defines the hosting scene
  25910. * @param updatable defines if the mesh must be flagged as updatable
  25911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25915. /**
  25916. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25917. * @param name defines the name of the mesh to create
  25918. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25919. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25920. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25921. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25922. * @param p the number of windings on X axis (positive integers, default 2)
  25923. * @param q the number of windings on Y axis (positive integers, default 3)
  25924. * @param scene defines the hosting scene
  25925. * @param updatable defines if the mesh must be flagged as updatable
  25926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25927. * @returns a new Mesh
  25928. */
  25929. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25930. /**
  25931. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25932. * @param name defines the name of the mesh to create
  25933. * @param points is an array successive Vector3
  25934. * @param scene defines the hosting scene
  25935. * @param updatable defines if the mesh must be flagged as updatable
  25936. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  25937. * @returns a new Mesh
  25938. */
  25939. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25940. /**
  25941. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25942. * @param name defines the name of the mesh to create
  25943. * @param points is an array successive Vector3
  25944. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25945. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25946. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25947. * @param scene defines the hosting scene
  25948. * @param updatable defines if the mesh must be flagged as updatable
  25949. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  25950. * @returns a new Mesh
  25951. */
  25952. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25953. /**
  25954. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25955. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25956. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  25957. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25958. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25959. * Remember you can only change the shape positions, not their number when updating a polygon.
  25960. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25961. * @param name defines the name of the mesh to create
  25962. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25963. * @param scene defines the hosting scene
  25964. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25965. * @param updatable defines if the mesh must be flagged as updatable
  25966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25967. * @param earcutInjection can be used to inject your own earcut reference
  25968. * @returns a new Mesh
  25969. */
  25970. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25971. /**
  25972. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25973. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25974. * @param name defines the name of the mesh to create
  25975. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25976. * @param depth defines the height of extrusion
  25977. * @param scene defines the hosting scene
  25978. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25979. * @param updatable defines if the mesh must be flagged as updatable
  25980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25981. * @param earcutInjection can be used to inject your own earcut reference
  25982. * @returns a new Mesh
  25983. */
  25984. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25985. /**
  25986. * Creates an extruded shape mesh.
  25987. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  25988. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25989. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25990. * @param name defines the name of the mesh to create
  25991. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25992. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25993. * @param scale is the value to scale the shape
  25994. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  25995. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25996. * @param scene defines the hosting scene
  25997. * @param updatable defines if the mesh must be flagged as updatable
  25998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25999. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  26000. * @returns a new Mesh
  26001. */
  26002. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26003. /**
  26004. * Creates an custom extruded shape mesh.
  26005. * The custom extrusion is a parametric shape.
  26006. * It has no predefined shape. Its final shape will depend on the input parameters.
  26007. * Please consider using the same method from the MeshBuilder class instead
  26008. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26009. * @param name defines the name of the mesh to create
  26010. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  26011. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26012. * @param scaleFunction is a custom Javascript function called on each path point
  26013. * @param rotationFunction is a custom Javascript function called on each path point
  26014. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26015. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26016. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  26017. * @param scene defines the hosting scene
  26018. * @param updatable defines if the mesh must be flagged as updatable
  26019. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26020. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  26021. * @returns a new Mesh
  26022. */
  26023. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26024. /**
  26025. * Creates lathe mesh.
  26026. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26027. * Please consider using the same method from the MeshBuilder class instead
  26028. * @param name defines the name of the mesh to create
  26029. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  26030. * @param radius is the radius value of the lathe
  26031. * @param tessellation is the side number of the lathe.
  26032. * @param scene defines the hosting scene
  26033. * @param updatable defines if the mesh must be flagged as updatable
  26034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26035. * @returns a new Mesh
  26036. */
  26037. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26038. /**
  26039. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26040. * @param name defines the name of the mesh to create
  26041. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26042. * @param scene defines the hosting scene
  26043. * @param updatable defines if the mesh must be flagged as updatable
  26044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26045. * @returns a new Mesh
  26046. */
  26047. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26048. /**
  26049. * Creates a ground mesh.
  26050. * Please consider using the same method from the MeshBuilder class instead
  26051. * @param name defines the name of the mesh to create
  26052. * @param width set the width of the ground
  26053. * @param height set the height of the ground
  26054. * @param subdivisions sets the number of subdivisions per side
  26055. * @param scene defines the hosting scene
  26056. * @param updatable defines if the mesh must be flagged as updatable
  26057. * @returns a new Mesh
  26058. */
  26059. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26060. /**
  26061. * Creates a tiled ground mesh.
  26062. * Please consider using the same method from the MeshBuilder class instead
  26063. * @param name defines the name of the mesh to create
  26064. * @param xmin set the ground minimum X coordinate
  26065. * @param zmin set the ground minimum Y coordinate
  26066. * @param xmax set the ground maximum X coordinate
  26067. * @param zmax set the ground maximum Z coordinate
  26068. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  26069. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  26070. * @param scene defines the hosting scene
  26071. * @param updatable defines if the mesh must be flagged as updatable
  26072. * @returns a new Mesh
  26073. */
  26074. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26075. w: number;
  26076. h: number;
  26077. }, precision: {
  26078. w: number;
  26079. h: number;
  26080. }, scene: Scene, updatable?: boolean): Mesh;
  26081. /**
  26082. * Creates a ground mesh from a height map.
  26083. * Please consider using the same method from the MeshBuilder class instead
  26084. * @see http://doc.babylonjs.com/babylon101/height_map
  26085. * @param name defines the name of the mesh to create
  26086. * @param url sets the URL of the height map image resource
  26087. * @param width set the ground width size
  26088. * @param height set the ground height size
  26089. * @param subdivisions sets the number of subdivision per side
  26090. * @param minHeight is the minimum altitude on the ground
  26091. * @param maxHeight is the maximum altitude on the ground
  26092. * @param scene defines the hosting scene
  26093. * @param updatable defines if the mesh must be flagged as updatable
  26094. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26095. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26096. * @returns a new Mesh
  26097. */
  26098. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  26099. /**
  26100. * Creates a tube mesh.
  26101. * The tube is a parametric shape.
  26102. * It has no predefined shape. Its final shape will depend on the input parameters.
  26103. * Please consider using the same method from the MeshBuilder class instead
  26104. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26105. * @param name defines the name of the mesh to create
  26106. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26107. * @param radius sets the tube radius size
  26108. * @param tessellation is the number of sides on the tubular surface
  26109. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  26110. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  26111. * @param scene defines the hosting scene
  26112. * @param updatable defines if the mesh must be flagged as updatable
  26113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26114. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  26115. * @returns a new Mesh
  26116. */
  26117. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26118. (i: number, distance: number): number;
  26119. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26120. /**
  26121. * Creates a polyhedron mesh.
  26122. * Please consider using the same method from the MeshBuilder class instead.
  26123. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  26124. * * The parameter `size` (positive float, default 1) sets the polygon size
  26125. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26126. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  26127. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  26128. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  26129. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  26130. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  26131. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26134. * @param name defines the name of the mesh to create
  26135. * @param options defines the options used to create the mesh
  26136. * @param scene defines the hosting scene
  26137. * @returns a new Mesh
  26138. */
  26139. static CreatePolyhedron(name: string, options: {
  26140. type?: number;
  26141. size?: number;
  26142. sizeX?: number;
  26143. sizeY?: number;
  26144. sizeZ?: number;
  26145. custom?: any;
  26146. faceUV?: Vector4[];
  26147. faceColors?: Color4[];
  26148. updatable?: boolean;
  26149. sideOrientation?: number;
  26150. }, scene: Scene): Mesh;
  26151. /**
  26152. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26153. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26154. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  26155. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26156. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  26157. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26160. * @param name defines the name of the mesh
  26161. * @param options defines the options used to create the mesh
  26162. * @param scene defines the hosting scene
  26163. * @returns a new Mesh
  26164. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26165. */
  26166. static CreateIcoSphere(name: string, options: {
  26167. radius?: number;
  26168. flat?: boolean;
  26169. subdivisions?: number;
  26170. sideOrientation?: number;
  26171. updatable?: boolean;
  26172. }, scene: Scene): Mesh;
  26173. /**
  26174. * Creates a decal mesh.
  26175. * Please consider using the same method from the MeshBuilder class instead.
  26176. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26177. * @param name defines the name of the mesh
  26178. * @param sourceMesh defines the mesh receiving the decal
  26179. * @param position sets the position of the decal in world coordinates
  26180. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26181. * @param size sets the decal scaling
  26182. * @param angle sets the angle to rotate the decal
  26183. * @returns a new Mesh
  26184. */
  26185. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26186. /**
  26187. * Prepare internal position array for software CPU skinning
  26188. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26189. */
  26190. setPositionsForCPUSkinning(): Float32Array;
  26191. /**
  26192. * Prepare internal normal array for software CPU skinning
  26193. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26194. */
  26195. setNormalsForCPUSkinning(): Float32Array;
  26196. /**
  26197. * Updates the vertex buffer by applying transformation from the bones
  26198. * @param skeleton defines the skeleton to apply to current mesh
  26199. * @returns the current mesh
  26200. */
  26201. applySkeleton(skeleton: Skeleton): Mesh;
  26202. /**
  26203. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  26204. * @param meshes defines the list of meshes to scan
  26205. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26206. */
  26207. static MinMax(meshes: AbstractMesh[]): {
  26208. min: Vector3;
  26209. max: Vector3;
  26210. };
  26211. /**
  26212. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26213. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26214. * @returns a vector3
  26215. */
  26216. static Center(meshesOrMinMaxVector: {
  26217. min: Vector3;
  26218. max: Vector3;
  26219. } | AbstractMesh[]): Vector3;
  26220. /**
  26221. * Merge the array of meshes into a single mesh for performance reasons.
  26222. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26223. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26224. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26225. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26226. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26227. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26228. * @returns a new mesh
  26229. */
  26230. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26231. /** @hidden */
  26232. addInstance(instance: InstancedMesh): void;
  26233. /** @hidden */
  26234. removeInstance(instance: InstancedMesh): void;
  26235. }
  26236. }
  26237. declare module "babylonjs/Cameras/camera" {
  26238. import { SmartArray } from "babylonjs/Misc/smartArray";
  26239. import { Observable } from "babylonjs/Misc/observable";
  26240. import { Nullable } from "babylonjs/types";
  26241. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26242. import { Scene } from "babylonjs/scene";
  26243. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26244. import { Node } from "babylonjs/node";
  26245. import { Mesh } from "babylonjs/Meshes/mesh";
  26246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26247. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26248. import { Viewport } from "babylonjs/Maths/math.viewport";
  26249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26251. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26252. import { Ray } from "babylonjs/Culling/ray";
  26253. /**
  26254. * This is the base class of all the camera used in the application.
  26255. * @see http://doc.babylonjs.com/features/cameras
  26256. */
  26257. export class Camera extends Node {
  26258. /** @hidden */
  26259. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26260. /**
  26261. * This is the default projection mode used by the cameras.
  26262. * It helps recreating a feeling of perspective and better appreciate depth.
  26263. * This is the best way to simulate real life cameras.
  26264. */
  26265. static readonly PERSPECTIVE_CAMERA: number;
  26266. /**
  26267. * This helps creating camera with an orthographic mode.
  26268. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  26269. */
  26270. static readonly ORTHOGRAPHIC_CAMERA: number;
  26271. /**
  26272. * This is the default FOV mode for perspective cameras.
  26273. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26274. */
  26275. static readonly FOVMODE_VERTICAL_FIXED: number;
  26276. /**
  26277. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26278. */
  26279. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26280. /**
  26281. * This specifies ther is no need for a camera rig.
  26282. * Basically only one eye is rendered corresponding to the camera.
  26283. */
  26284. static readonly RIG_MODE_NONE: number;
  26285. /**
  26286. * Simulates a camera Rig with one blue eye and one red eye.
  26287. * This can be use with 3d blue and red glasses.
  26288. */
  26289. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26290. /**
  26291. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26292. */
  26293. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26294. /**
  26295. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26296. */
  26297. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26298. /**
  26299. * Defines that both eyes of the camera will be rendered over under each other.
  26300. */
  26301. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26302. /**
  26303. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26304. */
  26305. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26306. /**
  26307. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26308. */
  26309. static readonly RIG_MODE_VR: number;
  26310. /**
  26311. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26312. */
  26313. static readonly RIG_MODE_WEBVR: number;
  26314. /**
  26315. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26316. */
  26317. static readonly RIG_MODE_CUSTOM: number;
  26318. /**
  26319. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26320. */
  26321. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26322. /**
  26323. * Define the input manager associated with the camera.
  26324. */
  26325. inputs: CameraInputsManager<Camera>;
  26326. /** @hidden */
  26327. _position: Vector3;
  26328. /**
  26329. * Define the current local position of the camera in the scene
  26330. */
  26331. get position(): Vector3;
  26332. set position(newPosition: Vector3);
  26333. /**
  26334. * The vector the camera should consider as up.
  26335. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26336. */
  26337. upVector: Vector3;
  26338. /**
  26339. * Define the current limit on the left side for an orthographic camera
  26340. * In scene unit
  26341. */
  26342. orthoLeft: Nullable<number>;
  26343. /**
  26344. * Define the current limit on the right side for an orthographic camera
  26345. * In scene unit
  26346. */
  26347. orthoRight: Nullable<number>;
  26348. /**
  26349. * Define the current limit on the bottom side for an orthographic camera
  26350. * In scene unit
  26351. */
  26352. orthoBottom: Nullable<number>;
  26353. /**
  26354. * Define the current limit on the top side for an orthographic camera
  26355. * In scene unit
  26356. */
  26357. orthoTop: Nullable<number>;
  26358. /**
  26359. * Field Of View is set in Radians. (default is 0.8)
  26360. */
  26361. fov: number;
  26362. /**
  26363. * Define the minimum distance the camera can see from.
  26364. * This is important to note that the depth buffer are not infinite and the closer it starts
  26365. * the more your scene might encounter depth fighting issue.
  26366. */
  26367. minZ: number;
  26368. /**
  26369. * Define the maximum distance the camera can see to.
  26370. * This is important to note that the depth buffer are not infinite and the further it end
  26371. * the more your scene might encounter depth fighting issue.
  26372. */
  26373. maxZ: number;
  26374. /**
  26375. * Define the default inertia of the camera.
  26376. * This helps giving a smooth feeling to the camera movement.
  26377. */
  26378. inertia: number;
  26379. /**
  26380. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26381. */
  26382. mode: number;
  26383. /**
  26384. * Define whether the camera is intermediate.
  26385. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26386. */
  26387. isIntermediate: boolean;
  26388. /**
  26389. * Define the viewport of the camera.
  26390. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26391. */
  26392. viewport: Viewport;
  26393. /**
  26394. * Restricts the camera to viewing objects with the same layerMask.
  26395. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26396. */
  26397. layerMask: number;
  26398. /**
  26399. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26400. */
  26401. fovMode: number;
  26402. /**
  26403. * Rig mode of the camera.
  26404. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26405. * This is normally controlled byt the camera themselves as internal use.
  26406. */
  26407. cameraRigMode: number;
  26408. /**
  26409. * Defines the distance between both "eyes" in case of a RIG
  26410. */
  26411. interaxialDistance: number;
  26412. /**
  26413. * Defines if stereoscopic rendering is done side by side or over under.
  26414. */
  26415. isStereoscopicSideBySide: boolean;
  26416. /**
  26417. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  26418. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26419. * else in the scene. (Eg. security camera)
  26420. *
  26421. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  26422. */
  26423. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26424. /**
  26425. * When set, the camera will render to this render target instead of the default canvas
  26426. *
  26427. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26428. */
  26429. outputRenderTarget: Nullable<RenderTargetTexture>;
  26430. /**
  26431. * Observable triggered when the camera view matrix has changed.
  26432. */
  26433. onViewMatrixChangedObservable: Observable<Camera>;
  26434. /**
  26435. * Observable triggered when the camera Projection matrix has changed.
  26436. */
  26437. onProjectionMatrixChangedObservable: Observable<Camera>;
  26438. /**
  26439. * Observable triggered when the inputs have been processed.
  26440. */
  26441. onAfterCheckInputsObservable: Observable<Camera>;
  26442. /**
  26443. * Observable triggered when reset has been called and applied to the camera.
  26444. */
  26445. onRestoreStateObservable: Observable<Camera>;
  26446. /**
  26447. * Is this camera a part of a rig system?
  26448. */
  26449. isRigCamera: boolean;
  26450. /**
  26451. * If isRigCamera set to true this will be set with the parent camera.
  26452. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26453. */
  26454. rigParent?: Camera;
  26455. /** @hidden */
  26456. _cameraRigParams: any;
  26457. /** @hidden */
  26458. _rigCameras: Camera[];
  26459. /** @hidden */
  26460. _rigPostProcess: Nullable<PostProcess>;
  26461. protected _webvrViewMatrix: Matrix;
  26462. /** @hidden */
  26463. _skipRendering: boolean;
  26464. /** @hidden */
  26465. _projectionMatrix: Matrix;
  26466. /** @hidden */
  26467. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26468. /** @hidden */
  26469. _activeMeshes: SmartArray<AbstractMesh>;
  26470. protected _globalPosition: Vector3;
  26471. /** @hidden */
  26472. _computedViewMatrix: Matrix;
  26473. private _doNotComputeProjectionMatrix;
  26474. private _transformMatrix;
  26475. private _frustumPlanes;
  26476. private _refreshFrustumPlanes;
  26477. private _storedFov;
  26478. private _stateStored;
  26479. /**
  26480. * Instantiates a new camera object.
  26481. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26482. * @see http://doc.babylonjs.com/features/cameras
  26483. * @param name Defines the name of the camera in the scene
  26484. * @param position Defines the position of the camera
  26485. * @param scene Defines the scene the camera belongs too
  26486. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26487. */
  26488. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26489. /**
  26490. * Store current camera state (fov, position, etc..)
  26491. * @returns the camera
  26492. */
  26493. storeState(): Camera;
  26494. /**
  26495. * Restores the camera state values if it has been stored. You must call storeState() first
  26496. */
  26497. protected _restoreStateValues(): boolean;
  26498. /**
  26499. * Restored camera state. You must call storeState() first.
  26500. * @returns true if restored and false otherwise
  26501. */
  26502. restoreState(): boolean;
  26503. /**
  26504. * Gets the class name of the camera.
  26505. * @returns the class name
  26506. */
  26507. getClassName(): string;
  26508. /** @hidden */
  26509. readonly _isCamera: boolean;
  26510. /**
  26511. * Gets a string representation of the camera useful for debug purpose.
  26512. * @param fullDetails Defines that a more verboe level of logging is required
  26513. * @returns the string representation
  26514. */
  26515. toString(fullDetails?: boolean): string;
  26516. /**
  26517. * Gets the current world space position of the camera.
  26518. */
  26519. get globalPosition(): Vector3;
  26520. /**
  26521. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26522. * @returns the active meshe list
  26523. */
  26524. getActiveMeshes(): SmartArray<AbstractMesh>;
  26525. /**
  26526. * Check whether a mesh is part of the current active mesh list of the camera
  26527. * @param mesh Defines the mesh to check
  26528. * @returns true if active, false otherwise
  26529. */
  26530. isActiveMesh(mesh: Mesh): boolean;
  26531. /**
  26532. * Is this camera ready to be used/rendered
  26533. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26534. * @return true if the camera is ready
  26535. */
  26536. isReady(completeCheck?: boolean): boolean;
  26537. /** @hidden */
  26538. _initCache(): void;
  26539. /** @hidden */
  26540. _updateCache(ignoreParentClass?: boolean): void;
  26541. /** @hidden */
  26542. _isSynchronized(): boolean;
  26543. /** @hidden */
  26544. _isSynchronizedViewMatrix(): boolean;
  26545. /** @hidden */
  26546. _isSynchronizedProjectionMatrix(): boolean;
  26547. /**
  26548. * Attach the input controls to a specific dom element to get the input from.
  26549. * @param element Defines the element the controls should be listened from
  26550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26551. */
  26552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26553. /**
  26554. * Detach the current controls from the specified dom element.
  26555. * @param element Defines the element to stop listening the inputs from
  26556. */
  26557. detachControl(element: HTMLElement): void;
  26558. /**
  26559. * Update the camera state according to the different inputs gathered during the frame.
  26560. */
  26561. update(): void;
  26562. /** @hidden */
  26563. _checkInputs(): void;
  26564. /** @hidden */
  26565. get rigCameras(): Camera[];
  26566. /**
  26567. * Gets the post process used by the rig cameras
  26568. */
  26569. get rigPostProcess(): Nullable<PostProcess>;
  26570. /**
  26571. * Internal, gets the first post proces.
  26572. * @returns the first post process to be run on this camera.
  26573. */
  26574. _getFirstPostProcess(): Nullable<PostProcess>;
  26575. private _cascadePostProcessesToRigCams;
  26576. /**
  26577. * Attach a post process to the camera.
  26578. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26579. * @param postProcess The post process to attach to the camera
  26580. * @param insertAt The position of the post process in case several of them are in use in the scene
  26581. * @returns the position the post process has been inserted at
  26582. */
  26583. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26584. /**
  26585. * Detach a post process to the camera.
  26586. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26587. * @param postProcess The post process to detach from the camera
  26588. */
  26589. detachPostProcess(postProcess: PostProcess): void;
  26590. /**
  26591. * Gets the current world matrix of the camera
  26592. */
  26593. getWorldMatrix(): Matrix;
  26594. /** @hidden */
  26595. _getViewMatrix(): Matrix;
  26596. /**
  26597. * Gets the current view matrix of the camera.
  26598. * @param force forces the camera to recompute the matrix without looking at the cached state
  26599. * @returns the view matrix
  26600. */
  26601. getViewMatrix(force?: boolean): Matrix;
  26602. /**
  26603. * Freeze the projection matrix.
  26604. * It will prevent the cache check of the camera projection compute and can speed up perf
  26605. * if no parameter of the camera are meant to change
  26606. * @param projection Defines manually a projection if necessary
  26607. */
  26608. freezeProjectionMatrix(projection?: Matrix): void;
  26609. /**
  26610. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26611. */
  26612. unfreezeProjectionMatrix(): void;
  26613. /**
  26614. * Gets the current projection matrix of the camera.
  26615. * @param force forces the camera to recompute the matrix without looking at the cached state
  26616. * @returns the projection matrix
  26617. */
  26618. getProjectionMatrix(force?: boolean): Matrix;
  26619. /**
  26620. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26621. * @returns a Matrix
  26622. */
  26623. getTransformationMatrix(): Matrix;
  26624. private _updateFrustumPlanes;
  26625. /**
  26626. * Checks if a cullable object (mesh...) is in the camera frustum
  26627. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26628. * @param target The object to check
  26629. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26630. * @returns true if the object is in frustum otherwise false
  26631. */
  26632. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26633. /**
  26634. * Checks if a cullable object (mesh...) is in the camera frustum
  26635. * Unlike isInFrustum this cheks the full bounding box
  26636. * @param target The object to check
  26637. * @returns true if the object is in frustum otherwise false
  26638. */
  26639. isCompletelyInFrustum(target: ICullable): boolean;
  26640. /**
  26641. * Gets a ray in the forward direction from the camera.
  26642. * @param length Defines the length of the ray to create
  26643. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26644. * @param origin Defines the start point of the ray which defaults to the camera position
  26645. * @returns the forward ray
  26646. */
  26647. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26648. /**
  26649. * Releases resources associated with this node.
  26650. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26651. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26652. */
  26653. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26654. /** @hidden */
  26655. _isLeftCamera: boolean;
  26656. /**
  26657. * Gets the left camera of a rig setup in case of Rigged Camera
  26658. */
  26659. get isLeftCamera(): boolean;
  26660. /** @hidden */
  26661. _isRightCamera: boolean;
  26662. /**
  26663. * Gets the right camera of a rig setup in case of Rigged Camera
  26664. */
  26665. get isRightCamera(): boolean;
  26666. /**
  26667. * Gets the left camera of a rig setup in case of Rigged Camera
  26668. */
  26669. get leftCamera(): Nullable<FreeCamera>;
  26670. /**
  26671. * Gets the right camera of a rig setup in case of Rigged Camera
  26672. */
  26673. get rightCamera(): Nullable<FreeCamera>;
  26674. /**
  26675. * Gets the left camera target of a rig setup in case of Rigged Camera
  26676. * @returns the target position
  26677. */
  26678. getLeftTarget(): Nullable<Vector3>;
  26679. /**
  26680. * Gets the right camera target of a rig setup in case of Rigged Camera
  26681. * @returns the target position
  26682. */
  26683. getRightTarget(): Nullable<Vector3>;
  26684. /**
  26685. * @hidden
  26686. */
  26687. setCameraRigMode(mode: number, rigParams: any): void;
  26688. /** @hidden */
  26689. static _setStereoscopicRigMode(camera: Camera): void;
  26690. /** @hidden */
  26691. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26692. /** @hidden */
  26693. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26694. /** @hidden */
  26695. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26696. /** @hidden */
  26697. _getVRProjectionMatrix(): Matrix;
  26698. protected _updateCameraRotationMatrix(): void;
  26699. protected _updateWebVRCameraRotationMatrix(): void;
  26700. /**
  26701. * This function MUST be overwritten by the different WebVR cameras available.
  26702. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26703. * @hidden
  26704. */
  26705. _getWebVRProjectionMatrix(): Matrix;
  26706. /**
  26707. * This function MUST be overwritten by the different WebVR cameras available.
  26708. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26709. * @hidden
  26710. */
  26711. _getWebVRViewMatrix(): Matrix;
  26712. /** @hidden */
  26713. setCameraRigParameter(name: string, value: any): void;
  26714. /**
  26715. * needs to be overridden by children so sub has required properties to be copied
  26716. * @hidden
  26717. */
  26718. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26719. /**
  26720. * May need to be overridden by children
  26721. * @hidden
  26722. */
  26723. _updateRigCameras(): void;
  26724. /** @hidden */
  26725. _setupInputs(): void;
  26726. /**
  26727. * Serialiaze the camera setup to a json represention
  26728. * @returns the JSON representation
  26729. */
  26730. serialize(): any;
  26731. /**
  26732. * Clones the current camera.
  26733. * @param name The cloned camera name
  26734. * @returns the cloned camera
  26735. */
  26736. clone(name: string): Camera;
  26737. /**
  26738. * Gets the direction of the camera relative to a given local axis.
  26739. * @param localAxis Defines the reference axis to provide a relative direction.
  26740. * @return the direction
  26741. */
  26742. getDirection(localAxis: Vector3): Vector3;
  26743. /**
  26744. * Returns the current camera absolute rotation
  26745. */
  26746. get absoluteRotation(): Quaternion;
  26747. /**
  26748. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26749. * @param localAxis Defines the reference axis to provide a relative direction.
  26750. * @param result Defines the vector to store the result in
  26751. */
  26752. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26753. /**
  26754. * Gets a camera constructor for a given camera type
  26755. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26756. * @param name The name of the camera the result will be able to instantiate
  26757. * @param scene The scene the result will construct the camera in
  26758. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26759. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26760. * @returns a factory method to construc the camera
  26761. */
  26762. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26763. /**
  26764. * Compute the world matrix of the camera.
  26765. * @returns the camera world matrix
  26766. */
  26767. computeWorldMatrix(): Matrix;
  26768. /**
  26769. * Parse a JSON and creates the camera from the parsed information
  26770. * @param parsedCamera The JSON to parse
  26771. * @param scene The scene to instantiate the camera in
  26772. * @returns the newly constructed camera
  26773. */
  26774. static Parse(parsedCamera: any, scene: Scene): Camera;
  26775. }
  26776. }
  26777. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26778. import { Nullable } from "babylonjs/types";
  26779. import { Scene } from "babylonjs/scene";
  26780. import { Vector4 } from "babylonjs/Maths/math.vector";
  26781. import { Mesh } from "babylonjs/Meshes/mesh";
  26782. /**
  26783. * Class containing static functions to help procedurally build meshes
  26784. */
  26785. export class DiscBuilder {
  26786. /**
  26787. * Creates a plane polygonal mesh. By default, this is a disc
  26788. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26789. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  26790. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  26791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26794. * @param name defines the name of the mesh
  26795. * @param options defines the options used to create the mesh
  26796. * @param scene defines the hosting scene
  26797. * @returns the plane polygonal mesh
  26798. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26799. */
  26800. static CreateDisc(name: string, options: {
  26801. radius?: number;
  26802. tessellation?: number;
  26803. arc?: number;
  26804. updatable?: boolean;
  26805. sideOrientation?: number;
  26806. frontUVs?: Vector4;
  26807. backUVs?: Vector4;
  26808. }, scene?: Nullable<Scene>): Mesh;
  26809. }
  26810. }
  26811. declare module "babylonjs/Materials/fresnelParameters" {
  26812. import { Color3 } from "babylonjs/Maths/math.color";
  26813. /**
  26814. * This represents all the required information to add a fresnel effect on a material:
  26815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26816. */
  26817. export class FresnelParameters {
  26818. private _isEnabled;
  26819. /**
  26820. * Define if the fresnel effect is enable or not.
  26821. */
  26822. get isEnabled(): boolean;
  26823. set isEnabled(value: boolean);
  26824. /**
  26825. * Define the color used on edges (grazing angle)
  26826. */
  26827. leftColor: Color3;
  26828. /**
  26829. * Define the color used on center
  26830. */
  26831. rightColor: Color3;
  26832. /**
  26833. * Define bias applied to computed fresnel term
  26834. */
  26835. bias: number;
  26836. /**
  26837. * Defined the power exponent applied to fresnel term
  26838. */
  26839. power: number;
  26840. /**
  26841. * Clones the current fresnel and its valuues
  26842. * @returns a clone fresnel configuration
  26843. */
  26844. clone(): FresnelParameters;
  26845. /**
  26846. * Serializes the current fresnel parameters to a JSON representation.
  26847. * @return the JSON serialization
  26848. */
  26849. serialize(): any;
  26850. /**
  26851. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26852. * @param parsedFresnelParameters Define the JSON representation
  26853. * @returns the parsed parameters
  26854. */
  26855. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26856. }
  26857. }
  26858. declare module "babylonjs/Materials/pushMaterial" {
  26859. import { Nullable } from "babylonjs/types";
  26860. import { Scene } from "babylonjs/scene";
  26861. import { Matrix } from "babylonjs/Maths/math.vector";
  26862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26863. import { Mesh } from "babylonjs/Meshes/mesh";
  26864. import { Material } from "babylonjs/Materials/material";
  26865. import { Effect } from "babylonjs/Materials/effect";
  26866. /**
  26867. * Base class of materials working in push mode in babylon JS
  26868. * @hidden
  26869. */
  26870. export class PushMaterial extends Material {
  26871. protected _activeEffect: Effect;
  26872. protected _normalMatrix: Matrix;
  26873. /**
  26874. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26875. * This means that the material can keep using a previous shader while a new one is being compiled.
  26876. * This is mostly used when shader parallel compilation is supported (true by default)
  26877. */
  26878. allowShaderHotSwapping: boolean;
  26879. constructor(name: string, scene: Scene);
  26880. getEffect(): Effect;
  26881. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26882. /**
  26883. * Binds the given world matrix to the active effect
  26884. *
  26885. * @param world the matrix to bind
  26886. */
  26887. bindOnlyWorldMatrix(world: Matrix): void;
  26888. /**
  26889. * Binds the given normal matrix to the active effect
  26890. *
  26891. * @param normalMatrix the matrix to bind
  26892. */
  26893. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26894. bind(world: Matrix, mesh?: Mesh): void;
  26895. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26896. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26897. }
  26898. }
  26899. declare module "babylonjs/Materials/materialFlags" {
  26900. /**
  26901. * This groups all the flags used to control the materials channel.
  26902. */
  26903. export class MaterialFlags {
  26904. private static _DiffuseTextureEnabled;
  26905. /**
  26906. * Are diffuse textures enabled in the application.
  26907. */
  26908. static get DiffuseTextureEnabled(): boolean;
  26909. static set DiffuseTextureEnabled(value: boolean);
  26910. private static _AmbientTextureEnabled;
  26911. /**
  26912. * Are ambient textures enabled in the application.
  26913. */
  26914. static get AmbientTextureEnabled(): boolean;
  26915. static set AmbientTextureEnabled(value: boolean);
  26916. private static _OpacityTextureEnabled;
  26917. /**
  26918. * Are opacity textures enabled in the application.
  26919. */
  26920. static get OpacityTextureEnabled(): boolean;
  26921. static set OpacityTextureEnabled(value: boolean);
  26922. private static _ReflectionTextureEnabled;
  26923. /**
  26924. * Are reflection textures enabled in the application.
  26925. */
  26926. static get ReflectionTextureEnabled(): boolean;
  26927. static set ReflectionTextureEnabled(value: boolean);
  26928. private static _EmissiveTextureEnabled;
  26929. /**
  26930. * Are emissive textures enabled in the application.
  26931. */
  26932. static get EmissiveTextureEnabled(): boolean;
  26933. static set EmissiveTextureEnabled(value: boolean);
  26934. private static _SpecularTextureEnabled;
  26935. /**
  26936. * Are specular textures enabled in the application.
  26937. */
  26938. static get SpecularTextureEnabled(): boolean;
  26939. static set SpecularTextureEnabled(value: boolean);
  26940. private static _BumpTextureEnabled;
  26941. /**
  26942. * Are bump textures enabled in the application.
  26943. */
  26944. static get BumpTextureEnabled(): boolean;
  26945. static set BumpTextureEnabled(value: boolean);
  26946. private static _LightmapTextureEnabled;
  26947. /**
  26948. * Are lightmap textures enabled in the application.
  26949. */
  26950. static get LightmapTextureEnabled(): boolean;
  26951. static set LightmapTextureEnabled(value: boolean);
  26952. private static _RefractionTextureEnabled;
  26953. /**
  26954. * Are refraction textures enabled in the application.
  26955. */
  26956. static get RefractionTextureEnabled(): boolean;
  26957. static set RefractionTextureEnabled(value: boolean);
  26958. private static _ColorGradingTextureEnabled;
  26959. /**
  26960. * Are color grading textures enabled in the application.
  26961. */
  26962. static get ColorGradingTextureEnabled(): boolean;
  26963. static set ColorGradingTextureEnabled(value: boolean);
  26964. private static _FresnelEnabled;
  26965. /**
  26966. * Are fresnels enabled in the application.
  26967. */
  26968. static get FresnelEnabled(): boolean;
  26969. static set FresnelEnabled(value: boolean);
  26970. private static _ClearCoatTextureEnabled;
  26971. /**
  26972. * Are clear coat textures enabled in the application.
  26973. */
  26974. static get ClearCoatTextureEnabled(): boolean;
  26975. static set ClearCoatTextureEnabled(value: boolean);
  26976. private static _ClearCoatBumpTextureEnabled;
  26977. /**
  26978. * Are clear coat bump textures enabled in the application.
  26979. */
  26980. static get ClearCoatBumpTextureEnabled(): boolean;
  26981. static set ClearCoatBumpTextureEnabled(value: boolean);
  26982. private static _ClearCoatTintTextureEnabled;
  26983. /**
  26984. * Are clear coat tint textures enabled in the application.
  26985. */
  26986. static get ClearCoatTintTextureEnabled(): boolean;
  26987. static set ClearCoatTintTextureEnabled(value: boolean);
  26988. private static _SheenTextureEnabled;
  26989. /**
  26990. * Are sheen textures enabled in the application.
  26991. */
  26992. static get SheenTextureEnabled(): boolean;
  26993. static set SheenTextureEnabled(value: boolean);
  26994. private static _AnisotropicTextureEnabled;
  26995. /**
  26996. * Are anisotropic textures enabled in the application.
  26997. */
  26998. static get AnisotropicTextureEnabled(): boolean;
  26999. static set AnisotropicTextureEnabled(value: boolean);
  27000. private static _ThicknessTextureEnabled;
  27001. /**
  27002. * Are thickness textures enabled in the application.
  27003. */
  27004. static get ThicknessTextureEnabled(): boolean;
  27005. static set ThicknessTextureEnabled(value: boolean);
  27006. }
  27007. }
  27008. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27009. /** @hidden */
  27010. export var defaultFragmentDeclaration: {
  27011. name: string;
  27012. shader: string;
  27013. };
  27014. }
  27015. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27016. /** @hidden */
  27017. export var defaultUboDeclaration: {
  27018. name: string;
  27019. shader: string;
  27020. };
  27021. }
  27022. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27023. /** @hidden */
  27024. export var lightFragmentDeclaration: {
  27025. name: string;
  27026. shader: string;
  27027. };
  27028. }
  27029. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27030. /** @hidden */
  27031. export var lightUboDeclaration: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27037. /** @hidden */
  27038. export var lightsFragmentFunctions: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27044. /** @hidden */
  27045. export var shadowsFragmentFunctions: {
  27046. name: string;
  27047. shader: string;
  27048. };
  27049. }
  27050. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27051. /** @hidden */
  27052. export var fresnelFunction: {
  27053. name: string;
  27054. shader: string;
  27055. };
  27056. }
  27057. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27058. /** @hidden */
  27059. export var reflectionFunction: {
  27060. name: string;
  27061. shader: string;
  27062. };
  27063. }
  27064. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27065. /** @hidden */
  27066. export var bumpFragmentFunctions: {
  27067. name: string;
  27068. shader: string;
  27069. };
  27070. }
  27071. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27072. /** @hidden */
  27073. export var logDepthDeclaration: {
  27074. name: string;
  27075. shader: string;
  27076. };
  27077. }
  27078. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27079. /** @hidden */
  27080. export var bumpFragment: {
  27081. name: string;
  27082. shader: string;
  27083. };
  27084. }
  27085. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27086. /** @hidden */
  27087. export var depthPrePass: {
  27088. name: string;
  27089. shader: string;
  27090. };
  27091. }
  27092. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27093. /** @hidden */
  27094. export var lightFragment: {
  27095. name: string;
  27096. shader: string;
  27097. };
  27098. }
  27099. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27100. /** @hidden */
  27101. export var logDepthFragment: {
  27102. name: string;
  27103. shader: string;
  27104. };
  27105. }
  27106. declare module "babylonjs/Shaders/default.fragment" {
  27107. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27108. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27109. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27110. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27111. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27112. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27113. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27114. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27115. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27116. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27117. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27118. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27119. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27120. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27121. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27122. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27123. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27124. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27125. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27126. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27127. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27128. /** @hidden */
  27129. export var defaultPixelShader: {
  27130. name: string;
  27131. shader: string;
  27132. };
  27133. }
  27134. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27135. /** @hidden */
  27136. export var defaultVertexDeclaration: {
  27137. name: string;
  27138. shader: string;
  27139. };
  27140. }
  27141. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27142. /** @hidden */
  27143. export var bumpVertexDeclaration: {
  27144. name: string;
  27145. shader: string;
  27146. };
  27147. }
  27148. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27149. /** @hidden */
  27150. export var bumpVertex: {
  27151. name: string;
  27152. shader: string;
  27153. };
  27154. }
  27155. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27156. /** @hidden */
  27157. export var fogVertex: {
  27158. name: string;
  27159. shader: string;
  27160. };
  27161. }
  27162. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27163. /** @hidden */
  27164. export var shadowsVertex: {
  27165. name: string;
  27166. shader: string;
  27167. };
  27168. }
  27169. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27170. /** @hidden */
  27171. export var pointCloudVertex: {
  27172. name: string;
  27173. shader: string;
  27174. };
  27175. }
  27176. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27177. /** @hidden */
  27178. export var logDepthVertex: {
  27179. name: string;
  27180. shader: string;
  27181. };
  27182. }
  27183. declare module "babylonjs/Shaders/default.vertex" {
  27184. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27185. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27186. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27187. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27188. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27189. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27190. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27191. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27192. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27193. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27194. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27195. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27196. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27198. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27199. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27200. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27202. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27203. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27204. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27205. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27206. /** @hidden */
  27207. export var defaultVertexShader: {
  27208. name: string;
  27209. shader: string;
  27210. };
  27211. }
  27212. declare module "babylonjs/Materials/standardMaterial" {
  27213. import { SmartArray } from "babylonjs/Misc/smartArray";
  27214. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27215. import { Nullable } from "babylonjs/types";
  27216. import { Scene } from "babylonjs/scene";
  27217. import { Matrix } from "babylonjs/Maths/math.vector";
  27218. import { Color3 } from "babylonjs/Maths/math.color";
  27219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27221. import { Mesh } from "babylonjs/Meshes/mesh";
  27222. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27223. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27224. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27225. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27226. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27228. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27229. import "babylonjs/Shaders/default.fragment";
  27230. import "babylonjs/Shaders/default.vertex";
  27231. /** @hidden */
  27232. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27233. MAINUV1: boolean;
  27234. MAINUV2: boolean;
  27235. DIFFUSE: boolean;
  27236. DIFFUSEDIRECTUV: number;
  27237. AMBIENT: boolean;
  27238. AMBIENTDIRECTUV: number;
  27239. OPACITY: boolean;
  27240. OPACITYDIRECTUV: number;
  27241. OPACITYRGB: boolean;
  27242. REFLECTION: boolean;
  27243. EMISSIVE: boolean;
  27244. EMISSIVEDIRECTUV: number;
  27245. SPECULAR: boolean;
  27246. SPECULARDIRECTUV: number;
  27247. BUMP: boolean;
  27248. BUMPDIRECTUV: number;
  27249. PARALLAX: boolean;
  27250. PARALLAXOCCLUSION: boolean;
  27251. SPECULAROVERALPHA: boolean;
  27252. CLIPPLANE: boolean;
  27253. CLIPPLANE2: boolean;
  27254. CLIPPLANE3: boolean;
  27255. CLIPPLANE4: boolean;
  27256. CLIPPLANE5: boolean;
  27257. CLIPPLANE6: boolean;
  27258. ALPHATEST: boolean;
  27259. DEPTHPREPASS: boolean;
  27260. ALPHAFROMDIFFUSE: boolean;
  27261. POINTSIZE: boolean;
  27262. FOG: boolean;
  27263. SPECULARTERM: boolean;
  27264. DIFFUSEFRESNEL: boolean;
  27265. OPACITYFRESNEL: boolean;
  27266. REFLECTIONFRESNEL: boolean;
  27267. REFRACTIONFRESNEL: boolean;
  27268. EMISSIVEFRESNEL: boolean;
  27269. FRESNEL: boolean;
  27270. NORMAL: boolean;
  27271. UV1: boolean;
  27272. UV2: boolean;
  27273. VERTEXCOLOR: boolean;
  27274. VERTEXALPHA: boolean;
  27275. NUM_BONE_INFLUENCERS: number;
  27276. BonesPerMesh: number;
  27277. BONETEXTURE: boolean;
  27278. INSTANCES: boolean;
  27279. GLOSSINESS: boolean;
  27280. ROUGHNESS: boolean;
  27281. EMISSIVEASILLUMINATION: boolean;
  27282. LINKEMISSIVEWITHDIFFUSE: boolean;
  27283. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27284. LIGHTMAP: boolean;
  27285. LIGHTMAPDIRECTUV: number;
  27286. OBJECTSPACE_NORMALMAP: boolean;
  27287. USELIGHTMAPASSHADOWMAP: boolean;
  27288. REFLECTIONMAP_3D: boolean;
  27289. REFLECTIONMAP_SPHERICAL: boolean;
  27290. REFLECTIONMAP_PLANAR: boolean;
  27291. REFLECTIONMAP_CUBIC: boolean;
  27292. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27293. REFLECTIONMAP_PROJECTION: boolean;
  27294. REFLECTIONMAP_SKYBOX: boolean;
  27295. REFLECTIONMAP_EXPLICIT: boolean;
  27296. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27297. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27298. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27299. INVERTCUBICMAP: boolean;
  27300. LOGARITHMICDEPTH: boolean;
  27301. REFRACTION: boolean;
  27302. REFRACTIONMAP_3D: boolean;
  27303. REFLECTIONOVERALPHA: boolean;
  27304. TWOSIDEDLIGHTING: boolean;
  27305. SHADOWFLOAT: boolean;
  27306. MORPHTARGETS: boolean;
  27307. MORPHTARGETS_NORMAL: boolean;
  27308. MORPHTARGETS_TANGENT: boolean;
  27309. MORPHTARGETS_UV: boolean;
  27310. NUM_MORPH_INFLUENCERS: number;
  27311. NONUNIFORMSCALING: boolean;
  27312. PREMULTIPLYALPHA: boolean;
  27313. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27314. ALPHABLEND: boolean;
  27315. IMAGEPROCESSING: boolean;
  27316. VIGNETTE: boolean;
  27317. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27318. VIGNETTEBLENDMODEOPAQUE: boolean;
  27319. TONEMAPPING: boolean;
  27320. TONEMAPPING_ACES: boolean;
  27321. CONTRAST: boolean;
  27322. COLORCURVES: boolean;
  27323. COLORGRADING: boolean;
  27324. COLORGRADING3D: boolean;
  27325. SAMPLER3DGREENDEPTH: boolean;
  27326. SAMPLER3DBGRMAP: boolean;
  27327. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27328. MULTIVIEW: boolean;
  27329. /**
  27330. * If the reflection texture on this material is in linear color space
  27331. * @hidden
  27332. */
  27333. IS_REFLECTION_LINEAR: boolean;
  27334. /**
  27335. * If the refraction texture on this material is in linear color space
  27336. * @hidden
  27337. */
  27338. IS_REFRACTION_LINEAR: boolean;
  27339. EXPOSURE: boolean;
  27340. constructor();
  27341. setReflectionMode(modeToEnable: string): void;
  27342. }
  27343. /**
  27344. * This is the default material used in Babylon. It is the best trade off between quality
  27345. * and performances.
  27346. * @see http://doc.babylonjs.com/babylon101/materials
  27347. */
  27348. export class StandardMaterial extends PushMaterial {
  27349. private _diffuseTexture;
  27350. /**
  27351. * The basic texture of the material as viewed under a light.
  27352. */
  27353. diffuseTexture: Nullable<BaseTexture>;
  27354. private _ambientTexture;
  27355. /**
  27356. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27357. */
  27358. ambientTexture: Nullable<BaseTexture>;
  27359. private _opacityTexture;
  27360. /**
  27361. * Define the transparency of the material from a texture.
  27362. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27363. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27364. */
  27365. opacityTexture: Nullable<BaseTexture>;
  27366. private _reflectionTexture;
  27367. /**
  27368. * Define the texture used to display the reflection.
  27369. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27370. */
  27371. reflectionTexture: Nullable<BaseTexture>;
  27372. private _emissiveTexture;
  27373. /**
  27374. * Define texture of the material as if self lit.
  27375. * This will be mixed in the final result even in the absence of light.
  27376. */
  27377. emissiveTexture: Nullable<BaseTexture>;
  27378. private _specularTexture;
  27379. /**
  27380. * Define how the color and intensity of the highlight given by the light in the material.
  27381. */
  27382. specularTexture: Nullable<BaseTexture>;
  27383. private _bumpTexture;
  27384. /**
  27385. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27386. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  27387. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27388. */
  27389. bumpTexture: Nullable<BaseTexture>;
  27390. private _lightmapTexture;
  27391. /**
  27392. * Complex lighting can be computationally expensive to compute at runtime.
  27393. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27394. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27395. */
  27396. lightmapTexture: Nullable<BaseTexture>;
  27397. private _refractionTexture;
  27398. /**
  27399. * Define the texture used to display the refraction.
  27400. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27401. */
  27402. refractionTexture: Nullable<BaseTexture>;
  27403. /**
  27404. * The color of the material lit by the environmental background lighting.
  27405. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27406. */
  27407. ambientColor: Color3;
  27408. /**
  27409. * The basic color of the material as viewed under a light.
  27410. */
  27411. diffuseColor: Color3;
  27412. /**
  27413. * Define how the color and intensity of the highlight given by the light in the material.
  27414. */
  27415. specularColor: Color3;
  27416. /**
  27417. * Define the color of the material as if self lit.
  27418. * This will be mixed in the final result even in the absence of light.
  27419. */
  27420. emissiveColor: Color3;
  27421. /**
  27422. * Defines how sharp are the highlights in the material.
  27423. * The bigger the value the sharper giving a more glossy feeling to the result.
  27424. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27425. */
  27426. specularPower: number;
  27427. private _useAlphaFromDiffuseTexture;
  27428. /**
  27429. * Does the transparency come from the diffuse texture alpha channel.
  27430. */
  27431. useAlphaFromDiffuseTexture: boolean;
  27432. private _useEmissiveAsIllumination;
  27433. /**
  27434. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27435. */
  27436. useEmissiveAsIllumination: boolean;
  27437. private _linkEmissiveWithDiffuse;
  27438. /**
  27439. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27440. * the emissive level when the final color is close to one.
  27441. */
  27442. linkEmissiveWithDiffuse: boolean;
  27443. private _useSpecularOverAlpha;
  27444. /**
  27445. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27446. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27447. */
  27448. useSpecularOverAlpha: boolean;
  27449. private _useReflectionOverAlpha;
  27450. /**
  27451. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27452. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27453. */
  27454. useReflectionOverAlpha: boolean;
  27455. private _disableLighting;
  27456. /**
  27457. * Does lights from the scene impacts this material.
  27458. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27459. */
  27460. disableLighting: boolean;
  27461. private _useObjectSpaceNormalMap;
  27462. /**
  27463. * Allows using an object space normal map (instead of tangent space).
  27464. */
  27465. useObjectSpaceNormalMap: boolean;
  27466. private _useParallax;
  27467. /**
  27468. * Is parallax enabled or not.
  27469. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27470. */
  27471. useParallax: boolean;
  27472. private _useParallaxOcclusion;
  27473. /**
  27474. * Is parallax occlusion enabled or not.
  27475. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27476. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27477. */
  27478. useParallaxOcclusion: boolean;
  27479. /**
  27480. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  27481. */
  27482. parallaxScaleBias: number;
  27483. private _roughness;
  27484. /**
  27485. * Helps to define how blurry the reflections should appears in the material.
  27486. */
  27487. roughness: number;
  27488. /**
  27489. * In case of refraction, define the value of the index of refraction.
  27490. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27491. */
  27492. indexOfRefraction: number;
  27493. /**
  27494. * Invert the refraction texture alongside the y axis.
  27495. * It can be useful with procedural textures or probe for instance.
  27496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27497. */
  27498. invertRefractionY: boolean;
  27499. /**
  27500. * Defines the alpha limits in alpha test mode.
  27501. */
  27502. alphaCutOff: number;
  27503. private _useLightmapAsShadowmap;
  27504. /**
  27505. * In case of light mapping, define whether the map contains light or shadow informations.
  27506. */
  27507. useLightmapAsShadowmap: boolean;
  27508. private _diffuseFresnelParameters;
  27509. /**
  27510. * Define the diffuse fresnel parameters of the material.
  27511. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27512. */
  27513. diffuseFresnelParameters: FresnelParameters;
  27514. private _opacityFresnelParameters;
  27515. /**
  27516. * Define the opacity fresnel parameters of the material.
  27517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27518. */
  27519. opacityFresnelParameters: FresnelParameters;
  27520. private _reflectionFresnelParameters;
  27521. /**
  27522. * Define the reflection fresnel parameters of the material.
  27523. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27524. */
  27525. reflectionFresnelParameters: FresnelParameters;
  27526. private _refractionFresnelParameters;
  27527. /**
  27528. * Define the refraction fresnel parameters of the material.
  27529. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27530. */
  27531. refractionFresnelParameters: FresnelParameters;
  27532. private _emissiveFresnelParameters;
  27533. /**
  27534. * Define the emissive fresnel parameters of the material.
  27535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27536. */
  27537. emissiveFresnelParameters: FresnelParameters;
  27538. private _useReflectionFresnelFromSpecular;
  27539. /**
  27540. * If true automatically deducts the fresnels values from the material specularity.
  27541. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27542. */
  27543. useReflectionFresnelFromSpecular: boolean;
  27544. private _useGlossinessFromSpecularMapAlpha;
  27545. /**
  27546. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27547. */
  27548. useGlossinessFromSpecularMapAlpha: boolean;
  27549. private _maxSimultaneousLights;
  27550. /**
  27551. * Defines the maximum number of lights that can be used in the material
  27552. */
  27553. maxSimultaneousLights: number;
  27554. private _invertNormalMapX;
  27555. /**
  27556. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27557. */
  27558. invertNormalMapX: boolean;
  27559. private _invertNormalMapY;
  27560. /**
  27561. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27562. */
  27563. invertNormalMapY: boolean;
  27564. private _twoSidedLighting;
  27565. /**
  27566. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27567. */
  27568. twoSidedLighting: boolean;
  27569. /**
  27570. * Default configuration related to image processing available in the standard Material.
  27571. */
  27572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27573. /**
  27574. * Gets the image processing configuration used either in this material.
  27575. */
  27576. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27577. /**
  27578. * Sets the Default image processing configuration used either in the this material.
  27579. *
  27580. * If sets to null, the scene one is in use.
  27581. */
  27582. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27583. /**
  27584. * Keep track of the image processing observer to allow dispose and replace.
  27585. */
  27586. private _imageProcessingObserver;
  27587. /**
  27588. * Attaches a new image processing configuration to the Standard Material.
  27589. * @param configuration
  27590. */
  27591. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27592. /**
  27593. * Gets wether the color curves effect is enabled.
  27594. */
  27595. get cameraColorCurvesEnabled(): boolean;
  27596. /**
  27597. * Sets wether the color curves effect is enabled.
  27598. */
  27599. set cameraColorCurvesEnabled(value: boolean);
  27600. /**
  27601. * Gets wether the color grading effect is enabled.
  27602. */
  27603. get cameraColorGradingEnabled(): boolean;
  27604. /**
  27605. * Gets wether the color grading effect is enabled.
  27606. */
  27607. set cameraColorGradingEnabled(value: boolean);
  27608. /**
  27609. * Gets wether tonemapping is enabled or not.
  27610. */
  27611. get cameraToneMappingEnabled(): boolean;
  27612. /**
  27613. * Sets wether tonemapping is enabled or not
  27614. */
  27615. set cameraToneMappingEnabled(value: boolean);
  27616. /**
  27617. * The camera exposure used on this material.
  27618. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27619. * This corresponds to a photographic exposure.
  27620. */
  27621. get cameraExposure(): number;
  27622. /**
  27623. * The camera exposure used on this material.
  27624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27625. * This corresponds to a photographic exposure.
  27626. */
  27627. set cameraExposure(value: number);
  27628. /**
  27629. * Gets The camera contrast used on this material.
  27630. */
  27631. get cameraContrast(): number;
  27632. /**
  27633. * Sets The camera contrast used on this material.
  27634. */
  27635. set cameraContrast(value: number);
  27636. /**
  27637. * Gets the Color Grading 2D Lookup Texture.
  27638. */
  27639. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27640. /**
  27641. * Sets the Color Grading 2D Lookup Texture.
  27642. */
  27643. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27644. /**
  27645. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27646. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27647. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27648. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27649. */
  27650. get cameraColorCurves(): Nullable<ColorCurves>;
  27651. /**
  27652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27654. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27656. */
  27657. set cameraColorCurves(value: Nullable<ColorCurves>);
  27658. /**
  27659. * Custom callback helping to override the default shader used in the material.
  27660. */
  27661. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27662. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27663. protected _worldViewProjectionMatrix: Matrix;
  27664. protected _globalAmbientColor: Color3;
  27665. protected _useLogarithmicDepth: boolean;
  27666. protected _rebuildInParallel: boolean;
  27667. /**
  27668. * Instantiates a new standard material.
  27669. * This is the default material used in Babylon. It is the best trade off between quality
  27670. * and performances.
  27671. * @see http://doc.babylonjs.com/babylon101/materials
  27672. * @param name Define the name of the material in the scene
  27673. * @param scene Define the scene the material belong to
  27674. */
  27675. constructor(name: string, scene: Scene);
  27676. /**
  27677. * Gets a boolean indicating that current material needs to register RTT
  27678. */
  27679. get hasRenderTargetTextures(): boolean;
  27680. /**
  27681. * Gets the current class name of the material e.g. "StandardMaterial"
  27682. * Mainly use in serialization.
  27683. * @returns the class name
  27684. */
  27685. getClassName(): string;
  27686. /**
  27687. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27688. * You can try switching to logarithmic depth.
  27689. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27690. */
  27691. get useLogarithmicDepth(): boolean;
  27692. set useLogarithmicDepth(value: boolean);
  27693. /**
  27694. * Specifies if the material will require alpha blending
  27695. * @returns a boolean specifying if alpha blending is needed
  27696. */
  27697. needAlphaBlending(): boolean;
  27698. /**
  27699. * Specifies if this material should be rendered in alpha test mode
  27700. * @returns a boolean specifying if an alpha test is needed.
  27701. */
  27702. needAlphaTesting(): boolean;
  27703. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27704. /**
  27705. * Get the texture used for alpha test purpose.
  27706. * @returns the diffuse texture in case of the standard material.
  27707. */
  27708. getAlphaTestTexture(): Nullable<BaseTexture>;
  27709. /**
  27710. * Get if the submesh is ready to be used and all its information available.
  27711. * Child classes can use it to update shaders
  27712. * @param mesh defines the mesh to check
  27713. * @param subMesh defines which submesh to check
  27714. * @param useInstances specifies that instances should be used
  27715. * @returns a boolean indicating that the submesh is ready or not
  27716. */
  27717. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27718. /**
  27719. * Builds the material UBO layouts.
  27720. * Used internally during the effect preparation.
  27721. */
  27722. buildUniformLayout(): void;
  27723. /**
  27724. * Unbinds the material from the mesh
  27725. */
  27726. unbind(): void;
  27727. /**
  27728. * Binds the submesh to this material by preparing the effect and shader to draw
  27729. * @param world defines the world transformation matrix
  27730. * @param mesh defines the mesh containing the submesh
  27731. * @param subMesh defines the submesh to bind the material to
  27732. */
  27733. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27734. /**
  27735. * Get the list of animatables in the material.
  27736. * @returns the list of animatables object used in the material
  27737. */
  27738. getAnimatables(): IAnimatable[];
  27739. /**
  27740. * Gets the active textures from the material
  27741. * @returns an array of textures
  27742. */
  27743. getActiveTextures(): BaseTexture[];
  27744. /**
  27745. * Specifies if the material uses a texture
  27746. * @param texture defines the texture to check against the material
  27747. * @returns a boolean specifying if the material uses the texture
  27748. */
  27749. hasTexture(texture: BaseTexture): boolean;
  27750. /**
  27751. * Disposes the material
  27752. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27753. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27754. */
  27755. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27756. /**
  27757. * Makes a duplicate of the material, and gives it a new name
  27758. * @param name defines the new name for the duplicated material
  27759. * @returns the cloned material
  27760. */
  27761. clone(name: string): StandardMaterial;
  27762. /**
  27763. * Serializes this material in a JSON representation
  27764. * @returns the serialized material object
  27765. */
  27766. serialize(): any;
  27767. /**
  27768. * Creates a standard material from parsed material data
  27769. * @param source defines the JSON representation of the material
  27770. * @param scene defines the hosting scene
  27771. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27772. * @returns a new standard material
  27773. */
  27774. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27775. /**
  27776. * Are diffuse textures enabled in the application.
  27777. */
  27778. static get DiffuseTextureEnabled(): boolean;
  27779. static set DiffuseTextureEnabled(value: boolean);
  27780. /**
  27781. * Are ambient textures enabled in the application.
  27782. */
  27783. static get AmbientTextureEnabled(): boolean;
  27784. static set AmbientTextureEnabled(value: boolean);
  27785. /**
  27786. * Are opacity textures enabled in the application.
  27787. */
  27788. static get OpacityTextureEnabled(): boolean;
  27789. static set OpacityTextureEnabled(value: boolean);
  27790. /**
  27791. * Are reflection textures enabled in the application.
  27792. */
  27793. static get ReflectionTextureEnabled(): boolean;
  27794. static set ReflectionTextureEnabled(value: boolean);
  27795. /**
  27796. * Are emissive textures enabled in the application.
  27797. */
  27798. static get EmissiveTextureEnabled(): boolean;
  27799. static set EmissiveTextureEnabled(value: boolean);
  27800. /**
  27801. * Are specular textures enabled in the application.
  27802. */
  27803. static get SpecularTextureEnabled(): boolean;
  27804. static set SpecularTextureEnabled(value: boolean);
  27805. /**
  27806. * Are bump textures enabled in the application.
  27807. */
  27808. static get BumpTextureEnabled(): boolean;
  27809. static set BumpTextureEnabled(value: boolean);
  27810. /**
  27811. * Are lightmap textures enabled in the application.
  27812. */
  27813. static get LightmapTextureEnabled(): boolean;
  27814. static set LightmapTextureEnabled(value: boolean);
  27815. /**
  27816. * Are refraction textures enabled in the application.
  27817. */
  27818. static get RefractionTextureEnabled(): boolean;
  27819. static set RefractionTextureEnabled(value: boolean);
  27820. /**
  27821. * Are color grading textures enabled in the application.
  27822. */
  27823. static get ColorGradingTextureEnabled(): boolean;
  27824. static set ColorGradingTextureEnabled(value: boolean);
  27825. /**
  27826. * Are fresnels enabled in the application.
  27827. */
  27828. static get FresnelEnabled(): boolean;
  27829. static set FresnelEnabled(value: boolean);
  27830. }
  27831. }
  27832. declare module "babylonjs/Particles/solidParticleSystem" {
  27833. import { Nullable } from "babylonjs/types";
  27834. import { Vector3 } from "babylonjs/Maths/math.vector";
  27835. import { Mesh } from "babylonjs/Meshes/mesh";
  27836. import { Scene, IDisposable } from "babylonjs/scene";
  27837. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27838. import { Material } from "babylonjs/Materials/material";
  27839. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27840. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  27841. /**
  27842. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27843. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  27844. * The SPS is also a particle system. It provides some methods to manage the particles.
  27845. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27846. *
  27847. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27848. */
  27849. export class SolidParticleSystem implements IDisposable {
  27850. /**
  27851. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27852. * Example : var p = SPS.particles[i];
  27853. */
  27854. particles: SolidParticle[];
  27855. /**
  27856. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27857. */
  27858. nbParticles: number;
  27859. /**
  27860. * If the particles must ever face the camera (default false). Useful for planar particles.
  27861. */
  27862. billboard: boolean;
  27863. /**
  27864. * Recompute normals when adding a shape
  27865. */
  27866. recomputeNormals: boolean;
  27867. /**
  27868. * This a counter ofr your own usage. It's not set by any SPS functions.
  27869. */
  27870. counter: number;
  27871. /**
  27872. * The SPS name. This name is also given to the underlying mesh.
  27873. */
  27874. name: string;
  27875. /**
  27876. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27877. */
  27878. mesh: Mesh;
  27879. /**
  27880. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27881. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27882. */
  27883. vars: any;
  27884. /**
  27885. * This array is populated when the SPS is set as 'pickable'.
  27886. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27887. * Each element of this array is an object `{idx: int, faceId: int}`.
  27888. * `idx` is the picked particle index in the `SPS.particles` array
  27889. * `faceId` is the picked face index counted within this particle.
  27890. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27891. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27892. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27893. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27894. */
  27895. pickedParticles: {
  27896. idx: number;
  27897. faceId: number;
  27898. }[];
  27899. /**
  27900. * This array is populated when the SPS is set as 'pickable'
  27901. * Each key of this array is a submesh index.
  27902. * Each element of this array is a second array defined like this :
  27903. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27904. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27905. * `idx` is the picked particle index in the `SPS.particles` array
  27906. * `faceId` is the picked face index counted within this particle.
  27907. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27908. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27909. */
  27910. pickedBySubMesh: {
  27911. idx: number;
  27912. faceId: number;
  27913. }[][];
  27914. /**
  27915. * This array is populated when `enableDepthSort` is set to true.
  27916. * Each element of this array is an instance of the class DepthSortedParticle.
  27917. */
  27918. depthSortedParticles: DepthSortedParticle[];
  27919. /**
  27920. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27921. * @hidden
  27922. */
  27923. _bSphereOnly: boolean;
  27924. /**
  27925. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27926. * @hidden
  27927. */
  27928. _bSphereRadiusFactor: number;
  27929. private _scene;
  27930. private _positions;
  27931. private _indices;
  27932. private _normals;
  27933. private _colors;
  27934. private _uvs;
  27935. private _indices32;
  27936. private _positions32;
  27937. private _normals32;
  27938. private _fixedNormal32;
  27939. private _colors32;
  27940. private _uvs32;
  27941. private _index;
  27942. private _updatable;
  27943. private _pickable;
  27944. private _isVisibilityBoxLocked;
  27945. private _alwaysVisible;
  27946. private _depthSort;
  27947. private _expandable;
  27948. private _shapeCounter;
  27949. private _copy;
  27950. private _color;
  27951. private _computeParticleColor;
  27952. private _computeParticleTexture;
  27953. private _computeParticleRotation;
  27954. private _computeParticleVertex;
  27955. private _computeBoundingBox;
  27956. private _depthSortParticles;
  27957. private _camera;
  27958. private _mustUnrotateFixedNormals;
  27959. private _particlesIntersect;
  27960. private _needs32Bits;
  27961. private _isNotBuilt;
  27962. private _lastParticleId;
  27963. private _idxOfId;
  27964. private _multimaterialEnabled;
  27965. private _useModelMaterial;
  27966. private _indicesByMaterial;
  27967. private _materialIndexes;
  27968. private _depthSortFunction;
  27969. private _materialSortFunction;
  27970. private _materials;
  27971. private _multimaterial;
  27972. private _materialIndexesById;
  27973. private _defaultMaterial;
  27974. private _autoUpdateSubMeshes;
  27975. /**
  27976. * Creates a SPS (Solid Particle System) object.
  27977. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27978. * @param scene (Scene) is the scene in which the SPS is added.
  27979. * @param options defines the options of the sps e.g.
  27980. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27981. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27982. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27983. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27984. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27985. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27986. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27987. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27988. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27989. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27990. */
  27991. constructor(name: string, scene: Scene, options?: {
  27992. updatable?: boolean;
  27993. isPickable?: boolean;
  27994. enableDepthSort?: boolean;
  27995. particleIntersection?: boolean;
  27996. boundingSphereOnly?: boolean;
  27997. bSphereRadiusFactor?: number;
  27998. expandable?: boolean;
  27999. useModelMaterial?: boolean;
  28000. enableMultiMaterial?: boolean;
  28001. });
  28002. /**
  28003. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28004. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28005. * @returns the created mesh
  28006. */
  28007. buildMesh(): Mesh;
  28008. /**
  28009. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28010. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28011. * Thus the particles generated from `digest()` have their property `position` set yet.
  28012. * @param mesh ( Mesh ) is the mesh to be digested
  28013. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  28014. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28015. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28016. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28017. * @returns the current SPS
  28018. */
  28019. digest(mesh: Mesh, options?: {
  28020. facetNb?: number;
  28021. number?: number;
  28022. delta?: number;
  28023. storage?: [];
  28024. }): SolidParticleSystem;
  28025. /**
  28026. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28027. * @hidden
  28028. */
  28029. private _unrotateFixedNormals;
  28030. /**
  28031. * Resets the temporary working copy particle
  28032. * @hidden
  28033. */
  28034. private _resetCopy;
  28035. /**
  28036. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28037. * @param p the current index in the positions array to be updated
  28038. * @param ind the current index in the indices array
  28039. * @param shape a Vector3 array, the shape geometry
  28040. * @param positions the positions array to be updated
  28041. * @param meshInd the shape indices array
  28042. * @param indices the indices array to be updated
  28043. * @param meshUV the shape uv array
  28044. * @param uvs the uv array to be updated
  28045. * @param meshCol the shape color array
  28046. * @param colors the color array to be updated
  28047. * @param meshNor the shape normals array
  28048. * @param normals the normals array to be updated
  28049. * @param idx the particle index
  28050. * @param idxInShape the particle index in its shape
  28051. * @param options the addShape() method passed options
  28052. * @model the particle model
  28053. * @hidden
  28054. */
  28055. private _meshBuilder;
  28056. /**
  28057. * Returns a shape Vector3 array from positions float array
  28058. * @param positions float array
  28059. * @returns a vector3 array
  28060. * @hidden
  28061. */
  28062. private _posToShape;
  28063. /**
  28064. * Returns a shapeUV array from a float uvs (array deep copy)
  28065. * @param uvs as a float array
  28066. * @returns a shapeUV array
  28067. * @hidden
  28068. */
  28069. private _uvsToShapeUV;
  28070. /**
  28071. * Adds a new particle object in the particles array
  28072. * @param idx particle index in particles array
  28073. * @param id particle id
  28074. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28075. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28076. * @param model particle ModelShape object
  28077. * @param shapeId model shape identifier
  28078. * @param idxInShape index of the particle in the current model
  28079. * @param bInfo model bounding info object
  28080. * @param storage target storage array, if any
  28081. * @hidden
  28082. */
  28083. private _addParticle;
  28084. /**
  28085. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28086. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28087. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28088. * @param nb (positive integer) the number of particles to be created from this model
  28089. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28090. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28091. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28092. * @returns the number of shapes in the system
  28093. */
  28094. addShape(mesh: Mesh, nb: number, options?: {
  28095. positionFunction?: any;
  28096. vertexFunction?: any;
  28097. storage?: [];
  28098. }): number;
  28099. /**
  28100. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28101. * @hidden
  28102. */
  28103. private _rebuildParticle;
  28104. /**
  28105. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28106. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  28107. * @returns the SPS.
  28108. */
  28109. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28110. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28111. * Returns an array with the removed particles.
  28112. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  28113. * The SPS can't be empty so at least one particle needs to remain in place.
  28114. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28115. * @param start index of the first particle to remove
  28116. * @param end index of the last particle to remove (included)
  28117. * @returns an array populated with the removed particles
  28118. */
  28119. removeParticles(start: number, end: number): SolidParticle[];
  28120. /**
  28121. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28122. * @param solidParticleArray an array populated with Solid Particles objects
  28123. * @returns the SPS
  28124. */
  28125. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28126. /**
  28127. * Creates a new particle and modifies the SPS mesh geometry :
  28128. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28129. * - calls _addParticle() to populate the particle array
  28130. * factorized code from addShape() and insertParticlesFromArray()
  28131. * @param idx particle index in the particles array
  28132. * @param i particle index in its shape
  28133. * @param modelShape particle ModelShape object
  28134. * @param shape shape vertex array
  28135. * @param meshInd shape indices array
  28136. * @param meshUV shape uv array
  28137. * @param meshCol shape color array
  28138. * @param meshNor shape normals array
  28139. * @param bbInfo shape bounding info
  28140. * @param storage target particle storage
  28141. * @options addShape() passed options
  28142. * @hidden
  28143. */
  28144. private _insertNewParticle;
  28145. /**
  28146. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28147. * This method calls `updateParticle()` for each particle of the SPS.
  28148. * For an animated SPS, it is usually called within the render loop.
  28149. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  28150. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28151. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28152. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28153. * @returns the SPS.
  28154. */
  28155. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28156. /**
  28157. * Disposes the SPS.
  28158. */
  28159. dispose(): void;
  28160. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28161. * idx is the particle index in the SPS
  28162. * faceId is the picked face index counted within this particle.
  28163. * Returns null if the pickInfo can't identify a picked particle.
  28164. * @param pickingInfo (PickingInfo object)
  28165. * @returns {idx: number, faceId: number} or null
  28166. */
  28167. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28168. idx: number;
  28169. faceId: number;
  28170. }>;
  28171. /**
  28172. * Returns a SolidParticle object from its identifier : particle.id
  28173. * @param id (integer) the particle Id
  28174. * @returns the searched particle or null if not found in the SPS.
  28175. */
  28176. getParticleById(id: number): Nullable<SolidParticle>;
  28177. /**
  28178. * Returns a new array populated with the particles having the passed shapeId.
  28179. * @param shapeId (integer) the shape identifier
  28180. * @returns a new solid particle array
  28181. */
  28182. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28183. /**
  28184. * Populates the passed array "ref" with the particles having the passed shapeId.
  28185. * @param shapeId the shape identifier
  28186. * @returns the SPS
  28187. * @param ref
  28188. */
  28189. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28190. /**
  28191. * Computes the required SubMeshes according the materials assigned to the particles.
  28192. * @returns the solid particle system.
  28193. * Does nothing if called before the SPS mesh is built.
  28194. */
  28195. computeSubMeshes(): SolidParticleSystem;
  28196. /**
  28197. * Sorts the solid particles by material when MultiMaterial is enabled.
  28198. * Updates the indices32 array.
  28199. * Updates the indicesByMaterial array.
  28200. * Updates the mesh indices array.
  28201. * @returns the SPS
  28202. * @hidden
  28203. */
  28204. private _sortParticlesByMaterial;
  28205. /**
  28206. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28207. * @hidden
  28208. */
  28209. private _setMaterialIndexesById;
  28210. /**
  28211. * Returns an array with unique values of Materials from the passed array
  28212. * @param array the material array to be checked and filtered
  28213. * @hidden
  28214. */
  28215. private _filterUniqueMaterialId;
  28216. /**
  28217. * Sets a new Standard Material as _defaultMaterial if not already set.
  28218. * @hidden
  28219. */
  28220. private _setDefaultMaterial;
  28221. /**
  28222. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28224. * @returns the SPS.
  28225. */
  28226. refreshVisibleSize(): SolidParticleSystem;
  28227. /**
  28228. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28229. * @param size the size (float) of the visibility box
  28230. * note : this doesn't lock the SPS mesh bounding box.
  28231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28232. */
  28233. setVisibilityBox(size: number): void;
  28234. /**
  28235. * Gets whether the SPS as always visible or not
  28236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28237. */
  28238. get isAlwaysVisible(): boolean;
  28239. /**
  28240. * Sets the SPS as always visible or not
  28241. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28242. */
  28243. set isAlwaysVisible(val: boolean);
  28244. /**
  28245. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28247. */
  28248. set isVisibilityBoxLocked(val: boolean);
  28249. /**
  28250. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28252. */
  28253. get isVisibilityBoxLocked(): boolean;
  28254. /**
  28255. * Tells to `setParticles()` to compute the particle rotations or not.
  28256. * Default value : true. The SPS is faster when it's set to false.
  28257. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28258. */
  28259. set computeParticleRotation(val: boolean);
  28260. /**
  28261. * Tells to `setParticles()` to compute the particle colors or not.
  28262. * Default value : true. The SPS is faster when it's set to false.
  28263. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28264. */
  28265. set computeParticleColor(val: boolean);
  28266. set computeParticleTexture(val: boolean);
  28267. /**
  28268. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28269. * Default value : false. The SPS is faster when it's set to false.
  28270. * Note : the particle custom vertex positions aren't stored values.
  28271. */
  28272. set computeParticleVertex(val: boolean);
  28273. /**
  28274. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28275. */
  28276. set computeBoundingBox(val: boolean);
  28277. /**
  28278. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28279. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28280. * Default : `true`
  28281. */
  28282. set depthSortParticles(val: boolean);
  28283. /**
  28284. * Gets if `setParticles()` computes the particle rotations or not.
  28285. * Default value : true. The SPS is faster when it's set to false.
  28286. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28287. */
  28288. get computeParticleRotation(): boolean;
  28289. /**
  28290. * Gets if `setParticles()` computes the particle colors or not.
  28291. * Default value : true. The SPS is faster when it's set to false.
  28292. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28293. */
  28294. get computeParticleColor(): boolean;
  28295. /**
  28296. * Gets if `setParticles()` computes the particle textures or not.
  28297. * Default value : true. The SPS is faster when it's set to false.
  28298. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28299. */
  28300. get computeParticleTexture(): boolean;
  28301. /**
  28302. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28303. * Default value : false. The SPS is faster when it's set to false.
  28304. * Note : the particle custom vertex positions aren't stored values.
  28305. */
  28306. get computeParticleVertex(): boolean;
  28307. /**
  28308. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28309. */
  28310. get computeBoundingBox(): boolean;
  28311. /**
  28312. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28313. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28314. * Default : `true`
  28315. */
  28316. get depthSortParticles(): boolean;
  28317. /**
  28318. * Gets if the SPS is created as expandable at construction time.
  28319. * Default : `false`
  28320. */
  28321. get expandable(): boolean;
  28322. /**
  28323. * Gets if the SPS supports the Multi Materials
  28324. */
  28325. get multimaterialEnabled(): boolean;
  28326. /**
  28327. * Gets if the SPS uses the model materials for its own multimaterial.
  28328. */
  28329. get useModelMaterial(): boolean;
  28330. /**
  28331. * The SPS used material array.
  28332. */
  28333. get materials(): Material[];
  28334. /**
  28335. * Sets the SPS MultiMaterial from the passed materials.
  28336. * Note : the passed array is internally copied and not used then by reference.
  28337. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28338. */
  28339. setMultiMaterial(materials: Material[]): void;
  28340. /**
  28341. * The SPS computed multimaterial object
  28342. */
  28343. get multimaterial(): MultiMaterial;
  28344. set multimaterial(mm: MultiMaterial);
  28345. /**
  28346. * If the subMeshes must be updated on the next call to setParticles()
  28347. */
  28348. get autoUpdateSubMeshes(): boolean;
  28349. set autoUpdateSubMeshes(val: boolean);
  28350. /**
  28351. * This function does nothing. It may be overwritten to set all the particle first values.
  28352. * The SPS doesn't call this function, you may have to call it by your own.
  28353. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28354. */
  28355. initParticles(): void;
  28356. /**
  28357. * This function does nothing. It may be overwritten to recycle a particle.
  28358. * The SPS doesn't call this function, you may have to call it by your own.
  28359. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28360. * @param particle The particle to recycle
  28361. * @returns the recycled particle
  28362. */
  28363. recycleParticle(particle: SolidParticle): SolidParticle;
  28364. /**
  28365. * Updates a particle : this function should be overwritten by the user.
  28366. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28367. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28368. * @example : just set a particle position or velocity and recycle conditions
  28369. * @param particle The particle to update
  28370. * @returns the updated particle
  28371. */
  28372. updateParticle(particle: SolidParticle): SolidParticle;
  28373. /**
  28374. * Updates a vertex of a particle : it can be overwritten by the user.
  28375. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28376. * @param particle the current particle
  28377. * @param vertex the current index of the current particle
  28378. * @param pt the index of the current vertex in the particle shape
  28379. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28380. * @example : just set a vertex particle position
  28381. * @returns the updated vertex
  28382. */
  28383. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28384. /**
  28385. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28386. * This does nothing and may be overwritten by the user.
  28387. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28388. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28389. * @param update the boolean update value actually passed to setParticles()
  28390. */
  28391. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28392. /**
  28393. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28394. * This will be passed three parameters.
  28395. * This does nothing and may be overwritten by the user.
  28396. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28397. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28398. * @param update the boolean update value actually passed to setParticles()
  28399. */
  28400. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28401. }
  28402. }
  28403. declare module "babylonjs/Particles/solidParticle" {
  28404. import { Nullable } from "babylonjs/types";
  28405. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28406. import { Color4 } from "babylonjs/Maths/math.color";
  28407. import { Mesh } from "babylonjs/Meshes/mesh";
  28408. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28409. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28410. import { Plane } from "babylonjs/Maths/math.plane";
  28411. import { Material } from "babylonjs/Materials/material";
  28412. /**
  28413. * Represents one particle of a solid particle system.
  28414. */
  28415. export class SolidParticle {
  28416. /**
  28417. * particle global index
  28418. */
  28419. idx: number;
  28420. /**
  28421. * particle identifier
  28422. */
  28423. id: number;
  28424. /**
  28425. * The color of the particle
  28426. */
  28427. color: Nullable<Color4>;
  28428. /**
  28429. * The world space position of the particle.
  28430. */
  28431. position: Vector3;
  28432. /**
  28433. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28434. */
  28435. rotation: Vector3;
  28436. /**
  28437. * The world space rotation quaternion of the particle.
  28438. */
  28439. rotationQuaternion: Nullable<Quaternion>;
  28440. /**
  28441. * The scaling of the particle.
  28442. */
  28443. scaling: Vector3;
  28444. /**
  28445. * The uvs of the particle.
  28446. */
  28447. uvs: Vector4;
  28448. /**
  28449. * The current speed of the particle.
  28450. */
  28451. velocity: Vector3;
  28452. /**
  28453. * The pivot point in the particle local space.
  28454. */
  28455. pivot: Vector3;
  28456. /**
  28457. * Must the particle be translated from its pivot point in its local space ?
  28458. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28459. * Default : false
  28460. */
  28461. translateFromPivot: boolean;
  28462. /**
  28463. * Is the particle active or not ?
  28464. */
  28465. alive: boolean;
  28466. /**
  28467. * Is the particle visible or not ?
  28468. */
  28469. isVisible: boolean;
  28470. /**
  28471. * Index of this particle in the global "positions" array (Internal use)
  28472. * @hidden
  28473. */
  28474. _pos: number;
  28475. /**
  28476. * @hidden Index of this particle in the global "indices" array (Internal use)
  28477. */
  28478. _ind: number;
  28479. /**
  28480. * @hidden ModelShape of this particle (Internal use)
  28481. */
  28482. _model: ModelShape;
  28483. /**
  28484. * ModelShape id of this particle
  28485. */
  28486. shapeId: number;
  28487. /**
  28488. * Index of the particle in its shape id
  28489. */
  28490. idxInShape: number;
  28491. /**
  28492. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28493. */
  28494. _modelBoundingInfo: BoundingInfo;
  28495. /**
  28496. * @hidden Particle BoundingInfo object (Internal use)
  28497. */
  28498. _boundingInfo: BoundingInfo;
  28499. /**
  28500. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28501. */
  28502. _sps: SolidParticleSystem;
  28503. /**
  28504. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28505. */
  28506. _stillInvisible: boolean;
  28507. /**
  28508. * @hidden Last computed particle rotation matrix
  28509. */
  28510. _rotationMatrix: number[];
  28511. /**
  28512. * Parent particle Id, if any.
  28513. * Default null.
  28514. */
  28515. parentId: Nullable<number>;
  28516. /**
  28517. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28518. */
  28519. materialIndex: Nullable<number>;
  28520. /**
  28521. * Custom object or properties.
  28522. */
  28523. props: Nullable<any>;
  28524. /**
  28525. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28526. * The possible values are :
  28527. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28528. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28529. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28530. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28531. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28532. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28533. * */
  28534. cullingStrategy: number;
  28535. /**
  28536. * @hidden Internal global position in the SPS.
  28537. */
  28538. _globalPosition: Vector3;
  28539. /**
  28540. * Creates a Solid Particle object.
  28541. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28542. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28543. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28544. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28545. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28546. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28547. * @param shapeId (integer) is the model shape identifier in the SPS.
  28548. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28549. * @param sps defines the sps it is associated to
  28550. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28551. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28552. */
  28553. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28554. /**
  28555. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28556. * @param target the particle target
  28557. * @returns the current particle
  28558. */
  28559. copyToRef(target: SolidParticle): SolidParticle;
  28560. /**
  28561. * Legacy support, changed scale to scaling
  28562. */
  28563. get scale(): Vector3;
  28564. /**
  28565. * Legacy support, changed scale to scaling
  28566. */
  28567. set scale(scale: Vector3);
  28568. /**
  28569. * Legacy support, changed quaternion to rotationQuaternion
  28570. */
  28571. get quaternion(): Nullable<Quaternion>;
  28572. /**
  28573. * Legacy support, changed quaternion to rotationQuaternion
  28574. */
  28575. set quaternion(q: Nullable<Quaternion>);
  28576. /**
  28577. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28578. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28579. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28580. * @returns true if it intersects
  28581. */
  28582. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28583. /**
  28584. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28585. * A particle is in the frustum if its bounding box intersects the frustum
  28586. * @param frustumPlanes defines the frustum to test
  28587. * @returns true if the particle is in the frustum planes
  28588. */
  28589. isInFrustum(frustumPlanes: Plane[]): boolean;
  28590. /**
  28591. * get the rotation matrix of the particle
  28592. * @hidden
  28593. */
  28594. getRotationMatrix(m: Matrix): void;
  28595. }
  28596. /**
  28597. * Represents the shape of the model used by one particle of a solid particle system.
  28598. * SPS internal tool, don't use it manually.
  28599. */
  28600. export class ModelShape {
  28601. /**
  28602. * The shape id
  28603. * @hidden
  28604. */
  28605. shapeID: number;
  28606. /**
  28607. * flat array of model positions (internal use)
  28608. * @hidden
  28609. */
  28610. _shape: Vector3[];
  28611. /**
  28612. * flat array of model UVs (internal use)
  28613. * @hidden
  28614. */
  28615. _shapeUV: number[];
  28616. /**
  28617. * color array of the model
  28618. * @hidden
  28619. */
  28620. _shapeColors: number[];
  28621. /**
  28622. * indices array of the model
  28623. * @hidden
  28624. */
  28625. _indices: number[];
  28626. /**
  28627. * normals array of the model
  28628. * @hidden
  28629. */
  28630. _normals: number[];
  28631. /**
  28632. * length of the shape in the model indices array (internal use)
  28633. * @hidden
  28634. */
  28635. _indicesLength: number;
  28636. /**
  28637. * Custom position function (internal use)
  28638. * @hidden
  28639. */
  28640. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28641. /**
  28642. * Custom vertex function (internal use)
  28643. * @hidden
  28644. */
  28645. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28646. /**
  28647. * Model material (internal use)
  28648. * @hidden
  28649. */
  28650. _material: Nullable<Material>;
  28651. /**
  28652. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  28653. * SPS internal tool, don't use it manually.
  28654. * @hidden
  28655. */
  28656. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28657. }
  28658. /**
  28659. * Represents a Depth Sorted Particle in the solid particle system.
  28660. * @hidden
  28661. */
  28662. export class DepthSortedParticle {
  28663. /**
  28664. * Particle index
  28665. */
  28666. idx: number;
  28667. /**
  28668. * Index of the particle in the "indices" array
  28669. */
  28670. ind: number;
  28671. /**
  28672. * Length of the particle shape in the "indices" array
  28673. */
  28674. indicesLength: number;
  28675. /**
  28676. * Squared distance from the particle to the camera
  28677. */
  28678. sqDistance: number;
  28679. /**
  28680. * Material index when used with MultiMaterials
  28681. */
  28682. materialIndex: number;
  28683. /**
  28684. * Creates a new sorted particle
  28685. * @param materialIndex
  28686. */
  28687. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28688. }
  28689. }
  28690. declare module "babylonjs/Collisions/meshCollisionData" {
  28691. import { Collider } from "babylonjs/Collisions/collider";
  28692. import { Vector3 } from "babylonjs/Maths/math.vector";
  28693. import { Nullable } from "babylonjs/types";
  28694. import { Observer } from "babylonjs/Misc/observable";
  28695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28696. /**
  28697. * @hidden
  28698. */
  28699. export class _MeshCollisionData {
  28700. _checkCollisions: boolean;
  28701. _collisionMask: number;
  28702. _collisionGroup: number;
  28703. _collider: Nullable<Collider>;
  28704. _oldPositionForCollisions: Vector3;
  28705. _diffPositionForCollisions: Vector3;
  28706. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28707. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28708. }
  28709. }
  28710. declare module "babylonjs/Meshes/abstractMesh" {
  28711. import { Observable } from "babylonjs/Misc/observable";
  28712. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28713. import { Camera } from "babylonjs/Cameras/camera";
  28714. import { Scene, IDisposable } from "babylonjs/scene";
  28715. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28716. import { Node } from "babylonjs/node";
  28717. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28718. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28720. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28721. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28722. import { Material } from "babylonjs/Materials/material";
  28723. import { Light } from "babylonjs/Lights/light";
  28724. import { Skeleton } from "babylonjs/Bones/skeleton";
  28725. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28726. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28727. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28728. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28729. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28730. import { Plane } from "babylonjs/Maths/math.plane";
  28731. import { Ray } from "babylonjs/Culling/ray";
  28732. import { Collider } from "babylonjs/Collisions/collider";
  28733. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28734. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28735. /** @hidden */
  28736. class _FacetDataStorage {
  28737. facetPositions: Vector3[];
  28738. facetNormals: Vector3[];
  28739. facetPartitioning: number[][];
  28740. facetNb: number;
  28741. partitioningSubdivisions: number;
  28742. partitioningBBoxRatio: number;
  28743. facetDataEnabled: boolean;
  28744. facetParameters: any;
  28745. bbSize: Vector3;
  28746. subDiv: {
  28747. max: number;
  28748. X: number;
  28749. Y: number;
  28750. Z: number;
  28751. };
  28752. facetDepthSort: boolean;
  28753. facetDepthSortEnabled: boolean;
  28754. depthSortedIndices: IndicesArray;
  28755. depthSortedFacets: {
  28756. ind: number;
  28757. sqDistance: number;
  28758. }[];
  28759. facetDepthSortFunction: (f1: {
  28760. ind: number;
  28761. sqDistance: number;
  28762. }, f2: {
  28763. ind: number;
  28764. sqDistance: number;
  28765. }) => number;
  28766. facetDepthSortFrom: Vector3;
  28767. facetDepthSortOrigin: Vector3;
  28768. invertedMatrix: Matrix;
  28769. }
  28770. /**
  28771. * @hidden
  28772. **/
  28773. class _InternalAbstractMeshDataInfo {
  28774. _hasVertexAlpha: boolean;
  28775. _useVertexColors: boolean;
  28776. _numBoneInfluencers: number;
  28777. _applyFog: boolean;
  28778. _receiveShadows: boolean;
  28779. _facetData: _FacetDataStorage;
  28780. _visibility: number;
  28781. _skeleton: Nullable<Skeleton>;
  28782. _layerMask: number;
  28783. _computeBonesUsingShaders: boolean;
  28784. _isActive: boolean;
  28785. _onlyForInstances: boolean;
  28786. _isActiveIntermediate: boolean;
  28787. _onlyForInstancesIntermediate: boolean;
  28788. _actAsRegularMesh: boolean;
  28789. }
  28790. /**
  28791. * Class used to store all common mesh properties
  28792. */
  28793. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28794. /** No occlusion */
  28795. static OCCLUSION_TYPE_NONE: number;
  28796. /** Occlusion set to optimisitic */
  28797. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28798. /** Occlusion set to strict */
  28799. static OCCLUSION_TYPE_STRICT: number;
  28800. /** Use an accurante occlusion algorithm */
  28801. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28802. /** Use a conservative occlusion algorithm */
  28803. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28804. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28805. * Test order :
  28806. * Is the bounding sphere outside the frustum ?
  28807. * If not, are the bounding box vertices outside the frustum ?
  28808. * It not, then the cullable object is in the frustum.
  28809. */
  28810. static readonly CULLINGSTRATEGY_STANDARD: number;
  28811. /** Culling strategy : Bounding Sphere Only.
  28812. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28813. * It's also less accurate than the standard because some not visible objects can still be selected.
  28814. * Test : is the bounding sphere outside the frustum ?
  28815. * If not, then the cullable object is in the frustum.
  28816. */
  28817. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28818. /** Culling strategy : Optimistic Inclusion.
  28819. * This in an inclusion test first, then the standard exclusion test.
  28820. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28821. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  28822. * Anyway, it's as accurate as the standard strategy.
  28823. * Test :
  28824. * Is the cullable object bounding sphere center in the frustum ?
  28825. * If not, apply the default culling strategy.
  28826. */
  28827. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28828. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28829. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28830. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28831. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  28832. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28833. * Test :
  28834. * Is the cullable object bounding sphere center in the frustum ?
  28835. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28836. */
  28837. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28838. /**
  28839. * No billboard
  28840. */
  28841. static get BILLBOARDMODE_NONE(): number;
  28842. /** Billboard on X axis */
  28843. static get BILLBOARDMODE_X(): number;
  28844. /** Billboard on Y axis */
  28845. static get BILLBOARDMODE_Y(): number;
  28846. /** Billboard on Z axis */
  28847. static get BILLBOARDMODE_Z(): number;
  28848. /** Billboard on all axes */
  28849. static get BILLBOARDMODE_ALL(): number;
  28850. /** Billboard on using position instead of orientation */
  28851. static get BILLBOARDMODE_USE_POSITION(): number;
  28852. /** @hidden */
  28853. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28854. /**
  28855. * The culling strategy to use to check whether the mesh must be rendered or not.
  28856. * This value can be changed at any time and will be used on the next render mesh selection.
  28857. * The possible values are :
  28858. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28859. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28860. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28861. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28862. * Please read each static variable documentation to get details about the culling process.
  28863. * */
  28864. cullingStrategy: number;
  28865. /**
  28866. * Gets the number of facets in the mesh
  28867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28868. */
  28869. get facetNb(): number;
  28870. /**
  28871. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28873. */
  28874. get partitioningSubdivisions(): number;
  28875. set partitioningSubdivisions(nb: number);
  28876. /**
  28877. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28878. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28880. */
  28881. get partitioningBBoxRatio(): number;
  28882. set partitioningBBoxRatio(ratio: number);
  28883. /**
  28884. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28885. * Works only for updatable meshes.
  28886. * Doesn't work with multi-materials
  28887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28888. */
  28889. get mustDepthSortFacets(): boolean;
  28890. set mustDepthSortFacets(sort: boolean);
  28891. /**
  28892. * The location (Vector3) where the facet depth sort must be computed from.
  28893. * By default, the active camera position.
  28894. * Used only when facet depth sort is enabled
  28895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28896. */
  28897. get facetDepthSortFrom(): Vector3;
  28898. set facetDepthSortFrom(location: Vector3);
  28899. /**
  28900. * gets a boolean indicating if facetData is enabled
  28901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28902. */
  28903. get isFacetDataEnabled(): boolean;
  28904. /** @hidden */
  28905. _updateNonUniformScalingState(value: boolean): boolean;
  28906. /**
  28907. * An event triggered when this mesh collides with another one
  28908. */
  28909. onCollideObservable: Observable<AbstractMesh>;
  28910. /** Set a function to call when this mesh collides with another one */
  28911. set onCollide(callback: () => void);
  28912. /**
  28913. * An event triggered when the collision's position changes
  28914. */
  28915. onCollisionPositionChangeObservable: Observable<Vector3>;
  28916. /** Set a function to call when the collision's position changes */
  28917. set onCollisionPositionChange(callback: () => void);
  28918. /**
  28919. * An event triggered when material is changed
  28920. */
  28921. onMaterialChangedObservable: Observable<AbstractMesh>;
  28922. /**
  28923. * Gets or sets the orientation for POV movement & rotation
  28924. */
  28925. definedFacingForward: boolean;
  28926. /** @hidden */
  28927. _occlusionQuery: Nullable<WebGLQuery>;
  28928. /** @hidden */
  28929. _renderingGroup: Nullable<RenderingGroup>;
  28930. /**
  28931. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28932. */
  28933. get visibility(): number;
  28934. /**
  28935. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28936. */
  28937. set visibility(value: number);
  28938. /** Gets or sets the alpha index used to sort transparent meshes
  28939. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28940. */
  28941. alphaIndex: number;
  28942. /**
  28943. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28944. */
  28945. isVisible: boolean;
  28946. /**
  28947. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28948. */
  28949. isPickable: boolean;
  28950. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28951. showSubMeshesBoundingBox: boolean;
  28952. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28953. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28954. */
  28955. isBlocker: boolean;
  28956. /**
  28957. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28958. */
  28959. enablePointerMoveEvents: boolean;
  28960. /**
  28961. * Specifies the rendering group id for this mesh (0 by default)
  28962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28963. */
  28964. renderingGroupId: number;
  28965. private _material;
  28966. /** Gets or sets current material */
  28967. get material(): Nullable<Material>;
  28968. set material(value: Nullable<Material>);
  28969. /**
  28970. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28971. * @see http://doc.babylonjs.com/babylon101/shadows
  28972. */
  28973. get receiveShadows(): boolean;
  28974. set receiveShadows(value: boolean);
  28975. /** Defines color to use when rendering outline */
  28976. outlineColor: Color3;
  28977. /** Define width to use when rendering outline */
  28978. outlineWidth: number;
  28979. /** Defines color to use when rendering overlay */
  28980. overlayColor: Color3;
  28981. /** Defines alpha to use when rendering overlay */
  28982. overlayAlpha: number;
  28983. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28984. get hasVertexAlpha(): boolean;
  28985. set hasVertexAlpha(value: boolean);
  28986. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  28987. get useVertexColors(): boolean;
  28988. set useVertexColors(value: boolean);
  28989. /**
  28990. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28991. */
  28992. get computeBonesUsingShaders(): boolean;
  28993. set computeBonesUsingShaders(value: boolean);
  28994. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28995. get numBoneInfluencers(): number;
  28996. set numBoneInfluencers(value: number);
  28997. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28998. get applyFog(): boolean;
  28999. set applyFog(value: boolean);
  29000. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29001. useOctreeForRenderingSelection: boolean;
  29002. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29003. useOctreeForPicking: boolean;
  29004. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29005. useOctreeForCollisions: boolean;
  29006. /**
  29007. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29008. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29009. */
  29010. get layerMask(): number;
  29011. set layerMask(value: number);
  29012. /**
  29013. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29014. */
  29015. alwaysSelectAsActiveMesh: boolean;
  29016. /**
  29017. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29018. */
  29019. doNotSyncBoundingInfo: boolean;
  29020. /**
  29021. * Gets or sets the current action manager
  29022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29023. */
  29024. actionManager: Nullable<AbstractActionManager>;
  29025. private _meshCollisionData;
  29026. /**
  29027. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29028. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29029. */
  29030. ellipsoid: Vector3;
  29031. /**
  29032. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29033. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29034. */
  29035. ellipsoidOffset: Vector3;
  29036. /**
  29037. * Gets or sets a collision mask used to mask collisions (default is -1).
  29038. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29039. */
  29040. get collisionMask(): number;
  29041. set collisionMask(mask: number);
  29042. /**
  29043. * Gets or sets the current collision group mask (-1 by default).
  29044. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29045. */
  29046. get collisionGroup(): number;
  29047. set collisionGroup(mask: number);
  29048. /**
  29049. * Defines edge width used when edgesRenderer is enabled
  29050. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29051. */
  29052. edgesWidth: number;
  29053. /**
  29054. * Defines edge color used when edgesRenderer is enabled
  29055. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29056. */
  29057. edgesColor: Color4;
  29058. /** @hidden */
  29059. _edgesRenderer: Nullable<IEdgesRenderer>;
  29060. /** @hidden */
  29061. _masterMesh: Nullable<AbstractMesh>;
  29062. /** @hidden */
  29063. _boundingInfo: Nullable<BoundingInfo>;
  29064. /** @hidden */
  29065. _renderId: number;
  29066. /**
  29067. * Gets or sets the list of subMeshes
  29068. * @see http://doc.babylonjs.com/how_to/multi_materials
  29069. */
  29070. subMeshes: SubMesh[];
  29071. /** @hidden */
  29072. _intersectionsInProgress: AbstractMesh[];
  29073. /** @hidden */
  29074. _unIndexed: boolean;
  29075. /** @hidden */
  29076. _lightSources: Light[];
  29077. /** Gets the list of lights affecting that mesh */
  29078. get lightSources(): Light[];
  29079. /** @hidden */
  29080. get _positions(): Nullable<Vector3[]>;
  29081. /** @hidden */
  29082. _waitingData: {
  29083. lods: Nullable<any>;
  29084. actions: Nullable<any>;
  29085. freezeWorldMatrix: Nullable<boolean>;
  29086. };
  29087. /** @hidden */
  29088. _bonesTransformMatrices: Nullable<Float32Array>;
  29089. /** @hidden */
  29090. _transformMatrixTexture: Nullable<RawTexture>;
  29091. /**
  29092. * Gets or sets a skeleton to apply skining transformations
  29093. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29094. */
  29095. set skeleton(value: Nullable<Skeleton>);
  29096. get skeleton(): Nullable<Skeleton>;
  29097. /**
  29098. * An event triggered when the mesh is rebuilt.
  29099. */
  29100. onRebuildObservable: Observable<AbstractMesh>;
  29101. /**
  29102. * Creates a new AbstractMesh
  29103. * @param name defines the name of the mesh
  29104. * @param scene defines the hosting scene
  29105. */
  29106. constructor(name: string, scene?: Nullable<Scene>);
  29107. /**
  29108. * Returns the string "AbstractMesh"
  29109. * @returns "AbstractMesh"
  29110. */
  29111. getClassName(): string;
  29112. /**
  29113. * Gets a string representation of the current mesh
  29114. * @param fullDetails defines a boolean indicating if full details must be included
  29115. * @returns a string representation of the current mesh
  29116. */
  29117. toString(fullDetails?: boolean): string;
  29118. /**
  29119. * @hidden
  29120. */
  29121. protected _getEffectiveParent(): Nullable<Node>;
  29122. /** @hidden */
  29123. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29124. /** @hidden */
  29125. _rebuild(): void;
  29126. /** @hidden */
  29127. _resyncLightSources(): void;
  29128. /** @hidden */
  29129. _resyncLightSource(light: Light): void;
  29130. /** @hidden */
  29131. _unBindEffect(): void;
  29132. /** @hidden */
  29133. _removeLightSource(light: Light, dispose: boolean): void;
  29134. private _markSubMeshesAsDirty;
  29135. /** @hidden */
  29136. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29137. /** @hidden */
  29138. _markSubMeshesAsAttributesDirty(): void;
  29139. /** @hidden */
  29140. _markSubMeshesAsMiscDirty(): void;
  29141. /**
  29142. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29143. */
  29144. get scaling(): Vector3;
  29145. set scaling(newScaling: Vector3);
  29146. /**
  29147. * Returns true if the mesh is blocked. Implemented by child classes
  29148. */
  29149. get isBlocked(): boolean;
  29150. /**
  29151. * Returns the mesh itself by default. Implemented by child classes
  29152. * @param camera defines the camera to use to pick the right LOD level
  29153. * @returns the currentAbstractMesh
  29154. */
  29155. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29156. /**
  29157. * Returns 0 by default. Implemented by child classes
  29158. * @returns an integer
  29159. */
  29160. getTotalVertices(): number;
  29161. /**
  29162. * Returns a positive integer : the total number of indices in this mesh geometry.
  29163. * @returns the numner of indices or zero if the mesh has no geometry.
  29164. */
  29165. getTotalIndices(): number;
  29166. /**
  29167. * Returns null by default. Implemented by child classes
  29168. * @returns null
  29169. */
  29170. getIndices(): Nullable<IndicesArray>;
  29171. /**
  29172. * Returns the array of the requested vertex data kind. Implemented by child classes
  29173. * @param kind defines the vertex data kind to use
  29174. * @returns null
  29175. */
  29176. getVerticesData(kind: string): Nullable<FloatArray>;
  29177. /**
  29178. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29179. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29180. * Note that a new underlying VertexBuffer object is created each call.
  29181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29182. * @param kind defines vertex data kind:
  29183. * * VertexBuffer.PositionKind
  29184. * * VertexBuffer.UVKind
  29185. * * VertexBuffer.UV2Kind
  29186. * * VertexBuffer.UV3Kind
  29187. * * VertexBuffer.UV4Kind
  29188. * * VertexBuffer.UV5Kind
  29189. * * VertexBuffer.UV6Kind
  29190. * * VertexBuffer.ColorKind
  29191. * * VertexBuffer.MatricesIndicesKind
  29192. * * VertexBuffer.MatricesIndicesExtraKind
  29193. * * VertexBuffer.MatricesWeightsKind
  29194. * * VertexBuffer.MatricesWeightsExtraKind
  29195. * @param data defines the data source
  29196. * @param updatable defines if the data must be flagged as updatable (or static)
  29197. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  29198. * @returns the current mesh
  29199. */
  29200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29201. /**
  29202. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29203. * If the mesh has no geometry, it is simply returned as it is.
  29204. * @param kind defines vertex data kind:
  29205. * * VertexBuffer.PositionKind
  29206. * * VertexBuffer.UVKind
  29207. * * VertexBuffer.UV2Kind
  29208. * * VertexBuffer.UV3Kind
  29209. * * VertexBuffer.UV4Kind
  29210. * * VertexBuffer.UV5Kind
  29211. * * VertexBuffer.UV6Kind
  29212. * * VertexBuffer.ColorKind
  29213. * * VertexBuffer.MatricesIndicesKind
  29214. * * VertexBuffer.MatricesIndicesExtraKind
  29215. * * VertexBuffer.MatricesWeightsKind
  29216. * * VertexBuffer.MatricesWeightsExtraKind
  29217. * @param data defines the data source
  29218. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  29219. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29220. * @returns the current mesh
  29221. */
  29222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29223. /**
  29224. * Sets the mesh indices,
  29225. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29226. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29227. * @param totalVertices Defines the total number of vertices
  29228. * @returns the current mesh
  29229. */
  29230. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29231. /**
  29232. * Gets a boolean indicating if specific vertex data is present
  29233. * @param kind defines the vertex data kind to use
  29234. * @returns true is data kind is present
  29235. */
  29236. isVerticesDataPresent(kind: string): boolean;
  29237. /**
  29238. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29239. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29240. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29241. * @returns a BoundingInfo
  29242. */
  29243. getBoundingInfo(): BoundingInfo;
  29244. /**
  29245. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29246. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29247. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29248. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29249. * @returns the current mesh
  29250. */
  29251. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29252. /**
  29253. * Overwrite the current bounding info
  29254. * @param boundingInfo defines the new bounding info
  29255. * @returns the current mesh
  29256. */
  29257. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29258. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29259. get useBones(): boolean;
  29260. /** @hidden */
  29261. _preActivate(): void;
  29262. /** @hidden */
  29263. _preActivateForIntermediateRendering(renderId: number): void;
  29264. /** @hidden */
  29265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29266. /** @hidden */
  29267. _postActivate(): void;
  29268. /** @hidden */
  29269. _freeze(): void;
  29270. /** @hidden */
  29271. _unFreeze(): void;
  29272. /**
  29273. * Gets the current world matrix
  29274. * @returns a Matrix
  29275. */
  29276. getWorldMatrix(): Matrix;
  29277. /** @hidden */
  29278. _getWorldMatrixDeterminant(): number;
  29279. /**
  29280. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29281. */
  29282. get isAnInstance(): boolean;
  29283. /**
  29284. * Gets a boolean indicating if this mesh has instances
  29285. */
  29286. get hasInstances(): boolean;
  29287. /**
  29288. * Perform relative position change from the point of view of behind the front of the mesh.
  29289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29290. * Supports definition of mesh facing forward or backward
  29291. * @param amountRight defines the distance on the right axis
  29292. * @param amountUp defines the distance on the up axis
  29293. * @param amountForward defines the distance on the forward axis
  29294. * @returns the current mesh
  29295. */
  29296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29297. /**
  29298. * Calculate relative position change from the point of view of behind the front of the mesh.
  29299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29300. * Supports definition of mesh facing forward or backward
  29301. * @param amountRight defines the distance on the right axis
  29302. * @param amountUp defines the distance on the up axis
  29303. * @param amountForward defines the distance on the forward axis
  29304. * @returns the new displacement vector
  29305. */
  29306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29307. /**
  29308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29309. * Supports definition of mesh facing forward or backward
  29310. * @param flipBack defines the flip
  29311. * @param twirlClockwise defines the twirl
  29312. * @param tiltRight defines the tilt
  29313. * @returns the current mesh
  29314. */
  29315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29316. /**
  29317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29318. * Supports definition of mesh facing forward or backward.
  29319. * @param flipBack defines the flip
  29320. * @param twirlClockwise defines the twirl
  29321. * @param tiltRight defines the tilt
  29322. * @returns the new rotation vector
  29323. */
  29324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29325. /**
  29326. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29327. * This means the mesh underlying bounding box and sphere are recomputed.
  29328. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29329. * @returns the current mesh
  29330. */
  29331. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29332. /** @hidden */
  29333. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29334. /** @hidden */
  29335. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29336. /** @hidden */
  29337. _updateBoundingInfo(): AbstractMesh;
  29338. /** @hidden */
  29339. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29340. /** @hidden */
  29341. protected _afterComputeWorldMatrix(): void;
  29342. /** @hidden */
  29343. get _effectiveMesh(): AbstractMesh;
  29344. /**
  29345. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29346. * A mesh is in the frustum if its bounding box intersects the frustum
  29347. * @param frustumPlanes defines the frustum to test
  29348. * @returns true if the mesh is in the frustum planes
  29349. */
  29350. isInFrustum(frustumPlanes: Plane[]): boolean;
  29351. /**
  29352. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29353. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29354. * @param frustumPlanes defines the frustum to test
  29355. * @returns true if the mesh is completely in the frustum planes
  29356. */
  29357. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29358. /**
  29359. * True if the mesh intersects another mesh or a SolidParticle object
  29360. * @param mesh defines a target mesh or SolidParticle to test
  29361. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  29362. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29363. * @returns true if there is an intersection
  29364. */
  29365. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29366. /**
  29367. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29368. * @param point defines the point to test
  29369. * @returns true if there is an intersection
  29370. */
  29371. intersectsPoint(point: Vector3): boolean;
  29372. /**
  29373. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29375. */
  29376. get checkCollisions(): boolean;
  29377. set checkCollisions(collisionEnabled: boolean);
  29378. /**
  29379. * Gets Collider object used to compute collisions (not physics)
  29380. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29381. */
  29382. get collider(): Nullable<Collider>;
  29383. /**
  29384. * Move the mesh using collision engine
  29385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29386. * @param displacement defines the requested displacement vector
  29387. * @returns the current mesh
  29388. */
  29389. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29390. private _onCollisionPositionChange;
  29391. /** @hidden */
  29392. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29393. /** @hidden */
  29394. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29395. /** @hidden */
  29396. _checkCollision(collider: Collider): AbstractMesh;
  29397. /** @hidden */
  29398. _generatePointsArray(): boolean;
  29399. /**
  29400. * Checks if the passed Ray intersects with the mesh
  29401. * @param ray defines the ray to use
  29402. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29403. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29404. * @returns the picking info
  29405. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29406. */
  29407. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29408. /**
  29409. * Clones the current mesh
  29410. * @param name defines the mesh name
  29411. * @param newParent defines the new mesh parent
  29412. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29413. * @returns the new mesh
  29414. */
  29415. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29416. /**
  29417. * Disposes all the submeshes of the current meshnp
  29418. * @returns the current mesh
  29419. */
  29420. releaseSubMeshes(): AbstractMesh;
  29421. /**
  29422. * Releases resources associated with this abstract mesh.
  29423. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29424. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29425. */
  29426. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29427. /**
  29428. * Adds the passed mesh as a child to the current mesh
  29429. * @param mesh defines the child mesh
  29430. * @returns the current mesh
  29431. */
  29432. addChild(mesh: AbstractMesh): AbstractMesh;
  29433. /**
  29434. * Removes the passed mesh from the current mesh children list
  29435. * @param mesh defines the child mesh
  29436. * @returns the current mesh
  29437. */
  29438. removeChild(mesh: AbstractMesh): AbstractMesh;
  29439. /** @hidden */
  29440. private _initFacetData;
  29441. /**
  29442. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29443. * This method can be called within the render loop.
  29444. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  29445. * @returns the current mesh
  29446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29447. */
  29448. updateFacetData(): AbstractMesh;
  29449. /**
  29450. * Returns the facetLocalNormals array.
  29451. * The normals are expressed in the mesh local spac
  29452. * @returns an array of Vector3
  29453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29454. */
  29455. getFacetLocalNormals(): Vector3[];
  29456. /**
  29457. * Returns the facetLocalPositions array.
  29458. * The facet positions are expressed in the mesh local space
  29459. * @returns an array of Vector3
  29460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29461. */
  29462. getFacetLocalPositions(): Vector3[];
  29463. /**
  29464. * Returns the facetLocalPartioning array
  29465. * @returns an array of array of numbers
  29466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29467. */
  29468. getFacetLocalPartitioning(): number[][];
  29469. /**
  29470. * Returns the i-th facet position in the world system.
  29471. * This method allocates a new Vector3 per call
  29472. * @param i defines the facet index
  29473. * @returns a new Vector3
  29474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29475. */
  29476. getFacetPosition(i: number): Vector3;
  29477. /**
  29478. * Sets the reference Vector3 with the i-th facet position in the world system
  29479. * @param i defines the facet index
  29480. * @param ref defines the target vector
  29481. * @returns the current mesh
  29482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29483. */
  29484. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29485. /**
  29486. * Returns the i-th facet normal in the world system.
  29487. * This method allocates a new Vector3 per call
  29488. * @param i defines the facet index
  29489. * @returns a new Vector3
  29490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29491. */
  29492. getFacetNormal(i: number): Vector3;
  29493. /**
  29494. * Sets the reference Vector3 with the i-th facet normal in the world system
  29495. * @param i defines the facet index
  29496. * @param ref defines the target vector
  29497. * @returns the current mesh
  29498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29499. */
  29500. getFacetNormalToRef(i: number, ref: Vector3): this;
  29501. /**
  29502. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  29503. * @param x defines x coordinate
  29504. * @param y defines y coordinate
  29505. * @param z defines z coordinate
  29506. * @returns the array of facet indexes
  29507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29508. */
  29509. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29510. /**
  29511. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29512. * @param projected sets as the (x,y,z) world projection on the facet
  29513. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  29514. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  29515. * @param x defines x coordinate
  29516. * @param y defines y coordinate
  29517. * @param z defines z coordinate
  29518. * @returns the face index if found (or null instead)
  29519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29520. */
  29521. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29522. /**
  29523. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29524. * @param projected sets as the (x,y,z) local projection on the facet
  29525. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  29526. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  29527. * @param x defines x coordinate
  29528. * @param y defines y coordinate
  29529. * @param z defines z coordinate
  29530. * @returns the face index if found (or null instead)
  29531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29532. */
  29533. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29534. /**
  29535. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29536. * @returns the parameters
  29537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29538. */
  29539. getFacetDataParameters(): any;
  29540. /**
  29541. * Disables the feature FacetData and frees the related memory
  29542. * @returns the current mesh
  29543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29544. */
  29545. disableFacetData(): AbstractMesh;
  29546. /**
  29547. * Updates the AbstractMesh indices array
  29548. * @param indices defines the data source
  29549. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29550. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  29551. * @returns the current mesh
  29552. */
  29553. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29554. /**
  29555. * Creates new normals data for the mesh
  29556. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29557. * @returns the current mesh
  29558. */
  29559. createNormals(updatable: boolean): AbstractMesh;
  29560. /**
  29561. * Align the mesh with a normal
  29562. * @param normal defines the normal to use
  29563. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29564. * @returns the current mesh
  29565. */
  29566. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29567. /** @hidden */
  29568. _checkOcclusionQuery(): boolean;
  29569. /**
  29570. * Disables the mesh edge rendering mode
  29571. * @returns the currentAbstractMesh
  29572. */
  29573. disableEdgesRendering(): AbstractMesh;
  29574. /**
  29575. * Enables the edge rendering mode on the mesh.
  29576. * This mode makes the mesh edges visible
  29577. * @param epsilon defines the maximal distance between two angles to detect a face
  29578. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29579. * @returns the currentAbstractMesh
  29580. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29581. */
  29582. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29583. }
  29584. }
  29585. declare module "babylonjs/Actions/actionEvent" {
  29586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29587. import { Nullable } from "babylonjs/types";
  29588. import { Sprite } from "babylonjs/Sprites/sprite";
  29589. import { Scene } from "babylonjs/scene";
  29590. import { Vector2 } from "babylonjs/Maths/math.vector";
  29591. /**
  29592. * Interface used to define ActionEvent
  29593. */
  29594. export interface IActionEvent {
  29595. /** The mesh or sprite that triggered the action */
  29596. source: any;
  29597. /** The X mouse cursor position at the time of the event */
  29598. pointerX: number;
  29599. /** The Y mouse cursor position at the time of the event */
  29600. pointerY: number;
  29601. /** The mesh that is currently pointed at (can be null) */
  29602. meshUnderPointer: Nullable<AbstractMesh>;
  29603. /** the original (browser) event that triggered the ActionEvent */
  29604. sourceEvent?: any;
  29605. /** additional data for the event */
  29606. additionalData?: any;
  29607. }
  29608. /**
  29609. * ActionEvent is the event being sent when an action is triggered.
  29610. */
  29611. export class ActionEvent implements IActionEvent {
  29612. /** The mesh or sprite that triggered the action */
  29613. source: any;
  29614. /** The X mouse cursor position at the time of the event */
  29615. pointerX: number;
  29616. /** The Y mouse cursor position at the time of the event */
  29617. pointerY: number;
  29618. /** The mesh that is currently pointed at (can be null) */
  29619. meshUnderPointer: Nullable<AbstractMesh>;
  29620. /** the original (browser) event that triggered the ActionEvent */
  29621. sourceEvent?: any;
  29622. /** additional data for the event */
  29623. additionalData?: any;
  29624. /**
  29625. * Creates a new ActionEvent
  29626. * @param source The mesh or sprite that triggered the action
  29627. * @param pointerX The X mouse cursor position at the time of the event
  29628. * @param pointerY The Y mouse cursor position at the time of the event
  29629. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29630. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29631. * @param additionalData additional data for the event
  29632. */
  29633. constructor(
  29634. /** The mesh or sprite that triggered the action */
  29635. source: any,
  29636. /** The X mouse cursor position at the time of the event */
  29637. pointerX: number,
  29638. /** The Y mouse cursor position at the time of the event */
  29639. pointerY: number,
  29640. /** The mesh that is currently pointed at (can be null) */
  29641. meshUnderPointer: Nullable<AbstractMesh>,
  29642. /** the original (browser) event that triggered the ActionEvent */
  29643. sourceEvent?: any,
  29644. /** additional data for the event */
  29645. additionalData?: any);
  29646. /**
  29647. * Helper function to auto-create an ActionEvent from a source mesh.
  29648. * @param source The source mesh that triggered the event
  29649. * @param evt The original (browser) event
  29650. * @param additionalData additional data for the event
  29651. * @returns the new ActionEvent
  29652. */
  29653. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29654. /**
  29655. * Helper function to auto-create an ActionEvent from a source sprite
  29656. * @param source The source sprite that triggered the event
  29657. * @param scene Scene associated with the sprite
  29658. * @param evt The original (browser) event
  29659. * @param additionalData additional data for the event
  29660. * @returns the new ActionEvent
  29661. */
  29662. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29663. /**
  29664. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29665. * @param scene the scene where the event occurred
  29666. * @param evt The original (browser) event
  29667. * @returns the new ActionEvent
  29668. */
  29669. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29670. /**
  29671. * Helper function to auto-create an ActionEvent from a primitive
  29672. * @param prim defines the target primitive
  29673. * @param pointerPos defines the pointer position
  29674. * @param evt The original (browser) event
  29675. * @param additionalData additional data for the event
  29676. * @returns the new ActionEvent
  29677. */
  29678. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29679. }
  29680. }
  29681. declare module "babylonjs/Actions/abstractActionManager" {
  29682. import { IDisposable } from "babylonjs/scene";
  29683. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29684. import { IAction } from "babylonjs/Actions/action";
  29685. import { Nullable } from "babylonjs/types";
  29686. /**
  29687. * Abstract class used to decouple action Manager from scene and meshes.
  29688. * Do not instantiate.
  29689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29690. */
  29691. export abstract class AbstractActionManager implements IDisposable {
  29692. /** Gets the list of active triggers */
  29693. static Triggers: {
  29694. [key: string]: number;
  29695. };
  29696. /** Gets the cursor to use when hovering items */
  29697. hoverCursor: string;
  29698. /** Gets the list of actions */
  29699. actions: IAction[];
  29700. /**
  29701. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29702. */
  29703. isRecursive: boolean;
  29704. /**
  29705. * Releases all associated resources
  29706. */
  29707. abstract dispose(): void;
  29708. /**
  29709. * Does this action manager has pointer triggers
  29710. */
  29711. abstract get hasPointerTriggers(): boolean;
  29712. /**
  29713. * Does this action manager has pick triggers
  29714. */
  29715. abstract get hasPickTriggers(): boolean;
  29716. /**
  29717. * Process a specific trigger
  29718. * @param trigger defines the trigger to process
  29719. * @param evt defines the event details to be processed
  29720. */
  29721. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29722. /**
  29723. * Does this action manager handles actions of any of the given triggers
  29724. * @param triggers defines the triggers to be tested
  29725. * @return a boolean indicating whether one (or more) of the triggers is handled
  29726. */
  29727. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29728. /**
  29729. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29730. * speed.
  29731. * @param triggerA defines the trigger to be tested
  29732. * @param triggerB defines the trigger to be tested
  29733. * @return a boolean indicating whether one (or more) of the triggers is handled
  29734. */
  29735. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29736. /**
  29737. * Does this action manager handles actions of a given trigger
  29738. * @param trigger defines the trigger to be tested
  29739. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29740. * @return whether the trigger is handled
  29741. */
  29742. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29743. /**
  29744. * Serialize this manager to a JSON object
  29745. * @param name defines the property name to store this manager
  29746. * @returns a JSON representation of this manager
  29747. */
  29748. abstract serialize(name: string): any;
  29749. /**
  29750. * Registers an action to this action manager
  29751. * @param action defines the action to be registered
  29752. * @return the action amended (prepared) after registration
  29753. */
  29754. abstract registerAction(action: IAction): Nullable<IAction>;
  29755. /**
  29756. * Unregisters an action to this action manager
  29757. * @param action defines the action to be unregistered
  29758. * @return a boolean indicating whether the action has been unregistered
  29759. */
  29760. abstract unregisterAction(action: IAction): Boolean;
  29761. /**
  29762. * Does exist one action manager with at least one trigger
  29763. **/
  29764. static get HasTriggers(): boolean;
  29765. /**
  29766. * Does exist one action manager with at least one pick trigger
  29767. **/
  29768. static get HasPickTriggers(): boolean;
  29769. /**
  29770. * Does exist one action manager that handles actions of a given trigger
  29771. * @param trigger defines the trigger to be tested
  29772. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29773. **/
  29774. static HasSpecificTrigger(trigger: number): boolean;
  29775. }
  29776. }
  29777. declare module "babylonjs/node" {
  29778. import { Scene } from "babylonjs/scene";
  29779. import { Nullable } from "babylonjs/types";
  29780. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29781. import { Engine } from "babylonjs/Engines/engine";
  29782. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29783. import { Observable } from "babylonjs/Misc/observable";
  29784. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29785. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29786. import { Animatable } from "babylonjs/Animations/animatable";
  29787. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29788. import { Animation } from "babylonjs/Animations/animation";
  29789. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29791. /**
  29792. * Defines how a node can be built from a string name.
  29793. */
  29794. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29795. /**
  29796. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29797. */
  29798. export class Node implements IBehaviorAware<Node> {
  29799. /** @hidden */
  29800. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29801. private static _NodeConstructors;
  29802. /**
  29803. * Add a new node constructor
  29804. * @param type defines the type name of the node to construct
  29805. * @param constructorFunc defines the constructor function
  29806. */
  29807. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29808. /**
  29809. * Returns a node constructor based on type name
  29810. * @param type defines the type name
  29811. * @param name defines the new node name
  29812. * @param scene defines the hosting scene
  29813. * @param options defines optional options to transmit to constructors
  29814. * @returns the new constructor or null
  29815. */
  29816. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29817. /**
  29818. * Gets or sets the name of the node
  29819. */
  29820. name: string;
  29821. /**
  29822. * Gets or sets the id of the node
  29823. */
  29824. id: string;
  29825. /**
  29826. * Gets or sets the unique id of the node
  29827. */
  29828. uniqueId: number;
  29829. /**
  29830. * Gets or sets a string used to store user defined state for the node
  29831. */
  29832. state: string;
  29833. /**
  29834. * Gets or sets an object used to store user defined information for the node
  29835. */
  29836. metadata: any;
  29837. /**
  29838. * For internal use only. Please do not use.
  29839. */
  29840. reservedDataStore: any;
  29841. /**
  29842. * List of inspectable custom properties (used by the Inspector)
  29843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29844. */
  29845. inspectableCustomProperties: IInspectable[];
  29846. private _doNotSerialize;
  29847. /**
  29848. * Gets or sets a boolean used to define if the node must be serialized
  29849. */
  29850. get doNotSerialize(): boolean;
  29851. set doNotSerialize(value: boolean);
  29852. /** @hidden */
  29853. _isDisposed: boolean;
  29854. /**
  29855. * Gets a list of Animations associated with the node
  29856. */
  29857. animations: import("babylonjs/Animations/animation").Animation[];
  29858. protected _ranges: {
  29859. [name: string]: Nullable<AnimationRange>;
  29860. };
  29861. /**
  29862. * Callback raised when the node is ready to be used
  29863. */
  29864. onReady: Nullable<(node: Node) => void>;
  29865. private _isEnabled;
  29866. private _isParentEnabled;
  29867. private _isReady;
  29868. /** @hidden */
  29869. _currentRenderId: number;
  29870. private _parentUpdateId;
  29871. /** @hidden */
  29872. _childUpdateId: number;
  29873. /** @hidden */
  29874. _waitingParentId: Nullable<string>;
  29875. /** @hidden */
  29876. _scene: Scene;
  29877. /** @hidden */
  29878. _cache: any;
  29879. private _parentNode;
  29880. private _children;
  29881. /** @hidden */
  29882. _worldMatrix: Matrix;
  29883. /** @hidden */
  29884. _worldMatrixDeterminant: number;
  29885. /** @hidden */
  29886. _worldMatrixDeterminantIsDirty: boolean;
  29887. /** @hidden */
  29888. private _sceneRootNodesIndex;
  29889. /**
  29890. * Gets a boolean indicating if the node has been disposed
  29891. * @returns true if the node was disposed
  29892. */
  29893. isDisposed(): boolean;
  29894. /**
  29895. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29896. * @see https://doc.babylonjs.com/how_to/parenting
  29897. */
  29898. set parent(parent: Nullable<Node>);
  29899. get parent(): Nullable<Node>;
  29900. /** @hidden */
  29901. _addToSceneRootNodes(): void;
  29902. /** @hidden */
  29903. _removeFromSceneRootNodes(): void;
  29904. private _animationPropertiesOverride;
  29905. /**
  29906. * Gets or sets the animation properties override
  29907. */
  29908. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29909. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29910. /**
  29911. * Gets a string idenfifying the name of the class
  29912. * @returns "Node" string
  29913. */
  29914. getClassName(): string;
  29915. /** @hidden */
  29916. readonly _isNode: boolean;
  29917. /**
  29918. * An event triggered when the mesh is disposed
  29919. */
  29920. onDisposeObservable: Observable<Node>;
  29921. private _onDisposeObserver;
  29922. /**
  29923. * Sets a callback that will be raised when the node will be disposed
  29924. */
  29925. set onDispose(callback: () => void);
  29926. /**
  29927. * Creates a new Node
  29928. * @param name the name and id to be given to this node
  29929. * @param scene the scene this node will be added to
  29930. */
  29931. constructor(name: string, scene?: Nullable<Scene>);
  29932. /**
  29933. * Gets the scene of the node
  29934. * @returns a scene
  29935. */
  29936. getScene(): Scene;
  29937. /**
  29938. * Gets the engine of the node
  29939. * @returns a Engine
  29940. */
  29941. getEngine(): Engine;
  29942. private _behaviors;
  29943. /**
  29944. * Attach a behavior to the node
  29945. * @see http://doc.babylonjs.com/features/behaviour
  29946. * @param behavior defines the behavior to attach
  29947. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29948. * @returns the current Node
  29949. */
  29950. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29951. /**
  29952. * Remove an attached behavior
  29953. * @see http://doc.babylonjs.com/features/behaviour
  29954. * @param behavior defines the behavior to attach
  29955. * @returns the current Node
  29956. */
  29957. removeBehavior(behavior: Behavior<Node>): Node;
  29958. /**
  29959. * Gets the list of attached behaviors
  29960. * @see http://doc.babylonjs.com/features/behaviour
  29961. */
  29962. get behaviors(): Behavior<Node>[];
  29963. /**
  29964. * Gets an attached behavior by name
  29965. * @param name defines the name of the behavior to look for
  29966. * @see http://doc.babylonjs.com/features/behaviour
  29967. * @returns null if behavior was not found else the requested behavior
  29968. */
  29969. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29970. /**
  29971. * Returns the latest update of the World matrix
  29972. * @returns a Matrix
  29973. */
  29974. getWorldMatrix(): Matrix;
  29975. /** @hidden */
  29976. _getWorldMatrixDeterminant(): number;
  29977. /**
  29978. * Returns directly the latest state of the mesh World matrix.
  29979. * A Matrix is returned.
  29980. */
  29981. get worldMatrixFromCache(): Matrix;
  29982. /** @hidden */
  29983. _initCache(): void;
  29984. /** @hidden */
  29985. updateCache(force?: boolean): void;
  29986. /** @hidden */
  29987. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29988. /** @hidden */
  29989. _updateCache(ignoreParentClass?: boolean): void;
  29990. /** @hidden */
  29991. _isSynchronized(): boolean;
  29992. /** @hidden */
  29993. _markSyncedWithParent(): void;
  29994. /** @hidden */
  29995. isSynchronizedWithParent(): boolean;
  29996. /** @hidden */
  29997. isSynchronized(): boolean;
  29998. /**
  29999. * Is this node ready to be used/rendered
  30000. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30001. * @return true if the node is ready
  30002. */
  30003. isReady(completeCheck?: boolean): boolean;
  30004. /**
  30005. * Is this node enabled?
  30006. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  30007. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  30008. * @return whether this node (and its parent) is enabled
  30009. */
  30010. isEnabled(checkAncestors?: boolean): boolean;
  30011. /** @hidden */
  30012. protected _syncParentEnabledState(): void;
  30013. /**
  30014. * Set the enabled state of this node
  30015. * @param value defines the new enabled state
  30016. */
  30017. setEnabled(value: boolean): void;
  30018. /**
  30019. * Is this node a descendant of the given node?
  30020. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30021. * @param ancestor defines the parent node to inspect
  30022. * @returns a boolean indicating if this node is a descendant of the given node
  30023. */
  30024. isDescendantOf(ancestor: Node): boolean;
  30025. /** @hidden */
  30026. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30027. /**
  30028. * Will return all nodes that have this node as ascendant
  30029. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  30030. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  30031. * @return all children nodes of all types
  30032. */
  30033. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30034. /**
  30035. * Get all child-meshes of this node
  30036. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  30037. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  30038. * @returns an array of AbstractMesh
  30039. */
  30040. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30041. /**
  30042. * Get all direct children of this node
  30043. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  30044. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  30045. * @returns an array of Node
  30046. */
  30047. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30048. /** @hidden */
  30049. _setReady(state: boolean): void;
  30050. /**
  30051. * Get an animation by name
  30052. * @param name defines the name of the animation to look for
  30053. * @returns null if not found else the requested animation
  30054. */
  30055. getAnimationByName(name: string): Nullable<Animation>;
  30056. /**
  30057. * Creates an animation range for this node
  30058. * @param name defines the name of the range
  30059. * @param from defines the starting key
  30060. * @param to defines the end key
  30061. */
  30062. createAnimationRange(name: string, from: number, to: number): void;
  30063. /**
  30064. * Delete a specific animation range
  30065. * @param name defines the name of the range to delete
  30066. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30067. */
  30068. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30069. /**
  30070. * Get an animation range by name
  30071. * @param name defines the name of the animation range to look for
  30072. * @returns null if not found else the requested animation range
  30073. */
  30074. getAnimationRange(name: string): Nullable<AnimationRange>;
  30075. /**
  30076. * Gets the list of all animation ranges defined on this node
  30077. * @returns an array
  30078. */
  30079. getAnimationRanges(): Nullable<AnimationRange>[];
  30080. /**
  30081. * Will start the animation sequence
  30082. * @param name defines the range frames for animation sequence
  30083. * @param loop defines if the animation should loop (false by default)
  30084. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30085. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30086. * @returns the object created for this animation. If range does not exist, it will return null
  30087. */
  30088. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30089. /**
  30090. * Serialize animation ranges into a JSON compatible object
  30091. * @returns serialization object
  30092. */
  30093. serializeAnimationRanges(): any;
  30094. /**
  30095. * Computes the world matrix of the node
  30096. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30097. * @returns the world matrix
  30098. */
  30099. computeWorldMatrix(force?: boolean): Matrix;
  30100. /**
  30101. * Releases resources associated with this node.
  30102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30104. */
  30105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30106. /**
  30107. * Parse animation range data from a serialization object and store them into a given node
  30108. * @param node defines where to store the animation ranges
  30109. * @param parsedNode defines the serialization object to read data from
  30110. * @param scene defines the hosting scene
  30111. */
  30112. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30113. /**
  30114. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30115. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30116. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  30117. * @returns the new bounding vectors
  30118. */
  30119. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30120. min: Vector3;
  30121. max: Vector3;
  30122. };
  30123. }
  30124. }
  30125. declare module "babylonjs/Animations/animation" {
  30126. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30127. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30128. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30129. import { Nullable } from "babylonjs/types";
  30130. import { Scene } from "babylonjs/scene";
  30131. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30132. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30133. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30134. import { Node } from "babylonjs/node";
  30135. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30136. import { Size } from "babylonjs/Maths/math.size";
  30137. import { Animatable } from "babylonjs/Animations/animatable";
  30138. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30139. /**
  30140. * @hidden
  30141. */
  30142. export class _IAnimationState {
  30143. key: number;
  30144. repeatCount: number;
  30145. workValue?: any;
  30146. loopMode?: number;
  30147. offsetValue?: any;
  30148. highLimitValue?: any;
  30149. }
  30150. /**
  30151. * Class used to store any kind of animation
  30152. */
  30153. export class Animation {
  30154. /**Name of the animation */
  30155. name: string;
  30156. /**Property to animate */
  30157. targetProperty: string;
  30158. /**The frames per second of the animation */
  30159. framePerSecond: number;
  30160. /**The data type of the animation */
  30161. dataType: number;
  30162. /**The loop mode of the animation */
  30163. loopMode?: number | undefined;
  30164. /**Specifies if blending should be enabled */
  30165. enableBlending?: boolean | undefined;
  30166. /**
  30167. * Use matrix interpolation instead of using direct key value when animating matrices
  30168. */
  30169. static AllowMatricesInterpolation: boolean;
  30170. /**
  30171. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30172. */
  30173. static AllowMatrixDecomposeForInterpolation: boolean;
  30174. /**
  30175. * Stores the key frames of the animation
  30176. */
  30177. private _keys;
  30178. /**
  30179. * Stores the easing function of the animation
  30180. */
  30181. private _easingFunction;
  30182. /**
  30183. * @hidden Internal use only
  30184. */
  30185. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30186. /**
  30187. * The set of event that will be linked to this animation
  30188. */
  30189. private _events;
  30190. /**
  30191. * Stores an array of target property paths
  30192. */
  30193. targetPropertyPath: string[];
  30194. /**
  30195. * Stores the blending speed of the animation
  30196. */
  30197. blendingSpeed: number;
  30198. /**
  30199. * Stores the animation ranges for the animation
  30200. */
  30201. private _ranges;
  30202. /**
  30203. * @hidden Internal use
  30204. */
  30205. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30206. /**
  30207. * Sets up an animation
  30208. * @param property The property to animate
  30209. * @param animationType The animation type to apply
  30210. * @param framePerSecond The frames per second of the animation
  30211. * @param easingFunction The easing function used in the animation
  30212. * @returns The created animation
  30213. */
  30214. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30215. /**
  30216. * Create and start an animation on a node
  30217. * @param name defines the name of the global animation that will be run on all nodes
  30218. * @param node defines the root node where the animation will take place
  30219. * @param targetProperty defines property to animate
  30220. * @param framePerSecond defines the number of frame per second yo use
  30221. * @param totalFrame defines the number of frames in total
  30222. * @param from defines the initial value
  30223. * @param to defines the final value
  30224. * @param loopMode defines which loop mode you want to use (off by default)
  30225. * @param easingFunction defines the easing function to use (linear by default)
  30226. * @param onAnimationEnd defines the callback to call when animation end
  30227. * @returns the animatable created for this animation
  30228. */
  30229. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30230. /**
  30231. * Create and start an animation on a node and its descendants
  30232. * @param name defines the name of the global animation that will be run on all nodes
  30233. * @param node defines the root node where the animation will take place
  30234. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  30235. * @param targetProperty defines property to animate
  30236. * @param framePerSecond defines the number of frame per second to use
  30237. * @param totalFrame defines the number of frames in total
  30238. * @param from defines the initial value
  30239. * @param to defines the final value
  30240. * @param loopMode defines which loop mode you want to use (off by default)
  30241. * @param easingFunction defines the easing function to use (linear by default)
  30242. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30243. * @returns the list of animatables created for all nodes
  30244. * @example https://www.babylonjs-playground.com/#MH0VLI
  30245. */
  30246. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  30247. /**
  30248. * Creates a new animation, merges it with the existing animations and starts it
  30249. * @param name Name of the animation
  30250. * @param node Node which contains the scene that begins the animations
  30251. * @param targetProperty Specifies which property to animate
  30252. * @param framePerSecond The frames per second of the animation
  30253. * @param totalFrame The total number of frames
  30254. * @param from The frame at the beginning of the animation
  30255. * @param to The frame at the end of the animation
  30256. * @param loopMode Specifies the loop mode of the animation
  30257. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30258. * @param onAnimationEnd Callback to run once the animation is complete
  30259. * @returns Nullable animation
  30260. */
  30261. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30262. /**
  30263. * Transition property of an host to the target Value
  30264. * @param property The property to transition
  30265. * @param targetValue The target Value of the property
  30266. * @param host The object where the property to animate belongs
  30267. * @param scene Scene used to run the animation
  30268. * @param frameRate Framerate (in frame/s) to use
  30269. * @param transition The transition type we want to use
  30270. * @param duration The duration of the animation, in milliseconds
  30271. * @param onAnimationEnd Callback trigger at the end of the animation
  30272. * @returns Nullable animation
  30273. */
  30274. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30275. /**
  30276. * Return the array of runtime animations currently using this animation
  30277. */
  30278. get runtimeAnimations(): RuntimeAnimation[];
  30279. /**
  30280. * Specifies if any of the runtime animations are currently running
  30281. */
  30282. get hasRunningRuntimeAnimations(): boolean;
  30283. /**
  30284. * Initializes the animation
  30285. * @param name Name of the animation
  30286. * @param targetProperty Property to animate
  30287. * @param framePerSecond The frames per second of the animation
  30288. * @param dataType The data type of the animation
  30289. * @param loopMode The loop mode of the animation
  30290. * @param enableBlending Specifies if blending should be enabled
  30291. */
  30292. constructor(
  30293. /**Name of the animation */
  30294. name: string,
  30295. /**Property to animate */
  30296. targetProperty: string,
  30297. /**The frames per second of the animation */
  30298. framePerSecond: number,
  30299. /**The data type of the animation */
  30300. dataType: number,
  30301. /**The loop mode of the animation */
  30302. loopMode?: number | undefined,
  30303. /**Specifies if blending should be enabled */
  30304. enableBlending?: boolean | undefined);
  30305. /**
  30306. * Converts the animation to a string
  30307. * @param fullDetails support for multiple levels of logging within scene loading
  30308. * @returns String form of the animation
  30309. */
  30310. toString(fullDetails?: boolean): string;
  30311. /**
  30312. * Add an event to this animation
  30313. * @param event Event to add
  30314. */
  30315. addEvent(event: AnimationEvent): void;
  30316. /**
  30317. * Remove all events found at the given frame
  30318. * @param frame The frame to remove events from
  30319. */
  30320. removeEvents(frame: number): void;
  30321. /**
  30322. * Retrieves all the events from the animation
  30323. * @returns Events from the animation
  30324. */
  30325. getEvents(): AnimationEvent[];
  30326. /**
  30327. * Creates an animation range
  30328. * @param name Name of the animation range
  30329. * @param from Starting frame of the animation range
  30330. * @param to Ending frame of the animation
  30331. */
  30332. createRange(name: string, from: number, to: number): void;
  30333. /**
  30334. * Deletes an animation range by name
  30335. * @param name Name of the animation range to delete
  30336. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30337. */
  30338. deleteRange(name: string, deleteFrames?: boolean): void;
  30339. /**
  30340. * Gets the animation range by name, or null if not defined
  30341. * @param name Name of the animation range
  30342. * @returns Nullable animation range
  30343. */
  30344. getRange(name: string): Nullable<AnimationRange>;
  30345. /**
  30346. * Gets the key frames from the animation
  30347. * @returns The key frames of the animation
  30348. */
  30349. getKeys(): Array<IAnimationKey>;
  30350. /**
  30351. * Gets the highest frame rate of the animation
  30352. * @returns Highest frame rate of the animation
  30353. */
  30354. getHighestFrame(): number;
  30355. /**
  30356. * Gets the easing function of the animation
  30357. * @returns Easing function of the animation
  30358. */
  30359. getEasingFunction(): IEasingFunction;
  30360. /**
  30361. * Sets the easing function of the animation
  30362. * @param easingFunction A custom mathematical formula for animation
  30363. */
  30364. setEasingFunction(easingFunction: EasingFunction): void;
  30365. /**
  30366. * Interpolates a scalar linearly
  30367. * @param startValue Start value of the animation curve
  30368. * @param endValue End value of the animation curve
  30369. * @param gradient Scalar amount to interpolate
  30370. * @returns Interpolated scalar value
  30371. */
  30372. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30373. /**
  30374. * Interpolates a scalar cubically
  30375. * @param startValue Start value of the animation curve
  30376. * @param outTangent End tangent of the animation
  30377. * @param endValue End value of the animation curve
  30378. * @param inTangent Start tangent of the animation curve
  30379. * @param gradient Scalar amount to interpolate
  30380. * @returns Interpolated scalar value
  30381. */
  30382. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30383. /**
  30384. * Interpolates a quaternion using a spherical linear interpolation
  30385. * @param startValue Start value of the animation curve
  30386. * @param endValue End value of the animation curve
  30387. * @param gradient Scalar amount to interpolate
  30388. * @returns Interpolated quaternion value
  30389. */
  30390. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30391. /**
  30392. * Interpolates a quaternion cubically
  30393. * @param startValue Start value of the animation curve
  30394. * @param outTangent End tangent of the animation curve
  30395. * @param endValue End value of the animation curve
  30396. * @param inTangent Start tangent of the animation curve
  30397. * @param gradient Scalar amount to interpolate
  30398. * @returns Interpolated quaternion value
  30399. */
  30400. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30401. /**
  30402. * Interpolates a Vector3 linearl
  30403. * @param startValue Start value of the animation curve
  30404. * @param endValue End value of the animation curve
  30405. * @param gradient Scalar amount to interpolate
  30406. * @returns Interpolated scalar value
  30407. */
  30408. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30409. /**
  30410. * Interpolates a Vector3 cubically
  30411. * @param startValue Start value of the animation curve
  30412. * @param outTangent End tangent of the animation
  30413. * @param endValue End value of the animation curve
  30414. * @param inTangent Start tangent of the animation curve
  30415. * @param gradient Scalar amount to interpolate
  30416. * @returns InterpolatedVector3 value
  30417. */
  30418. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30419. /**
  30420. * Interpolates a Vector2 linearly
  30421. * @param startValue Start value of the animation curve
  30422. * @param endValue End value of the animation curve
  30423. * @param gradient Scalar amount to interpolate
  30424. * @returns Interpolated Vector2 value
  30425. */
  30426. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30427. /**
  30428. * Interpolates a Vector2 cubically
  30429. * @param startValue Start value of the animation curve
  30430. * @param outTangent End tangent of the animation
  30431. * @param endValue End value of the animation curve
  30432. * @param inTangent Start tangent of the animation curve
  30433. * @param gradient Scalar amount to interpolate
  30434. * @returns Interpolated Vector2 value
  30435. */
  30436. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30437. /**
  30438. * Interpolates a size linearly
  30439. * @param startValue Start value of the animation curve
  30440. * @param endValue End value of the animation curve
  30441. * @param gradient Scalar amount to interpolate
  30442. * @returns Interpolated Size value
  30443. */
  30444. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30445. /**
  30446. * Interpolates a Color3 linearly
  30447. * @param startValue Start value of the animation curve
  30448. * @param endValue End value of the animation curve
  30449. * @param gradient Scalar amount to interpolate
  30450. * @returns Interpolated Color3 value
  30451. */
  30452. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30453. /**
  30454. * Interpolates a Color4 linearly
  30455. * @param startValue Start value of the animation curve
  30456. * @param endValue End value of the animation curve
  30457. * @param gradient Scalar amount to interpolate
  30458. * @returns Interpolated Color3 value
  30459. */
  30460. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30461. /**
  30462. * @hidden Internal use only
  30463. */
  30464. _getKeyValue(value: any): any;
  30465. /**
  30466. * @hidden Internal use only
  30467. */
  30468. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30469. /**
  30470. * Defines the function to use to interpolate matrices
  30471. * @param startValue defines the start matrix
  30472. * @param endValue defines the end matrix
  30473. * @param gradient defines the gradient between both matrices
  30474. * @param result defines an optional target matrix where to store the interpolation
  30475. * @returns the interpolated matrix
  30476. */
  30477. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30478. /**
  30479. * Makes a copy of the animation
  30480. * @returns Cloned animation
  30481. */
  30482. clone(): Animation;
  30483. /**
  30484. * Sets the key frames of the animation
  30485. * @param values The animation key frames to set
  30486. */
  30487. setKeys(values: Array<IAnimationKey>): void;
  30488. /**
  30489. * Serializes the animation to an object
  30490. * @returns Serialized object
  30491. */
  30492. serialize(): any;
  30493. /**
  30494. * Float animation type
  30495. */
  30496. static readonly ANIMATIONTYPE_FLOAT: number;
  30497. /**
  30498. * Vector3 animation type
  30499. */
  30500. static readonly ANIMATIONTYPE_VECTOR3: number;
  30501. /**
  30502. * Quaternion animation type
  30503. */
  30504. static readonly ANIMATIONTYPE_QUATERNION: number;
  30505. /**
  30506. * Matrix animation type
  30507. */
  30508. static readonly ANIMATIONTYPE_MATRIX: number;
  30509. /**
  30510. * Color3 animation type
  30511. */
  30512. static readonly ANIMATIONTYPE_COLOR3: number;
  30513. /**
  30514. * Color3 animation type
  30515. */
  30516. static readonly ANIMATIONTYPE_COLOR4: number;
  30517. /**
  30518. * Vector2 animation type
  30519. */
  30520. static readonly ANIMATIONTYPE_VECTOR2: number;
  30521. /**
  30522. * Size animation type
  30523. */
  30524. static readonly ANIMATIONTYPE_SIZE: number;
  30525. /**
  30526. * Relative Loop Mode
  30527. */
  30528. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30529. /**
  30530. * Cycle Loop Mode
  30531. */
  30532. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30533. /**
  30534. * Constant Loop Mode
  30535. */
  30536. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30537. /** @hidden */
  30538. static _UniversalLerp(left: any, right: any, amount: number): any;
  30539. /**
  30540. * Parses an animation object and creates an animation
  30541. * @param parsedAnimation Parsed animation object
  30542. * @returns Animation object
  30543. */
  30544. static Parse(parsedAnimation: any): Animation;
  30545. /**
  30546. * Appends the serialized animations from the source animations
  30547. * @param source Source containing the animations
  30548. * @param destination Target to store the animations
  30549. */
  30550. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30551. }
  30552. }
  30553. declare module "babylonjs/Animations/animatable.interface" {
  30554. import { Nullable } from "babylonjs/types";
  30555. import { Animation } from "babylonjs/Animations/animation";
  30556. /**
  30557. * Interface containing an array of animations
  30558. */
  30559. export interface IAnimatable {
  30560. /**
  30561. * Array of animations
  30562. */
  30563. animations: Nullable<Array<Animation>>;
  30564. }
  30565. }
  30566. declare module "babylonjs/Misc/decorators" {
  30567. import { Nullable } from "babylonjs/types";
  30568. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30569. import { Scene } from "babylonjs/scene";
  30570. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30571. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30572. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30573. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30574. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30575. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30576. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30577. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30578. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30579. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30580. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30581. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30582. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30583. /**
  30584. * Decorator used to define property that can be serialized as reference to a camera
  30585. * @param sourceName defines the name of the property to decorate
  30586. */
  30587. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30588. /**
  30589. * Class used to help serialization objects
  30590. */
  30591. export class SerializationHelper {
  30592. /** @hidden */
  30593. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30594. /** @hidden */
  30595. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30596. /** @hidden */
  30597. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30598. /** @hidden */
  30599. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30600. /**
  30601. * Appends the serialized animations from the source animations
  30602. * @param source Source containing the animations
  30603. * @param destination Target to store the animations
  30604. */
  30605. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30606. /**
  30607. * Static function used to serialized a specific entity
  30608. * @param entity defines the entity to serialize
  30609. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30610. * @returns a JSON compatible object representing the serialization of the entity
  30611. */
  30612. static Serialize<T>(entity: T, serializationObject?: any): any;
  30613. /**
  30614. * Creates a new entity from a serialization data object
  30615. * @param creationFunction defines a function used to instanciated the new entity
  30616. * @param source defines the source serialization data
  30617. * @param scene defines the hosting scene
  30618. * @param rootUrl defines the root url for resources
  30619. * @returns a new entity
  30620. */
  30621. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30622. /**
  30623. * Clones an object
  30624. * @param creationFunction defines the function used to instanciate the new object
  30625. * @param source defines the source object
  30626. * @returns the cloned object
  30627. */
  30628. static Clone<T>(creationFunction: () => T, source: T): T;
  30629. /**
  30630. * Instanciates a new object based on a source one (some data will be shared between both object)
  30631. * @param creationFunction defines the function used to instanciate the new object
  30632. * @param source defines the source object
  30633. * @returns the new object
  30634. */
  30635. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30636. }
  30637. }
  30638. declare module "babylonjs/Misc/guid" {
  30639. /**
  30640. * Class used to manipulate GUIDs
  30641. */
  30642. export class GUID {
  30643. /**
  30644. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30645. * Be aware Math.random() could cause collisions, but:
  30646. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  30647. * @returns a pseudo random id
  30648. */
  30649. static RandomId(): string;
  30650. }
  30651. }
  30652. declare module "babylonjs/Materials/Textures/baseTexture" {
  30653. import { Observable } from "babylonjs/Misc/observable";
  30654. import { Nullable } from "babylonjs/types";
  30655. import { Scene } from "babylonjs/scene";
  30656. import { Matrix } from "babylonjs/Maths/math.vector";
  30657. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30658. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30659. import { ISize } from "babylonjs/Maths/math.size";
  30660. import "babylonjs/Misc/fileTools";
  30661. /**
  30662. * Base class of all the textures in babylon.
  30663. * It groups all the common properties the materials, post process, lights... might need
  30664. * in order to make a correct use of the texture.
  30665. */
  30666. export class BaseTexture implements IAnimatable {
  30667. /**
  30668. * Default anisotropic filtering level for the application.
  30669. * It is set to 4 as a good tradeoff between perf and quality.
  30670. */
  30671. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30672. /**
  30673. * Gets or sets the unique id of the texture
  30674. */
  30675. uniqueId: number;
  30676. /**
  30677. * Define the name of the texture.
  30678. */
  30679. name: string;
  30680. /**
  30681. * Gets or sets an object used to store user defined information.
  30682. */
  30683. metadata: any;
  30684. /**
  30685. * For internal use only. Please do not use.
  30686. */
  30687. reservedDataStore: any;
  30688. private _hasAlpha;
  30689. /**
  30690. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30691. */
  30692. set hasAlpha(value: boolean);
  30693. get hasAlpha(): boolean;
  30694. /**
  30695. * Defines if the alpha value should be determined via the rgb values.
  30696. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30697. */
  30698. getAlphaFromRGB: boolean;
  30699. /**
  30700. * Intensity or strength of the texture.
  30701. * It is commonly used by materials to fine tune the intensity of the texture
  30702. */
  30703. level: number;
  30704. /**
  30705. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30706. * This is part of the texture as textures usually maps to one uv set.
  30707. */
  30708. coordinatesIndex: number;
  30709. private _coordinatesMode;
  30710. /**
  30711. * How a texture is mapped.
  30712. *
  30713. * | Value | Type | Description |
  30714. * | ----- | ----------------------------------- | ----------- |
  30715. * | 0 | EXPLICIT_MODE | |
  30716. * | 1 | SPHERICAL_MODE | |
  30717. * | 2 | PLANAR_MODE | |
  30718. * | 3 | CUBIC_MODE | |
  30719. * | 4 | PROJECTION_MODE | |
  30720. * | 5 | SKYBOX_MODE | |
  30721. * | 6 | INVCUBIC_MODE | |
  30722. * | 7 | EQUIRECTANGULAR_MODE | |
  30723. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30724. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30725. */
  30726. set coordinatesMode(value: number);
  30727. get coordinatesMode(): number;
  30728. /**
  30729. * | Value | Type | Description |
  30730. * | ----- | ------------------ | ----------- |
  30731. * | 0 | CLAMP_ADDRESSMODE | |
  30732. * | 1 | WRAP_ADDRESSMODE | |
  30733. * | 2 | MIRROR_ADDRESSMODE | |
  30734. */
  30735. wrapU: number;
  30736. /**
  30737. * | Value | Type | Description |
  30738. * | ----- | ------------------ | ----------- |
  30739. * | 0 | CLAMP_ADDRESSMODE | |
  30740. * | 1 | WRAP_ADDRESSMODE | |
  30741. * | 2 | MIRROR_ADDRESSMODE | |
  30742. */
  30743. wrapV: number;
  30744. /**
  30745. * | Value | Type | Description |
  30746. * | ----- | ------------------ | ----------- |
  30747. * | 0 | CLAMP_ADDRESSMODE | |
  30748. * | 1 | WRAP_ADDRESSMODE | |
  30749. * | 2 | MIRROR_ADDRESSMODE | |
  30750. */
  30751. wrapR: number;
  30752. /**
  30753. * With compliant hardware and browser (supporting anisotropic filtering)
  30754. * this defines the level of anisotropic filtering in the texture.
  30755. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30756. */
  30757. anisotropicFilteringLevel: number;
  30758. /**
  30759. * Define if the texture is a cube texture or if false a 2d texture.
  30760. */
  30761. get isCube(): boolean;
  30762. set isCube(value: boolean);
  30763. /**
  30764. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30765. */
  30766. get is3D(): boolean;
  30767. set is3D(value: boolean);
  30768. /**
  30769. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30770. */
  30771. get is2DArray(): boolean;
  30772. set is2DArray(value: boolean);
  30773. /**
  30774. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30775. * HDR texture are usually stored in linear space.
  30776. * This only impacts the PBR and Background materials
  30777. */
  30778. gammaSpace: boolean;
  30779. /**
  30780. * Gets or sets whether or not the texture contains RGBD data.
  30781. */
  30782. get isRGBD(): boolean;
  30783. set isRGBD(value: boolean);
  30784. /**
  30785. * Is Z inverted in the texture (useful in a cube texture).
  30786. */
  30787. invertZ: boolean;
  30788. /**
  30789. * Are mip maps generated for this texture or not.
  30790. */
  30791. get noMipmap(): boolean;
  30792. /**
  30793. * @hidden
  30794. */
  30795. lodLevelInAlpha: boolean;
  30796. /**
  30797. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30798. */
  30799. get lodGenerationOffset(): number;
  30800. set lodGenerationOffset(value: number);
  30801. /**
  30802. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30803. */
  30804. get lodGenerationScale(): number;
  30805. set lodGenerationScale(value: number);
  30806. /**
  30807. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30808. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30809. * average roughness values.
  30810. */
  30811. get linearSpecularLOD(): boolean;
  30812. set linearSpecularLOD(value: boolean);
  30813. /**
  30814. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30815. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30816. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30817. */
  30818. get irradianceTexture(): Nullable<BaseTexture>;
  30819. set irradianceTexture(value: Nullable<BaseTexture>);
  30820. /**
  30821. * Define if the texture is a render target.
  30822. */
  30823. isRenderTarget: boolean;
  30824. /**
  30825. * Define the unique id of the texture in the scene.
  30826. */
  30827. get uid(): string;
  30828. /**
  30829. * Return a string representation of the texture.
  30830. * @returns the texture as a string
  30831. */
  30832. toString(): string;
  30833. /**
  30834. * Get the class name of the texture.
  30835. * @returns "BaseTexture"
  30836. */
  30837. getClassName(): string;
  30838. /**
  30839. * Define the list of animation attached to the texture.
  30840. */
  30841. animations: import("babylonjs/Animations/animation").Animation[];
  30842. /**
  30843. * An event triggered when the texture is disposed.
  30844. */
  30845. onDisposeObservable: Observable<BaseTexture>;
  30846. private _onDisposeObserver;
  30847. /**
  30848. * Callback triggered when the texture has been disposed.
  30849. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30850. */
  30851. set onDispose(callback: () => void);
  30852. /**
  30853. * Define the current state of the loading sequence when in delayed load mode.
  30854. */
  30855. delayLoadState: number;
  30856. private _scene;
  30857. /** @hidden */
  30858. _texture: Nullable<InternalTexture>;
  30859. private _uid;
  30860. /**
  30861. * Define if the texture is preventinga material to render or not.
  30862. * If not and the texture is not ready, the engine will use a default black texture instead.
  30863. */
  30864. get isBlocking(): boolean;
  30865. /**
  30866. * Instantiates a new BaseTexture.
  30867. * Base class of all the textures in babylon.
  30868. * It groups all the common properties the materials, post process, lights... might need
  30869. * in order to make a correct use of the texture.
  30870. * @param scene Define the scene the texture blongs to
  30871. */
  30872. constructor(scene: Nullable<Scene>);
  30873. /**
  30874. * Get the scene the texture belongs to.
  30875. * @returns the scene or null if undefined
  30876. */
  30877. getScene(): Nullable<Scene>;
  30878. /**
  30879. * Get the texture transform matrix used to offset tile the texture for istance.
  30880. * @returns the transformation matrix
  30881. */
  30882. getTextureMatrix(): Matrix;
  30883. /**
  30884. * Get the texture reflection matrix used to rotate/transform the reflection.
  30885. * @returns the reflection matrix
  30886. */
  30887. getReflectionTextureMatrix(): Matrix;
  30888. /**
  30889. * Get the underlying lower level texture from Babylon.
  30890. * @returns the insternal texture
  30891. */
  30892. getInternalTexture(): Nullable<InternalTexture>;
  30893. /**
  30894. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30895. * @returns true if ready or not blocking
  30896. */
  30897. isReadyOrNotBlocking(): boolean;
  30898. /**
  30899. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30900. * @returns true if fully ready
  30901. */
  30902. isReady(): boolean;
  30903. private _cachedSize;
  30904. /**
  30905. * Get the size of the texture.
  30906. * @returns the texture size.
  30907. */
  30908. getSize(): ISize;
  30909. /**
  30910. * Get the base size of the texture.
  30911. * It can be different from the size if the texture has been resized for POT for instance
  30912. * @returns the base size
  30913. */
  30914. getBaseSize(): ISize;
  30915. /**
  30916. * Update the sampling mode of the texture.
  30917. * Default is Trilinear mode.
  30918. *
  30919. * | Value | Type | Description |
  30920. * | ----- | ------------------ | ----------- |
  30921. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30922. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30923. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30924. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30925. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30926. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30927. * | 7 | NEAREST_LINEAR | |
  30928. * | 8 | NEAREST_NEAREST | |
  30929. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30930. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30931. * | 11 | LINEAR_LINEAR | |
  30932. * | 12 | LINEAR_NEAREST | |
  30933. *
  30934. * > _mag_: magnification filter (close to the viewer)
  30935. * > _min_: minification filter (far from the viewer)
  30936. * > _mip_: filter used between mip map levels
  30937. *@param samplingMode Define the new sampling mode of the texture
  30938. */
  30939. updateSamplingMode(samplingMode: number): void;
  30940. /**
  30941. * Scales the texture if is `canRescale()`
  30942. * @param ratio the resize factor we want to use to rescale
  30943. */
  30944. scale(ratio: number): void;
  30945. /**
  30946. * Get if the texture can rescale.
  30947. */
  30948. get canRescale(): boolean;
  30949. /** @hidden */
  30950. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30951. /** @hidden */
  30952. _rebuild(): void;
  30953. /**
  30954. * Triggers the load sequence in delayed load mode.
  30955. */
  30956. delayLoad(): void;
  30957. /**
  30958. * Clones the texture.
  30959. * @returns the cloned texture
  30960. */
  30961. clone(): Nullable<BaseTexture>;
  30962. /**
  30963. * Get the texture underlying type (INT, FLOAT...)
  30964. */
  30965. get textureType(): number;
  30966. /**
  30967. * Get the texture underlying format (RGB, RGBA...)
  30968. */
  30969. get textureFormat(): number;
  30970. /**
  30971. * Indicates that textures need to be re-calculated for all materials
  30972. */
  30973. protected _markAllSubMeshesAsTexturesDirty(): void;
  30974. /**
  30975. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30976. * This will returns an RGBA array buffer containing either in values (0-255) or
  30977. * float values (0-1) depending of the underlying buffer type.
  30978. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30979. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30980. * @param buffer defines a user defined buffer to fill with data (can be null)
  30981. * @returns The Array buffer containing the pixels data.
  30982. */
  30983. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30984. /**
  30985. * Release and destroy the underlying lower level texture aka internalTexture.
  30986. */
  30987. releaseInternalTexture(): void;
  30988. /** @hidden */
  30989. get _lodTextureHigh(): Nullable<BaseTexture>;
  30990. /** @hidden */
  30991. get _lodTextureMid(): Nullable<BaseTexture>;
  30992. /** @hidden */
  30993. get _lodTextureLow(): Nullable<BaseTexture>;
  30994. /**
  30995. * Dispose the texture and release its associated resources.
  30996. */
  30997. dispose(): void;
  30998. /**
  30999. * Serialize the texture into a JSON representation that can be parsed later on.
  31000. * @returns the JSON representation of the texture
  31001. */
  31002. serialize(): any;
  31003. /**
  31004. * Helper function to be called back once a list of texture contains only ready textures.
  31005. * @param textures Define the list of textures to wait for
  31006. * @param callback Define the callback triggered once the entire list will be ready
  31007. */
  31008. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31009. }
  31010. }
  31011. declare module "babylonjs/Materials/effect" {
  31012. import { Observable } from "babylonjs/Misc/observable";
  31013. import { Nullable } from "babylonjs/types";
  31014. import { IDisposable } from "babylonjs/scene";
  31015. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31016. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31017. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31018. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31019. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31020. import { Engine } from "babylonjs/Engines/engine";
  31021. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31025. /**
  31026. * Options to be used when creating an effect.
  31027. */
  31028. export interface IEffectCreationOptions {
  31029. /**
  31030. * Atrributes that will be used in the shader.
  31031. */
  31032. attributes: string[];
  31033. /**
  31034. * Uniform varible names that will be set in the shader.
  31035. */
  31036. uniformsNames: string[];
  31037. /**
  31038. * Uniform buffer variable names that will be set in the shader.
  31039. */
  31040. uniformBuffersNames: string[];
  31041. /**
  31042. * Sampler texture variable names that will be set in the shader.
  31043. */
  31044. samplers: string[];
  31045. /**
  31046. * Define statements that will be set in the shader.
  31047. */
  31048. defines: any;
  31049. /**
  31050. * Possible fallbacks for this effect to improve performance when needed.
  31051. */
  31052. fallbacks: Nullable<IEffectFallbacks>;
  31053. /**
  31054. * Callback that will be called when the shader is compiled.
  31055. */
  31056. onCompiled: Nullable<(effect: Effect) => void>;
  31057. /**
  31058. * Callback that will be called if an error occurs during shader compilation.
  31059. */
  31060. onError: Nullable<(effect: Effect, errors: string) => void>;
  31061. /**
  31062. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31063. */
  31064. indexParameters?: any;
  31065. /**
  31066. * Max number of lights that can be used in the shader.
  31067. */
  31068. maxSimultaneousLights?: number;
  31069. /**
  31070. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31071. */
  31072. transformFeedbackVaryings?: Nullable<string[]>;
  31073. }
  31074. /**
  31075. * Effect containing vertex and fragment shader that can be executed on an object.
  31076. */
  31077. export class Effect implements IDisposable {
  31078. /**
  31079. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31080. */
  31081. static ShadersRepository: string;
  31082. /**
  31083. * Enable logging of the shader code when a compilation error occurs
  31084. */
  31085. static LogShaderCodeOnCompilationError: boolean;
  31086. /**
  31087. * Name of the effect.
  31088. */
  31089. name: any;
  31090. /**
  31091. * String container all the define statements that should be set on the shader.
  31092. */
  31093. defines: string;
  31094. /**
  31095. * Callback that will be called when the shader is compiled.
  31096. */
  31097. onCompiled: Nullable<(effect: Effect) => void>;
  31098. /**
  31099. * Callback that will be called if an error occurs during shader compilation.
  31100. */
  31101. onError: Nullable<(effect: Effect, errors: string) => void>;
  31102. /**
  31103. * Callback that will be called when effect is bound.
  31104. */
  31105. onBind: Nullable<(effect: Effect) => void>;
  31106. /**
  31107. * Unique ID of the effect.
  31108. */
  31109. uniqueId: number;
  31110. /**
  31111. * Observable that will be called when the shader is compiled.
  31112. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31113. */
  31114. onCompileObservable: Observable<Effect>;
  31115. /**
  31116. * Observable that will be called if an error occurs during shader compilation.
  31117. */
  31118. onErrorObservable: Observable<Effect>;
  31119. /** @hidden */
  31120. _onBindObservable: Nullable<Observable<Effect>>;
  31121. /**
  31122. * @hidden
  31123. * Specifies if the effect was previously ready
  31124. */
  31125. _wasPreviouslyReady: boolean;
  31126. /**
  31127. * Observable that will be called when effect is bound.
  31128. */
  31129. get onBindObservable(): Observable<Effect>;
  31130. /** @hidden */
  31131. _bonesComputationForcedToCPU: boolean;
  31132. private static _uniqueIdSeed;
  31133. private _engine;
  31134. private _uniformBuffersNames;
  31135. private _uniformsNames;
  31136. private _samplerList;
  31137. private _samplers;
  31138. private _isReady;
  31139. private _compilationError;
  31140. private _allFallbacksProcessed;
  31141. private _attributesNames;
  31142. private _attributes;
  31143. private _attributeLocationByName;
  31144. private _uniforms;
  31145. /**
  31146. * Key for the effect.
  31147. * @hidden
  31148. */
  31149. _key: string;
  31150. private _indexParameters;
  31151. private _fallbacks;
  31152. private _vertexSourceCode;
  31153. private _fragmentSourceCode;
  31154. private _vertexSourceCodeOverride;
  31155. private _fragmentSourceCodeOverride;
  31156. private _transformFeedbackVaryings;
  31157. /**
  31158. * Compiled shader to webGL program.
  31159. * @hidden
  31160. */
  31161. _pipelineContext: Nullable<IPipelineContext>;
  31162. private _valueCache;
  31163. private static _baseCache;
  31164. /**
  31165. * Instantiates an effect.
  31166. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31167. * @param baseName Name of the effect.
  31168. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31169. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31170. * @param samplers List of sampler variables that will be passed to the shader.
  31171. * @param engine Engine to be used to render the effect
  31172. * @param defines Define statements to be added to the shader.
  31173. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31174. * @param onCompiled Callback that will be called when the shader is compiled.
  31175. * @param onError Callback that will be called if an error occurs during shader compilation.
  31176. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31177. */
  31178. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  31179. private _useFinalCode;
  31180. /**
  31181. * Unique key for this effect
  31182. */
  31183. get key(): string;
  31184. /**
  31185. * If the effect has been compiled and prepared.
  31186. * @returns if the effect is compiled and prepared.
  31187. */
  31188. isReady(): boolean;
  31189. private _isReadyInternal;
  31190. /**
  31191. * The engine the effect was initialized with.
  31192. * @returns the engine.
  31193. */
  31194. getEngine(): Engine;
  31195. /**
  31196. * The pipeline context for this effect
  31197. * @returns the associated pipeline context
  31198. */
  31199. getPipelineContext(): Nullable<IPipelineContext>;
  31200. /**
  31201. * The set of names of attribute variables for the shader.
  31202. * @returns An array of attribute names.
  31203. */
  31204. getAttributesNames(): string[];
  31205. /**
  31206. * Returns the attribute at the given index.
  31207. * @param index The index of the attribute.
  31208. * @returns The location of the attribute.
  31209. */
  31210. getAttributeLocation(index: number): number;
  31211. /**
  31212. * Returns the attribute based on the name of the variable.
  31213. * @param name of the attribute to look up.
  31214. * @returns the attribute location.
  31215. */
  31216. getAttributeLocationByName(name: string): number;
  31217. /**
  31218. * The number of attributes.
  31219. * @returns the numnber of attributes.
  31220. */
  31221. getAttributesCount(): number;
  31222. /**
  31223. * Gets the index of a uniform variable.
  31224. * @param uniformName of the uniform to look up.
  31225. * @returns the index.
  31226. */
  31227. getUniformIndex(uniformName: string): number;
  31228. /**
  31229. * Returns the attribute based on the name of the variable.
  31230. * @param uniformName of the uniform to look up.
  31231. * @returns the location of the uniform.
  31232. */
  31233. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31234. /**
  31235. * Returns an array of sampler variable names
  31236. * @returns The array of sampler variable neames.
  31237. */
  31238. getSamplers(): string[];
  31239. /**
  31240. * The error from the last compilation.
  31241. * @returns the error string.
  31242. */
  31243. getCompilationError(): string;
  31244. /**
  31245. * Gets a boolean indicating that all fallbacks were used during compilation
  31246. * @returns true if all fallbacks were used
  31247. */
  31248. allFallbacksProcessed(): boolean;
  31249. /**
  31250. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31251. * @param func The callback to be used.
  31252. */
  31253. executeWhenCompiled(func: (effect: Effect) => void): void;
  31254. private _checkIsReady;
  31255. private _loadShader;
  31256. /**
  31257. * Recompiles the webGL program
  31258. * @param vertexSourceCode The source code for the vertex shader.
  31259. * @param fragmentSourceCode The source code for the fragment shader.
  31260. * @param onCompiled Callback called when completed.
  31261. * @param onError Callback called on error.
  31262. * @hidden
  31263. */
  31264. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31265. /**
  31266. * Prepares the effect
  31267. * @hidden
  31268. */
  31269. _prepareEffect(): void;
  31270. private _getShaderCodeAndErrorLine;
  31271. private _processCompilationErrors;
  31272. /**
  31273. * Checks if the effect is supported. (Must be called after compilation)
  31274. */
  31275. get isSupported(): boolean;
  31276. /**
  31277. * Binds a texture to the engine to be used as output of the shader.
  31278. * @param channel Name of the output variable.
  31279. * @param texture Texture to bind.
  31280. * @hidden
  31281. */
  31282. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31283. /**
  31284. * Sets a texture on the engine to be used in the shader.
  31285. * @param channel Name of the sampler variable.
  31286. * @param texture Texture to set.
  31287. */
  31288. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31289. /**
  31290. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31291. * @param channel Name of the sampler variable.
  31292. * @param texture Texture to set.
  31293. */
  31294. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31295. /**
  31296. * Sets an array of textures on the engine to be used in the shader.
  31297. * @param channel Name of the variable.
  31298. * @param textures Textures to set.
  31299. */
  31300. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31301. /**
  31302. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  31303. * @param channel Name of the sampler variable.
  31304. * @param postProcess Post process to get the input texture from.
  31305. */
  31306. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31307. /**
  31308. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31309. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  31310. * @param channel Name of the sampler variable.
  31311. * @param postProcess Post process to get the output texture from.
  31312. */
  31313. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31314. /** @hidden */
  31315. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31316. /** @hidden */
  31317. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31318. /** @hidden */
  31319. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31320. /** @hidden */
  31321. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31322. /**
  31323. * Binds a buffer to a uniform.
  31324. * @param buffer Buffer to bind.
  31325. * @param name Name of the uniform variable to bind to.
  31326. */
  31327. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31328. /**
  31329. * Binds block to a uniform.
  31330. * @param blockName Name of the block to bind.
  31331. * @param index Index to bind.
  31332. */
  31333. bindUniformBlock(blockName: string, index: number): void;
  31334. /**
  31335. * Sets an interger value on a uniform variable.
  31336. * @param uniformName Name of the variable.
  31337. * @param value Value to be set.
  31338. * @returns this effect.
  31339. */
  31340. setInt(uniformName: string, value: number): Effect;
  31341. /**
  31342. * Sets an int array on a uniform variable.
  31343. * @param uniformName Name of the variable.
  31344. * @param array array to be set.
  31345. * @returns this effect.
  31346. */
  31347. setIntArray(uniformName: string, array: Int32Array): Effect;
  31348. /**
  31349. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31350. * @param uniformName Name of the variable.
  31351. * @param array array to be set.
  31352. * @returns this effect.
  31353. */
  31354. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31355. /**
  31356. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31357. * @param uniformName Name of the variable.
  31358. * @param array array to be set.
  31359. * @returns this effect.
  31360. */
  31361. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31362. /**
  31363. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31364. * @param uniformName Name of the variable.
  31365. * @param array array to be set.
  31366. * @returns this effect.
  31367. */
  31368. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31369. /**
  31370. * Sets an float array on a uniform variable.
  31371. * @param uniformName Name of the variable.
  31372. * @param array array to be set.
  31373. * @returns this effect.
  31374. */
  31375. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31376. /**
  31377. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31378. * @param uniformName Name of the variable.
  31379. * @param array array to be set.
  31380. * @returns this effect.
  31381. */
  31382. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31383. /**
  31384. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31385. * @param uniformName Name of the variable.
  31386. * @param array array to be set.
  31387. * @returns this effect.
  31388. */
  31389. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31390. /**
  31391. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31392. * @param uniformName Name of the variable.
  31393. * @param array array to be set.
  31394. * @returns this effect.
  31395. */
  31396. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31397. /**
  31398. * Sets an array on a uniform variable.
  31399. * @param uniformName Name of the variable.
  31400. * @param array array to be set.
  31401. * @returns this effect.
  31402. */
  31403. setArray(uniformName: string, array: number[]): Effect;
  31404. /**
  31405. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31406. * @param uniformName Name of the variable.
  31407. * @param array array to be set.
  31408. * @returns this effect.
  31409. */
  31410. setArray2(uniformName: string, array: number[]): Effect;
  31411. /**
  31412. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31413. * @param uniformName Name of the variable.
  31414. * @param array array to be set.
  31415. * @returns this effect.
  31416. */
  31417. setArray3(uniformName: string, array: number[]): Effect;
  31418. /**
  31419. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31420. * @param uniformName Name of the variable.
  31421. * @param array array to be set.
  31422. * @returns this effect.
  31423. */
  31424. setArray4(uniformName: string, array: number[]): Effect;
  31425. /**
  31426. * Sets matrices on a uniform variable.
  31427. * @param uniformName Name of the variable.
  31428. * @param matrices matrices to be set.
  31429. * @returns this effect.
  31430. */
  31431. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31432. /**
  31433. * Sets matrix on a uniform variable.
  31434. * @param uniformName Name of the variable.
  31435. * @param matrix matrix to be set.
  31436. * @returns this effect.
  31437. */
  31438. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31439. /**
  31440. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  31441. * @param uniformName Name of the variable.
  31442. * @param matrix matrix to be set.
  31443. * @returns this effect.
  31444. */
  31445. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31446. /**
  31447. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31448. * @param uniformName Name of the variable.
  31449. * @param matrix matrix to be set.
  31450. * @returns this effect.
  31451. */
  31452. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31453. /**
  31454. * Sets a float on a uniform variable.
  31455. * @param uniformName Name of the variable.
  31456. * @param value value to be set.
  31457. * @returns this effect.
  31458. */
  31459. setFloat(uniformName: string, value: number): Effect;
  31460. /**
  31461. * Sets a boolean on a uniform variable.
  31462. * @param uniformName Name of the variable.
  31463. * @param bool value to be set.
  31464. * @returns this effect.
  31465. */
  31466. setBool(uniformName: string, bool: boolean): Effect;
  31467. /**
  31468. * Sets a Vector2 on a uniform variable.
  31469. * @param uniformName Name of the variable.
  31470. * @param vector2 vector2 to be set.
  31471. * @returns this effect.
  31472. */
  31473. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31474. /**
  31475. * Sets a float2 on a uniform variable.
  31476. * @param uniformName Name of the variable.
  31477. * @param x First float in float2.
  31478. * @param y Second float in float2.
  31479. * @returns this effect.
  31480. */
  31481. setFloat2(uniformName: string, x: number, y: number): Effect;
  31482. /**
  31483. * Sets a Vector3 on a uniform variable.
  31484. * @param uniformName Name of the variable.
  31485. * @param vector3 Value to be set.
  31486. * @returns this effect.
  31487. */
  31488. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31489. /**
  31490. * Sets a float3 on a uniform variable.
  31491. * @param uniformName Name of the variable.
  31492. * @param x First float in float3.
  31493. * @param y Second float in float3.
  31494. * @param z Third float in float3.
  31495. * @returns this effect.
  31496. */
  31497. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31498. /**
  31499. * Sets a Vector4 on a uniform variable.
  31500. * @param uniformName Name of the variable.
  31501. * @param vector4 Value to be set.
  31502. * @returns this effect.
  31503. */
  31504. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31505. /**
  31506. * Sets a float4 on a uniform variable.
  31507. * @param uniformName Name of the variable.
  31508. * @param x First float in float4.
  31509. * @param y Second float in float4.
  31510. * @param z Third float in float4.
  31511. * @param w Fourth float in float4.
  31512. * @returns this effect.
  31513. */
  31514. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31515. /**
  31516. * Sets a Color3 on a uniform variable.
  31517. * @param uniformName Name of the variable.
  31518. * @param color3 Value to be set.
  31519. * @returns this effect.
  31520. */
  31521. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31522. /**
  31523. * Sets a Color4 on a uniform variable.
  31524. * @param uniformName Name of the variable.
  31525. * @param color3 Value to be set.
  31526. * @param alpha Alpha value to be set.
  31527. * @returns this effect.
  31528. */
  31529. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31530. /**
  31531. * Sets a Color4 on a uniform variable
  31532. * @param uniformName defines the name of the variable
  31533. * @param color4 defines the value to be set
  31534. * @returns this effect.
  31535. */
  31536. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31537. /** Release all associated resources */
  31538. dispose(): void;
  31539. /**
  31540. * This function will add a new shader to the shader store
  31541. * @param name the name of the shader
  31542. * @param pixelShader optional pixel shader content
  31543. * @param vertexShader optional vertex shader content
  31544. */
  31545. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31546. /**
  31547. * Store of each shader (The can be looked up using effect.key)
  31548. */
  31549. static ShadersStore: {
  31550. [key: string]: string;
  31551. };
  31552. /**
  31553. * Store of each included file for a shader (The can be looked up using effect.key)
  31554. */
  31555. static IncludesShadersStore: {
  31556. [key: string]: string;
  31557. };
  31558. /**
  31559. * Resets the cache of effects.
  31560. */
  31561. static ResetCache(): void;
  31562. }
  31563. }
  31564. declare module "babylonjs/Engines/engineCapabilities" {
  31565. /**
  31566. * Interface used to describe the capabilities of the engine relatively to the current browser
  31567. */
  31568. export interface EngineCapabilities {
  31569. /** Maximum textures units per fragment shader */
  31570. maxTexturesImageUnits: number;
  31571. /** Maximum texture units per vertex shader */
  31572. maxVertexTextureImageUnits: number;
  31573. /** Maximum textures units in the entire pipeline */
  31574. maxCombinedTexturesImageUnits: number;
  31575. /** Maximum texture size */
  31576. maxTextureSize: number;
  31577. /** Maximum texture samples */
  31578. maxSamples?: number;
  31579. /** Maximum cube texture size */
  31580. maxCubemapTextureSize: number;
  31581. /** Maximum render texture size */
  31582. maxRenderTextureSize: number;
  31583. /** Maximum number of vertex attributes */
  31584. maxVertexAttribs: number;
  31585. /** Maximum number of varyings */
  31586. maxVaryingVectors: number;
  31587. /** Maximum number of uniforms per vertex shader */
  31588. maxVertexUniformVectors: number;
  31589. /** Maximum number of uniforms per fragment shader */
  31590. maxFragmentUniformVectors: number;
  31591. /** Defines if standard derivates (dx/dy) are supported */
  31592. standardDerivatives: boolean;
  31593. /** Defines if s3tc texture compression is supported */
  31594. s3tc?: WEBGL_compressed_texture_s3tc;
  31595. /** Defines if pvrtc texture compression is supported */
  31596. pvrtc: any;
  31597. /** Defines if etc1 texture compression is supported */
  31598. etc1: any;
  31599. /** Defines if etc2 texture compression is supported */
  31600. etc2: any;
  31601. /** Defines if astc texture compression is supported */
  31602. astc: any;
  31603. /** Defines if float textures are supported */
  31604. textureFloat: boolean;
  31605. /** Defines if vertex array objects are supported */
  31606. vertexArrayObject: boolean;
  31607. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31608. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31609. /** Gets the maximum level of anisotropy supported */
  31610. maxAnisotropy: number;
  31611. /** Defines if instancing is supported */
  31612. instancedArrays: boolean;
  31613. /** Defines if 32 bits indices are supported */
  31614. uintIndices: boolean;
  31615. /** Defines if high precision shaders are supported */
  31616. highPrecisionShaderSupported: boolean;
  31617. /** Defines if depth reading in the fragment shader is supported */
  31618. fragmentDepthSupported: boolean;
  31619. /** Defines if float texture linear filtering is supported*/
  31620. textureFloatLinearFiltering: boolean;
  31621. /** Defines if rendering to float textures is supported */
  31622. textureFloatRender: boolean;
  31623. /** Defines if half float textures are supported*/
  31624. textureHalfFloat: boolean;
  31625. /** Defines if half float texture linear filtering is supported*/
  31626. textureHalfFloatLinearFiltering: boolean;
  31627. /** Defines if rendering to half float textures is supported */
  31628. textureHalfFloatRender: boolean;
  31629. /** Defines if textureLOD shader command is supported */
  31630. textureLOD: boolean;
  31631. /** Defines if draw buffers extension is supported */
  31632. drawBuffersExtension: boolean;
  31633. /** Defines if depth textures are supported */
  31634. depthTextureExtension: boolean;
  31635. /** Defines if float color buffer are supported */
  31636. colorBufferFloat: boolean;
  31637. /** Gets disjoint timer query extension (null if not supported) */
  31638. timerQuery?: EXT_disjoint_timer_query;
  31639. /** Defines if timestamp can be used with timer query */
  31640. canUseTimestampForTimerQuery: boolean;
  31641. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31642. multiview?: any;
  31643. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31644. oculusMultiview?: any;
  31645. /** Function used to let the system compiles shaders in background */
  31646. parallelShaderCompile?: {
  31647. COMPLETION_STATUS_KHR: number;
  31648. };
  31649. /** Max number of texture samples for MSAA */
  31650. maxMSAASamples: number;
  31651. /** Defines if the blend min max extension is supported */
  31652. blendMinMax: boolean;
  31653. }
  31654. }
  31655. declare module "babylonjs/States/depthCullingState" {
  31656. import { Nullable } from "babylonjs/types";
  31657. /**
  31658. * @hidden
  31659. **/
  31660. export class DepthCullingState {
  31661. private _isDepthTestDirty;
  31662. private _isDepthMaskDirty;
  31663. private _isDepthFuncDirty;
  31664. private _isCullFaceDirty;
  31665. private _isCullDirty;
  31666. private _isZOffsetDirty;
  31667. private _isFrontFaceDirty;
  31668. private _depthTest;
  31669. private _depthMask;
  31670. private _depthFunc;
  31671. private _cull;
  31672. private _cullFace;
  31673. private _zOffset;
  31674. private _frontFace;
  31675. /**
  31676. * Initializes the state.
  31677. */
  31678. constructor();
  31679. get isDirty(): boolean;
  31680. get zOffset(): number;
  31681. set zOffset(value: number);
  31682. get cullFace(): Nullable<number>;
  31683. set cullFace(value: Nullable<number>);
  31684. get cull(): Nullable<boolean>;
  31685. set cull(value: Nullable<boolean>);
  31686. get depthFunc(): Nullable<number>;
  31687. set depthFunc(value: Nullable<number>);
  31688. get depthMask(): boolean;
  31689. set depthMask(value: boolean);
  31690. get depthTest(): boolean;
  31691. set depthTest(value: boolean);
  31692. get frontFace(): Nullable<number>;
  31693. set frontFace(value: Nullable<number>);
  31694. reset(): void;
  31695. apply(gl: WebGLRenderingContext): void;
  31696. }
  31697. }
  31698. declare module "babylonjs/States/stencilState" {
  31699. /**
  31700. * @hidden
  31701. **/
  31702. export class StencilState {
  31703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  31704. static readonly ALWAYS: number;
  31705. /** Passed to stencilOperation to specify that stencil value must be kept */
  31706. static readonly KEEP: number;
  31707. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31708. static readonly REPLACE: number;
  31709. private _isStencilTestDirty;
  31710. private _isStencilMaskDirty;
  31711. private _isStencilFuncDirty;
  31712. private _isStencilOpDirty;
  31713. private _stencilTest;
  31714. private _stencilMask;
  31715. private _stencilFunc;
  31716. private _stencilFuncRef;
  31717. private _stencilFuncMask;
  31718. private _stencilOpStencilFail;
  31719. private _stencilOpDepthFail;
  31720. private _stencilOpStencilDepthPass;
  31721. get isDirty(): boolean;
  31722. get stencilFunc(): number;
  31723. set stencilFunc(value: number);
  31724. get stencilFuncRef(): number;
  31725. set stencilFuncRef(value: number);
  31726. get stencilFuncMask(): number;
  31727. set stencilFuncMask(value: number);
  31728. get stencilOpStencilFail(): number;
  31729. set stencilOpStencilFail(value: number);
  31730. get stencilOpDepthFail(): number;
  31731. set stencilOpDepthFail(value: number);
  31732. get stencilOpStencilDepthPass(): number;
  31733. set stencilOpStencilDepthPass(value: number);
  31734. get stencilMask(): number;
  31735. set stencilMask(value: number);
  31736. get stencilTest(): boolean;
  31737. set stencilTest(value: boolean);
  31738. constructor();
  31739. reset(): void;
  31740. apply(gl: WebGLRenderingContext): void;
  31741. }
  31742. }
  31743. declare module "babylonjs/States/alphaCullingState" {
  31744. /**
  31745. * @hidden
  31746. **/
  31747. export class AlphaState {
  31748. private _isAlphaBlendDirty;
  31749. private _isBlendFunctionParametersDirty;
  31750. private _isBlendEquationParametersDirty;
  31751. private _isBlendConstantsDirty;
  31752. private _alphaBlend;
  31753. private _blendFunctionParameters;
  31754. private _blendEquationParameters;
  31755. private _blendConstants;
  31756. /**
  31757. * Initializes the state.
  31758. */
  31759. constructor();
  31760. get isDirty(): boolean;
  31761. get alphaBlend(): boolean;
  31762. set alphaBlend(value: boolean);
  31763. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31764. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31765. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31766. reset(): void;
  31767. apply(gl: WebGLRenderingContext): void;
  31768. }
  31769. }
  31770. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31771. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31772. /** @hidden */
  31773. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31774. attributeProcessor(attribute: string): string;
  31775. varyingProcessor(varying: string, isFragment: boolean): string;
  31776. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31777. }
  31778. }
  31779. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31780. /**
  31781. * Interface for attribute information associated with buffer instanciation
  31782. */
  31783. export interface InstancingAttributeInfo {
  31784. /**
  31785. * Name of the GLSL attribute
  31786. * if attribute index is not specified, this is used to retrieve the index from the effect
  31787. */
  31788. attributeName: string;
  31789. /**
  31790. * Index/offset of the attribute in the vertex shader
  31791. * if not specified, this will be computes from the name.
  31792. */
  31793. index?: number;
  31794. /**
  31795. * size of the attribute, 1, 2, 3 or 4
  31796. */
  31797. attributeSize: number;
  31798. /**
  31799. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31800. */
  31801. offset: number;
  31802. /**
  31803. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31804. * default to 1
  31805. */
  31806. divisor?: number;
  31807. /**
  31808. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31809. * default is FLOAT
  31810. */
  31811. attributeType?: number;
  31812. /**
  31813. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31814. */
  31815. normalized?: boolean;
  31816. }
  31817. }
  31818. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31820. import { Nullable } from "babylonjs/types";
  31821. module "babylonjs/Engines/thinEngine" {
  31822. interface ThinEngine {
  31823. /**
  31824. * Update a video texture
  31825. * @param texture defines the texture to update
  31826. * @param video defines the video element to use
  31827. * @param invertY defines if data must be stored with Y axis inverted
  31828. */
  31829. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31830. }
  31831. }
  31832. }
  31833. declare module "babylonjs/Materials/Textures/videoTexture" {
  31834. import { Observable } from "babylonjs/Misc/observable";
  31835. import { Nullable } from "babylonjs/types";
  31836. import { Scene } from "babylonjs/scene";
  31837. import { Texture } from "babylonjs/Materials/Textures/texture";
  31838. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31839. /**
  31840. * Settings for finer control over video usage
  31841. */
  31842. export interface VideoTextureSettings {
  31843. /**
  31844. * Applies `autoplay` to video, if specified
  31845. */
  31846. autoPlay?: boolean;
  31847. /**
  31848. * Applies `loop` to video, if specified
  31849. */
  31850. loop?: boolean;
  31851. /**
  31852. * Automatically updates internal texture from video at every frame in the render loop
  31853. */
  31854. autoUpdateTexture: boolean;
  31855. /**
  31856. * Image src displayed during the video loading or until the user interacts with the video.
  31857. */
  31858. poster?: string;
  31859. }
  31860. /**
  31861. * If you want to display a video in your scene, this is the special texture for that.
  31862. * This special texture works similar to other textures, with the exception of a few parameters.
  31863. * @see https://doc.babylonjs.com/how_to/video_texture
  31864. */
  31865. export class VideoTexture extends Texture {
  31866. /**
  31867. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31868. */
  31869. readonly autoUpdateTexture: boolean;
  31870. /**
  31871. * The video instance used by the texture internally
  31872. */
  31873. readonly video: HTMLVideoElement;
  31874. private _onUserActionRequestedObservable;
  31875. /**
  31876. * Event triggerd when a dom action is required by the user to play the video.
  31877. * This happens due to recent changes in browser policies preventing video to auto start.
  31878. */
  31879. get onUserActionRequestedObservable(): Observable<Texture>;
  31880. private _generateMipMaps;
  31881. private _engine;
  31882. private _stillImageCaptured;
  31883. private _displayingPosterTexture;
  31884. private _settings;
  31885. private _createInternalTextureOnEvent;
  31886. private _frameId;
  31887. private _currentSrc;
  31888. /**
  31889. * Creates a video texture.
  31890. * If you want to display a video in your scene, this is the special texture for that.
  31891. * This special texture works similar to other textures, with the exception of a few parameters.
  31892. * @see https://doc.babylonjs.com/how_to/video_texture
  31893. * @param name optional name, will detect from video source, if not defined
  31894. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31895. * @param scene is obviously the current scene.
  31896. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31897. * @param invertY is false by default but can be used to invert video on Y axis
  31898. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31899. * @param settings allows finer control over video usage
  31900. */
  31901. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31902. private _getName;
  31903. private _getVideo;
  31904. private _createInternalTexture;
  31905. private reset;
  31906. /**
  31907. * @hidden Internal method to initiate `update`.
  31908. */
  31909. _rebuild(): void;
  31910. /**
  31911. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31912. */
  31913. update(): void;
  31914. /**
  31915. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31916. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31917. */
  31918. updateTexture(isVisible: boolean): void;
  31919. protected _updateInternalTexture: () => void;
  31920. /**
  31921. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31922. * @param url New url.
  31923. */
  31924. updateURL(url: string): void;
  31925. /**
  31926. * Clones the texture.
  31927. * @returns the cloned texture
  31928. */
  31929. clone(): VideoTexture;
  31930. /**
  31931. * Dispose the texture and release its associated resources.
  31932. */
  31933. dispose(): void;
  31934. /**
  31935. * Creates a video texture straight from a stream.
  31936. * @param scene Define the scene the texture should be created in
  31937. * @param stream Define the stream the texture should be created from
  31938. * @returns The created video texture as a promise
  31939. */
  31940. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31941. /**
  31942. * Creates a video texture straight from your WebCam video feed.
  31943. * @param scene Define the scene the texture should be created in
  31944. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31945. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31946. * @returns The created video texture as a promise
  31947. */
  31948. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31949. minWidth: number;
  31950. maxWidth: number;
  31951. minHeight: number;
  31952. maxHeight: number;
  31953. deviceId: string;
  31954. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31955. /**
  31956. * Creates a video texture straight from your WebCam video feed.
  31957. * @param scene Define the scene the texture should be created in
  31958. * @param onReady Define a callback to triggered once the texture will be ready
  31959. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31960. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31961. */
  31962. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31963. minWidth: number;
  31964. maxWidth: number;
  31965. minHeight: number;
  31966. maxHeight: number;
  31967. deviceId: string;
  31968. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31969. }
  31970. }
  31971. declare module "babylonjs/Engines/thinEngine" {
  31972. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31973. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31974. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31975. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31976. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31977. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31978. import { Observable } from "babylonjs/Misc/observable";
  31979. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31980. import { StencilState } from "babylonjs/States/stencilState";
  31981. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31982. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31983. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31984. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31985. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31986. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31987. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31988. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31989. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31991. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31992. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31993. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31994. import { WebRequest } from "babylonjs/Misc/webRequest";
  31995. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31996. /**
  31997. * Defines the interface used by objects working like Scene
  31998. * @hidden
  31999. */
  32000. export interface ISceneLike {
  32001. _addPendingData(data: any): void;
  32002. _removePendingData(data: any): void;
  32003. offlineProvider: IOfflineProvider;
  32004. }
  32005. /** Interface defining initialization parameters for Engine class */
  32006. export interface EngineOptions extends WebGLContextAttributes {
  32007. /**
  32008. * Defines if the engine should no exceed a specified device ratio
  32009. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32010. */
  32011. limitDeviceRatio?: number;
  32012. /**
  32013. * Defines if webvr should be enabled automatically
  32014. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32015. */
  32016. autoEnableWebVR?: boolean;
  32017. /**
  32018. * Defines if webgl2 should be turned off even if supported
  32019. * @see http://doc.babylonjs.com/features/webgl2
  32020. */
  32021. disableWebGL2Support?: boolean;
  32022. /**
  32023. * Defines if webaudio should be initialized as well
  32024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32025. */
  32026. audioEngine?: boolean;
  32027. /**
  32028. * Defines if animations should run using a deterministic lock step
  32029. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32030. */
  32031. deterministicLockstep?: boolean;
  32032. /** Defines the maximum steps to use with deterministic lock step mode */
  32033. lockstepMaxSteps?: number;
  32034. /** Defines the seconds between each deterministic lock step */
  32035. timeStep?: number;
  32036. /**
  32037. * Defines that engine should ignore context lost events
  32038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32039. */
  32040. doNotHandleContextLost?: boolean;
  32041. /**
  32042. * Defines that engine should ignore modifying touch action attribute and style
  32043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32044. */
  32045. doNotHandleTouchAction?: boolean;
  32046. /**
  32047. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32048. */
  32049. useHighPrecisionFloats?: boolean;
  32050. }
  32051. /**
  32052. * The base engine class (root of all engines)
  32053. */
  32054. export class ThinEngine {
  32055. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32056. static ExceptionList: ({
  32057. key: string;
  32058. capture: string;
  32059. captureConstraint: number;
  32060. targets: string[];
  32061. } | {
  32062. key: string;
  32063. capture: null;
  32064. captureConstraint: null;
  32065. targets: string[];
  32066. })[];
  32067. /** @hidden */
  32068. static _TextureLoaders: IInternalTextureLoader[];
  32069. /**
  32070. * Returns the current npm package of the sdk
  32071. */
  32072. static get NpmPackage(): string;
  32073. /**
  32074. * Returns the current version of the framework
  32075. */
  32076. static get Version(): string;
  32077. /**
  32078. * Returns a string describing the current engine
  32079. */
  32080. get description(): string;
  32081. /**
  32082. * Gets or sets the epsilon value used by collision engine
  32083. */
  32084. static CollisionsEpsilon: number;
  32085. /**
  32086. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32087. */
  32088. static get ShadersRepository(): string;
  32089. static set ShadersRepository(value: string);
  32090. /** @hidden */
  32091. _shaderProcessor: IShaderProcessor;
  32092. /**
  32093. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32094. */
  32095. forcePOTTextures: boolean;
  32096. /**
  32097. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32098. */
  32099. isFullscreen: boolean;
  32100. /**
  32101. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32102. */
  32103. cullBackFaces: boolean;
  32104. /**
  32105. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32106. */
  32107. renderEvenInBackground: boolean;
  32108. /**
  32109. * Gets or sets a boolean indicating that cache can be kept between frames
  32110. */
  32111. preventCacheWipeBetweenFrames: boolean;
  32112. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32113. validateShaderPrograms: boolean;
  32114. /**
  32115. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32116. * This can provide greater z depth for distant objects.
  32117. */
  32118. useReverseDepthBuffer: boolean;
  32119. /**
  32120. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32121. */
  32122. disableUniformBuffers: boolean;
  32123. /** @hidden */
  32124. _uniformBuffers: UniformBuffer[];
  32125. /**
  32126. * Gets a boolean indicating that the engine supports uniform buffers
  32127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32128. */
  32129. get supportsUniformBuffers(): boolean;
  32130. /** @hidden */
  32131. _gl: WebGLRenderingContext;
  32132. /** @hidden */
  32133. _webGLVersion: number;
  32134. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32135. protected _windowIsBackground: boolean;
  32136. protected _creationOptions: EngineOptions;
  32137. protected _highPrecisionShadersAllowed: boolean;
  32138. /** @hidden */
  32139. get _shouldUseHighPrecisionShader(): boolean;
  32140. /**
  32141. * Gets a boolean indicating that only power of 2 textures are supported
  32142. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32143. */
  32144. get needPOTTextures(): boolean;
  32145. /** @hidden */
  32146. _badOS: boolean;
  32147. /** @hidden */
  32148. _badDesktopOS: boolean;
  32149. private _hardwareScalingLevel;
  32150. /** @hidden */
  32151. _caps: EngineCapabilities;
  32152. private _isStencilEnable;
  32153. private _glVersion;
  32154. private _glRenderer;
  32155. private _glVendor;
  32156. /** @hidden */
  32157. _videoTextureSupported: boolean;
  32158. protected _renderingQueueLaunched: boolean;
  32159. protected _activeRenderLoops: (() => void)[];
  32160. /**
  32161. * Observable signaled when a context lost event is raised
  32162. */
  32163. onContextLostObservable: Observable<ThinEngine>;
  32164. /**
  32165. * Observable signaled when a context restored event is raised
  32166. */
  32167. onContextRestoredObservable: Observable<ThinEngine>;
  32168. private _onContextLost;
  32169. private _onContextRestored;
  32170. protected _contextWasLost: boolean;
  32171. /** @hidden */
  32172. _doNotHandleContextLost: boolean;
  32173. /**
  32174. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32176. */
  32177. get doNotHandleContextLost(): boolean;
  32178. set doNotHandleContextLost(value: boolean);
  32179. /**
  32180. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32181. */
  32182. disableVertexArrayObjects: boolean;
  32183. /** @hidden */
  32184. protected _colorWrite: boolean;
  32185. /** @hidden */
  32186. protected _colorWriteChanged: boolean;
  32187. /** @hidden */
  32188. protected _depthCullingState: DepthCullingState;
  32189. /** @hidden */
  32190. protected _stencilState: StencilState;
  32191. /** @hidden */
  32192. _alphaState: AlphaState;
  32193. /** @hidden */
  32194. _alphaMode: number;
  32195. /** @hidden */
  32196. _alphaEquation: number;
  32197. /** @hidden */
  32198. _internalTexturesCache: InternalTexture[];
  32199. /** @hidden */
  32200. protected _activeChannel: number;
  32201. private _currentTextureChannel;
  32202. /** @hidden */
  32203. protected _boundTexturesCache: {
  32204. [key: string]: Nullable<InternalTexture>;
  32205. };
  32206. /** @hidden */
  32207. protected _currentEffect: Nullable<Effect>;
  32208. /** @hidden */
  32209. protected _currentProgram: Nullable<WebGLProgram>;
  32210. private _compiledEffects;
  32211. private _vertexAttribArraysEnabled;
  32212. /** @hidden */
  32213. protected _cachedViewport: Nullable<IViewportLike>;
  32214. private _cachedVertexArrayObject;
  32215. /** @hidden */
  32216. protected _cachedVertexBuffers: any;
  32217. /** @hidden */
  32218. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32219. /** @hidden */
  32220. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32221. /** @hidden */
  32222. _currentRenderTarget: Nullable<InternalTexture>;
  32223. private _uintIndicesCurrentlySet;
  32224. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32225. /** @hidden */
  32226. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32227. private _currentBufferPointers;
  32228. private _currentInstanceLocations;
  32229. private _currentInstanceBuffers;
  32230. private _textureUnits;
  32231. /** @hidden */
  32232. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32233. /** @hidden */
  32234. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32235. /** @hidden */
  32236. _boundRenderFunction: any;
  32237. private _vaoRecordInProgress;
  32238. private _mustWipeVertexAttributes;
  32239. private _emptyTexture;
  32240. private _emptyCubeTexture;
  32241. private _emptyTexture3D;
  32242. private _emptyTexture2DArray;
  32243. /** @hidden */
  32244. _frameHandler: number;
  32245. private _nextFreeTextureSlots;
  32246. private _maxSimultaneousTextures;
  32247. private _activeRequests;
  32248. /** @hidden */
  32249. _transformTextureUrl: Nullable<(url: string) => string>;
  32250. protected get _supportsHardwareTextureRescaling(): boolean;
  32251. private _framebufferDimensionsObject;
  32252. /**
  32253. * sets the object from which width and height will be taken from when getting render width and height
  32254. * Will fallback to the gl object
  32255. * @param dimensions the framebuffer width and height that will be used.
  32256. */
  32257. set framebufferDimensionsObject(dimensions: Nullable<{
  32258. framebufferWidth: number;
  32259. framebufferHeight: number;
  32260. }>);
  32261. /**
  32262. * Gets the current viewport
  32263. */
  32264. get currentViewport(): Nullable<IViewportLike>;
  32265. /**
  32266. * Gets the default empty texture
  32267. */
  32268. get emptyTexture(): InternalTexture;
  32269. /**
  32270. * Gets the default empty 3D texture
  32271. */
  32272. get emptyTexture3D(): InternalTexture;
  32273. /**
  32274. * Gets the default empty 2D array texture
  32275. */
  32276. get emptyTexture2DArray(): InternalTexture;
  32277. /**
  32278. * Gets the default empty cube texture
  32279. */
  32280. get emptyCubeTexture(): InternalTexture;
  32281. /**
  32282. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32283. */
  32284. readonly premultipliedAlpha: boolean;
  32285. /**
  32286. * Observable event triggered before each texture is initialized
  32287. */
  32288. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32289. /**
  32290. * Creates a new engine
  32291. * @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
  32292. * @param antialias defines enable antialiasing (default: false)
  32293. * @param options defines further options to be sent to the getContext() function
  32294. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32295. */
  32296. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32297. private _rebuildInternalTextures;
  32298. private _rebuildEffects;
  32299. /**
  32300. * Gets a boolean indicating if all created effects are ready
  32301. * @returns true if all effects are ready
  32302. */
  32303. areAllEffectsReady(): boolean;
  32304. protected _rebuildBuffers(): void;
  32305. protected _initGLContext(): void;
  32306. /**
  32307. * Gets version of the current webGL context
  32308. */
  32309. get webGLVersion(): number;
  32310. /**
  32311. * Gets a string idenfifying the name of the class
  32312. * @returns "Engine" string
  32313. */
  32314. getClassName(): string;
  32315. /**
  32316. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32317. */
  32318. get isStencilEnable(): boolean;
  32319. /** @hidden */
  32320. _prepareWorkingCanvas(): void;
  32321. /**
  32322. * Reset the texture cache to empty state
  32323. */
  32324. resetTextureCache(): void;
  32325. /**
  32326. * Gets an object containing information about the current webGL context
  32327. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32328. */
  32329. getGlInfo(): {
  32330. vendor: string;
  32331. renderer: string;
  32332. version: string;
  32333. };
  32334. /**
  32335. * Defines the hardware scaling level.
  32336. * By default the hardware scaling level is computed from the window device ratio.
  32337. * 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.
  32338. * @param level defines the level to use
  32339. */
  32340. setHardwareScalingLevel(level: number): void;
  32341. /**
  32342. * Gets the current hardware scaling level.
  32343. * By default the hardware scaling level is computed from the window device ratio.
  32344. * 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.
  32345. * @returns a number indicating the current hardware scaling level
  32346. */
  32347. getHardwareScalingLevel(): number;
  32348. /**
  32349. * Gets the list of loaded textures
  32350. * @returns an array containing all loaded textures
  32351. */
  32352. getLoadedTexturesCache(): InternalTexture[];
  32353. /**
  32354. * Gets the object containing all engine capabilities
  32355. * @returns the EngineCapabilities object
  32356. */
  32357. getCaps(): EngineCapabilities;
  32358. /**
  32359. * stop executing a render loop function and remove it from the execution array
  32360. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32361. */
  32362. stopRenderLoop(renderFunction?: () => void): void;
  32363. /** @hidden */
  32364. _renderLoop(): void;
  32365. /**
  32366. * Gets the HTML canvas attached with the current webGL context
  32367. * @returns a HTML canvas
  32368. */
  32369. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32370. /**
  32371. * Gets host window
  32372. * @returns the host window object
  32373. */
  32374. getHostWindow(): Nullable<Window>;
  32375. /**
  32376. * Gets the current render width
  32377. * @param useScreen defines if screen size must be used (or the current render target if any)
  32378. * @returns a number defining the current render width
  32379. */
  32380. getRenderWidth(useScreen?: boolean): number;
  32381. /**
  32382. * Gets the current render height
  32383. * @param useScreen defines if screen size must be used (or the current render target if any)
  32384. * @returns a number defining the current render height
  32385. */
  32386. getRenderHeight(useScreen?: boolean): number;
  32387. /**
  32388. * Can be used to override the current requestAnimationFrame requester.
  32389. * @hidden
  32390. */
  32391. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32392. /**
  32393. * Register and execute a render loop. The engine can have more than one render function
  32394. * @param renderFunction defines the function to continuously execute
  32395. */
  32396. runRenderLoop(renderFunction: () => void): void;
  32397. /**
  32398. * Clear the current render buffer or the current render target (if any is set up)
  32399. * @param color defines the color to use
  32400. * @param backBuffer defines if the back buffer must be cleared
  32401. * @param depth defines if the depth buffer must be cleared
  32402. * @param stencil defines if the stencil buffer must be cleared
  32403. */
  32404. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32405. private _viewportCached;
  32406. /** @hidden */
  32407. _viewport(x: number, y: number, width: number, height: number): void;
  32408. /**
  32409. * Set the WebGL's viewport
  32410. * @param viewport defines the viewport element to be used
  32411. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32412. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32413. */
  32414. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32415. /**
  32416. * Begin a new frame
  32417. */
  32418. beginFrame(): void;
  32419. /**
  32420. * Enf the current frame
  32421. */
  32422. endFrame(): void;
  32423. /**
  32424. * Resize the view according to the canvas' size
  32425. */
  32426. resize(): void;
  32427. /**
  32428. * Force a specific size of the canvas
  32429. * @param width defines the new canvas' width
  32430. * @param height defines the new canvas' height
  32431. */
  32432. setSize(width: number, height: number): void;
  32433. /**
  32434. * Binds the frame buffer to the specified texture.
  32435. * @param texture The texture to render to or null for the default canvas
  32436. * @param faceIndex The face of the texture to render to in case of cube texture
  32437. * @param requiredWidth The width of the target to render to
  32438. * @param requiredHeight The height of the target to render to
  32439. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32440. * @param lodLevel defines the lod level to bind to the frame buffer
  32441. * @param layer defines the 2d array index to bind to frame buffer to
  32442. */
  32443. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32444. /** @hidden */
  32445. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32446. /**
  32447. * Unbind the current render target texture from the webGL context
  32448. * @param texture defines the render target texture to unbind
  32449. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32450. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32451. */
  32452. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32453. /**
  32454. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32455. */
  32456. flushFramebuffer(): void;
  32457. /**
  32458. * Unbind the current render target and bind the default framebuffer
  32459. */
  32460. restoreDefaultFramebuffer(): void;
  32461. /** @hidden */
  32462. protected _resetVertexBufferBinding(): void;
  32463. /**
  32464. * Creates a vertex buffer
  32465. * @param data the data for the vertex buffer
  32466. * @returns the new WebGL static buffer
  32467. */
  32468. createVertexBuffer(data: DataArray): DataBuffer;
  32469. private _createVertexBuffer;
  32470. /**
  32471. * Creates a dynamic vertex buffer
  32472. * @param data the data for the dynamic vertex buffer
  32473. * @returns the new WebGL dynamic buffer
  32474. */
  32475. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32476. protected _resetIndexBufferBinding(): void;
  32477. /**
  32478. * Creates a new index buffer
  32479. * @param indices defines the content of the index buffer
  32480. * @param updatable defines if the index buffer must be updatable
  32481. * @returns a new webGL buffer
  32482. */
  32483. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32484. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32485. /**
  32486. * Bind a webGL buffer to the webGL context
  32487. * @param buffer defines the buffer to bind
  32488. */
  32489. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32490. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32491. private bindBuffer;
  32492. /**
  32493. * update the bound buffer with the given data
  32494. * @param data defines the data to update
  32495. */
  32496. updateArrayBuffer(data: Float32Array): void;
  32497. private _vertexAttribPointer;
  32498. /** @hidden */
  32499. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32500. private _bindVertexBuffersAttributes;
  32501. /**
  32502. * Records a vertex array object
  32503. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32504. * @param vertexBuffers defines the list of vertex buffers to store
  32505. * @param indexBuffer defines the index buffer to store
  32506. * @param effect defines the effect to store
  32507. * @returns the new vertex array object
  32508. */
  32509. recordVertexArrayObject(vertexBuffers: {
  32510. [key: string]: VertexBuffer;
  32511. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32512. /**
  32513. * Bind a specific vertex array object
  32514. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32515. * @param vertexArrayObject defines the vertex array object to bind
  32516. * @param indexBuffer defines the index buffer to bind
  32517. */
  32518. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32519. /**
  32520. * Bind webGl buffers directly to the webGL context
  32521. * @param vertexBuffer defines the vertex buffer to bind
  32522. * @param indexBuffer defines the index buffer to bind
  32523. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32524. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32525. * @param effect defines the effect associated with the vertex buffer
  32526. */
  32527. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32528. private _unbindVertexArrayObject;
  32529. /**
  32530. * Bind a list of vertex buffers to the webGL context
  32531. * @param vertexBuffers defines the list of vertex buffers to bind
  32532. * @param indexBuffer defines the index buffer to bind
  32533. * @param effect defines the effect associated with the vertex buffers
  32534. */
  32535. bindBuffers(vertexBuffers: {
  32536. [key: string]: Nullable<VertexBuffer>;
  32537. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32538. /**
  32539. * Unbind all instance attributes
  32540. */
  32541. unbindInstanceAttributes(): void;
  32542. /**
  32543. * Release and free the memory of a vertex array object
  32544. * @param vao defines the vertex array object to delete
  32545. */
  32546. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32547. /** @hidden */
  32548. _releaseBuffer(buffer: DataBuffer): boolean;
  32549. protected _deleteBuffer(buffer: DataBuffer): void;
  32550. /**
  32551. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32552. * @param instancesBuffer defines the webGL buffer to update and bind
  32553. * @param data defines the data to store in the buffer
  32554. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32555. */
  32556. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32557. /**
  32558. * Bind the content of a webGL buffer used with instantiation
  32559. * @param instancesBuffer defines the webGL buffer to bind
  32560. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32561. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32562. */
  32563. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32564. /**
  32565. * Disable the instance attribute corresponding to the name in parameter
  32566. * @param name defines the name of the attribute to disable
  32567. */
  32568. disableInstanceAttributeByName(name: string): void;
  32569. /**
  32570. * Disable the instance attribute corresponding to the location in parameter
  32571. * @param attributeLocation defines the attribute location of the attribute to disable
  32572. */
  32573. disableInstanceAttribute(attributeLocation: number): void;
  32574. /**
  32575. * Disable the attribute corresponding to the location in parameter
  32576. * @param attributeLocation defines the attribute location of the attribute to disable
  32577. */
  32578. disableAttributeByIndex(attributeLocation: number): void;
  32579. /**
  32580. * Send a draw order
  32581. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32582. * @param indexStart defines the starting index
  32583. * @param indexCount defines the number of index to draw
  32584. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32585. */
  32586. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32587. /**
  32588. * Draw a list of points
  32589. * @param verticesStart defines the index of first vertex to draw
  32590. * @param verticesCount defines the count of vertices to draw
  32591. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32592. */
  32593. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32594. /**
  32595. * Draw a list of unindexed primitives
  32596. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32597. * @param verticesStart defines the index of first vertex to draw
  32598. * @param verticesCount defines the count of vertices to draw
  32599. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32600. */
  32601. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32602. /**
  32603. * Draw a list of indexed primitives
  32604. * @param fillMode defines the primitive to use
  32605. * @param indexStart defines the starting index
  32606. * @param indexCount defines the number of index to draw
  32607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32608. */
  32609. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32610. /**
  32611. * Draw a list of unindexed primitives
  32612. * @param fillMode defines the primitive to use
  32613. * @param verticesStart defines the index of first vertex to draw
  32614. * @param verticesCount defines the count of vertices to draw
  32615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32616. */
  32617. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32618. private _drawMode;
  32619. /** @hidden */
  32620. protected _reportDrawCall(): void;
  32621. /** @hidden */
  32622. _releaseEffect(effect: Effect): void;
  32623. /** @hidden */
  32624. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32625. /**
  32626. * Create a new effect (used to store vertex/fragment shaders)
  32627. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32628. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32629. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32630. * @param samplers defines an array of string used to represent textures
  32631. * @param defines defines the string containing the defines to use to compile the shaders
  32632. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32633. * @param onCompiled defines a function to call when the effect creation is successful
  32634. * @param onError defines a function to call when the effect creation has failed
  32635. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32636. * @returns the new Effect
  32637. */
  32638. 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;
  32639. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32640. private _compileShader;
  32641. private _compileRawShader;
  32642. /** @hidden */
  32643. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32644. /**
  32645. * Directly creates a webGL program
  32646. * @param pipelineContext defines the pipeline context to attach to
  32647. * @param vertexCode defines the vertex shader code to use
  32648. * @param fragmentCode defines the fragment shader code to use
  32649. * @param context defines the webGL context to use (if not set, the current one will be used)
  32650. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32651. * @returns the new webGL program
  32652. */
  32653. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32654. /**
  32655. * Creates a webGL program
  32656. * @param pipelineContext defines the pipeline context to attach to
  32657. * @param vertexCode defines the vertex shader code to use
  32658. * @param fragmentCode defines the fragment shader code to use
  32659. * @param defines defines the string containing the defines to use to compile the shaders
  32660. * @param context defines the webGL context to use (if not set, the current one will be used)
  32661. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32662. * @returns the new webGL program
  32663. */
  32664. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32665. /**
  32666. * Creates a new pipeline context
  32667. * @returns the new pipeline
  32668. */
  32669. createPipelineContext(): IPipelineContext;
  32670. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32671. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32672. /** @hidden */
  32673. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32674. /** @hidden */
  32675. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32676. /** @hidden */
  32677. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32678. /**
  32679. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32680. * @param pipelineContext defines the pipeline context to use
  32681. * @param uniformsNames defines the list of uniform names
  32682. * @returns an array of webGL uniform locations
  32683. */
  32684. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32685. /**
  32686. * Gets the lsit of active attributes for a given webGL program
  32687. * @param pipelineContext defines the pipeline context to use
  32688. * @param attributesNames defines the list of attribute names to get
  32689. * @returns an array of indices indicating the offset of each attribute
  32690. */
  32691. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32692. /**
  32693. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32694. * @param effect defines the effect to activate
  32695. */
  32696. enableEffect(effect: Nullable<Effect>): void;
  32697. /**
  32698. * Set the value of an uniform to a number (int)
  32699. * @param uniform defines the webGL uniform location where to store the value
  32700. * @param value defines the int number to store
  32701. */
  32702. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32703. /**
  32704. * Set the value of an uniform to an array of int32
  32705. * @param uniform defines the webGL uniform location where to store the value
  32706. * @param array defines the array of int32 to store
  32707. */
  32708. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32709. /**
  32710. * Set the value of an uniform to an array of int32 (stored as vec2)
  32711. * @param uniform defines the webGL uniform location where to store the value
  32712. * @param array defines the array of int32 to store
  32713. */
  32714. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32715. /**
  32716. * Set the value of an uniform to an array of int32 (stored as vec3)
  32717. * @param uniform defines the webGL uniform location where to store the value
  32718. * @param array defines the array of int32 to store
  32719. */
  32720. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32721. /**
  32722. * Set the value of an uniform to an array of int32 (stored as vec4)
  32723. * @param uniform defines the webGL uniform location where to store the value
  32724. * @param array defines the array of int32 to store
  32725. */
  32726. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32727. /**
  32728. * Set the value of an uniform to an array of number
  32729. * @param uniform defines the webGL uniform location where to store the value
  32730. * @param array defines the array of number to store
  32731. */
  32732. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32733. /**
  32734. * Set the value of an uniform to an array of number (stored as vec2)
  32735. * @param uniform defines the webGL uniform location where to store the value
  32736. * @param array defines the array of number to store
  32737. */
  32738. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32739. /**
  32740. * Set the value of an uniform to an array of number (stored as vec3)
  32741. * @param uniform defines the webGL uniform location where to store the value
  32742. * @param array defines the array of number to store
  32743. */
  32744. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32745. /**
  32746. * Set the value of an uniform to an array of number (stored as vec4)
  32747. * @param uniform defines the webGL uniform location where to store the value
  32748. * @param array defines the array of number to store
  32749. */
  32750. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32751. /**
  32752. * Set the value of an uniform to an array of float32 (stored as matrices)
  32753. * @param uniform defines the webGL uniform location where to store the value
  32754. * @param matrices defines the array of float32 to store
  32755. */
  32756. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32757. /**
  32758. * Set the value of an uniform to a matrix (3x3)
  32759. * @param uniform defines the webGL uniform location where to store the value
  32760. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32761. */
  32762. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32763. /**
  32764. * Set the value of an uniform to a matrix (2x2)
  32765. * @param uniform defines the webGL uniform location where to store the value
  32766. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32767. */
  32768. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32769. /**
  32770. * Set the value of an uniform to a number (float)
  32771. * @param uniform defines the webGL uniform location where to store the value
  32772. * @param value defines the float number to store
  32773. */
  32774. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32775. /**
  32776. * Set the value of an uniform to a vec2
  32777. * @param uniform defines the webGL uniform location where to store the value
  32778. * @param x defines the 1st component of the value
  32779. * @param y defines the 2nd component of the value
  32780. */
  32781. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32782. /**
  32783. * Set the value of an uniform to a vec3
  32784. * @param uniform defines the webGL uniform location where to store the value
  32785. * @param x defines the 1st component of the value
  32786. * @param y defines the 2nd component of the value
  32787. * @param z defines the 3rd component of the value
  32788. */
  32789. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32790. /**
  32791. * Set the value of an uniform to a vec4
  32792. * @param uniform defines the webGL uniform location where to store the value
  32793. * @param x defines the 1st component of the value
  32794. * @param y defines the 2nd component of the value
  32795. * @param z defines the 3rd component of the value
  32796. * @param w defines the 4th component of the value
  32797. */
  32798. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32799. /**
  32800. * Apply all cached states (depth, culling, stencil and alpha)
  32801. */
  32802. applyStates(): void;
  32803. /**
  32804. * Enable or disable color writing
  32805. * @param enable defines the state to set
  32806. */
  32807. setColorWrite(enable: boolean): void;
  32808. /**
  32809. * Gets a boolean indicating if color writing is enabled
  32810. * @returns the current color writing state
  32811. */
  32812. getColorWrite(): boolean;
  32813. /**
  32814. * Gets the depth culling state manager
  32815. */
  32816. get depthCullingState(): DepthCullingState;
  32817. /**
  32818. * Gets the alpha state manager
  32819. */
  32820. get alphaState(): AlphaState;
  32821. /**
  32822. * Gets the stencil state manager
  32823. */
  32824. get stencilState(): StencilState;
  32825. /**
  32826. * Clears the list of texture accessible through engine.
  32827. * This can help preventing texture load conflict due to name collision.
  32828. */
  32829. clearInternalTexturesCache(): void;
  32830. /**
  32831. * Force the entire cache to be cleared
  32832. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32833. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32834. */
  32835. wipeCaches(bruteForce?: boolean): void;
  32836. /** @hidden */
  32837. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32838. min: number;
  32839. mag: number;
  32840. };
  32841. /** @hidden */
  32842. _createTexture(): WebGLTexture;
  32843. /**
  32844. * Usually called from Texture.ts.
  32845. * Passed information to create a WebGLTexture
  32846. * @param url defines a value which contains one of the following:
  32847. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32848. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32849. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32850. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32851. * @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)
  32852. * @param scene needed for loading to the correct scene
  32853. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32854. * @param onLoad optional callback to be called upon successful completion
  32855. * @param onError optional callback to be called upon failure
  32856. * @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
  32857. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32858. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32859. * @param forcedExtension defines the extension to use to pick the right loader
  32860. * @param mimeType defines an optional mime type
  32861. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32862. */
  32863. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  32864. /**
  32865. * Loads an image as an HTMLImageElement.
  32866. * @param input url string, ArrayBuffer, or Blob to load
  32867. * @param onLoad callback called when the image successfully loads
  32868. * @param onError callback called when the image fails to load
  32869. * @param offlineProvider offline provider for caching
  32870. * @param mimeType optional mime type
  32871. * @returns the HTMLImageElement of the loaded image
  32872. * @hidden
  32873. */
  32874. 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>;
  32875. /**
  32876. * @hidden
  32877. */
  32878. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32879. /**
  32880. * Creates a raw texture
  32881. * @param data defines the data to store in the texture
  32882. * @param width defines the width of the texture
  32883. * @param height defines the height of the texture
  32884. * @param format defines the format of the data
  32885. * @param generateMipMaps defines if the engine should generate the mip levels
  32886. * @param invertY defines if data must be stored with Y axis inverted
  32887. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32888. * @param compression defines the compression used (null by default)
  32889. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32890. * @returns the raw texture inside an InternalTexture
  32891. */
  32892. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32893. /**
  32894. * Creates a new raw cube texture
  32895. * @param data defines the array of data to use to create each face
  32896. * @param size defines the size of the textures
  32897. * @param format defines the format of the data
  32898. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32899. * @param generateMipMaps defines if the engine should generate the mip levels
  32900. * @param invertY defines if data must be stored with Y axis inverted
  32901. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32902. * @param compression defines the compression used (null by default)
  32903. * @returns the cube texture as an InternalTexture
  32904. */
  32905. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32906. /**
  32907. * Creates a new raw 3D texture
  32908. * @param data defines the data used to create the texture
  32909. * @param width defines the width of the texture
  32910. * @param height defines the height of the texture
  32911. * @param depth defines the depth of the texture
  32912. * @param format defines the format of the texture
  32913. * @param generateMipMaps defines if the engine must generate mip levels
  32914. * @param invertY defines if data must be stored with Y axis inverted
  32915. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32916. * @param compression defines the compressed used (can be null)
  32917. * @param textureType defines the compressed used (can be null)
  32918. * @returns a new raw 3D texture (stored in an InternalTexture)
  32919. */
  32920. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32921. /**
  32922. * Creates a new raw 2D array texture
  32923. * @param data defines the data used to create the texture
  32924. * @param width defines the width of the texture
  32925. * @param height defines the height of the texture
  32926. * @param depth defines the number of layers of the texture
  32927. * @param format defines the format of the texture
  32928. * @param generateMipMaps defines if the engine must generate mip levels
  32929. * @param invertY defines if data must be stored with Y axis inverted
  32930. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32931. * @param compression defines the compressed used (can be null)
  32932. * @param textureType defines the compressed used (can be null)
  32933. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32934. */
  32935. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32936. private _unpackFlipYCached;
  32937. /**
  32938. * In case you are sharing the context with other applications, it might
  32939. * be interested to not cache the unpack flip y state to ensure a consistent
  32940. * value would be set.
  32941. */
  32942. enableUnpackFlipYCached: boolean;
  32943. /** @hidden */
  32944. _unpackFlipY(value: boolean): void;
  32945. /** @hidden */
  32946. _getUnpackAlignement(): number;
  32947. private _getTextureTarget;
  32948. /**
  32949. * Update the sampling mode of a given texture
  32950. * @param samplingMode defines the required sampling mode
  32951. * @param texture defines the texture to update
  32952. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32953. */
  32954. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32955. /**
  32956. * Update the sampling mode of a given texture
  32957. * @param texture defines the texture to update
  32958. * @param wrapU defines the texture wrap mode of the u coordinates
  32959. * @param wrapV defines the texture wrap mode of the v coordinates
  32960. * @param wrapR defines the texture wrap mode of the r coordinates
  32961. */
  32962. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32963. /** @hidden */
  32964. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32965. width: number;
  32966. height: number;
  32967. layers?: number;
  32968. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32969. /** @hidden */
  32970. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32971. /** @hidden */
  32972. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32973. /**
  32974. * Update a portion of an internal texture
  32975. * @param texture defines the texture to update
  32976. * @param imageData defines the data to store into the texture
  32977. * @param xOffset defines the x coordinates of the update rectangle
  32978. * @param yOffset defines the y coordinates of the update rectangle
  32979. * @param width defines the width of the update rectangle
  32980. * @param height defines the height of the update rectangle
  32981. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32982. * @param lod defines the lod level to update (0 by default)
  32983. */
  32984. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32985. /** @hidden */
  32986. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32987. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32988. private _prepareWebGLTexture;
  32989. /** @hidden */
  32990. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32991. private _getDepthStencilBuffer;
  32992. /** @hidden */
  32993. _releaseFramebufferObjects(texture: InternalTexture): void;
  32994. /** @hidden */
  32995. _releaseTexture(texture: InternalTexture): void;
  32996. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32997. protected _setProgram(program: WebGLProgram): void;
  32998. protected _boundUniforms: {
  32999. [key: number]: WebGLUniformLocation;
  33000. };
  33001. /**
  33002. * Binds an effect to the webGL context
  33003. * @param effect defines the effect to bind
  33004. */
  33005. bindSamplers(effect: Effect): void;
  33006. private _activateCurrentTexture;
  33007. /** @hidden */
  33008. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33009. /** @hidden */
  33010. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33011. /**
  33012. * Unbind all textures from the webGL context
  33013. */
  33014. unbindAllTextures(): void;
  33015. /**
  33016. * Sets a texture to the according uniform.
  33017. * @param channel The texture channel
  33018. * @param uniform The uniform to set
  33019. * @param texture The texture to apply
  33020. */
  33021. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33022. private _bindSamplerUniformToChannel;
  33023. private _getTextureWrapMode;
  33024. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33025. /**
  33026. * Sets an array of texture to the webGL context
  33027. * @param channel defines the channel where the texture array must be set
  33028. * @param uniform defines the associated uniform location
  33029. * @param textures defines the array of textures to bind
  33030. */
  33031. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33032. /** @hidden */
  33033. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33034. private _setTextureParameterFloat;
  33035. private _setTextureParameterInteger;
  33036. /**
  33037. * Unbind all vertex attributes from the webGL context
  33038. */
  33039. unbindAllAttributes(): void;
  33040. /**
  33041. * 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
  33042. */
  33043. releaseEffects(): void;
  33044. /**
  33045. * Dispose and release all associated resources
  33046. */
  33047. dispose(): void;
  33048. /**
  33049. * Attach a new callback raised when context lost event is fired
  33050. * @param callback defines the callback to call
  33051. */
  33052. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33053. /**
  33054. * Attach a new callback raised when context restored event is fired
  33055. * @param callback defines the callback to call
  33056. */
  33057. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33058. /**
  33059. * Get the current error code of the webGL context
  33060. * @returns the error code
  33061. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33062. */
  33063. getError(): number;
  33064. private _canRenderToFloatFramebuffer;
  33065. private _canRenderToHalfFloatFramebuffer;
  33066. private _canRenderToFramebuffer;
  33067. /** @hidden */
  33068. _getWebGLTextureType(type: number): number;
  33069. /** @hidden */
  33070. _getInternalFormat(format: number): number;
  33071. /** @hidden */
  33072. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33073. /** @hidden */
  33074. _getRGBAMultiSampleBufferFormat(type: number): number;
  33075. /** @hidden */
  33076. _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;
  33077. /**
  33078. * Loads a file from a url
  33079. * @param url url to load
  33080. * @param onSuccess callback called when the file successfully loads
  33081. * @param onProgress callback called while file is loading (if the server supports this mode)
  33082. * @param offlineProvider defines the offline provider for caching
  33083. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33084. * @param onError callback called when the file fails to load
  33085. * @returns a file request object
  33086. * @hidden
  33087. */
  33088. 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;
  33089. /**
  33090. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33091. * @param x defines the x coordinate of the rectangle where pixels must be read
  33092. * @param y defines the y coordinate of the rectangle where pixels must be read
  33093. * @param width defines the width of the rectangle where pixels must be read
  33094. * @param height defines the height of the rectangle where pixels must be read
  33095. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33096. * @returns a Uint8Array containing RGBA colors
  33097. */
  33098. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33099. private static _isSupported;
  33100. /**
  33101. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33102. * @returns true if the engine can be created
  33103. * @ignorenaming
  33104. */
  33105. static isSupported(): boolean;
  33106. /**
  33107. * Find the next highest power of two.
  33108. * @param x Number to start search from.
  33109. * @return Next highest power of two.
  33110. */
  33111. static CeilingPOT(x: number): number;
  33112. /**
  33113. * Find the next lowest power of two.
  33114. * @param x Number to start search from.
  33115. * @return Next lowest power of two.
  33116. */
  33117. static FloorPOT(x: number): number;
  33118. /**
  33119. * Find the nearest power of two.
  33120. * @param x Number to start search from.
  33121. * @return Next nearest power of two.
  33122. */
  33123. static NearestPOT(x: number): number;
  33124. /**
  33125. * Get the closest exponent of two
  33126. * @param value defines the value to approximate
  33127. * @param max defines the maximum value to return
  33128. * @param mode defines how to define the closest value
  33129. * @returns closest exponent of two of the given value
  33130. */
  33131. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33132. /**
  33133. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33134. * @param func - the function to be called
  33135. * @param requester - the object that will request the next frame. Falls back to window.
  33136. * @returns frame number
  33137. */
  33138. static QueueNewFrame(func: () => void, requester?: any): number;
  33139. /**
  33140. * Gets host document
  33141. * @returns the host document object
  33142. */
  33143. getHostDocument(): Nullable<Document>;
  33144. }
  33145. }
  33146. declare module "babylonjs/Maths/sphericalPolynomial" {
  33147. import { Vector3 } from "babylonjs/Maths/math.vector";
  33148. import { Color3 } from "babylonjs/Maths/math.color";
  33149. /**
  33150. * Class representing spherical harmonics coefficients to the 3rd degree
  33151. */
  33152. export class SphericalHarmonics {
  33153. /**
  33154. * Defines whether or not the harmonics have been prescaled for rendering.
  33155. */
  33156. preScaled: boolean;
  33157. /**
  33158. * The l0,0 coefficients of the spherical harmonics
  33159. */
  33160. l00: Vector3;
  33161. /**
  33162. * The l1,-1 coefficients of the spherical harmonics
  33163. */
  33164. l1_1: Vector3;
  33165. /**
  33166. * The l1,0 coefficients of the spherical harmonics
  33167. */
  33168. l10: Vector3;
  33169. /**
  33170. * The l1,1 coefficients of the spherical harmonics
  33171. */
  33172. l11: Vector3;
  33173. /**
  33174. * The l2,-2 coefficients of the spherical harmonics
  33175. */
  33176. l2_2: Vector3;
  33177. /**
  33178. * The l2,-1 coefficients of the spherical harmonics
  33179. */
  33180. l2_1: Vector3;
  33181. /**
  33182. * The l2,0 coefficients of the spherical harmonics
  33183. */
  33184. l20: Vector3;
  33185. /**
  33186. * The l2,1 coefficients of the spherical harmonics
  33187. */
  33188. l21: Vector3;
  33189. /**
  33190. * The l2,2 coefficients of the spherical harmonics
  33191. */
  33192. l22: Vector3;
  33193. /**
  33194. * Adds a light to the spherical harmonics
  33195. * @param direction the direction of the light
  33196. * @param color the color of the light
  33197. * @param deltaSolidAngle the delta solid angle of the light
  33198. */
  33199. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33200. /**
  33201. * Scales the spherical harmonics by the given amount
  33202. * @param scale the amount to scale
  33203. */
  33204. scaleInPlace(scale: number): void;
  33205. /**
  33206. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33207. *
  33208. * ```
  33209. * E_lm = A_l * L_lm
  33210. * ```
  33211. *
  33212. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33213. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33214. * the scaling factors are given in equation 9.
  33215. */
  33216. convertIncidentRadianceToIrradiance(): void;
  33217. /**
  33218. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33219. *
  33220. * ```
  33221. * L = (1/pi) * E * rho
  33222. * ```
  33223. *
  33224. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33225. */
  33226. convertIrradianceToLambertianRadiance(): void;
  33227. /**
  33228. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33229. * required operations at run time.
  33230. *
  33231. * This is simply done by scaling back the SH with Ylm constants parameter.
  33232. * The trigonometric part being applied by the shader at run time.
  33233. */
  33234. preScaleForRendering(): void;
  33235. /**
  33236. * Constructs a spherical harmonics from an array.
  33237. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33238. * @returns the spherical harmonics
  33239. */
  33240. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33241. /**
  33242. * Gets the spherical harmonics from polynomial
  33243. * @param polynomial the spherical polynomial
  33244. * @returns the spherical harmonics
  33245. */
  33246. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33247. }
  33248. /**
  33249. * Class representing spherical polynomial coefficients to the 3rd degree
  33250. */
  33251. export class SphericalPolynomial {
  33252. private _harmonics;
  33253. /**
  33254. * The spherical harmonics used to create the polynomials.
  33255. */
  33256. get preScaledHarmonics(): SphericalHarmonics;
  33257. /**
  33258. * The x coefficients of the spherical polynomial
  33259. */
  33260. x: Vector3;
  33261. /**
  33262. * The y coefficients of the spherical polynomial
  33263. */
  33264. y: Vector3;
  33265. /**
  33266. * The z coefficients of the spherical polynomial
  33267. */
  33268. z: Vector3;
  33269. /**
  33270. * The xx coefficients of the spherical polynomial
  33271. */
  33272. xx: Vector3;
  33273. /**
  33274. * The yy coefficients of the spherical polynomial
  33275. */
  33276. yy: Vector3;
  33277. /**
  33278. * The zz coefficients of the spherical polynomial
  33279. */
  33280. zz: Vector3;
  33281. /**
  33282. * The xy coefficients of the spherical polynomial
  33283. */
  33284. xy: Vector3;
  33285. /**
  33286. * The yz coefficients of the spherical polynomial
  33287. */
  33288. yz: Vector3;
  33289. /**
  33290. * The zx coefficients of the spherical polynomial
  33291. */
  33292. zx: Vector3;
  33293. /**
  33294. * Adds an ambient color to the spherical polynomial
  33295. * @param color the color to add
  33296. */
  33297. addAmbient(color: Color3): void;
  33298. /**
  33299. * Scales the spherical polynomial by the given amount
  33300. * @param scale the amount to scale
  33301. */
  33302. scaleInPlace(scale: number): void;
  33303. /**
  33304. * Gets the spherical polynomial from harmonics
  33305. * @param harmonics the spherical harmonics
  33306. * @returns the spherical polynomial
  33307. */
  33308. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33309. /**
  33310. * Constructs a spherical polynomial from an array.
  33311. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33312. * @returns the spherical polynomial
  33313. */
  33314. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33315. }
  33316. }
  33317. declare module "babylonjs/Materials/Textures/internalTexture" {
  33318. import { Observable } from "babylonjs/Misc/observable";
  33319. import { Nullable, int } from "babylonjs/types";
  33320. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33322. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33323. /**
  33324. * Defines the source of the internal texture
  33325. */
  33326. export enum InternalTextureSource {
  33327. /**
  33328. * The source of the texture data is unknown
  33329. */
  33330. Unknown = 0,
  33331. /**
  33332. * Texture data comes from an URL
  33333. */
  33334. Url = 1,
  33335. /**
  33336. * Texture data is only used for temporary storage
  33337. */
  33338. Temp = 2,
  33339. /**
  33340. * Texture data comes from raw data (ArrayBuffer)
  33341. */
  33342. Raw = 3,
  33343. /**
  33344. * Texture content is dynamic (video or dynamic texture)
  33345. */
  33346. Dynamic = 4,
  33347. /**
  33348. * Texture content is generated by rendering to it
  33349. */
  33350. RenderTarget = 5,
  33351. /**
  33352. * Texture content is part of a multi render target process
  33353. */
  33354. MultiRenderTarget = 6,
  33355. /**
  33356. * Texture data comes from a cube data file
  33357. */
  33358. Cube = 7,
  33359. /**
  33360. * Texture data comes from a raw cube data
  33361. */
  33362. CubeRaw = 8,
  33363. /**
  33364. * Texture data come from a prefiltered cube data file
  33365. */
  33366. CubePrefiltered = 9,
  33367. /**
  33368. * Texture content is raw 3D data
  33369. */
  33370. Raw3D = 10,
  33371. /**
  33372. * Texture content is raw 2D array data
  33373. */
  33374. Raw2DArray = 11,
  33375. /**
  33376. * Texture content is a depth texture
  33377. */
  33378. Depth = 12,
  33379. /**
  33380. * Texture data comes from a raw cube data encoded with RGBD
  33381. */
  33382. CubeRawRGBD = 13
  33383. }
  33384. /**
  33385. * Class used to store data associated with WebGL texture data for the engine
  33386. * This class should not be used directly
  33387. */
  33388. export class InternalTexture {
  33389. /** @hidden */
  33390. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33391. /**
  33392. * Defines if the texture is ready
  33393. */
  33394. isReady: boolean;
  33395. /**
  33396. * Defines if the texture is a cube texture
  33397. */
  33398. isCube: boolean;
  33399. /**
  33400. * Defines if the texture contains 3D data
  33401. */
  33402. is3D: boolean;
  33403. /**
  33404. * Defines if the texture contains 2D array data
  33405. */
  33406. is2DArray: boolean;
  33407. /**
  33408. * Defines if the texture contains multiview data
  33409. */
  33410. isMultiview: boolean;
  33411. /**
  33412. * Gets the URL used to load this texture
  33413. */
  33414. url: string;
  33415. /**
  33416. * Gets the sampling mode of the texture
  33417. */
  33418. samplingMode: number;
  33419. /**
  33420. * Gets a boolean indicating if the texture needs mipmaps generation
  33421. */
  33422. generateMipMaps: boolean;
  33423. /**
  33424. * Gets the number of samples used by the texture (WebGL2+ only)
  33425. */
  33426. samples: number;
  33427. /**
  33428. * Gets the type of the texture (int, float...)
  33429. */
  33430. type: number;
  33431. /**
  33432. * Gets the format of the texture (RGB, RGBA...)
  33433. */
  33434. format: number;
  33435. /**
  33436. * Observable called when the texture is loaded
  33437. */
  33438. onLoadedObservable: Observable<InternalTexture>;
  33439. /**
  33440. * Gets the width of the texture
  33441. */
  33442. width: number;
  33443. /**
  33444. * Gets the height of the texture
  33445. */
  33446. height: number;
  33447. /**
  33448. * Gets the depth of the texture
  33449. */
  33450. depth: number;
  33451. /**
  33452. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33453. */
  33454. baseWidth: number;
  33455. /**
  33456. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33457. */
  33458. baseHeight: number;
  33459. /**
  33460. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33461. */
  33462. baseDepth: number;
  33463. /**
  33464. * Gets a boolean indicating if the texture is inverted on Y axis
  33465. */
  33466. invertY: boolean;
  33467. /** @hidden */
  33468. _invertVScale: boolean;
  33469. /** @hidden */
  33470. _associatedChannel: number;
  33471. /** @hidden */
  33472. _source: InternalTextureSource;
  33473. /** @hidden */
  33474. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33475. /** @hidden */
  33476. _bufferView: Nullable<ArrayBufferView>;
  33477. /** @hidden */
  33478. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33479. /** @hidden */
  33480. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33481. /** @hidden */
  33482. _size: number;
  33483. /** @hidden */
  33484. _extension: string;
  33485. /** @hidden */
  33486. _files: Nullable<string[]>;
  33487. /** @hidden */
  33488. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33489. /** @hidden */
  33490. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33491. /** @hidden */
  33492. _framebuffer: Nullable<WebGLFramebuffer>;
  33493. /** @hidden */
  33494. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33495. /** @hidden */
  33496. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33497. /** @hidden */
  33498. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33499. /** @hidden */
  33500. _attachments: Nullable<number[]>;
  33501. /** @hidden */
  33502. _cachedCoordinatesMode: Nullable<number>;
  33503. /** @hidden */
  33504. _cachedWrapU: Nullable<number>;
  33505. /** @hidden */
  33506. _cachedWrapV: Nullable<number>;
  33507. /** @hidden */
  33508. _cachedWrapR: Nullable<number>;
  33509. /** @hidden */
  33510. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33511. /** @hidden */
  33512. _isDisabled: boolean;
  33513. /** @hidden */
  33514. _compression: Nullable<string>;
  33515. /** @hidden */
  33516. _generateStencilBuffer: boolean;
  33517. /** @hidden */
  33518. _generateDepthBuffer: boolean;
  33519. /** @hidden */
  33520. _comparisonFunction: number;
  33521. /** @hidden */
  33522. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33523. /** @hidden */
  33524. _lodGenerationScale: number;
  33525. /** @hidden */
  33526. _lodGenerationOffset: number;
  33527. /** @hidden */
  33528. _depthStencilTexture: Nullable<InternalTexture>;
  33529. /** @hidden */
  33530. _colorTextureArray: Nullable<WebGLTexture>;
  33531. /** @hidden */
  33532. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33533. /** @hidden */
  33534. _lodTextureHigh: Nullable<BaseTexture>;
  33535. /** @hidden */
  33536. _lodTextureMid: Nullable<BaseTexture>;
  33537. /** @hidden */
  33538. _lodTextureLow: Nullable<BaseTexture>;
  33539. /** @hidden */
  33540. _isRGBD: boolean;
  33541. /** @hidden */
  33542. _linearSpecularLOD: boolean;
  33543. /** @hidden */
  33544. _irradianceTexture: Nullable<BaseTexture>;
  33545. /** @hidden */
  33546. _webGLTexture: Nullable<WebGLTexture>;
  33547. /** @hidden */
  33548. _references: number;
  33549. private _engine;
  33550. /**
  33551. * Gets the Engine the texture belongs to.
  33552. * @returns The babylon engine
  33553. */
  33554. getEngine(): ThinEngine;
  33555. /**
  33556. * Gets the data source type of the texture
  33557. */
  33558. get source(): InternalTextureSource;
  33559. /**
  33560. * Creates a new InternalTexture
  33561. * @param engine defines the engine to use
  33562. * @param source defines the type of data that will be used
  33563. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33564. */
  33565. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33566. /**
  33567. * Increments the number of references (ie. the number of Texture that point to it)
  33568. */
  33569. incrementReferences(): void;
  33570. /**
  33571. * Change the size of the texture (not the size of the content)
  33572. * @param width defines the new width
  33573. * @param height defines the new height
  33574. * @param depth defines the new depth (1 by default)
  33575. */
  33576. updateSize(width: int, height: int, depth?: int): void;
  33577. /** @hidden */
  33578. _rebuild(): void;
  33579. /** @hidden */
  33580. _swapAndDie(target: InternalTexture): void;
  33581. /**
  33582. * Dispose the current allocated resources
  33583. */
  33584. dispose(): void;
  33585. }
  33586. }
  33587. declare module "babylonjs/Audio/analyser" {
  33588. import { Scene } from "babylonjs/scene";
  33589. /**
  33590. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33592. */
  33593. export class Analyser {
  33594. /**
  33595. * Gets or sets the smoothing
  33596. * @ignorenaming
  33597. */
  33598. SMOOTHING: number;
  33599. /**
  33600. * Gets or sets the FFT table size
  33601. * @ignorenaming
  33602. */
  33603. FFT_SIZE: number;
  33604. /**
  33605. * Gets or sets the bar graph amplitude
  33606. * @ignorenaming
  33607. */
  33608. BARGRAPHAMPLITUDE: number;
  33609. /**
  33610. * Gets or sets the position of the debug canvas
  33611. * @ignorenaming
  33612. */
  33613. DEBUGCANVASPOS: {
  33614. x: number;
  33615. y: number;
  33616. };
  33617. /**
  33618. * Gets or sets the debug canvas size
  33619. * @ignorenaming
  33620. */
  33621. DEBUGCANVASSIZE: {
  33622. width: number;
  33623. height: number;
  33624. };
  33625. private _byteFreqs;
  33626. private _byteTime;
  33627. private _floatFreqs;
  33628. private _webAudioAnalyser;
  33629. private _debugCanvas;
  33630. private _debugCanvasContext;
  33631. private _scene;
  33632. private _registerFunc;
  33633. private _audioEngine;
  33634. /**
  33635. * Creates a new analyser
  33636. * @param scene defines hosting scene
  33637. */
  33638. constructor(scene: Scene);
  33639. /**
  33640. * Get the number of data values you will have to play with for the visualization
  33641. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33642. * @returns a number
  33643. */
  33644. getFrequencyBinCount(): number;
  33645. /**
  33646. * Gets the current frequency data as a byte array
  33647. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33648. * @returns a Uint8Array
  33649. */
  33650. getByteFrequencyData(): Uint8Array;
  33651. /**
  33652. * Gets the current waveform as a byte array
  33653. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33654. * @returns a Uint8Array
  33655. */
  33656. getByteTimeDomainData(): Uint8Array;
  33657. /**
  33658. * Gets the current frequency data as a float array
  33659. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33660. * @returns a Float32Array
  33661. */
  33662. getFloatFrequencyData(): Float32Array;
  33663. /**
  33664. * Renders the debug canvas
  33665. */
  33666. drawDebugCanvas(): void;
  33667. /**
  33668. * Stops rendering the debug canvas and removes it
  33669. */
  33670. stopDebugCanvas(): void;
  33671. /**
  33672. * Connects two audio nodes
  33673. * @param inputAudioNode defines first node to connect
  33674. * @param outputAudioNode defines second node to connect
  33675. */
  33676. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33677. /**
  33678. * Releases all associated resources
  33679. */
  33680. dispose(): void;
  33681. }
  33682. }
  33683. declare module "babylonjs/Audio/audioEngine" {
  33684. import { IDisposable } from "babylonjs/scene";
  33685. import { Analyser } from "babylonjs/Audio/analyser";
  33686. import { Nullable } from "babylonjs/types";
  33687. import { Observable } from "babylonjs/Misc/observable";
  33688. /**
  33689. * This represents an audio engine and it is responsible
  33690. * to play, synchronize and analyse sounds throughout the application.
  33691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33692. */
  33693. export interface IAudioEngine extends IDisposable {
  33694. /**
  33695. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33696. */
  33697. readonly canUseWebAudio: boolean;
  33698. /**
  33699. * Gets the current AudioContext if available.
  33700. */
  33701. readonly audioContext: Nullable<AudioContext>;
  33702. /**
  33703. * The master gain node defines the global audio volume of your audio engine.
  33704. */
  33705. readonly masterGain: GainNode;
  33706. /**
  33707. * Gets whether or not mp3 are supported by your browser.
  33708. */
  33709. readonly isMP3supported: boolean;
  33710. /**
  33711. * Gets whether or not ogg are supported by your browser.
  33712. */
  33713. readonly isOGGsupported: boolean;
  33714. /**
  33715. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33716. * @ignoreNaming
  33717. */
  33718. WarnedWebAudioUnsupported: boolean;
  33719. /**
  33720. * Defines if the audio engine relies on a custom unlocked button.
  33721. * In this case, the embedded button will not be displayed.
  33722. */
  33723. useCustomUnlockedButton: boolean;
  33724. /**
  33725. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33726. */
  33727. readonly unlocked: boolean;
  33728. /**
  33729. * Event raised when audio has been unlocked on the browser.
  33730. */
  33731. onAudioUnlockedObservable: Observable<AudioEngine>;
  33732. /**
  33733. * Event raised when audio has been locked on the browser.
  33734. */
  33735. onAudioLockedObservable: Observable<AudioEngine>;
  33736. /**
  33737. * Flags the audio engine in Locked state.
  33738. * This happens due to new browser policies preventing audio to autoplay.
  33739. */
  33740. lock(): void;
  33741. /**
  33742. * Unlocks the audio engine once a user action has been done on the dom.
  33743. * This is helpful to resume play once browser policies have been satisfied.
  33744. */
  33745. unlock(): void;
  33746. /**
  33747. * Gets the global volume sets on the master gain.
  33748. * @returns the global volume if set or -1 otherwise
  33749. */
  33750. getGlobalVolume(): number;
  33751. /**
  33752. * Sets the global volume of your experience (sets on the master gain).
  33753. * @param newVolume Defines the new global volume of the application
  33754. */
  33755. setGlobalVolume(newVolume: number): void;
  33756. /**
  33757. * Connect the audio engine to an audio analyser allowing some amazing
  33758. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33760. * @param analyser The analyser to connect to the engine
  33761. */
  33762. connectToAnalyser(analyser: Analyser): void;
  33763. }
  33764. /**
  33765. * This represents the default audio engine used in babylon.
  33766. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33768. */
  33769. export class AudioEngine implements IAudioEngine {
  33770. private _audioContext;
  33771. private _audioContextInitialized;
  33772. private _muteButton;
  33773. private _hostElement;
  33774. /**
  33775. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33776. */
  33777. canUseWebAudio: boolean;
  33778. /**
  33779. * The master gain node defines the global audio volume of your audio engine.
  33780. */
  33781. masterGain: GainNode;
  33782. /**
  33783. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33784. * @ignoreNaming
  33785. */
  33786. WarnedWebAudioUnsupported: boolean;
  33787. /**
  33788. * Gets whether or not mp3 are supported by your browser.
  33789. */
  33790. isMP3supported: boolean;
  33791. /**
  33792. * Gets whether or not ogg are supported by your browser.
  33793. */
  33794. isOGGsupported: boolean;
  33795. /**
  33796. * Gets whether audio has been unlocked on the device.
  33797. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33798. * a user interaction has happened.
  33799. */
  33800. unlocked: boolean;
  33801. /**
  33802. * Defines if the audio engine relies on a custom unlocked button.
  33803. * In this case, the embedded button will not be displayed.
  33804. */
  33805. useCustomUnlockedButton: boolean;
  33806. /**
  33807. * Event raised when audio has been unlocked on the browser.
  33808. */
  33809. onAudioUnlockedObservable: Observable<AudioEngine>;
  33810. /**
  33811. * Event raised when audio has been locked on the browser.
  33812. */
  33813. onAudioLockedObservable: Observable<AudioEngine>;
  33814. /**
  33815. * Gets the current AudioContext if available.
  33816. */
  33817. get audioContext(): Nullable<AudioContext>;
  33818. private _connectedAnalyser;
  33819. /**
  33820. * Instantiates a new audio engine.
  33821. *
  33822. * There should be only one per page as some browsers restrict the number
  33823. * of audio contexts you can create.
  33824. * @param hostElement defines the host element where to display the mute icon if necessary
  33825. */
  33826. constructor(hostElement?: Nullable<HTMLElement>);
  33827. /**
  33828. * Flags the audio engine in Locked state.
  33829. * This happens due to new browser policies preventing audio to autoplay.
  33830. */
  33831. lock(): void;
  33832. /**
  33833. * Unlocks the audio engine once a user action has been done on the dom.
  33834. * This is helpful to resume play once browser policies have been satisfied.
  33835. */
  33836. unlock(): void;
  33837. private _resumeAudioContext;
  33838. private _initializeAudioContext;
  33839. private _tryToRun;
  33840. private _triggerRunningState;
  33841. private _triggerSuspendedState;
  33842. private _displayMuteButton;
  33843. private _moveButtonToTopLeft;
  33844. private _onResize;
  33845. private _hideMuteButton;
  33846. /**
  33847. * Destroy and release the resources associated with the audio ccontext.
  33848. */
  33849. dispose(): void;
  33850. /**
  33851. * Gets the global volume sets on the master gain.
  33852. * @returns the global volume if set or -1 otherwise
  33853. */
  33854. getGlobalVolume(): number;
  33855. /**
  33856. * Sets the global volume of your experience (sets on the master gain).
  33857. * @param newVolume Defines the new global volume of the application
  33858. */
  33859. setGlobalVolume(newVolume: number): void;
  33860. /**
  33861. * Connect the audio engine to an audio analyser allowing some amazing
  33862. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33864. * @param analyser The analyser to connect to the engine
  33865. */
  33866. connectToAnalyser(analyser: Analyser): void;
  33867. }
  33868. }
  33869. declare module "babylonjs/Loading/loadingScreen" {
  33870. /**
  33871. * Interface used to present a loading screen while loading a scene
  33872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33873. */
  33874. export interface ILoadingScreen {
  33875. /**
  33876. * Function called to display the loading screen
  33877. */
  33878. displayLoadingUI: () => void;
  33879. /**
  33880. * Function called to hide the loading screen
  33881. */
  33882. hideLoadingUI: () => void;
  33883. /**
  33884. * Gets or sets the color to use for the background
  33885. */
  33886. loadingUIBackgroundColor: string;
  33887. /**
  33888. * Gets or sets the text to display while loading
  33889. */
  33890. loadingUIText: string;
  33891. }
  33892. /**
  33893. * Class used for the default loading screen
  33894. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33895. */
  33896. export class DefaultLoadingScreen implements ILoadingScreen {
  33897. private _renderingCanvas;
  33898. private _loadingText;
  33899. private _loadingDivBackgroundColor;
  33900. private _loadingDiv;
  33901. private _loadingTextDiv;
  33902. /** Gets or sets the logo url to use for the default loading screen */
  33903. static DefaultLogoUrl: string;
  33904. /** Gets or sets the spinner url to use for the default loading screen */
  33905. static DefaultSpinnerUrl: string;
  33906. /**
  33907. * Creates a new default loading screen
  33908. * @param _renderingCanvas defines the canvas used to render the scene
  33909. * @param _loadingText defines the default text to display
  33910. * @param _loadingDivBackgroundColor defines the default background color
  33911. */
  33912. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33913. /**
  33914. * Function called to display the loading screen
  33915. */
  33916. displayLoadingUI(): void;
  33917. /**
  33918. * Function called to hide the loading screen
  33919. */
  33920. hideLoadingUI(): void;
  33921. /**
  33922. * Gets or sets the text to display while loading
  33923. */
  33924. set loadingUIText(text: string);
  33925. get loadingUIText(): string;
  33926. /**
  33927. * Gets or sets the color to use for the background
  33928. */
  33929. get loadingUIBackgroundColor(): string;
  33930. set loadingUIBackgroundColor(color: string);
  33931. private _resizeLoadingUI;
  33932. }
  33933. }
  33934. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33935. /**
  33936. * Interface for any object that can request an animation frame
  33937. */
  33938. export interface ICustomAnimationFrameRequester {
  33939. /**
  33940. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33941. */
  33942. renderFunction?: Function;
  33943. /**
  33944. * Called to request the next frame to render to
  33945. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33946. */
  33947. requestAnimationFrame: Function;
  33948. /**
  33949. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33950. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33951. */
  33952. requestID?: number;
  33953. }
  33954. }
  33955. declare module "babylonjs/Misc/performanceMonitor" {
  33956. /**
  33957. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33958. */
  33959. export class PerformanceMonitor {
  33960. private _enabled;
  33961. private _rollingFrameTime;
  33962. private _lastFrameTimeMs;
  33963. /**
  33964. * constructor
  33965. * @param frameSampleSize The number of samples required to saturate the sliding window
  33966. */
  33967. constructor(frameSampleSize?: number);
  33968. /**
  33969. * Samples current frame
  33970. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33971. */
  33972. sampleFrame(timeMs?: number): void;
  33973. /**
  33974. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33975. */
  33976. get averageFrameTime(): number;
  33977. /**
  33978. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33979. */
  33980. get averageFrameTimeVariance(): number;
  33981. /**
  33982. * Returns the frame time of the most recent frame
  33983. */
  33984. get instantaneousFrameTime(): number;
  33985. /**
  33986. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33987. */
  33988. get averageFPS(): number;
  33989. /**
  33990. * Returns the average framerate in frames per second using the most recent frame time
  33991. */
  33992. get instantaneousFPS(): number;
  33993. /**
  33994. * Returns true if enough samples have been taken to completely fill the sliding window
  33995. */
  33996. get isSaturated(): boolean;
  33997. /**
  33998. * Enables contributions to the sliding window sample set
  33999. */
  34000. enable(): void;
  34001. /**
  34002. * Disables contributions to the sliding window sample set
  34003. * Samples will not be interpolated over the disabled period
  34004. */
  34005. disable(): void;
  34006. /**
  34007. * Returns true if sampling is enabled
  34008. */
  34009. get isEnabled(): boolean;
  34010. /**
  34011. * Resets performance monitor
  34012. */
  34013. reset(): void;
  34014. }
  34015. /**
  34016. * RollingAverage
  34017. *
  34018. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34019. */
  34020. export class RollingAverage {
  34021. /**
  34022. * Current average
  34023. */
  34024. average: number;
  34025. /**
  34026. * Current variance
  34027. */
  34028. variance: number;
  34029. protected _samples: Array<number>;
  34030. protected _sampleCount: number;
  34031. protected _pos: number;
  34032. protected _m2: number;
  34033. /**
  34034. * constructor
  34035. * @param length The number of samples required to saturate the sliding window
  34036. */
  34037. constructor(length: number);
  34038. /**
  34039. * Adds a sample to the sample set
  34040. * @param v The sample value
  34041. */
  34042. add(v: number): void;
  34043. /**
  34044. * Returns previously added values or null if outside of history or outside the sliding window domain
  34045. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34046. * @return Value previously recorded with add() or null if outside of range
  34047. */
  34048. history(i: number): number;
  34049. /**
  34050. * Returns true if enough samples have been taken to completely fill the sliding window
  34051. * @return true if sample-set saturated
  34052. */
  34053. isSaturated(): boolean;
  34054. /**
  34055. * Resets the rolling average (equivalent to 0 samples taken so far)
  34056. */
  34057. reset(): void;
  34058. /**
  34059. * Wraps a value around the sample range boundaries
  34060. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34061. * @return Wrapped position in sample range
  34062. */
  34063. protected _wrapPosition(i: number): number;
  34064. }
  34065. }
  34066. declare module "babylonjs/Misc/perfCounter" {
  34067. /**
  34068. * This class is used to track a performance counter which is number based.
  34069. * The user has access to many properties which give statistics of different nature.
  34070. *
  34071. * The implementer can track two kinds of Performance Counter: time and count.
  34072. * 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.
  34073. * 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.
  34074. */
  34075. export class PerfCounter {
  34076. /**
  34077. * Gets or sets a global boolean to turn on and off all the counters
  34078. */
  34079. static Enabled: boolean;
  34080. /**
  34081. * Returns the smallest value ever
  34082. */
  34083. get min(): number;
  34084. /**
  34085. * Returns the biggest value ever
  34086. */
  34087. get max(): number;
  34088. /**
  34089. * Returns the average value since the performance counter is running
  34090. */
  34091. get average(): number;
  34092. /**
  34093. * Returns the average value of the last second the counter was monitored
  34094. */
  34095. get lastSecAverage(): number;
  34096. /**
  34097. * Returns the current value
  34098. */
  34099. get current(): number;
  34100. /**
  34101. * Gets the accumulated total
  34102. */
  34103. get total(): number;
  34104. /**
  34105. * Gets the total value count
  34106. */
  34107. get count(): number;
  34108. /**
  34109. * Creates a new counter
  34110. */
  34111. constructor();
  34112. /**
  34113. * Call this method to start monitoring a new frame.
  34114. * 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.
  34115. */
  34116. fetchNewFrame(): void;
  34117. /**
  34118. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34119. * @param newCount the count value to add to the monitored count
  34120. * @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.
  34121. */
  34122. addCount(newCount: number, fetchResult: boolean): void;
  34123. /**
  34124. * Start monitoring this performance counter
  34125. */
  34126. beginMonitoring(): void;
  34127. /**
  34128. * Compute the time lapsed since the previous beginMonitoring() call.
  34129. * @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
  34130. */
  34131. endMonitoring(newFrame?: boolean): void;
  34132. private _fetchResult;
  34133. private _startMonitoringTime;
  34134. private _min;
  34135. private _max;
  34136. private _average;
  34137. private _current;
  34138. private _totalValueCount;
  34139. private _totalAccumulated;
  34140. private _lastSecAverage;
  34141. private _lastSecAccumulated;
  34142. private _lastSecTime;
  34143. private _lastSecValueCount;
  34144. }
  34145. }
  34146. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34147. module "babylonjs/Engines/thinEngine" {
  34148. interface ThinEngine {
  34149. /**
  34150. * Sets alpha constants used by some alpha blending modes
  34151. * @param r defines the red component
  34152. * @param g defines the green component
  34153. * @param b defines the blue component
  34154. * @param a defines the alpha component
  34155. */
  34156. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34157. /**
  34158. * Sets the current alpha mode
  34159. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34160. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34161. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34162. */
  34163. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34164. /**
  34165. * Gets the current alpha mode
  34166. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34167. * @returns the current alpha mode
  34168. */
  34169. getAlphaMode(): number;
  34170. /**
  34171. * Sets the current alpha equation
  34172. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34173. */
  34174. setAlphaEquation(equation: number): void;
  34175. /**
  34176. * Gets the current alpha equation.
  34177. * @returns the current alpha equation
  34178. */
  34179. getAlphaEquation(): number;
  34180. }
  34181. }
  34182. }
  34183. declare module "babylonjs/Engines/engine" {
  34184. import { Observable } from "babylonjs/Misc/observable";
  34185. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34186. import { Scene } from "babylonjs/scene";
  34187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34188. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34189. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34190. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34191. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34192. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34193. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34194. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34195. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34196. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34197. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34198. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34199. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34200. import "babylonjs/Engines/Extensions/engine.alpha";
  34201. import { Material } from "babylonjs/Materials/material";
  34202. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34203. /**
  34204. * Defines the interface used by display changed events
  34205. */
  34206. export interface IDisplayChangedEventArgs {
  34207. /** Gets the vrDisplay object (if any) */
  34208. vrDisplay: Nullable<any>;
  34209. /** Gets a boolean indicating if webVR is supported */
  34210. vrSupported: boolean;
  34211. }
  34212. /**
  34213. * Defines the interface used by objects containing a viewport (like a camera)
  34214. */
  34215. interface IViewportOwnerLike {
  34216. /**
  34217. * Gets or sets the viewport
  34218. */
  34219. viewport: IViewportLike;
  34220. }
  34221. /**
  34222. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34223. */
  34224. export class Engine extends ThinEngine {
  34225. /** Defines that alpha blending is disabled */
  34226. static readonly ALPHA_DISABLE: number;
  34227. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34228. static readonly ALPHA_ADD: number;
  34229. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34230. static readonly ALPHA_COMBINE: number;
  34231. /** Defines that alpha blending to DEST - SRC * DEST */
  34232. static readonly ALPHA_SUBTRACT: number;
  34233. /** Defines that alpha blending to SRC * DEST */
  34234. static readonly ALPHA_MULTIPLY: number;
  34235. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34236. static readonly ALPHA_MAXIMIZED: number;
  34237. /** Defines that alpha blending to SRC + DEST */
  34238. static readonly ALPHA_ONEONE: number;
  34239. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34240. static readonly ALPHA_PREMULTIPLIED: number;
  34241. /**
  34242. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34243. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34244. */
  34245. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34246. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34247. static readonly ALPHA_INTERPOLATE: number;
  34248. /**
  34249. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34250. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34251. */
  34252. static readonly ALPHA_SCREENMODE: number;
  34253. /** Defines that the ressource is not delayed*/
  34254. static readonly DELAYLOADSTATE_NONE: number;
  34255. /** Defines that the ressource was successfully delay loaded */
  34256. static readonly DELAYLOADSTATE_LOADED: number;
  34257. /** Defines that the ressource is currently delay loading */
  34258. static readonly DELAYLOADSTATE_LOADING: number;
  34259. /** Defines that the ressource is delayed and has not started loading */
  34260. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34261. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34262. static readonly NEVER: number;
  34263. /** 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 */
  34264. static readonly ALWAYS: number;
  34265. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34266. static readonly LESS: number;
  34267. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34268. static readonly EQUAL: number;
  34269. /** 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 */
  34270. static readonly LEQUAL: number;
  34271. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34272. static readonly GREATER: number;
  34273. /** 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 */
  34274. static readonly GEQUAL: number;
  34275. /** 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 */
  34276. static readonly NOTEQUAL: number;
  34277. /** Passed to stencilOperation to specify that stencil value must be kept */
  34278. static readonly KEEP: number;
  34279. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34280. static readonly REPLACE: number;
  34281. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34282. static readonly INCR: number;
  34283. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34284. static readonly DECR: number;
  34285. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34286. static readonly INVERT: number;
  34287. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34288. static readonly INCR_WRAP: number;
  34289. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34290. static readonly DECR_WRAP: number;
  34291. /** Texture is not repeating outside of 0..1 UVs */
  34292. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34293. /** Texture is repeating outside of 0..1 UVs */
  34294. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34295. /** Texture is repeating and mirrored */
  34296. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34297. /** ALPHA */
  34298. static readonly TEXTUREFORMAT_ALPHA: number;
  34299. /** LUMINANCE */
  34300. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34301. /** LUMINANCE_ALPHA */
  34302. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34303. /** RGB */
  34304. static readonly TEXTUREFORMAT_RGB: number;
  34305. /** RGBA */
  34306. static readonly TEXTUREFORMAT_RGBA: number;
  34307. /** RED */
  34308. static readonly TEXTUREFORMAT_RED: number;
  34309. /** RED (2nd reference) */
  34310. static readonly TEXTUREFORMAT_R: number;
  34311. /** RG */
  34312. static readonly TEXTUREFORMAT_RG: number;
  34313. /** RED_INTEGER */
  34314. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34315. /** RED_INTEGER (2nd reference) */
  34316. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34317. /** RG_INTEGER */
  34318. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34319. /** RGB_INTEGER */
  34320. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34321. /** RGBA_INTEGER */
  34322. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34323. /** UNSIGNED_BYTE */
  34324. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34325. /** UNSIGNED_BYTE (2nd reference) */
  34326. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34327. /** FLOAT */
  34328. static readonly TEXTURETYPE_FLOAT: number;
  34329. /** HALF_FLOAT */
  34330. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34331. /** BYTE */
  34332. static readonly TEXTURETYPE_BYTE: number;
  34333. /** SHORT */
  34334. static readonly TEXTURETYPE_SHORT: number;
  34335. /** UNSIGNED_SHORT */
  34336. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34337. /** INT */
  34338. static readonly TEXTURETYPE_INT: number;
  34339. /** UNSIGNED_INT */
  34340. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34341. /** UNSIGNED_SHORT_4_4_4_4 */
  34342. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34343. /** UNSIGNED_SHORT_5_5_5_1 */
  34344. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34345. /** UNSIGNED_SHORT_5_6_5 */
  34346. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34347. /** UNSIGNED_INT_2_10_10_10_REV */
  34348. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34349. /** UNSIGNED_INT_24_8 */
  34350. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34351. /** UNSIGNED_INT_10F_11F_11F_REV */
  34352. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34353. /** UNSIGNED_INT_5_9_9_9_REV */
  34354. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34355. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34356. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34357. /** nearest is mag = nearest and min = nearest and mip = linear */
  34358. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34359. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34360. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34361. /** Trilinear is mag = linear and min = linear and mip = linear */
  34362. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34363. /** nearest is mag = nearest and min = nearest and mip = linear */
  34364. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34365. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34366. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34367. /** Trilinear is mag = linear and min = linear and mip = linear */
  34368. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34369. /** mag = nearest and min = nearest and mip = nearest */
  34370. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34371. /** mag = nearest and min = linear and mip = nearest */
  34372. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34373. /** mag = nearest and min = linear and mip = linear */
  34374. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34375. /** mag = nearest and min = linear and mip = none */
  34376. static readonly TEXTURE_NEAREST_LINEAR: number;
  34377. /** mag = nearest and min = nearest and mip = none */
  34378. static readonly TEXTURE_NEAREST_NEAREST: number;
  34379. /** mag = linear and min = nearest and mip = nearest */
  34380. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34381. /** mag = linear and min = nearest and mip = linear */
  34382. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34383. /** mag = linear and min = linear and mip = none */
  34384. static readonly TEXTURE_LINEAR_LINEAR: number;
  34385. /** mag = linear and min = nearest and mip = none */
  34386. static readonly TEXTURE_LINEAR_NEAREST: number;
  34387. /** Explicit coordinates mode */
  34388. static readonly TEXTURE_EXPLICIT_MODE: number;
  34389. /** Spherical coordinates mode */
  34390. static readonly TEXTURE_SPHERICAL_MODE: number;
  34391. /** Planar coordinates mode */
  34392. static readonly TEXTURE_PLANAR_MODE: number;
  34393. /** Cubic coordinates mode */
  34394. static readonly TEXTURE_CUBIC_MODE: number;
  34395. /** Projection coordinates mode */
  34396. static readonly TEXTURE_PROJECTION_MODE: number;
  34397. /** Skybox coordinates mode */
  34398. static readonly TEXTURE_SKYBOX_MODE: number;
  34399. /** Inverse Cubic coordinates mode */
  34400. static readonly TEXTURE_INVCUBIC_MODE: number;
  34401. /** Equirectangular coordinates mode */
  34402. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34403. /** Equirectangular Fixed coordinates mode */
  34404. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34405. /** Equirectangular Fixed Mirrored coordinates mode */
  34406. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34407. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34408. static readonly SCALEMODE_FLOOR: number;
  34409. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34410. static readonly SCALEMODE_NEAREST: number;
  34411. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34412. static readonly SCALEMODE_CEILING: number;
  34413. /**
  34414. * Returns the current npm package of the sdk
  34415. */
  34416. static get NpmPackage(): string;
  34417. /**
  34418. * Returns the current version of the framework
  34419. */
  34420. static get Version(): string;
  34421. /** Gets the list of created engines */
  34422. static get Instances(): Engine[];
  34423. /**
  34424. * Gets the latest created engine
  34425. */
  34426. static get LastCreatedEngine(): Nullable<Engine>;
  34427. /**
  34428. * Gets the latest created scene
  34429. */
  34430. static get LastCreatedScene(): Nullable<Scene>;
  34431. /**
  34432. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34433. * @param flag defines which part of the materials must be marked as dirty
  34434. * @param predicate defines a predicate used to filter which materials should be affected
  34435. */
  34436. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34437. /**
  34438. * Method called to create the default loading screen.
  34439. * This can be overriden in your own app.
  34440. * @param canvas The rendering canvas element
  34441. * @returns The loading screen
  34442. */
  34443. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34444. /**
  34445. * Method called to create the default rescale post process on each engine.
  34446. */
  34447. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34448. /**
  34449. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34450. **/
  34451. enableOfflineSupport: boolean;
  34452. /**
  34453. * 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)
  34454. **/
  34455. disableManifestCheck: boolean;
  34456. /**
  34457. * Gets the list of created scenes
  34458. */
  34459. scenes: Scene[];
  34460. /**
  34461. * Event raised when a new scene is created
  34462. */
  34463. onNewSceneAddedObservable: Observable<Scene>;
  34464. /**
  34465. * Gets the list of created postprocesses
  34466. */
  34467. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34468. /**
  34469. * Gets a boolean indicating if the pointer is currently locked
  34470. */
  34471. isPointerLock: boolean;
  34472. /**
  34473. * Observable event triggered each time the rendering canvas is resized
  34474. */
  34475. onResizeObservable: Observable<Engine>;
  34476. /**
  34477. * Observable event triggered each time the canvas loses focus
  34478. */
  34479. onCanvasBlurObservable: Observable<Engine>;
  34480. /**
  34481. * Observable event triggered each time the canvas gains focus
  34482. */
  34483. onCanvasFocusObservable: Observable<Engine>;
  34484. /**
  34485. * Observable event triggered each time the canvas receives pointerout event
  34486. */
  34487. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34488. /**
  34489. * Observable raised when the engine begins a new frame
  34490. */
  34491. onBeginFrameObservable: Observable<Engine>;
  34492. /**
  34493. * If set, will be used to request the next animation frame for the render loop
  34494. */
  34495. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34496. /**
  34497. * Observable raised when the engine ends the current frame
  34498. */
  34499. onEndFrameObservable: Observable<Engine>;
  34500. /**
  34501. * Observable raised when the engine is about to compile a shader
  34502. */
  34503. onBeforeShaderCompilationObservable: Observable<Engine>;
  34504. /**
  34505. * Observable raised when the engine has jsut compiled a shader
  34506. */
  34507. onAfterShaderCompilationObservable: Observable<Engine>;
  34508. /**
  34509. * Gets the audio engine
  34510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34511. * @ignorenaming
  34512. */
  34513. static audioEngine: IAudioEngine;
  34514. /**
  34515. * Default AudioEngine factory responsible of creating the Audio Engine.
  34516. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34517. */
  34518. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34519. /**
  34520. * Default offline support factory responsible of creating a tool used to store data locally.
  34521. * By default, this will create a Database object if the workload has been embedded.
  34522. */
  34523. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34524. private _loadingScreen;
  34525. private _pointerLockRequested;
  34526. private _dummyFramebuffer;
  34527. private _rescalePostProcess;
  34528. private _deterministicLockstep;
  34529. private _lockstepMaxSteps;
  34530. private _timeStep;
  34531. protected get _supportsHardwareTextureRescaling(): boolean;
  34532. private _fps;
  34533. private _deltaTime;
  34534. /** @hidden */
  34535. _drawCalls: PerfCounter;
  34536. /** 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 */
  34537. canvasTabIndex: number;
  34538. /**
  34539. * Turn this value on if you want to pause FPS computation when in background
  34540. */
  34541. disablePerformanceMonitorInBackground: boolean;
  34542. private _performanceMonitor;
  34543. /**
  34544. * Gets the performance monitor attached to this engine
  34545. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34546. */
  34547. get performanceMonitor(): PerformanceMonitor;
  34548. private _onFocus;
  34549. private _onBlur;
  34550. private _onCanvasPointerOut;
  34551. private _onCanvasBlur;
  34552. private _onCanvasFocus;
  34553. private _onFullscreenChange;
  34554. private _onPointerLockChange;
  34555. /**
  34556. * Gets the HTML element used to attach event listeners
  34557. * @returns a HTML element
  34558. */
  34559. getInputElement(): Nullable<HTMLElement>;
  34560. /**
  34561. * Creates a new engine
  34562. * @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
  34563. * @param antialias defines enable antialiasing (default: false)
  34564. * @param options defines further options to be sent to the getContext() function
  34565. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34566. */
  34567. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34568. /**
  34569. * Gets current aspect ratio
  34570. * @param viewportOwner defines the camera to use to get the aspect ratio
  34571. * @param useScreen defines if screen size must be used (or the current render target if any)
  34572. * @returns a number defining the aspect ratio
  34573. */
  34574. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34575. /**
  34576. * Gets current screen aspect ratio
  34577. * @returns a number defining the aspect ratio
  34578. */
  34579. getScreenAspectRatio(): number;
  34580. /**
  34581. * Gets the client rect of the HTML canvas attached with the current webGL context
  34582. * @returns a client rectanglee
  34583. */
  34584. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34585. /**
  34586. * Gets the client rect of the HTML element used for events
  34587. * @returns a client rectanglee
  34588. */
  34589. getInputElementClientRect(): Nullable<ClientRect>;
  34590. /**
  34591. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34593. * @returns true if engine is in deterministic lock step mode
  34594. */
  34595. isDeterministicLockStep(): boolean;
  34596. /**
  34597. * Gets the max steps when engine is running in deterministic lock step
  34598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34599. * @returns the max steps
  34600. */
  34601. getLockstepMaxSteps(): number;
  34602. /**
  34603. * Returns the time in ms between steps when using deterministic lock step.
  34604. * @returns time step in (ms)
  34605. */
  34606. getTimeStep(): number;
  34607. /**
  34608. * Force the mipmap generation for the given render target texture
  34609. * @param texture defines the render target texture to use
  34610. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34611. */
  34612. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34613. /** States */
  34614. /**
  34615. * Set various states to the webGL context
  34616. * @param culling defines backface culling state
  34617. * @param zOffset defines the value to apply to zOffset (0 by default)
  34618. * @param force defines if states must be applied even if cache is up to date
  34619. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34620. */
  34621. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34622. /**
  34623. * Set the z offset to apply to current rendering
  34624. * @param value defines the offset to apply
  34625. */
  34626. setZOffset(value: number): void;
  34627. /**
  34628. * Gets the current value of the zOffset
  34629. * @returns the current zOffset state
  34630. */
  34631. getZOffset(): number;
  34632. /**
  34633. * Enable or disable depth buffering
  34634. * @param enable defines the state to set
  34635. */
  34636. setDepthBuffer(enable: boolean): void;
  34637. /**
  34638. * Gets a boolean indicating if depth writing is enabled
  34639. * @returns the current depth writing state
  34640. */
  34641. getDepthWrite(): boolean;
  34642. /**
  34643. * Enable or disable depth writing
  34644. * @param enable defines the state to set
  34645. */
  34646. setDepthWrite(enable: boolean): void;
  34647. /**
  34648. * Gets a boolean indicating if stencil buffer is enabled
  34649. * @returns the current stencil buffer state
  34650. */
  34651. getStencilBuffer(): boolean;
  34652. /**
  34653. * Enable or disable the stencil buffer
  34654. * @param enable defines if the stencil buffer must be enabled or disabled
  34655. */
  34656. setStencilBuffer(enable: boolean): void;
  34657. /**
  34658. * Gets the current stencil mask
  34659. * @returns a number defining the new stencil mask to use
  34660. */
  34661. getStencilMask(): number;
  34662. /**
  34663. * Sets the current stencil mask
  34664. * @param mask defines the new stencil mask to use
  34665. */
  34666. setStencilMask(mask: number): void;
  34667. /**
  34668. * Gets the current stencil function
  34669. * @returns a number defining the stencil function to use
  34670. */
  34671. getStencilFunction(): number;
  34672. /**
  34673. * Gets the current stencil reference value
  34674. * @returns a number defining the stencil reference value to use
  34675. */
  34676. getStencilFunctionReference(): number;
  34677. /**
  34678. * Gets the current stencil mask
  34679. * @returns a number defining the stencil mask to use
  34680. */
  34681. getStencilFunctionMask(): number;
  34682. /**
  34683. * Sets the current stencil function
  34684. * @param stencilFunc defines the new stencil function to use
  34685. */
  34686. setStencilFunction(stencilFunc: number): void;
  34687. /**
  34688. * Sets the current stencil reference
  34689. * @param reference defines the new stencil reference to use
  34690. */
  34691. setStencilFunctionReference(reference: number): void;
  34692. /**
  34693. * Sets the current stencil mask
  34694. * @param mask defines the new stencil mask to use
  34695. */
  34696. setStencilFunctionMask(mask: number): void;
  34697. /**
  34698. * Gets the current stencil operation when stencil fails
  34699. * @returns a number defining stencil operation to use when stencil fails
  34700. */
  34701. getStencilOperationFail(): number;
  34702. /**
  34703. * Gets the current stencil operation when depth fails
  34704. * @returns a number defining stencil operation to use when depth fails
  34705. */
  34706. getStencilOperationDepthFail(): number;
  34707. /**
  34708. * Gets the current stencil operation when stencil passes
  34709. * @returns a number defining stencil operation to use when stencil passes
  34710. */
  34711. getStencilOperationPass(): number;
  34712. /**
  34713. * Sets the stencil operation to use when stencil fails
  34714. * @param operation defines the stencil operation to use when stencil fails
  34715. */
  34716. setStencilOperationFail(operation: number): void;
  34717. /**
  34718. * Sets the stencil operation to use when depth fails
  34719. * @param operation defines the stencil operation to use when depth fails
  34720. */
  34721. setStencilOperationDepthFail(operation: number): void;
  34722. /**
  34723. * Sets the stencil operation to use when stencil passes
  34724. * @param operation defines the stencil operation to use when stencil passes
  34725. */
  34726. setStencilOperationPass(operation: number): void;
  34727. /**
  34728. * Sets a boolean indicating if the dithering state is enabled or disabled
  34729. * @param value defines the dithering state
  34730. */
  34731. setDitheringState(value: boolean): void;
  34732. /**
  34733. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34734. * @param value defines the rasterizer state
  34735. */
  34736. setRasterizerState(value: boolean): void;
  34737. /**
  34738. * Gets the current depth function
  34739. * @returns a number defining the depth function
  34740. */
  34741. getDepthFunction(): Nullable<number>;
  34742. /**
  34743. * Sets the current depth function
  34744. * @param depthFunc defines the function to use
  34745. */
  34746. setDepthFunction(depthFunc: number): void;
  34747. /**
  34748. * Sets the current depth function to GREATER
  34749. */
  34750. setDepthFunctionToGreater(): void;
  34751. /**
  34752. * Sets the current depth function to GEQUAL
  34753. */
  34754. setDepthFunctionToGreaterOrEqual(): void;
  34755. /**
  34756. * Sets the current depth function to LESS
  34757. */
  34758. setDepthFunctionToLess(): void;
  34759. /**
  34760. * Sets the current depth function to LEQUAL
  34761. */
  34762. setDepthFunctionToLessOrEqual(): void;
  34763. private _cachedStencilBuffer;
  34764. private _cachedStencilFunction;
  34765. private _cachedStencilMask;
  34766. private _cachedStencilOperationPass;
  34767. private _cachedStencilOperationFail;
  34768. private _cachedStencilOperationDepthFail;
  34769. private _cachedStencilReference;
  34770. /**
  34771. * Caches the the state of the stencil buffer
  34772. */
  34773. cacheStencilState(): void;
  34774. /**
  34775. * Restores the state of the stencil buffer
  34776. */
  34777. restoreStencilState(): void;
  34778. /**
  34779. * Directly set the WebGL Viewport
  34780. * @param x defines the x coordinate of the viewport (in screen space)
  34781. * @param y defines the y coordinate of the viewport (in screen space)
  34782. * @param width defines the width of the viewport (in screen space)
  34783. * @param height defines the height of the viewport (in screen space)
  34784. * @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
  34785. */
  34786. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34787. /**
  34788. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34789. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34790. * @param y defines the y-coordinate of the corner of the clear rectangle
  34791. * @param width defines the width of the clear rectangle
  34792. * @param height defines the height of the clear rectangle
  34793. * @param clearColor defines the clear color
  34794. */
  34795. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34796. /**
  34797. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34798. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34799. * @param y defines the y-coordinate of the corner of the clear rectangle
  34800. * @param width defines the width of the clear rectangle
  34801. * @param height defines the height of the clear rectangle
  34802. */
  34803. enableScissor(x: number, y: number, width: number, height: number): void;
  34804. /**
  34805. * Disable previously set scissor test rectangle
  34806. */
  34807. disableScissor(): void;
  34808. protected _reportDrawCall(): void;
  34809. /**
  34810. * Initializes a webVR display and starts listening to display change events
  34811. * The onVRDisplayChangedObservable will be notified upon these changes
  34812. * @returns The onVRDisplayChangedObservable
  34813. */
  34814. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34815. /** @hidden */
  34816. _prepareVRComponent(): void;
  34817. /** @hidden */
  34818. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34819. /** @hidden */
  34820. _submitVRFrame(): void;
  34821. /**
  34822. * Call this function to leave webVR mode
  34823. * Will do nothing if webVR is not supported or if there is no webVR device
  34824. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34825. */
  34826. disableVR(): void;
  34827. /**
  34828. * Gets a boolean indicating that the system is in VR mode and is presenting
  34829. * @returns true if VR mode is engaged
  34830. */
  34831. isVRPresenting(): boolean;
  34832. /** @hidden */
  34833. _requestVRFrame(): void;
  34834. /** @hidden */
  34835. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34836. /**
  34837. * Gets the source code of the vertex shader associated with a specific webGL program
  34838. * @param program defines the program to use
  34839. * @returns a string containing the source code of the vertex shader associated with the program
  34840. */
  34841. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34842. /**
  34843. * Gets the source code of the fragment shader associated with a specific webGL program
  34844. * @param program defines the program to use
  34845. * @returns a string containing the source code of the fragment shader associated with the program
  34846. */
  34847. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34848. /**
  34849. * Sets a depth stencil texture from a render target to the according uniform.
  34850. * @param channel The texture channel
  34851. * @param uniform The uniform to set
  34852. * @param texture The render target texture containing the depth stencil texture to apply
  34853. */
  34854. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34855. /**
  34856. * Sets a texture to the webGL context from a postprocess
  34857. * @param channel defines the channel to use
  34858. * @param postProcess defines the source postprocess
  34859. */
  34860. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34861. /**
  34862. * Binds the output of the passed in post process to the texture channel specified
  34863. * @param channel The channel the texture should be bound to
  34864. * @param postProcess The post process which's output should be bound
  34865. */
  34866. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34867. /** @hidden */
  34868. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34869. protected _rebuildBuffers(): void;
  34870. /** @hidden */
  34871. _renderFrame(): void;
  34872. _renderLoop(): void;
  34873. /** @hidden */
  34874. _renderViews(): boolean;
  34875. /**
  34876. * Toggle full screen mode
  34877. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34878. */
  34879. switchFullscreen(requestPointerLock: boolean): void;
  34880. /**
  34881. * Enters full screen mode
  34882. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34883. */
  34884. enterFullscreen(requestPointerLock: boolean): void;
  34885. /**
  34886. * Exits full screen mode
  34887. */
  34888. exitFullscreen(): void;
  34889. /**
  34890. * Enters Pointerlock mode
  34891. */
  34892. enterPointerlock(): void;
  34893. /**
  34894. * Exits Pointerlock mode
  34895. */
  34896. exitPointerlock(): void;
  34897. /**
  34898. * Begin a new frame
  34899. */
  34900. beginFrame(): void;
  34901. /**
  34902. * Enf the current frame
  34903. */
  34904. endFrame(): void;
  34905. resize(): void;
  34906. /**
  34907. * Force a specific size of the canvas
  34908. * @param width defines the new canvas' width
  34909. * @param height defines the new canvas' height
  34910. */
  34911. setSize(width: number, height: number): void;
  34912. /**
  34913. * Updates a dynamic vertex buffer.
  34914. * @param vertexBuffer the vertex buffer to update
  34915. * @param data the data used to update the vertex buffer
  34916. * @param byteOffset the byte offset of the data
  34917. * @param byteLength the byte length of the data
  34918. */
  34919. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34920. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34921. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34922. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34923. _releaseTexture(texture: InternalTexture): void;
  34924. /**
  34925. * @hidden
  34926. * Rescales a texture
  34927. * @param source input texutre
  34928. * @param destination destination texture
  34929. * @param scene scene to use to render the resize
  34930. * @param internalFormat format to use when resizing
  34931. * @param onComplete callback to be called when resize has completed
  34932. */
  34933. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34934. /**
  34935. * Gets the current framerate
  34936. * @returns a number representing the framerate
  34937. */
  34938. getFps(): number;
  34939. /**
  34940. * Gets the time spent between current and previous frame
  34941. * @returns a number representing the delta time in ms
  34942. */
  34943. getDeltaTime(): number;
  34944. private _measureFps;
  34945. /** @hidden */
  34946. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34947. /**
  34948. * Update a dynamic index buffer
  34949. * @param indexBuffer defines the target index buffer
  34950. * @param indices defines the data to update
  34951. * @param offset defines the offset in the target index buffer where update should start
  34952. */
  34953. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34954. /**
  34955. * Updates the sample count of a render target texture
  34956. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34957. * @param texture defines the texture to update
  34958. * @param samples defines the sample count to set
  34959. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34960. */
  34961. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34962. /**
  34963. * Updates a depth texture Comparison Mode and Function.
  34964. * If the comparison Function is equal to 0, the mode will be set to none.
  34965. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34966. * @param texture The texture to set the comparison function for
  34967. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34968. */
  34969. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34970. /**
  34971. * Creates a webGL buffer to use with instanciation
  34972. * @param capacity defines the size of the buffer
  34973. * @returns the webGL buffer
  34974. */
  34975. createInstancesBuffer(capacity: number): DataBuffer;
  34976. /**
  34977. * Delete a webGL buffer used with instanciation
  34978. * @param buffer defines the webGL buffer to delete
  34979. */
  34980. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34981. private _clientWaitAsync;
  34982. /** @hidden */
  34983. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34984. /** @hidden */
  34985. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34986. dispose(): void;
  34987. private _disableTouchAction;
  34988. /**
  34989. * Display the loading screen
  34990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34991. */
  34992. displayLoadingUI(): void;
  34993. /**
  34994. * Hide the loading screen
  34995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34996. */
  34997. hideLoadingUI(): void;
  34998. /**
  34999. * Gets the current loading screen object
  35000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35001. */
  35002. get loadingScreen(): ILoadingScreen;
  35003. /**
  35004. * Sets the current loading screen object
  35005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35006. */
  35007. set loadingScreen(loadingScreen: ILoadingScreen);
  35008. /**
  35009. * Sets the current loading screen text
  35010. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35011. */
  35012. set loadingUIText(text: string);
  35013. /**
  35014. * Sets the current loading screen background color
  35015. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35016. */
  35017. set loadingUIBackgroundColor(color: string);
  35018. /** Pointerlock and fullscreen */
  35019. /**
  35020. * Ask the browser to promote the current element to pointerlock mode
  35021. * @param element defines the DOM element to promote
  35022. */
  35023. static _RequestPointerlock(element: HTMLElement): void;
  35024. /**
  35025. * Asks the browser to exit pointerlock mode
  35026. */
  35027. static _ExitPointerlock(): void;
  35028. /**
  35029. * Ask the browser to promote the current element to fullscreen rendering mode
  35030. * @param element defines the DOM element to promote
  35031. */
  35032. static _RequestFullscreen(element: HTMLElement): void;
  35033. /**
  35034. * Asks the browser to exit fullscreen mode
  35035. */
  35036. static _ExitFullscreen(): void;
  35037. }
  35038. }
  35039. declare module "babylonjs/Engines/engineStore" {
  35040. import { Nullable } from "babylonjs/types";
  35041. import { Engine } from "babylonjs/Engines/engine";
  35042. import { Scene } from "babylonjs/scene";
  35043. /**
  35044. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35045. * during the life time of the application.
  35046. */
  35047. export class EngineStore {
  35048. /** Gets the list of created engines */
  35049. static Instances: import("babylonjs/Engines/engine").Engine[];
  35050. /** @hidden */
  35051. static _LastCreatedScene: Nullable<Scene>;
  35052. /**
  35053. * Gets the latest created engine
  35054. */
  35055. static get LastCreatedEngine(): Nullable<Engine>;
  35056. /**
  35057. * Gets the latest created scene
  35058. */
  35059. static get LastCreatedScene(): Nullable<Scene>;
  35060. /**
  35061. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35062. * @ignorenaming
  35063. */
  35064. static UseFallbackTexture: boolean;
  35065. /**
  35066. * Texture content used if a texture cannot loaded
  35067. * @ignorenaming
  35068. */
  35069. static FallbackTexture: string;
  35070. }
  35071. }
  35072. declare module "babylonjs/Misc/promise" {
  35073. /**
  35074. * Helper class that provides a small promise polyfill
  35075. */
  35076. export class PromisePolyfill {
  35077. /**
  35078. * Static function used to check if the polyfill is required
  35079. * If this is the case then the function will inject the polyfill to window.Promise
  35080. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35081. */
  35082. static Apply(force?: boolean): void;
  35083. }
  35084. }
  35085. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35086. /**
  35087. * Interface for screenshot methods with describe argument called `size` as object with options
  35088. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35089. */
  35090. export interface IScreenshotSize {
  35091. /**
  35092. * number in pixels for canvas height
  35093. */
  35094. height?: number;
  35095. /**
  35096. * multiplier allowing render at a higher or lower resolution
  35097. * If value is defined then height and width will be ignored and taken from camera
  35098. */
  35099. precision?: number;
  35100. /**
  35101. * number in pixels for canvas width
  35102. */
  35103. width?: number;
  35104. }
  35105. }
  35106. declare module "babylonjs/Misc/tools" {
  35107. import { Nullable, float } from "babylonjs/types";
  35108. import { DomManagement } from "babylonjs/Misc/domManagement";
  35109. import { WebRequest } from "babylonjs/Misc/webRequest";
  35110. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35111. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35112. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35113. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35114. import { Camera } from "babylonjs/Cameras/camera";
  35115. import { Engine } from "babylonjs/Engines/engine";
  35116. interface IColor4Like {
  35117. r: float;
  35118. g: float;
  35119. b: float;
  35120. a: float;
  35121. }
  35122. /**
  35123. * Class containing a set of static utilities functions
  35124. */
  35125. export class Tools {
  35126. /**
  35127. * Gets or sets the base URL to use to load assets
  35128. */
  35129. static get BaseUrl(): string;
  35130. static set BaseUrl(value: string);
  35131. /**
  35132. * Enable/Disable Custom HTTP Request Headers globally.
  35133. * default = false
  35134. * @see CustomRequestHeaders
  35135. */
  35136. static UseCustomRequestHeaders: boolean;
  35137. /**
  35138. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35139. * i.e. when loading files, where the server/service expects an Authorization header
  35140. */
  35141. static CustomRequestHeaders: {
  35142. [key: string]: string;
  35143. };
  35144. /**
  35145. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35146. */
  35147. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35148. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35149. /**
  35150. * Default behaviour for cors in the application.
  35151. * It can be a string if the expected behavior is identical in the entire app.
  35152. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35153. */
  35154. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35155. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35156. /**
  35157. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35158. * @ignorenaming
  35159. */
  35160. static get UseFallbackTexture(): boolean;
  35161. static set UseFallbackTexture(value: boolean);
  35162. /**
  35163. * Use this object to register external classes like custom textures or material
  35164. * to allow the laoders to instantiate them
  35165. */
  35166. static get RegisteredExternalClasses(): {
  35167. [key: string]: Object;
  35168. };
  35169. static set RegisteredExternalClasses(classes: {
  35170. [key: string]: Object;
  35171. });
  35172. /**
  35173. * Texture content used if a texture cannot loaded
  35174. * @ignorenaming
  35175. */
  35176. static get fallbackTexture(): string;
  35177. static set fallbackTexture(value: string);
  35178. /**
  35179. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35180. * @param u defines the coordinate on X axis
  35181. * @param v defines the coordinate on Y axis
  35182. * @param width defines the width of the source data
  35183. * @param height defines the height of the source data
  35184. * @param pixels defines the source byte array
  35185. * @param color defines the output color
  35186. */
  35187. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35188. /**
  35189. * Interpolates between a and b via alpha
  35190. * @param a The lower value (returned when alpha = 0)
  35191. * @param b The upper value (returned when alpha = 1)
  35192. * @param alpha The interpolation-factor
  35193. * @return The mixed value
  35194. */
  35195. static Mix(a: number, b: number, alpha: number): number;
  35196. /**
  35197. * Tries to instantiate a new object from a given class name
  35198. * @param className defines the class name to instantiate
  35199. * @returns the new object or null if the system was not able to do the instantiation
  35200. */
  35201. static Instantiate(className: string): any;
  35202. /**
  35203. * Provides a slice function that will work even on IE
  35204. * @param data defines the array to slice
  35205. * @param start defines the start of the data (optional)
  35206. * @param end defines the end of the data (optional)
  35207. * @returns the new sliced array
  35208. */
  35209. static Slice<T>(data: T, start?: number, end?: number): T;
  35210. /**
  35211. * Polyfill for setImmediate
  35212. * @param action defines the action to execute after the current execution block
  35213. */
  35214. static SetImmediate(action: () => void): void;
  35215. /**
  35216. * Function indicating if a number is an exponent of 2
  35217. * @param value defines the value to test
  35218. * @returns true if the value is an exponent of 2
  35219. */
  35220. static IsExponentOfTwo(value: number): boolean;
  35221. private static _tmpFloatArray;
  35222. /**
  35223. * Returns the nearest 32-bit single precision float representation of a Number
  35224. * @param value A Number. If the parameter is of a different type, it will get converted
  35225. * to a number or to NaN if it cannot be converted
  35226. * @returns number
  35227. */
  35228. static FloatRound(value: number): number;
  35229. /**
  35230. * Extracts the filename from a path
  35231. * @param path defines the path to use
  35232. * @returns the filename
  35233. */
  35234. static GetFilename(path: string): string;
  35235. /**
  35236. * Extracts the "folder" part of a path (everything before the filename).
  35237. * @param uri The URI to extract the info from
  35238. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35239. * @returns The "folder" part of the path
  35240. */
  35241. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35242. /**
  35243. * Extracts text content from a DOM element hierarchy
  35244. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35245. */
  35246. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35247. /**
  35248. * Convert an angle in radians to degrees
  35249. * @param angle defines the angle to convert
  35250. * @returns the angle in degrees
  35251. */
  35252. static ToDegrees(angle: number): number;
  35253. /**
  35254. * Convert an angle in degrees to radians
  35255. * @param angle defines the angle to convert
  35256. * @returns the angle in radians
  35257. */
  35258. static ToRadians(angle: number): number;
  35259. /**
  35260. * Returns an array if obj is not an array
  35261. * @param obj defines the object to evaluate as an array
  35262. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35263. * @returns either obj directly if obj is an array or a new array containing obj
  35264. */
  35265. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35266. /**
  35267. * Gets the pointer prefix to use
  35268. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35269. */
  35270. static GetPointerPrefix(): string;
  35271. /**
  35272. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35273. * @param url define the url we are trying
  35274. * @param element define the dom element where to configure the cors policy
  35275. */
  35276. static SetCorsBehavior(url: string | string[], element: {
  35277. crossOrigin: string | null;
  35278. }): void;
  35279. /**
  35280. * Removes unwanted characters from an url
  35281. * @param url defines the url to clean
  35282. * @returns the cleaned url
  35283. */
  35284. static CleanUrl(url: string): string;
  35285. /**
  35286. * Gets or sets a function used to pre-process url before using them to load assets
  35287. */
  35288. static get PreprocessUrl(): (url: string) => string;
  35289. static set PreprocessUrl(processor: (url: string) => string);
  35290. /**
  35291. * Loads an image as an HTMLImageElement.
  35292. * @param input url string, ArrayBuffer, or Blob to load
  35293. * @param onLoad callback called when the image successfully loads
  35294. * @param onError callback called when the image fails to load
  35295. * @param offlineProvider offline provider for caching
  35296. * @param mimeType optional mime type
  35297. * @returns the HTMLImageElement of the loaded image
  35298. */
  35299. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35300. /**
  35301. * Loads a file from a url
  35302. * @param url url string, ArrayBuffer, or Blob to load
  35303. * @param onSuccess callback called when the file successfully loads
  35304. * @param onProgress callback called while file is loading (if the server supports this mode)
  35305. * @param offlineProvider defines the offline provider for caching
  35306. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35307. * @param onError callback called when the file fails to load
  35308. * @returns a file request object
  35309. */
  35310. 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;
  35311. /**
  35312. * Loads a file from a url
  35313. * @param url the file url to load
  35314. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35315. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35316. */
  35317. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35318. /**
  35319. * Load a script (identified by an url). When the url returns, the
  35320. * content of this file is added into a new script element, attached to the DOM (body element)
  35321. * @param scriptUrl defines the url of the script to laod
  35322. * @param onSuccess defines the callback called when the script is loaded
  35323. * @param onError defines the callback to call if an error occurs
  35324. * @param scriptId defines the id of the script element
  35325. */
  35326. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35327. /**
  35328. * Load an asynchronous script (identified by an url). When the url returns, the
  35329. * content of this file is added into a new script element, attached to the DOM (body element)
  35330. * @param scriptUrl defines the url of the script to laod
  35331. * @param scriptId defines the id of the script element
  35332. * @returns a promise request object
  35333. */
  35334. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35335. /**
  35336. * Loads a file from a blob
  35337. * @param fileToLoad defines the blob to use
  35338. * @param callback defines the callback to call when data is loaded
  35339. * @param progressCallback defines the callback to call during loading process
  35340. * @returns a file request object
  35341. */
  35342. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35343. /**
  35344. * Reads a file from a File object
  35345. * @param file defines the file to load
  35346. * @param onSuccess defines the callback to call when data is loaded
  35347. * @param onProgress defines the callback to call during loading process
  35348. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35349. * @param onError defines the callback to call when an error occurs
  35350. * @returns a file request object
  35351. */
  35352. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35353. /**
  35354. * Creates a data url from a given string content
  35355. * @param content defines the content to convert
  35356. * @returns the new data url link
  35357. */
  35358. static FileAsURL(content: string): string;
  35359. /**
  35360. * Format the given number to a specific decimal format
  35361. * @param value defines the number to format
  35362. * @param decimals defines the number of decimals to use
  35363. * @returns the formatted string
  35364. */
  35365. static Format(value: number, decimals?: number): string;
  35366. /**
  35367. * Tries to copy an object by duplicating every property
  35368. * @param source defines the source object
  35369. * @param destination defines the target object
  35370. * @param doNotCopyList defines a list of properties to avoid
  35371. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35372. */
  35373. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35374. /**
  35375. * Gets a boolean indicating if the given object has no own property
  35376. * @param obj defines the object to test
  35377. * @returns true if object has no own property
  35378. */
  35379. static IsEmpty(obj: any): boolean;
  35380. /**
  35381. * Function used to register events at window level
  35382. * @param windowElement defines the Window object to use
  35383. * @param events defines the events to register
  35384. */
  35385. static RegisterTopRootEvents(windowElement: Window, events: {
  35386. name: string;
  35387. handler: Nullable<(e: FocusEvent) => any>;
  35388. }[]): void;
  35389. /**
  35390. * Function used to unregister events from window level
  35391. * @param windowElement defines the Window object to use
  35392. * @param events defines the events to unregister
  35393. */
  35394. static UnregisterTopRootEvents(windowElement: Window, events: {
  35395. name: string;
  35396. handler: Nullable<(e: FocusEvent) => any>;
  35397. }[]): void;
  35398. /**
  35399. * @ignore
  35400. */
  35401. static _ScreenshotCanvas: HTMLCanvasElement;
  35402. /**
  35403. * Dumps the current bound framebuffer
  35404. * @param width defines the rendering width
  35405. * @param height defines the rendering height
  35406. * @param engine defines the hosting engine
  35407. * @param successCallback defines the callback triggered once the data are available
  35408. * @param mimeType defines the mime type of the result
  35409. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35410. */
  35411. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35412. /**
  35413. * Converts the canvas data to blob.
  35414. * This acts as a polyfill for browsers not supporting the to blob function.
  35415. * @param canvas Defines the canvas to extract the data from
  35416. * @param successCallback Defines the callback triggered once the data are available
  35417. * @param mimeType Defines the mime type of the result
  35418. */
  35419. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35420. /**
  35421. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35422. * @param successCallback defines the callback triggered once the data are available
  35423. * @param mimeType defines the mime type of the result
  35424. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35425. */
  35426. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35427. /**
  35428. * Downloads a blob in the browser
  35429. * @param blob defines the blob to download
  35430. * @param fileName defines the name of the downloaded file
  35431. */
  35432. static Download(blob: Blob, fileName: string): void;
  35433. /**
  35434. * Captures a screenshot of the current rendering
  35435. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35436. * @param engine defines the rendering engine
  35437. * @param camera defines the source camera
  35438. * @param size This parameter can be set to a single number or to an object with the
  35439. * following (optional) properties: precision, width, height. If a single number is passed,
  35440. * it will be used for both width and height. If an object is passed, the screenshot size
  35441. * will be derived from the parameters. The precision property is a multiplier allowing
  35442. * rendering at a higher or lower resolution
  35443. * @param successCallback defines the callback receives a single parameter which contains the
  35444. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35445. * src parameter of an <img> to display it
  35446. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35447. * Check your browser for supported MIME types
  35448. */
  35449. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35450. /**
  35451. * Captures a screenshot of the current rendering
  35452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35453. * @param engine defines the rendering engine
  35454. * @param camera defines the source camera
  35455. * @param size This parameter can be set to a single number or to an object with the
  35456. * following (optional) properties: precision, width, height. If a single number is passed,
  35457. * it will be used for both width and height. If an object is passed, the screenshot size
  35458. * will be derived from the parameters. The precision property is a multiplier allowing
  35459. * rendering at a higher or lower resolution
  35460. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35461. * Check your browser for supported MIME types
  35462. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35463. * to the src parameter of an <img> to display it
  35464. */
  35465. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35466. /**
  35467. * Generates an image screenshot from the specified camera.
  35468. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35469. * @param engine The engine to use for rendering
  35470. * @param camera The camera to use for rendering
  35471. * @param size This parameter can be set to a single number or to an object with the
  35472. * following (optional) properties: precision, width, height. If a single number is passed,
  35473. * it will be used for both width and height. If an object is passed, the screenshot size
  35474. * will be derived from the parameters. The precision property is a multiplier allowing
  35475. * rendering at a higher or lower resolution
  35476. * @param successCallback The callback receives a single parameter which contains the
  35477. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35478. * src parameter of an <img> to display it
  35479. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35480. * Check your browser for supported MIME types
  35481. * @param samples Texture samples (default: 1)
  35482. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35483. * @param fileName A name for for the downloaded file.
  35484. */
  35485. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35486. /**
  35487. * Generates an image screenshot from the specified camera.
  35488. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35489. * @param engine The engine to use for rendering
  35490. * @param camera The camera to use for rendering
  35491. * @param size This parameter can be set to a single number or to an object with the
  35492. * following (optional) properties: precision, width, height. If a single number is passed,
  35493. * it will be used for both width and height. If an object is passed, the screenshot size
  35494. * will be derived from the parameters. The precision property is a multiplier allowing
  35495. * rendering at a higher or lower resolution
  35496. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35497. * Check your browser for supported MIME types
  35498. * @param samples Texture samples (default: 1)
  35499. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35500. * @param fileName A name for for the downloaded file.
  35501. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35502. * to the src parameter of an <img> to display it
  35503. */
  35504. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35505. /**
  35506. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35507. * Be aware Math.random() could cause collisions, but:
  35508. * "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"
  35509. * @returns a pseudo random id
  35510. */
  35511. static RandomId(): string;
  35512. /**
  35513. * Test if the given uri is a base64 string
  35514. * @param uri The uri to test
  35515. * @return True if the uri is a base64 string or false otherwise
  35516. */
  35517. static IsBase64(uri: string): boolean;
  35518. /**
  35519. * Decode the given base64 uri.
  35520. * @param uri The uri to decode
  35521. * @return The decoded base64 data.
  35522. */
  35523. static DecodeBase64(uri: string): ArrayBuffer;
  35524. /**
  35525. * Gets the absolute url.
  35526. * @param url the input url
  35527. * @return the absolute url
  35528. */
  35529. static GetAbsoluteUrl(url: string): string;
  35530. /**
  35531. * No log
  35532. */
  35533. static readonly NoneLogLevel: number;
  35534. /**
  35535. * Only message logs
  35536. */
  35537. static readonly MessageLogLevel: number;
  35538. /**
  35539. * Only warning logs
  35540. */
  35541. static readonly WarningLogLevel: number;
  35542. /**
  35543. * Only error logs
  35544. */
  35545. static readonly ErrorLogLevel: number;
  35546. /**
  35547. * All logs
  35548. */
  35549. static readonly AllLogLevel: number;
  35550. /**
  35551. * Gets a value indicating the number of loading errors
  35552. * @ignorenaming
  35553. */
  35554. static get errorsCount(): number;
  35555. /**
  35556. * Callback called when a new log is added
  35557. */
  35558. static OnNewCacheEntry: (entry: string) => void;
  35559. /**
  35560. * Log a message to the console
  35561. * @param message defines the message to log
  35562. */
  35563. static Log(message: string): void;
  35564. /**
  35565. * Write a warning message to the console
  35566. * @param message defines the message to log
  35567. */
  35568. static Warn(message: string): void;
  35569. /**
  35570. * Write an error message to the console
  35571. * @param message defines the message to log
  35572. */
  35573. static Error(message: string): void;
  35574. /**
  35575. * Gets current log cache (list of logs)
  35576. */
  35577. static get LogCache(): string;
  35578. /**
  35579. * Clears the log cache
  35580. */
  35581. static ClearLogCache(): void;
  35582. /**
  35583. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35584. */
  35585. static set LogLevels(level: number);
  35586. /**
  35587. * Checks if the window object exists
  35588. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35589. */
  35590. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35591. /**
  35592. * No performance log
  35593. */
  35594. static readonly PerformanceNoneLogLevel: number;
  35595. /**
  35596. * Use user marks to log performance
  35597. */
  35598. static readonly PerformanceUserMarkLogLevel: number;
  35599. /**
  35600. * Log performance to the console
  35601. */
  35602. static readonly PerformanceConsoleLogLevel: number;
  35603. private static _performance;
  35604. /**
  35605. * Sets the current performance log level
  35606. */
  35607. static set PerformanceLogLevel(level: number);
  35608. private static _StartPerformanceCounterDisabled;
  35609. private static _EndPerformanceCounterDisabled;
  35610. private static _StartUserMark;
  35611. private static _EndUserMark;
  35612. private static _StartPerformanceConsole;
  35613. private static _EndPerformanceConsole;
  35614. /**
  35615. * Starts a performance counter
  35616. */
  35617. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35618. /**
  35619. * Ends a specific performance coutner
  35620. */
  35621. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35622. /**
  35623. * Gets either window.performance.now() if supported or Date.now() else
  35624. */
  35625. static get Now(): number;
  35626. /**
  35627. * This method will return the name of the class used to create the instance of the given object.
  35628. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35629. * @param object the object to get the class name from
  35630. * @param isType defines if the object is actually a type
  35631. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35632. */
  35633. static GetClassName(object: any, isType?: boolean): string;
  35634. /**
  35635. * Gets the first element of an array satisfying a given predicate
  35636. * @param array defines the array to browse
  35637. * @param predicate defines the predicate to use
  35638. * @returns null if not found or the element
  35639. */
  35640. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35641. /**
  35642. * This method will return the name of the full name of the class, including its owning module (if any).
  35643. * 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).
  35644. * @param object the object to get the class name from
  35645. * @param isType defines if the object is actually a type
  35646. * @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.
  35647. * @ignorenaming
  35648. */
  35649. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35650. /**
  35651. * Returns a promise that resolves after the given amount of time.
  35652. * @param delay Number of milliseconds to delay
  35653. * @returns Promise that resolves after the given amount of time
  35654. */
  35655. static DelayAsync(delay: number): Promise<void>;
  35656. /**
  35657. * Utility function to detect if the current user agent is Safari
  35658. * @returns whether or not the current user agent is safari
  35659. */
  35660. static IsSafari(): boolean;
  35661. }
  35662. /**
  35663. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35664. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35665. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35666. * @param name The name of the class, case should be preserved
  35667. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35668. */
  35669. export function className(name: string, module?: string): (target: Object) => void;
  35670. /**
  35671. * An implementation of a loop for asynchronous functions.
  35672. */
  35673. export class AsyncLoop {
  35674. /**
  35675. * Defines the number of iterations for the loop
  35676. */
  35677. iterations: number;
  35678. /**
  35679. * Defines the current index of the loop.
  35680. */
  35681. index: number;
  35682. private _done;
  35683. private _fn;
  35684. private _successCallback;
  35685. /**
  35686. * Constructor.
  35687. * @param iterations the number of iterations.
  35688. * @param func the function to run each iteration
  35689. * @param successCallback the callback that will be called upon succesful execution
  35690. * @param offset starting offset.
  35691. */
  35692. constructor(
  35693. /**
  35694. * Defines the number of iterations for the loop
  35695. */
  35696. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35697. /**
  35698. * Execute the next iteration. Must be called after the last iteration was finished.
  35699. */
  35700. executeNext(): void;
  35701. /**
  35702. * Break the loop and run the success callback.
  35703. */
  35704. breakLoop(): void;
  35705. /**
  35706. * Create and run an async loop.
  35707. * @param iterations the number of iterations.
  35708. * @param fn the function to run each iteration
  35709. * @param successCallback the callback that will be called upon succesful execution
  35710. * @param offset starting offset.
  35711. * @returns the created async loop object
  35712. */
  35713. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35714. /**
  35715. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35716. * @param iterations total number of iterations
  35717. * @param syncedIterations number of synchronous iterations in each async iteration.
  35718. * @param fn the function to call each iteration.
  35719. * @param callback a success call back that will be called when iterating stops.
  35720. * @param breakFunction a break condition (optional)
  35721. * @param timeout timeout settings for the setTimeout function. default - 0.
  35722. * @returns the created async loop object
  35723. */
  35724. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35725. }
  35726. }
  35727. declare module "babylonjs/Misc/stringDictionary" {
  35728. import { Nullable } from "babylonjs/types";
  35729. /**
  35730. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35731. * The underlying implementation relies on an associative array to ensure the best performances.
  35732. * The value can be anything including 'null' but except 'undefined'
  35733. */
  35734. export class StringDictionary<T> {
  35735. /**
  35736. * This will clear this dictionary and copy the content from the 'source' one.
  35737. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35738. * @param source the dictionary to take the content from and copy to this dictionary
  35739. */
  35740. copyFrom(source: StringDictionary<T>): void;
  35741. /**
  35742. * Get a value based from its key
  35743. * @param key the given key to get the matching value from
  35744. * @return the value if found, otherwise undefined is returned
  35745. */
  35746. get(key: string): T | undefined;
  35747. /**
  35748. * Get a value from its key or add it if it doesn't exist.
  35749. * This method will ensure you that a given key/data will be present in the dictionary.
  35750. * @param key the given key to get the matching value from
  35751. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35752. * The factory will only be invoked if there's no data for the given key.
  35753. * @return the value corresponding to the key.
  35754. */
  35755. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35756. /**
  35757. * Get a value from its key if present in the dictionary otherwise add it
  35758. * @param key the key to get the value from
  35759. * @param val if there's no such key/value pair in the dictionary add it with this value
  35760. * @return the value corresponding to the key
  35761. */
  35762. getOrAdd(key: string, val: T): T;
  35763. /**
  35764. * Check if there's a given key in the dictionary
  35765. * @param key the key to check for
  35766. * @return true if the key is present, false otherwise
  35767. */
  35768. contains(key: string): boolean;
  35769. /**
  35770. * Add a new key and its corresponding value
  35771. * @param key the key to add
  35772. * @param value the value corresponding to the key
  35773. * @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
  35774. */
  35775. add(key: string, value: T): boolean;
  35776. /**
  35777. * Update a specific value associated to a key
  35778. * @param key defines the key to use
  35779. * @param value defines the value to store
  35780. * @returns true if the value was updated (or false if the key was not found)
  35781. */
  35782. set(key: string, value: T): boolean;
  35783. /**
  35784. * Get the element of the given key and remove it from the dictionary
  35785. * @param key defines the key to search
  35786. * @returns the value associated with the key or null if not found
  35787. */
  35788. getAndRemove(key: string): Nullable<T>;
  35789. /**
  35790. * Remove a key/value from the dictionary.
  35791. * @param key the key to remove
  35792. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35793. */
  35794. remove(key: string): boolean;
  35795. /**
  35796. * Clear the whole content of the dictionary
  35797. */
  35798. clear(): void;
  35799. /**
  35800. * Gets the current count
  35801. */
  35802. get count(): number;
  35803. /**
  35804. * Execute a callback on each key/val of the dictionary.
  35805. * Note that you can remove any element in this dictionary in the callback implementation
  35806. * @param callback the callback to execute on a given key/value pair
  35807. */
  35808. forEach(callback: (key: string, val: T) => void): void;
  35809. /**
  35810. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35811. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35812. * Note that you can remove any element in this dictionary in the callback implementation
  35813. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35814. * @returns the first item
  35815. */
  35816. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35817. private _count;
  35818. private _data;
  35819. }
  35820. }
  35821. declare module "babylonjs/Collisions/collisionCoordinator" {
  35822. import { Nullable } from "babylonjs/types";
  35823. import { Scene } from "babylonjs/scene";
  35824. import { Vector3 } from "babylonjs/Maths/math.vector";
  35825. import { Collider } from "babylonjs/Collisions/collider";
  35826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35827. /** @hidden */
  35828. export interface ICollisionCoordinator {
  35829. createCollider(): Collider;
  35830. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35831. init(scene: Scene): void;
  35832. }
  35833. /** @hidden */
  35834. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35835. private _scene;
  35836. private _scaledPosition;
  35837. private _scaledVelocity;
  35838. private _finalPosition;
  35839. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35840. createCollider(): Collider;
  35841. init(scene: Scene): void;
  35842. private _collideWithWorld;
  35843. }
  35844. }
  35845. declare module "babylonjs/Inputs/scene.inputManager" {
  35846. import { Nullable } from "babylonjs/types";
  35847. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35848. import { Vector2 } from "babylonjs/Maths/math.vector";
  35849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35850. import { Scene } from "babylonjs/scene";
  35851. /**
  35852. * Class used to manage all inputs for the scene.
  35853. */
  35854. export class InputManager {
  35855. /** The distance in pixel that you have to move to prevent some events */
  35856. static DragMovementThreshold: number;
  35857. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35858. static LongPressDelay: number;
  35859. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35860. static DoubleClickDelay: number;
  35861. /** If you need to check double click without raising a single click at first click, enable this flag */
  35862. static ExclusiveDoubleClickMode: boolean;
  35863. private _wheelEventName;
  35864. private _onPointerMove;
  35865. private _onPointerDown;
  35866. private _onPointerUp;
  35867. private _initClickEvent;
  35868. private _initActionManager;
  35869. private _delayedSimpleClick;
  35870. private _delayedSimpleClickTimeout;
  35871. private _previousDelayedSimpleClickTimeout;
  35872. private _meshPickProceed;
  35873. private _previousButtonPressed;
  35874. private _currentPickResult;
  35875. private _previousPickResult;
  35876. private _totalPointersPressed;
  35877. private _doubleClickOccured;
  35878. private _pointerOverMesh;
  35879. private _pickedDownMesh;
  35880. private _pickedUpMesh;
  35881. private _pointerX;
  35882. private _pointerY;
  35883. private _unTranslatedPointerX;
  35884. private _unTranslatedPointerY;
  35885. private _startingPointerPosition;
  35886. private _previousStartingPointerPosition;
  35887. private _startingPointerTime;
  35888. private _previousStartingPointerTime;
  35889. private _pointerCaptures;
  35890. private _onKeyDown;
  35891. private _onKeyUp;
  35892. private _onCanvasFocusObserver;
  35893. private _onCanvasBlurObserver;
  35894. private _scene;
  35895. /**
  35896. * Creates a new InputManager
  35897. * @param scene defines the hosting scene
  35898. */
  35899. constructor(scene: Scene);
  35900. /**
  35901. * Gets the mesh that is currently under the pointer
  35902. */
  35903. get meshUnderPointer(): Nullable<AbstractMesh>;
  35904. /**
  35905. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35906. */
  35907. get unTranslatedPointer(): Vector2;
  35908. /**
  35909. * Gets or sets the current on-screen X position of the pointer
  35910. */
  35911. get pointerX(): number;
  35912. set pointerX(value: number);
  35913. /**
  35914. * Gets or sets the current on-screen Y position of the pointer
  35915. */
  35916. get pointerY(): number;
  35917. set pointerY(value: number);
  35918. private _updatePointerPosition;
  35919. private _processPointerMove;
  35920. private _setRayOnPointerInfo;
  35921. private _checkPrePointerObservable;
  35922. /**
  35923. * Use this method to simulate a pointer move on a mesh
  35924. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35925. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35926. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35927. */
  35928. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35929. /**
  35930. * Use this method to simulate a pointer down on a mesh
  35931. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35932. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35933. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35934. */
  35935. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35936. private _processPointerDown;
  35937. /** @hidden */
  35938. _isPointerSwiping(): boolean;
  35939. /**
  35940. * Use this method to simulate a pointer up on a mesh
  35941. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35942. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35943. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35944. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35945. */
  35946. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35947. private _processPointerUp;
  35948. /**
  35949. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35950. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35951. * @returns true if the pointer was captured
  35952. */
  35953. isPointerCaptured(pointerId?: number): boolean;
  35954. /**
  35955. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35956. * @param attachUp defines if you want to attach events to pointerup
  35957. * @param attachDown defines if you want to attach events to pointerdown
  35958. * @param attachMove defines if you want to attach events to pointermove
  35959. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35960. */
  35961. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35962. /**
  35963. * Detaches all event handlers
  35964. */
  35965. detachControl(): void;
  35966. /**
  35967. * Force the value of meshUnderPointer
  35968. * @param mesh defines the mesh to use
  35969. */
  35970. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35971. /**
  35972. * Gets the mesh under the pointer
  35973. * @returns a Mesh or null if no mesh is under the pointer
  35974. */
  35975. getPointerOverMesh(): Nullable<AbstractMesh>;
  35976. }
  35977. }
  35978. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35979. /**
  35980. * Helper class used to generate session unique ID
  35981. */
  35982. export class UniqueIdGenerator {
  35983. private static _UniqueIdCounter;
  35984. /**
  35985. * Gets an unique (relatively to the current scene) Id
  35986. */
  35987. static get UniqueId(): number;
  35988. }
  35989. }
  35990. declare module "babylonjs/Animations/animationGroup" {
  35991. import { Animatable } from "babylonjs/Animations/animatable";
  35992. import { Animation } from "babylonjs/Animations/animation";
  35993. import { Scene, IDisposable } from "babylonjs/scene";
  35994. import { Observable } from "babylonjs/Misc/observable";
  35995. import { Nullable } from "babylonjs/types";
  35996. import "babylonjs/Animations/animatable";
  35997. /**
  35998. * This class defines the direct association between an animation and a target
  35999. */
  36000. export class TargetedAnimation {
  36001. /**
  36002. * Animation to perform
  36003. */
  36004. animation: Animation;
  36005. /**
  36006. * Target to animate
  36007. */
  36008. target: any;
  36009. /**
  36010. * Serialize the object
  36011. * @returns the JSON object representing the current entity
  36012. */
  36013. serialize(): any;
  36014. }
  36015. /**
  36016. * Use this class to create coordinated animations on multiple targets
  36017. */
  36018. export class AnimationGroup implements IDisposable {
  36019. /** The name of the animation group */
  36020. name: string;
  36021. private _scene;
  36022. private _targetedAnimations;
  36023. private _animatables;
  36024. private _from;
  36025. private _to;
  36026. private _isStarted;
  36027. private _isPaused;
  36028. private _speedRatio;
  36029. private _loopAnimation;
  36030. /**
  36031. * Gets or sets the unique id of the node
  36032. */
  36033. uniqueId: number;
  36034. /**
  36035. * This observable will notify when one animation have ended
  36036. */
  36037. onAnimationEndObservable: Observable<TargetedAnimation>;
  36038. /**
  36039. * Observer raised when one animation loops
  36040. */
  36041. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36042. /**
  36043. * Observer raised when all animations have looped
  36044. */
  36045. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36046. /**
  36047. * This observable will notify when all animations have ended.
  36048. */
  36049. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36050. /**
  36051. * This observable will notify when all animations have paused.
  36052. */
  36053. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36054. /**
  36055. * This observable will notify when all animations are playing.
  36056. */
  36057. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36058. /**
  36059. * Gets the first frame
  36060. */
  36061. get from(): number;
  36062. /**
  36063. * Gets the last frame
  36064. */
  36065. get to(): number;
  36066. /**
  36067. * Define if the animations are started
  36068. */
  36069. get isStarted(): boolean;
  36070. /**
  36071. * Gets a value indicating that the current group is playing
  36072. */
  36073. get isPlaying(): boolean;
  36074. /**
  36075. * Gets or sets the speed ratio to use for all animations
  36076. */
  36077. get speedRatio(): number;
  36078. /**
  36079. * Gets or sets the speed ratio to use for all animations
  36080. */
  36081. set speedRatio(value: number);
  36082. /**
  36083. * Gets or sets if all animations should loop or not
  36084. */
  36085. get loopAnimation(): boolean;
  36086. set loopAnimation(value: boolean);
  36087. /**
  36088. * Gets the targeted animations for this animation group
  36089. */
  36090. get targetedAnimations(): Array<TargetedAnimation>;
  36091. /**
  36092. * returning the list of animatables controlled by this animation group.
  36093. */
  36094. get animatables(): Array<Animatable>;
  36095. /**
  36096. * Instantiates a new Animation Group.
  36097. * This helps managing several animations at once.
  36098. * @see http://doc.babylonjs.com/how_to/group
  36099. * @param name Defines the name of the group
  36100. * @param scene Defines the scene the group belongs to
  36101. */
  36102. constructor(
  36103. /** The name of the animation group */
  36104. name: string, scene?: Nullable<Scene>);
  36105. /**
  36106. * Add an animation (with its target) in the group
  36107. * @param animation defines the animation we want to add
  36108. * @param target defines the target of the animation
  36109. * @returns the TargetedAnimation object
  36110. */
  36111. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36112. /**
  36113. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36114. * It can add constant keys at begin or end
  36115. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36116. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36117. * @returns the animation group
  36118. */
  36119. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36120. private _animationLoopCount;
  36121. private _animationLoopFlags;
  36122. private _processLoop;
  36123. /**
  36124. * Start all animations on given targets
  36125. * @param loop defines if animations must loop
  36126. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36127. * @param from defines the from key (optional)
  36128. * @param to defines the to key (optional)
  36129. * @returns the current animation group
  36130. */
  36131. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  36132. /**
  36133. * Pause all animations
  36134. * @returns the animation group
  36135. */
  36136. pause(): AnimationGroup;
  36137. /**
  36138. * Play all animations to initial state
  36139. * This function will start() the animations if they were not started or will restart() them if they were paused
  36140. * @param loop defines if animations must loop
  36141. * @returns the animation group
  36142. */
  36143. play(loop?: boolean): AnimationGroup;
  36144. /**
  36145. * Reset all animations to initial state
  36146. * @returns the animation group
  36147. */
  36148. reset(): AnimationGroup;
  36149. /**
  36150. * Restart animations from key 0
  36151. * @returns the animation group
  36152. */
  36153. restart(): AnimationGroup;
  36154. /**
  36155. * Stop all animations
  36156. * @returns the animation group
  36157. */
  36158. stop(): AnimationGroup;
  36159. /**
  36160. * Set animation weight for all animatables
  36161. * @param weight defines the weight to use
  36162. * @return the animationGroup
  36163. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36164. */
  36165. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36166. /**
  36167. * Synchronize and normalize all animatables with a source animatable
  36168. * @param root defines the root animatable to synchronize with
  36169. * @return the animationGroup
  36170. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36171. */
  36172. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36173. /**
  36174. * Goes to a specific frame in this animation group
  36175. * @param frame the frame number to go to
  36176. * @return the animationGroup
  36177. */
  36178. goToFrame(frame: number): AnimationGroup;
  36179. /**
  36180. * Dispose all associated resources
  36181. */
  36182. dispose(): void;
  36183. private _checkAnimationGroupEnded;
  36184. /**
  36185. * Clone the current animation group and returns a copy
  36186. * @param newName defines the name of the new group
  36187. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36188. * @returns the new aniamtion group
  36189. */
  36190. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36191. /**
  36192. * Serializes the animationGroup to an object
  36193. * @returns Serialized object
  36194. */
  36195. serialize(): any;
  36196. /**
  36197. * Returns a new AnimationGroup object parsed from the source provided.
  36198. * @param parsedAnimationGroup defines the source
  36199. * @param scene defines the scene that will receive the animationGroup
  36200. * @returns a new AnimationGroup
  36201. */
  36202. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36203. /**
  36204. * Returns the string "AnimationGroup"
  36205. * @returns "AnimationGroup"
  36206. */
  36207. getClassName(): string;
  36208. /**
  36209. * Creates a detailled string about the object
  36210. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36211. * @returns a string representing the object
  36212. */
  36213. toString(fullDetails?: boolean): string;
  36214. }
  36215. }
  36216. declare module "babylonjs/scene" {
  36217. import { Nullable } from "babylonjs/types";
  36218. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36219. import { Observable } from "babylonjs/Misc/observable";
  36220. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36221. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36222. import { Geometry } from "babylonjs/Meshes/geometry";
  36223. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36226. import { Mesh } from "babylonjs/Meshes/mesh";
  36227. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36228. import { Bone } from "babylonjs/Bones/bone";
  36229. import { Skeleton } from "babylonjs/Bones/skeleton";
  36230. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36231. import { Camera } from "babylonjs/Cameras/camera";
  36232. import { AbstractScene } from "babylonjs/abstractScene";
  36233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36235. import { Material } from "babylonjs/Materials/material";
  36236. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36237. import { Effect } from "babylonjs/Materials/effect";
  36238. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36239. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36240. import { Light } from "babylonjs/Lights/light";
  36241. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36242. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36243. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36244. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36245. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36246. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36247. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36248. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36249. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36250. import { Engine } from "babylonjs/Engines/engine";
  36251. import { Node } from "babylonjs/node";
  36252. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36253. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36254. import { WebRequest } from "babylonjs/Misc/webRequest";
  36255. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36256. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36257. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36258. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36259. import { Plane } from "babylonjs/Maths/math.plane";
  36260. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36261. import { Ray } from "babylonjs/Culling/ray";
  36262. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36263. import { Animation } from "babylonjs/Animations/animation";
  36264. import { Animatable } from "babylonjs/Animations/animatable";
  36265. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36266. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36267. import { Collider } from "babylonjs/Collisions/collider";
  36268. /**
  36269. * Define an interface for all classes that will hold resources
  36270. */
  36271. export interface IDisposable {
  36272. /**
  36273. * Releases all held resources
  36274. */
  36275. dispose(): void;
  36276. }
  36277. /** Interface defining initialization parameters for Scene class */
  36278. export interface SceneOptions {
  36279. /**
  36280. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36281. * It will improve performance when the number of geometries becomes important.
  36282. */
  36283. useGeometryUniqueIdsMap?: boolean;
  36284. /**
  36285. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36286. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36287. */
  36288. useMaterialMeshMap?: boolean;
  36289. /**
  36290. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36291. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36292. */
  36293. useClonedMeshMap?: boolean;
  36294. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36295. virtual?: boolean;
  36296. }
  36297. /**
  36298. * Represents a scene to be rendered by the engine.
  36299. * @see http://doc.babylonjs.com/features/scene
  36300. */
  36301. export class Scene extends AbstractScene implements IAnimatable {
  36302. /** The fog is deactivated */
  36303. static readonly FOGMODE_NONE: number;
  36304. /** The fog density is following an exponential function */
  36305. static readonly FOGMODE_EXP: number;
  36306. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36307. static readonly FOGMODE_EXP2: number;
  36308. /** The fog density is following a linear function. */
  36309. static readonly FOGMODE_LINEAR: number;
  36310. /**
  36311. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36313. */
  36314. static MinDeltaTime: number;
  36315. /**
  36316. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36318. */
  36319. static MaxDeltaTime: number;
  36320. /**
  36321. * Factory used to create the default material.
  36322. * @param name The name of the material to create
  36323. * @param scene The scene to create the material for
  36324. * @returns The default material
  36325. */
  36326. static DefaultMaterialFactory(scene: Scene): Material;
  36327. /**
  36328. * Factory used to create the a collision coordinator.
  36329. * @returns The collision coordinator
  36330. */
  36331. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36332. /** @hidden */
  36333. _inputManager: InputManager;
  36334. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36335. cameraToUseForPointers: Nullable<Camera>;
  36336. /** @hidden */
  36337. readonly _isScene: boolean;
  36338. /** @hidden */
  36339. _blockEntityCollection: boolean;
  36340. /**
  36341. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36342. */
  36343. autoClear: boolean;
  36344. /**
  36345. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36346. */
  36347. autoClearDepthAndStencil: boolean;
  36348. /**
  36349. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36350. */
  36351. clearColor: Color4;
  36352. /**
  36353. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36354. */
  36355. ambientColor: Color3;
  36356. /**
  36357. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36358. * It should only be one of the following (if not the default embedded one):
  36359. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36360. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36361. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36362. * The material properties need to be setup according to the type of texture in use.
  36363. */
  36364. environmentBRDFTexture: BaseTexture;
  36365. /** @hidden */
  36366. protected _environmentTexture: Nullable<BaseTexture>;
  36367. /**
  36368. * Texture used in all pbr material as the reflection texture.
  36369. * As in the majority of the scene they are the same (exception for multi room and so on),
  36370. * this is easier to reference from here than from all the materials.
  36371. */
  36372. get environmentTexture(): Nullable<BaseTexture>;
  36373. /**
  36374. * Texture used in all pbr material as the reflection texture.
  36375. * As in the majority of the scene they are the same (exception for multi room and so on),
  36376. * this is easier to set here than in all the materials.
  36377. */
  36378. set environmentTexture(value: Nullable<BaseTexture>);
  36379. /** @hidden */
  36380. protected _environmentIntensity: number;
  36381. /**
  36382. * Intensity of the environment in all pbr material.
  36383. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36384. * As in the majority of the scene they are the same (exception for multi room and so on),
  36385. * this is easier to reference from here than from all the materials.
  36386. */
  36387. get environmentIntensity(): number;
  36388. /**
  36389. * Intensity of the environment in all pbr material.
  36390. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36391. * As in the majority of the scene they are the same (exception for multi room and so on),
  36392. * this is easier to set here than in all the materials.
  36393. */
  36394. set environmentIntensity(value: number);
  36395. /** @hidden */
  36396. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36397. /**
  36398. * Default image processing configuration used either in the rendering
  36399. * Forward main pass or through the imageProcessingPostProcess if present.
  36400. * As in the majority of the scene they are the same (exception for multi camera),
  36401. * this is easier to reference from here than from all the materials and post process.
  36402. *
  36403. * No setter as we it is a shared configuration, you can set the values instead.
  36404. */
  36405. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36406. private _forceWireframe;
  36407. /**
  36408. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36409. */
  36410. set forceWireframe(value: boolean);
  36411. get forceWireframe(): boolean;
  36412. private _skipFrustumClipping;
  36413. /**
  36414. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36415. */
  36416. set skipFrustumClipping(value: boolean);
  36417. get skipFrustumClipping(): boolean;
  36418. private _forcePointsCloud;
  36419. /**
  36420. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36421. */
  36422. set forcePointsCloud(value: boolean);
  36423. get forcePointsCloud(): boolean;
  36424. /**
  36425. * Gets or sets the active clipplane 1
  36426. */
  36427. clipPlane: Nullable<Plane>;
  36428. /**
  36429. * Gets or sets the active clipplane 2
  36430. */
  36431. clipPlane2: Nullable<Plane>;
  36432. /**
  36433. * Gets or sets the active clipplane 3
  36434. */
  36435. clipPlane3: Nullable<Plane>;
  36436. /**
  36437. * Gets or sets the active clipplane 4
  36438. */
  36439. clipPlane4: Nullable<Plane>;
  36440. /**
  36441. * Gets or sets the active clipplane 5
  36442. */
  36443. clipPlane5: Nullable<Plane>;
  36444. /**
  36445. * Gets or sets the active clipplane 6
  36446. */
  36447. clipPlane6: Nullable<Plane>;
  36448. /**
  36449. * Gets or sets a boolean indicating if animations are enabled
  36450. */
  36451. animationsEnabled: boolean;
  36452. private _animationPropertiesOverride;
  36453. /**
  36454. * Gets or sets the animation properties override
  36455. */
  36456. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36457. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36458. /**
  36459. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36460. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36461. */
  36462. useConstantAnimationDeltaTime: boolean;
  36463. /**
  36464. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36465. * Please note that it requires to run a ray cast through the scene on every frame
  36466. */
  36467. constantlyUpdateMeshUnderPointer: boolean;
  36468. /**
  36469. * Defines the HTML cursor to use when hovering over interactive elements
  36470. */
  36471. hoverCursor: string;
  36472. /**
  36473. * Defines the HTML default cursor to use (empty by default)
  36474. */
  36475. defaultCursor: string;
  36476. /**
  36477. * Defines whether cursors are handled by the scene.
  36478. */
  36479. doNotHandleCursors: boolean;
  36480. /**
  36481. * This is used to call preventDefault() on pointer down
  36482. * in order to block unwanted artifacts like system double clicks
  36483. */
  36484. preventDefaultOnPointerDown: boolean;
  36485. /**
  36486. * This is used to call preventDefault() on pointer up
  36487. * in order to block unwanted artifacts like system double clicks
  36488. */
  36489. preventDefaultOnPointerUp: boolean;
  36490. /**
  36491. * Gets or sets user defined metadata
  36492. */
  36493. metadata: any;
  36494. /**
  36495. * For internal use only. Please do not use.
  36496. */
  36497. reservedDataStore: any;
  36498. /**
  36499. * Gets the name of the plugin used to load this scene (null by default)
  36500. */
  36501. loadingPluginName: string;
  36502. /**
  36503. * Use this array to add regular expressions used to disable offline support for specific urls
  36504. */
  36505. disableOfflineSupportExceptionRules: RegExp[];
  36506. /**
  36507. * An event triggered when the scene is disposed.
  36508. */
  36509. onDisposeObservable: Observable<Scene>;
  36510. private _onDisposeObserver;
  36511. /** Sets a function to be executed when this scene is disposed. */
  36512. set onDispose(callback: () => void);
  36513. /**
  36514. * An event triggered before rendering the scene (right after animations and physics)
  36515. */
  36516. onBeforeRenderObservable: Observable<Scene>;
  36517. private _onBeforeRenderObserver;
  36518. /** Sets a function to be executed before rendering this scene */
  36519. set beforeRender(callback: Nullable<() => void>);
  36520. /**
  36521. * An event triggered after rendering the scene
  36522. */
  36523. onAfterRenderObservable: Observable<Scene>;
  36524. /**
  36525. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36526. */
  36527. onAfterRenderCameraObservable: Observable<Camera>;
  36528. private _onAfterRenderObserver;
  36529. /** Sets a function to be executed after rendering this scene */
  36530. set afterRender(callback: Nullable<() => void>);
  36531. /**
  36532. * An event triggered before animating the scene
  36533. */
  36534. onBeforeAnimationsObservable: Observable<Scene>;
  36535. /**
  36536. * An event triggered after animations processing
  36537. */
  36538. onAfterAnimationsObservable: Observable<Scene>;
  36539. /**
  36540. * An event triggered before draw calls are ready to be sent
  36541. */
  36542. onBeforeDrawPhaseObservable: Observable<Scene>;
  36543. /**
  36544. * An event triggered after draw calls have been sent
  36545. */
  36546. onAfterDrawPhaseObservable: Observable<Scene>;
  36547. /**
  36548. * An event triggered when the scene is ready
  36549. */
  36550. onReadyObservable: Observable<Scene>;
  36551. /**
  36552. * An event triggered before rendering a camera
  36553. */
  36554. onBeforeCameraRenderObservable: Observable<Camera>;
  36555. private _onBeforeCameraRenderObserver;
  36556. /** Sets a function to be executed before rendering a camera*/
  36557. set beforeCameraRender(callback: () => void);
  36558. /**
  36559. * An event triggered after rendering a camera
  36560. */
  36561. onAfterCameraRenderObservable: Observable<Camera>;
  36562. private _onAfterCameraRenderObserver;
  36563. /** Sets a function to be executed after rendering a camera*/
  36564. set afterCameraRender(callback: () => void);
  36565. /**
  36566. * An event triggered when active meshes evaluation is about to start
  36567. */
  36568. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36569. /**
  36570. * An event triggered when active meshes evaluation is done
  36571. */
  36572. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36573. /**
  36574. * An event triggered when particles rendering is about to start
  36575. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36576. */
  36577. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36578. /**
  36579. * An event triggered when particles rendering is done
  36580. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36581. */
  36582. onAfterParticlesRenderingObservable: Observable<Scene>;
  36583. /**
  36584. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36585. */
  36586. onDataLoadedObservable: Observable<Scene>;
  36587. /**
  36588. * An event triggered when a camera is created
  36589. */
  36590. onNewCameraAddedObservable: Observable<Camera>;
  36591. /**
  36592. * An event triggered when a camera is removed
  36593. */
  36594. onCameraRemovedObservable: Observable<Camera>;
  36595. /**
  36596. * An event triggered when a light is created
  36597. */
  36598. onNewLightAddedObservable: Observable<Light>;
  36599. /**
  36600. * An event triggered when a light is removed
  36601. */
  36602. onLightRemovedObservable: Observable<Light>;
  36603. /**
  36604. * An event triggered when a geometry is created
  36605. */
  36606. onNewGeometryAddedObservable: Observable<Geometry>;
  36607. /**
  36608. * An event triggered when a geometry is removed
  36609. */
  36610. onGeometryRemovedObservable: Observable<Geometry>;
  36611. /**
  36612. * An event triggered when a transform node is created
  36613. */
  36614. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36615. /**
  36616. * An event triggered when a transform node is removed
  36617. */
  36618. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36619. /**
  36620. * An event triggered when a mesh is created
  36621. */
  36622. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36623. /**
  36624. * An event triggered when a mesh is removed
  36625. */
  36626. onMeshRemovedObservable: Observable<AbstractMesh>;
  36627. /**
  36628. * An event triggered when a skeleton is created
  36629. */
  36630. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36631. /**
  36632. * An event triggered when a skeleton is removed
  36633. */
  36634. onSkeletonRemovedObservable: Observable<Skeleton>;
  36635. /**
  36636. * An event triggered when a material is created
  36637. */
  36638. onNewMaterialAddedObservable: Observable<Material>;
  36639. /**
  36640. * An event triggered when a material is removed
  36641. */
  36642. onMaterialRemovedObservable: Observable<Material>;
  36643. /**
  36644. * An event triggered when a texture is created
  36645. */
  36646. onNewTextureAddedObservable: Observable<BaseTexture>;
  36647. /**
  36648. * An event triggered when a texture is removed
  36649. */
  36650. onTextureRemovedObservable: Observable<BaseTexture>;
  36651. /**
  36652. * An event triggered when render targets are about to be rendered
  36653. * Can happen multiple times per frame.
  36654. */
  36655. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36656. /**
  36657. * An event triggered when render targets were rendered.
  36658. * Can happen multiple times per frame.
  36659. */
  36660. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36661. /**
  36662. * An event triggered before calculating deterministic simulation step
  36663. */
  36664. onBeforeStepObservable: Observable<Scene>;
  36665. /**
  36666. * An event triggered after calculating deterministic simulation step
  36667. */
  36668. onAfterStepObservable: Observable<Scene>;
  36669. /**
  36670. * An event triggered when the activeCamera property is updated
  36671. */
  36672. onActiveCameraChanged: Observable<Scene>;
  36673. /**
  36674. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36675. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36676. * 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)
  36677. */
  36678. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36679. /**
  36680. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36681. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36682. * 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)
  36683. */
  36684. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36685. /**
  36686. * This Observable will when a mesh has been imported into the scene.
  36687. */
  36688. onMeshImportedObservable: Observable<AbstractMesh>;
  36689. /**
  36690. * This Observable will when an animation file has been imported into the scene.
  36691. */
  36692. onAnimationFileImportedObservable: Observable<Scene>;
  36693. /**
  36694. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36695. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36696. */
  36697. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36698. /** @hidden */
  36699. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36700. /**
  36701. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36702. */
  36703. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36704. /**
  36705. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36706. */
  36707. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36708. /**
  36709. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36710. */
  36711. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36712. /** Callback called when a pointer move is detected */
  36713. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36714. /** Callback called when a pointer down is detected */
  36715. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36716. /** Callback called when a pointer up is detected */
  36717. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36718. /** Callback called when a pointer pick is detected */
  36719. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36720. /**
  36721. * 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).
  36722. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36723. */
  36724. onPrePointerObservable: Observable<PointerInfoPre>;
  36725. /**
  36726. * Observable event triggered each time an input event is received from the rendering canvas
  36727. */
  36728. onPointerObservable: Observable<PointerInfo>;
  36729. /**
  36730. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36731. */
  36732. get unTranslatedPointer(): Vector2;
  36733. /**
  36734. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36735. */
  36736. static get DragMovementThreshold(): number;
  36737. static set DragMovementThreshold(value: number);
  36738. /**
  36739. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36740. */
  36741. static get LongPressDelay(): number;
  36742. static set LongPressDelay(value: number);
  36743. /**
  36744. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36745. */
  36746. static get DoubleClickDelay(): number;
  36747. static set DoubleClickDelay(value: number);
  36748. /** If you need to check double click without raising a single click at first click, enable this flag */
  36749. static get ExclusiveDoubleClickMode(): boolean;
  36750. static set ExclusiveDoubleClickMode(value: boolean);
  36751. /** @hidden */
  36752. _mirroredCameraPosition: Nullable<Vector3>;
  36753. /**
  36754. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36755. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36756. */
  36757. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36758. /**
  36759. * Observable event triggered each time an keyboard event is received from the hosting window
  36760. */
  36761. onKeyboardObservable: Observable<KeyboardInfo>;
  36762. private _useRightHandedSystem;
  36763. /**
  36764. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36765. */
  36766. set useRightHandedSystem(value: boolean);
  36767. get useRightHandedSystem(): boolean;
  36768. private _timeAccumulator;
  36769. private _currentStepId;
  36770. private _currentInternalStep;
  36771. /**
  36772. * Sets the step Id used by deterministic lock step
  36773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36774. * @param newStepId defines the step Id
  36775. */
  36776. setStepId(newStepId: number): void;
  36777. /**
  36778. * Gets the step Id used by deterministic lock step
  36779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36780. * @returns the step Id
  36781. */
  36782. getStepId(): number;
  36783. /**
  36784. * Gets the internal step used by deterministic lock step
  36785. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36786. * @returns the internal step
  36787. */
  36788. getInternalStep(): number;
  36789. private _fogEnabled;
  36790. /**
  36791. * Gets or sets a boolean indicating if fog is enabled on this scene
  36792. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36793. * (Default is true)
  36794. */
  36795. set fogEnabled(value: boolean);
  36796. get fogEnabled(): boolean;
  36797. private _fogMode;
  36798. /**
  36799. * Gets or sets the fog mode to use
  36800. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36801. * | mode | value |
  36802. * | --- | --- |
  36803. * | FOGMODE_NONE | 0 |
  36804. * | FOGMODE_EXP | 1 |
  36805. * | FOGMODE_EXP2 | 2 |
  36806. * | FOGMODE_LINEAR | 3 |
  36807. */
  36808. set fogMode(value: number);
  36809. get fogMode(): number;
  36810. /**
  36811. * Gets or sets the fog color to use
  36812. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36813. * (Default is Color3(0.2, 0.2, 0.3))
  36814. */
  36815. fogColor: Color3;
  36816. /**
  36817. * Gets or sets the fog density to use
  36818. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36819. * (Default is 0.1)
  36820. */
  36821. fogDensity: number;
  36822. /**
  36823. * Gets or sets the fog start distance to use
  36824. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36825. * (Default is 0)
  36826. */
  36827. fogStart: number;
  36828. /**
  36829. * Gets or sets the fog end distance to use
  36830. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36831. * (Default is 1000)
  36832. */
  36833. fogEnd: number;
  36834. private _shadowsEnabled;
  36835. /**
  36836. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36837. */
  36838. set shadowsEnabled(value: boolean);
  36839. get shadowsEnabled(): boolean;
  36840. private _lightsEnabled;
  36841. /**
  36842. * Gets or sets a boolean indicating if lights are enabled on this scene
  36843. */
  36844. set lightsEnabled(value: boolean);
  36845. get lightsEnabled(): boolean;
  36846. /** All of the active cameras added to this scene. */
  36847. activeCameras: Camera[];
  36848. /** @hidden */
  36849. _activeCamera: Nullable<Camera>;
  36850. /** Gets or sets the current active camera */
  36851. get activeCamera(): Nullable<Camera>;
  36852. set activeCamera(value: Nullable<Camera>);
  36853. private _defaultMaterial;
  36854. /** The default material used on meshes when no material is affected */
  36855. get defaultMaterial(): Material;
  36856. /** The default material used on meshes when no material is affected */
  36857. set defaultMaterial(value: Material);
  36858. private _texturesEnabled;
  36859. /**
  36860. * Gets or sets a boolean indicating if textures are enabled on this scene
  36861. */
  36862. set texturesEnabled(value: boolean);
  36863. get texturesEnabled(): boolean;
  36864. /**
  36865. * Gets or sets a boolean indicating if particles are enabled on this scene
  36866. */
  36867. particlesEnabled: boolean;
  36868. /**
  36869. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36870. */
  36871. spritesEnabled: boolean;
  36872. private _skeletonsEnabled;
  36873. /**
  36874. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36875. */
  36876. set skeletonsEnabled(value: boolean);
  36877. get skeletonsEnabled(): boolean;
  36878. /**
  36879. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36880. */
  36881. lensFlaresEnabled: boolean;
  36882. /**
  36883. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36885. */
  36886. collisionsEnabled: boolean;
  36887. private _collisionCoordinator;
  36888. /** @hidden */
  36889. get collisionCoordinator(): ICollisionCoordinator;
  36890. /**
  36891. * Defines the gravity applied to this scene (used only for collisions)
  36892. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36893. */
  36894. gravity: Vector3;
  36895. /**
  36896. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36897. */
  36898. postProcessesEnabled: boolean;
  36899. /**
  36900. * The list of postprocesses added to the scene
  36901. */
  36902. postProcesses: PostProcess[];
  36903. /**
  36904. * Gets the current postprocess manager
  36905. */
  36906. postProcessManager: PostProcessManager;
  36907. /**
  36908. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36909. */
  36910. renderTargetsEnabled: boolean;
  36911. /**
  36912. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36913. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36914. */
  36915. dumpNextRenderTargets: boolean;
  36916. /**
  36917. * The list of user defined render targets added to the scene
  36918. */
  36919. customRenderTargets: RenderTargetTexture[];
  36920. /**
  36921. * Defines if texture loading must be delayed
  36922. * If true, textures will only be loaded when they need to be rendered
  36923. */
  36924. useDelayedTextureLoading: boolean;
  36925. /**
  36926. * Gets the list of meshes imported to the scene through SceneLoader
  36927. */
  36928. importedMeshesFiles: String[];
  36929. /**
  36930. * Gets or sets a boolean indicating if probes are enabled on this scene
  36931. */
  36932. probesEnabled: boolean;
  36933. /**
  36934. * Gets or sets the current offline provider to use to store scene data
  36935. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36936. */
  36937. offlineProvider: IOfflineProvider;
  36938. /**
  36939. * Gets or sets the action manager associated with the scene
  36940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36941. */
  36942. actionManager: AbstractActionManager;
  36943. private _meshesForIntersections;
  36944. /**
  36945. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36946. */
  36947. proceduralTexturesEnabled: boolean;
  36948. private _engine;
  36949. private _totalVertices;
  36950. /** @hidden */
  36951. _activeIndices: PerfCounter;
  36952. /** @hidden */
  36953. _activeParticles: PerfCounter;
  36954. /** @hidden */
  36955. _activeBones: PerfCounter;
  36956. private _animationRatio;
  36957. /** @hidden */
  36958. _animationTimeLast: number;
  36959. /** @hidden */
  36960. _animationTime: number;
  36961. /**
  36962. * Gets or sets a general scale for animation speed
  36963. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36964. */
  36965. animationTimeScale: number;
  36966. /** @hidden */
  36967. _cachedMaterial: Nullable<Material>;
  36968. /** @hidden */
  36969. _cachedEffect: Nullable<Effect>;
  36970. /** @hidden */
  36971. _cachedVisibility: Nullable<number>;
  36972. private _renderId;
  36973. private _frameId;
  36974. private _executeWhenReadyTimeoutId;
  36975. private _intermediateRendering;
  36976. private _viewUpdateFlag;
  36977. private _projectionUpdateFlag;
  36978. /** @hidden */
  36979. _toBeDisposed: Nullable<IDisposable>[];
  36980. private _activeRequests;
  36981. /** @hidden */
  36982. _pendingData: any[];
  36983. private _isDisposed;
  36984. /**
  36985. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36986. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36987. */
  36988. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36989. private _activeMeshes;
  36990. private _processedMaterials;
  36991. private _renderTargets;
  36992. /** @hidden */
  36993. _activeParticleSystems: SmartArray<IParticleSystem>;
  36994. private _activeSkeletons;
  36995. private _softwareSkinnedMeshes;
  36996. private _renderingManager;
  36997. /** @hidden */
  36998. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36999. private _transformMatrix;
  37000. private _sceneUbo;
  37001. /** @hidden */
  37002. _viewMatrix: Matrix;
  37003. private _projectionMatrix;
  37004. /** @hidden */
  37005. _forcedViewPosition: Nullable<Vector3>;
  37006. /** @hidden */
  37007. _frustumPlanes: Plane[];
  37008. /**
  37009. * Gets the list of frustum planes (built from the active camera)
  37010. */
  37011. get frustumPlanes(): Plane[];
  37012. /**
  37013. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37014. * This is useful if there are more lights that the maximum simulteanous authorized
  37015. */
  37016. requireLightSorting: boolean;
  37017. /** @hidden */
  37018. readonly useMaterialMeshMap: boolean;
  37019. /** @hidden */
  37020. readonly useClonedMeshMap: boolean;
  37021. private _externalData;
  37022. private _uid;
  37023. /**
  37024. * @hidden
  37025. * Backing store of defined scene components.
  37026. */
  37027. _components: ISceneComponent[];
  37028. /**
  37029. * @hidden
  37030. * Backing store of defined scene components.
  37031. */
  37032. _serializableComponents: ISceneSerializableComponent[];
  37033. /**
  37034. * List of components to register on the next registration step.
  37035. */
  37036. private _transientComponents;
  37037. /**
  37038. * Registers the transient components if needed.
  37039. */
  37040. private _registerTransientComponents;
  37041. /**
  37042. * @hidden
  37043. * Add a component to the scene.
  37044. * Note that the ccomponent could be registered on th next frame if this is called after
  37045. * the register component stage.
  37046. * @param component Defines the component to add to the scene
  37047. */
  37048. _addComponent(component: ISceneComponent): void;
  37049. /**
  37050. * @hidden
  37051. * Gets a component from the scene.
  37052. * @param name defines the name of the component to retrieve
  37053. * @returns the component or null if not present
  37054. */
  37055. _getComponent(name: string): Nullable<ISceneComponent>;
  37056. /**
  37057. * @hidden
  37058. * Defines the actions happening before camera updates.
  37059. */
  37060. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37061. /**
  37062. * @hidden
  37063. * Defines the actions happening before clear the canvas.
  37064. */
  37065. _beforeClearStage: Stage<SimpleStageAction>;
  37066. /**
  37067. * @hidden
  37068. * Defines the actions when collecting render targets for the frame.
  37069. */
  37070. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37071. /**
  37072. * @hidden
  37073. * Defines the actions happening for one camera in the frame.
  37074. */
  37075. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37076. /**
  37077. * @hidden
  37078. * Defines the actions happening during the per mesh ready checks.
  37079. */
  37080. _isReadyForMeshStage: Stage<MeshStageAction>;
  37081. /**
  37082. * @hidden
  37083. * Defines the actions happening before evaluate active mesh checks.
  37084. */
  37085. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37086. /**
  37087. * @hidden
  37088. * Defines the actions happening during the evaluate sub mesh checks.
  37089. */
  37090. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37091. /**
  37092. * @hidden
  37093. * Defines the actions happening during the active mesh stage.
  37094. */
  37095. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37096. /**
  37097. * @hidden
  37098. * Defines the actions happening during the per camera render target step.
  37099. */
  37100. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37101. /**
  37102. * @hidden
  37103. * Defines the actions happening just before the active camera is drawing.
  37104. */
  37105. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37106. /**
  37107. * @hidden
  37108. * Defines the actions happening just before a render target is drawing.
  37109. */
  37110. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37111. /**
  37112. * @hidden
  37113. * Defines the actions happening just before a rendering group is drawing.
  37114. */
  37115. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37116. /**
  37117. * @hidden
  37118. * Defines the actions happening just before a mesh is drawing.
  37119. */
  37120. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37121. /**
  37122. * @hidden
  37123. * Defines the actions happening just after a mesh has been drawn.
  37124. */
  37125. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37126. /**
  37127. * @hidden
  37128. * Defines the actions happening just after a rendering group has been drawn.
  37129. */
  37130. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37131. /**
  37132. * @hidden
  37133. * Defines the actions happening just after the active camera has been drawn.
  37134. */
  37135. _afterCameraDrawStage: Stage<CameraStageAction>;
  37136. /**
  37137. * @hidden
  37138. * Defines the actions happening just after a render target has been drawn.
  37139. */
  37140. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37141. /**
  37142. * @hidden
  37143. * Defines the actions happening just after rendering all cameras and computing intersections.
  37144. */
  37145. _afterRenderStage: Stage<SimpleStageAction>;
  37146. /**
  37147. * @hidden
  37148. * Defines the actions happening when a pointer move event happens.
  37149. */
  37150. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37151. /**
  37152. * @hidden
  37153. * Defines the actions happening when a pointer down event happens.
  37154. */
  37155. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37156. /**
  37157. * @hidden
  37158. * Defines the actions happening when a pointer up event happens.
  37159. */
  37160. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37161. /**
  37162. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37163. */
  37164. private geometriesByUniqueId;
  37165. /**
  37166. * Creates a new Scene
  37167. * @param engine defines the engine to use to render this scene
  37168. * @param options defines the scene options
  37169. */
  37170. constructor(engine: Engine, options?: SceneOptions);
  37171. /**
  37172. * Gets a string idenfifying the name of the class
  37173. * @returns "Scene" string
  37174. */
  37175. getClassName(): string;
  37176. private _defaultMeshCandidates;
  37177. /**
  37178. * @hidden
  37179. */
  37180. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37181. private _defaultSubMeshCandidates;
  37182. /**
  37183. * @hidden
  37184. */
  37185. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37186. /**
  37187. * Sets the default candidate providers for the scene.
  37188. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37189. * and getCollidingSubMeshCandidates to their default function
  37190. */
  37191. setDefaultCandidateProviders(): void;
  37192. /**
  37193. * Gets the mesh that is currently under the pointer
  37194. */
  37195. get meshUnderPointer(): Nullable<AbstractMesh>;
  37196. /**
  37197. * Gets or sets the current on-screen X position of the pointer
  37198. */
  37199. get pointerX(): number;
  37200. set pointerX(value: number);
  37201. /**
  37202. * Gets or sets the current on-screen Y position of the pointer
  37203. */
  37204. get pointerY(): number;
  37205. set pointerY(value: number);
  37206. /**
  37207. * Gets the cached material (ie. the latest rendered one)
  37208. * @returns the cached material
  37209. */
  37210. getCachedMaterial(): Nullable<Material>;
  37211. /**
  37212. * Gets the cached effect (ie. the latest rendered one)
  37213. * @returns the cached effect
  37214. */
  37215. getCachedEffect(): Nullable<Effect>;
  37216. /**
  37217. * Gets the cached visibility state (ie. the latest rendered one)
  37218. * @returns the cached visibility state
  37219. */
  37220. getCachedVisibility(): Nullable<number>;
  37221. /**
  37222. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37223. * @param material defines the current material
  37224. * @param effect defines the current effect
  37225. * @param visibility defines the current visibility state
  37226. * @returns true if one parameter is not cached
  37227. */
  37228. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37229. /**
  37230. * Gets the engine associated with the scene
  37231. * @returns an Engine
  37232. */
  37233. getEngine(): Engine;
  37234. /**
  37235. * Gets the total number of vertices rendered per frame
  37236. * @returns the total number of vertices rendered per frame
  37237. */
  37238. getTotalVertices(): number;
  37239. /**
  37240. * Gets the performance counter for total vertices
  37241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37242. */
  37243. get totalVerticesPerfCounter(): PerfCounter;
  37244. /**
  37245. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37246. * @returns the total number of active indices rendered per frame
  37247. */
  37248. getActiveIndices(): number;
  37249. /**
  37250. * Gets the performance counter for active indices
  37251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37252. */
  37253. get totalActiveIndicesPerfCounter(): PerfCounter;
  37254. /**
  37255. * Gets the total number of active particles rendered per frame
  37256. * @returns the total number of active particles rendered per frame
  37257. */
  37258. getActiveParticles(): number;
  37259. /**
  37260. * Gets the performance counter for active particles
  37261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37262. */
  37263. get activeParticlesPerfCounter(): PerfCounter;
  37264. /**
  37265. * Gets the total number of active bones rendered per frame
  37266. * @returns the total number of active bones rendered per frame
  37267. */
  37268. getActiveBones(): number;
  37269. /**
  37270. * Gets the performance counter for active bones
  37271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37272. */
  37273. get activeBonesPerfCounter(): PerfCounter;
  37274. /**
  37275. * Gets the array of active meshes
  37276. * @returns an array of AbstractMesh
  37277. */
  37278. getActiveMeshes(): SmartArray<AbstractMesh>;
  37279. /**
  37280. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37281. * @returns a number
  37282. */
  37283. getAnimationRatio(): number;
  37284. /**
  37285. * Gets an unique Id for the current render phase
  37286. * @returns a number
  37287. */
  37288. getRenderId(): number;
  37289. /**
  37290. * Gets an unique Id for the current frame
  37291. * @returns a number
  37292. */
  37293. getFrameId(): number;
  37294. /** Call this function if you want to manually increment the render Id*/
  37295. incrementRenderId(): void;
  37296. private _createUbo;
  37297. /**
  37298. * Use this method to simulate a pointer move on a mesh
  37299. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37300. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37301. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37302. * @returns the current scene
  37303. */
  37304. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37305. /**
  37306. * Use this method to simulate a pointer down on a mesh
  37307. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37308. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37309. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37310. * @returns the current scene
  37311. */
  37312. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37313. /**
  37314. * Use this method to simulate a pointer up on a mesh
  37315. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37316. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37317. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37318. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37319. * @returns the current scene
  37320. */
  37321. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37322. /**
  37323. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37324. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37325. * @returns true if the pointer was captured
  37326. */
  37327. isPointerCaptured(pointerId?: number): boolean;
  37328. /**
  37329. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37330. * @param attachUp defines if you want to attach events to pointerup
  37331. * @param attachDown defines if you want to attach events to pointerdown
  37332. * @param attachMove defines if you want to attach events to pointermove
  37333. */
  37334. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37335. /** Detaches all event handlers*/
  37336. detachControl(): void;
  37337. /**
  37338. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37339. * Delay loaded resources are not taking in account
  37340. * @return true if all required resources are ready
  37341. */
  37342. isReady(): boolean;
  37343. /** Resets all cached information relative to material (including effect and visibility) */
  37344. resetCachedMaterial(): void;
  37345. /**
  37346. * Registers a function to be called before every frame render
  37347. * @param func defines the function to register
  37348. */
  37349. registerBeforeRender(func: () => void): void;
  37350. /**
  37351. * Unregisters a function called before every frame render
  37352. * @param func defines the function to unregister
  37353. */
  37354. unregisterBeforeRender(func: () => void): void;
  37355. /**
  37356. * Registers a function to be called after every frame render
  37357. * @param func defines the function to register
  37358. */
  37359. registerAfterRender(func: () => void): void;
  37360. /**
  37361. * Unregisters a function called after every frame render
  37362. * @param func defines the function to unregister
  37363. */
  37364. unregisterAfterRender(func: () => void): void;
  37365. private _executeOnceBeforeRender;
  37366. /**
  37367. * The provided function will run before render once and will be disposed afterwards.
  37368. * A timeout delay can be provided so that the function will be executed in N ms.
  37369. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37370. * @param func The function to be executed.
  37371. * @param timeout optional delay in ms
  37372. */
  37373. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37374. /** @hidden */
  37375. _addPendingData(data: any): void;
  37376. /** @hidden */
  37377. _removePendingData(data: any): void;
  37378. /**
  37379. * Returns the number of items waiting to be loaded
  37380. * @returns the number of items waiting to be loaded
  37381. */
  37382. getWaitingItemsCount(): number;
  37383. /**
  37384. * Returns a boolean indicating if the scene is still loading data
  37385. */
  37386. get isLoading(): boolean;
  37387. /**
  37388. * Registers a function to be executed when the scene is ready
  37389. * @param {Function} func - the function to be executed
  37390. */
  37391. executeWhenReady(func: () => void): void;
  37392. /**
  37393. * Returns a promise that resolves when the scene is ready
  37394. * @returns A promise that resolves when the scene is ready
  37395. */
  37396. whenReadyAsync(): Promise<void>;
  37397. /** @hidden */
  37398. _checkIsReady(): void;
  37399. /**
  37400. * Gets all animatable attached to the scene
  37401. */
  37402. get animatables(): Animatable[];
  37403. /**
  37404. * Resets the last animation time frame.
  37405. * Useful to override when animations start running when loading a scene for the first time.
  37406. */
  37407. resetLastAnimationTimeFrame(): void;
  37408. /**
  37409. * Gets the current view matrix
  37410. * @returns a Matrix
  37411. */
  37412. getViewMatrix(): Matrix;
  37413. /**
  37414. * Gets the current projection matrix
  37415. * @returns a Matrix
  37416. */
  37417. getProjectionMatrix(): Matrix;
  37418. /**
  37419. * Gets the current transform matrix
  37420. * @returns a Matrix made of View * Projection
  37421. */
  37422. getTransformMatrix(): Matrix;
  37423. /**
  37424. * Sets the current transform matrix
  37425. * @param viewL defines the View matrix to use
  37426. * @param projectionL defines the Projection matrix to use
  37427. * @param viewR defines the right View matrix to use (if provided)
  37428. * @param projectionR defines the right Projection matrix to use (if provided)
  37429. */
  37430. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37431. /**
  37432. * Gets the uniform buffer used to store scene data
  37433. * @returns a UniformBuffer
  37434. */
  37435. getSceneUniformBuffer(): UniformBuffer;
  37436. /**
  37437. * Gets an unique (relatively to the current scene) Id
  37438. * @returns an unique number for the scene
  37439. */
  37440. getUniqueId(): number;
  37441. /**
  37442. * Add a mesh to the list of scene's meshes
  37443. * @param newMesh defines the mesh to add
  37444. * @param recursive if all child meshes should also be added to the scene
  37445. */
  37446. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37447. /**
  37448. * Remove a mesh for the list of scene's meshes
  37449. * @param toRemove defines the mesh to remove
  37450. * @param recursive if all child meshes should also be removed from the scene
  37451. * @returns the index where the mesh was in the mesh list
  37452. */
  37453. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37454. /**
  37455. * Add a transform node to the list of scene's transform nodes
  37456. * @param newTransformNode defines the transform node to add
  37457. */
  37458. addTransformNode(newTransformNode: TransformNode): void;
  37459. /**
  37460. * Remove a transform node for the list of scene's transform nodes
  37461. * @param toRemove defines the transform node to remove
  37462. * @returns the index where the transform node was in the transform node list
  37463. */
  37464. removeTransformNode(toRemove: TransformNode): number;
  37465. /**
  37466. * Remove a skeleton for the list of scene's skeletons
  37467. * @param toRemove defines the skeleton to remove
  37468. * @returns the index where the skeleton was in the skeleton list
  37469. */
  37470. removeSkeleton(toRemove: Skeleton): number;
  37471. /**
  37472. * Remove a morph target for the list of scene's morph targets
  37473. * @param toRemove defines the morph target to remove
  37474. * @returns the index where the morph target was in the morph target list
  37475. */
  37476. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37477. /**
  37478. * Remove a light for the list of scene's lights
  37479. * @param toRemove defines the light to remove
  37480. * @returns the index where the light was in the light list
  37481. */
  37482. removeLight(toRemove: Light): number;
  37483. /**
  37484. * Remove a camera for the list of scene's cameras
  37485. * @param toRemove defines the camera to remove
  37486. * @returns the index where the camera was in the camera list
  37487. */
  37488. removeCamera(toRemove: Camera): number;
  37489. /**
  37490. * Remove a particle system for the list of scene's particle systems
  37491. * @param toRemove defines the particle system to remove
  37492. * @returns the index where the particle system was in the particle system list
  37493. */
  37494. removeParticleSystem(toRemove: IParticleSystem): number;
  37495. /**
  37496. * Remove a animation for the list of scene's animations
  37497. * @param toRemove defines the animation to remove
  37498. * @returns the index where the animation was in the animation list
  37499. */
  37500. removeAnimation(toRemove: Animation): number;
  37501. /**
  37502. * Will stop the animation of the given target
  37503. * @param target - the target
  37504. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37505. * @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)
  37506. */
  37507. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37508. /**
  37509. * Removes the given animation group from this scene.
  37510. * @param toRemove The animation group to remove
  37511. * @returns The index of the removed animation group
  37512. */
  37513. removeAnimationGroup(toRemove: AnimationGroup): number;
  37514. /**
  37515. * Removes the given multi-material from this scene.
  37516. * @param toRemove The multi-material to remove
  37517. * @returns The index of the removed multi-material
  37518. */
  37519. removeMultiMaterial(toRemove: MultiMaterial): number;
  37520. /**
  37521. * Removes the given material from this scene.
  37522. * @param toRemove The material to remove
  37523. * @returns The index of the removed material
  37524. */
  37525. removeMaterial(toRemove: Material): number;
  37526. /**
  37527. * Removes the given action manager from this scene.
  37528. * @param toRemove The action manager to remove
  37529. * @returns The index of the removed action manager
  37530. */
  37531. removeActionManager(toRemove: AbstractActionManager): number;
  37532. /**
  37533. * Removes the given texture from this scene.
  37534. * @param toRemove The texture to remove
  37535. * @returns The index of the removed texture
  37536. */
  37537. removeTexture(toRemove: BaseTexture): number;
  37538. /**
  37539. * Adds the given light to this scene
  37540. * @param newLight The light to add
  37541. */
  37542. addLight(newLight: Light): void;
  37543. /**
  37544. * Sorts the list list based on light priorities
  37545. */
  37546. sortLightsByPriority(): void;
  37547. /**
  37548. * Adds the given camera to this scene
  37549. * @param newCamera The camera to add
  37550. */
  37551. addCamera(newCamera: Camera): void;
  37552. /**
  37553. * Adds the given skeleton to this scene
  37554. * @param newSkeleton The skeleton to add
  37555. */
  37556. addSkeleton(newSkeleton: Skeleton): void;
  37557. /**
  37558. * Adds the given particle system to this scene
  37559. * @param newParticleSystem The particle system to add
  37560. */
  37561. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37562. /**
  37563. * Adds the given animation to this scene
  37564. * @param newAnimation The animation to add
  37565. */
  37566. addAnimation(newAnimation: Animation): void;
  37567. /**
  37568. * Adds the given animation group to this scene.
  37569. * @param newAnimationGroup The animation group to add
  37570. */
  37571. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37572. /**
  37573. * Adds the given multi-material to this scene
  37574. * @param newMultiMaterial The multi-material to add
  37575. */
  37576. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37577. /**
  37578. * Adds the given material to this scene
  37579. * @param newMaterial The material to add
  37580. */
  37581. addMaterial(newMaterial: Material): void;
  37582. /**
  37583. * Adds the given morph target to this scene
  37584. * @param newMorphTargetManager The morph target to add
  37585. */
  37586. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37587. /**
  37588. * Adds the given geometry to this scene
  37589. * @param newGeometry The geometry to add
  37590. */
  37591. addGeometry(newGeometry: Geometry): void;
  37592. /**
  37593. * Adds the given action manager to this scene
  37594. * @param newActionManager The action manager to add
  37595. */
  37596. addActionManager(newActionManager: AbstractActionManager): void;
  37597. /**
  37598. * Adds the given texture to this scene.
  37599. * @param newTexture The texture to add
  37600. */
  37601. addTexture(newTexture: BaseTexture): void;
  37602. /**
  37603. * Switch active camera
  37604. * @param newCamera defines the new active camera
  37605. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37606. */
  37607. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37608. /**
  37609. * sets the active camera of the scene using its ID
  37610. * @param id defines the camera's ID
  37611. * @return the new active camera or null if none found.
  37612. */
  37613. setActiveCameraByID(id: string): Nullable<Camera>;
  37614. /**
  37615. * sets the active camera of the scene using its name
  37616. * @param name defines the camera's name
  37617. * @returns the new active camera or null if none found.
  37618. */
  37619. setActiveCameraByName(name: string): Nullable<Camera>;
  37620. /**
  37621. * get an animation group using its name
  37622. * @param name defines the material's name
  37623. * @return the animation group or null if none found.
  37624. */
  37625. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37626. /**
  37627. * Get a material using its unique id
  37628. * @param uniqueId defines the material's unique id
  37629. * @return the material or null if none found.
  37630. */
  37631. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37632. /**
  37633. * get a material using its id
  37634. * @param id defines the material's ID
  37635. * @return the material or null if none found.
  37636. */
  37637. getMaterialByID(id: string): Nullable<Material>;
  37638. /**
  37639. * Gets a the last added material using a given id
  37640. * @param id defines the material's ID
  37641. * @return the last material with the given id or null if none found.
  37642. */
  37643. getLastMaterialByID(id: string): Nullable<Material>;
  37644. /**
  37645. * Gets a material using its name
  37646. * @param name defines the material's name
  37647. * @return the material or null if none found.
  37648. */
  37649. getMaterialByName(name: string): Nullable<Material>;
  37650. /**
  37651. * Get a texture using its unique id
  37652. * @param uniqueId defines the texture's unique id
  37653. * @return the texture or null if none found.
  37654. */
  37655. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37656. /**
  37657. * Gets a camera using its id
  37658. * @param id defines the id to look for
  37659. * @returns the camera or null if not found
  37660. */
  37661. getCameraByID(id: string): Nullable<Camera>;
  37662. /**
  37663. * Gets a camera using its unique id
  37664. * @param uniqueId defines the unique id to look for
  37665. * @returns the camera or null if not found
  37666. */
  37667. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37668. /**
  37669. * Gets a camera using its name
  37670. * @param name defines the camera's name
  37671. * @return the camera or null if none found.
  37672. */
  37673. getCameraByName(name: string): Nullable<Camera>;
  37674. /**
  37675. * Gets a bone using its id
  37676. * @param id defines the bone's id
  37677. * @return the bone or null if not found
  37678. */
  37679. getBoneByID(id: string): Nullable<Bone>;
  37680. /**
  37681. * Gets a bone using its id
  37682. * @param name defines the bone's name
  37683. * @return the bone or null if not found
  37684. */
  37685. getBoneByName(name: string): Nullable<Bone>;
  37686. /**
  37687. * Gets a light node using its name
  37688. * @param name defines the the light's name
  37689. * @return the light or null if none found.
  37690. */
  37691. getLightByName(name: string): Nullable<Light>;
  37692. /**
  37693. * Gets a light node using its id
  37694. * @param id defines the light's id
  37695. * @return the light or null if none found.
  37696. */
  37697. getLightByID(id: string): Nullable<Light>;
  37698. /**
  37699. * Gets a light node using its scene-generated unique ID
  37700. * @param uniqueId defines the light's unique id
  37701. * @return the light or null if none found.
  37702. */
  37703. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37704. /**
  37705. * Gets a particle system by id
  37706. * @param id defines the particle system id
  37707. * @return the corresponding system or null if none found
  37708. */
  37709. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37710. /**
  37711. * Gets a geometry using its ID
  37712. * @param id defines the geometry's id
  37713. * @return the geometry or null if none found.
  37714. */
  37715. getGeometryByID(id: string): Nullable<Geometry>;
  37716. private _getGeometryByUniqueID;
  37717. /**
  37718. * Add a new geometry to this scene
  37719. * @param geometry defines the geometry to be added to the scene.
  37720. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37721. * @return a boolean defining if the geometry was added or not
  37722. */
  37723. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37724. /**
  37725. * Removes an existing geometry
  37726. * @param geometry defines the geometry to be removed from the scene
  37727. * @return a boolean defining if the geometry was removed or not
  37728. */
  37729. removeGeometry(geometry: Geometry): boolean;
  37730. /**
  37731. * Gets the list of geometries attached to the scene
  37732. * @returns an array of Geometry
  37733. */
  37734. getGeometries(): Geometry[];
  37735. /**
  37736. * Gets the first added mesh found of a given ID
  37737. * @param id defines the id to search for
  37738. * @return the mesh found or null if not found at all
  37739. */
  37740. getMeshByID(id: string): Nullable<AbstractMesh>;
  37741. /**
  37742. * Gets a list of meshes using their id
  37743. * @param id defines the id to search for
  37744. * @returns a list of meshes
  37745. */
  37746. getMeshesByID(id: string): Array<AbstractMesh>;
  37747. /**
  37748. * Gets the first added transform node found of a given ID
  37749. * @param id defines the id to search for
  37750. * @return the found transform node or null if not found at all.
  37751. */
  37752. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37753. /**
  37754. * Gets a transform node with its auto-generated unique id
  37755. * @param uniqueId efines the unique id to search for
  37756. * @return the found transform node or null if not found at all.
  37757. */
  37758. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37759. /**
  37760. * Gets a list of transform nodes using their id
  37761. * @param id defines the id to search for
  37762. * @returns a list of transform nodes
  37763. */
  37764. getTransformNodesByID(id: string): Array<TransformNode>;
  37765. /**
  37766. * Gets a mesh with its auto-generated unique id
  37767. * @param uniqueId defines the unique id to search for
  37768. * @return the found mesh or null if not found at all.
  37769. */
  37770. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37771. /**
  37772. * Gets a the last added mesh using a given id
  37773. * @param id defines the id to search for
  37774. * @return the found mesh or null if not found at all.
  37775. */
  37776. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37777. /**
  37778. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37779. * @param id defines the id to search for
  37780. * @return the found node or null if not found at all
  37781. */
  37782. getLastEntryByID(id: string): Nullable<Node>;
  37783. /**
  37784. * Gets a node (Mesh, Camera, Light) using a given id
  37785. * @param id defines the id to search for
  37786. * @return the found node or null if not found at all
  37787. */
  37788. getNodeByID(id: string): Nullable<Node>;
  37789. /**
  37790. * Gets a node (Mesh, Camera, Light) using a given name
  37791. * @param name defines the name to search for
  37792. * @return the found node or null if not found at all.
  37793. */
  37794. getNodeByName(name: string): Nullable<Node>;
  37795. /**
  37796. * Gets a mesh using a given name
  37797. * @param name defines the name to search for
  37798. * @return the found mesh or null if not found at all.
  37799. */
  37800. getMeshByName(name: string): Nullable<AbstractMesh>;
  37801. /**
  37802. * Gets a transform node using a given name
  37803. * @param name defines the name to search for
  37804. * @return the found transform node or null if not found at all.
  37805. */
  37806. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37807. /**
  37808. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37809. * @param id defines the id to search for
  37810. * @return the found skeleton or null if not found at all.
  37811. */
  37812. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37813. /**
  37814. * Gets a skeleton using a given auto generated unique id
  37815. * @param uniqueId defines the unique id to search for
  37816. * @return the found skeleton or null if not found at all.
  37817. */
  37818. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37819. /**
  37820. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37821. * @param id defines the id to search for
  37822. * @return the found skeleton or null if not found at all.
  37823. */
  37824. getSkeletonById(id: string): Nullable<Skeleton>;
  37825. /**
  37826. * Gets a skeleton using a given name
  37827. * @param name defines the name to search for
  37828. * @return the found skeleton or null if not found at all.
  37829. */
  37830. getSkeletonByName(name: string): Nullable<Skeleton>;
  37831. /**
  37832. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37833. * @param id defines the id to search for
  37834. * @return the found morph target manager or null if not found at all.
  37835. */
  37836. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37837. /**
  37838. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37839. * @param id defines the id to search for
  37840. * @return the found morph target or null if not found at all.
  37841. */
  37842. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37843. /**
  37844. * Gets a boolean indicating if the given mesh is active
  37845. * @param mesh defines the mesh to look for
  37846. * @returns true if the mesh is in the active list
  37847. */
  37848. isActiveMesh(mesh: AbstractMesh): boolean;
  37849. /**
  37850. * Return a unique id as a string which can serve as an identifier for the scene
  37851. */
  37852. get uid(): string;
  37853. /**
  37854. * Add an externaly attached data from its key.
  37855. * This method call will fail and return false, if such key already exists.
  37856. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37857. * @param key the unique key that identifies the data
  37858. * @param data the data object to associate to the key for this Engine instance
  37859. * @return true if no such key were already present and the data was added successfully, false otherwise
  37860. */
  37861. addExternalData<T>(key: string, data: T): boolean;
  37862. /**
  37863. * Get an externaly attached data from its key
  37864. * @param key the unique key that identifies the data
  37865. * @return the associated data, if present (can be null), or undefined if not present
  37866. */
  37867. getExternalData<T>(key: string): Nullable<T>;
  37868. /**
  37869. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37870. * @param key the unique key that identifies the data
  37871. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37872. * @return the associated data, can be null if the factory returned null.
  37873. */
  37874. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37875. /**
  37876. * Remove an externaly attached data from the Engine instance
  37877. * @param key the unique key that identifies the data
  37878. * @return true if the data was successfully removed, false if it doesn't exist
  37879. */
  37880. removeExternalData(key: string): boolean;
  37881. private _evaluateSubMesh;
  37882. /**
  37883. * Clear the processed materials smart array preventing retention point in material dispose.
  37884. */
  37885. freeProcessedMaterials(): void;
  37886. private _preventFreeActiveMeshesAndRenderingGroups;
  37887. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37888. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37889. * when disposing several meshes in a row or a hierarchy of meshes.
  37890. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37891. */
  37892. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37893. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37894. /**
  37895. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37896. */
  37897. freeActiveMeshes(): void;
  37898. /**
  37899. * Clear the info related to rendering groups preventing retention points during dispose.
  37900. */
  37901. freeRenderingGroups(): void;
  37902. /** @hidden */
  37903. _isInIntermediateRendering(): boolean;
  37904. /**
  37905. * Lambda returning the list of potentially active meshes.
  37906. */
  37907. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37908. /**
  37909. * Lambda returning the list of potentially active sub meshes.
  37910. */
  37911. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37912. /**
  37913. * Lambda returning the list of potentially intersecting sub meshes.
  37914. */
  37915. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37916. /**
  37917. * Lambda returning the list of potentially colliding sub meshes.
  37918. */
  37919. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37920. private _activeMeshesFrozen;
  37921. private _skipEvaluateActiveMeshesCompletely;
  37922. /**
  37923. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37924. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37925. * @returns the current scene
  37926. */
  37927. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37928. /**
  37929. * Use this function to restart evaluating active meshes on every frame
  37930. * @returns the current scene
  37931. */
  37932. unfreezeActiveMeshes(): Scene;
  37933. private _evaluateActiveMeshes;
  37934. private _activeMesh;
  37935. /**
  37936. * Update the transform matrix to update from the current active camera
  37937. * @param force defines a boolean used to force the update even if cache is up to date
  37938. */
  37939. updateTransformMatrix(force?: boolean): void;
  37940. private _bindFrameBuffer;
  37941. /** @hidden */
  37942. _allowPostProcessClearColor: boolean;
  37943. /** @hidden */
  37944. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37945. private _processSubCameras;
  37946. private _checkIntersections;
  37947. /** @hidden */
  37948. _advancePhysicsEngineStep(step: number): void;
  37949. /**
  37950. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37951. */
  37952. getDeterministicFrameTime: () => number;
  37953. /** @hidden */
  37954. _animate(): void;
  37955. /** Execute all animations (for a frame) */
  37956. animate(): void;
  37957. /**
  37958. * Render the scene
  37959. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37960. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37961. */
  37962. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37963. /**
  37964. * Freeze all materials
  37965. * A frozen material will not be updatable but should be faster to render
  37966. */
  37967. freezeMaterials(): void;
  37968. /**
  37969. * Unfreeze all materials
  37970. * A frozen material will not be updatable but should be faster to render
  37971. */
  37972. unfreezeMaterials(): void;
  37973. /**
  37974. * Releases all held ressources
  37975. */
  37976. dispose(): void;
  37977. /**
  37978. * Gets if the scene is already disposed
  37979. */
  37980. get isDisposed(): boolean;
  37981. /**
  37982. * Call this function to reduce memory footprint of the scene.
  37983. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37984. */
  37985. clearCachedVertexData(): void;
  37986. /**
  37987. * This function will remove the local cached buffer data from texture.
  37988. * It will save memory but will prevent the texture from being rebuilt
  37989. */
  37990. cleanCachedTextureBuffer(): void;
  37991. /**
  37992. * Get the world extend vectors with an optional filter
  37993. *
  37994. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37995. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37996. */
  37997. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37998. min: Vector3;
  37999. max: Vector3;
  38000. };
  38001. /**
  38002. * Creates a ray that can be used to pick in the scene
  38003. * @param x defines the x coordinate of the origin (on-screen)
  38004. * @param y defines the y coordinate of the origin (on-screen)
  38005. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38006. * @param camera defines the camera to use for the picking
  38007. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38008. * @returns a Ray
  38009. */
  38010. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38011. /**
  38012. * Creates a ray that can be used to pick in the scene
  38013. * @param x defines the x coordinate of the origin (on-screen)
  38014. * @param y defines the y coordinate of the origin (on-screen)
  38015. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38016. * @param result defines the ray where to store the picking ray
  38017. * @param camera defines the camera to use for the picking
  38018. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38019. * @returns the current scene
  38020. */
  38021. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38022. /**
  38023. * Creates a ray that can be used to pick in the scene
  38024. * @param x defines the x coordinate of the origin (on-screen)
  38025. * @param y defines the y coordinate of the origin (on-screen)
  38026. * @param camera defines the camera to use for the picking
  38027. * @returns a Ray
  38028. */
  38029. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38030. /**
  38031. * Creates a ray that can be used to pick in the scene
  38032. * @param x defines the x coordinate of the origin (on-screen)
  38033. * @param y defines the y coordinate of the origin (on-screen)
  38034. * @param result defines the ray where to store the picking ray
  38035. * @param camera defines the camera to use for the picking
  38036. * @returns the current scene
  38037. */
  38038. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38039. /** Launch a ray to try to pick a mesh in the scene
  38040. * @param x position on screen
  38041. * @param y position on screen
  38042. * @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
  38043. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38044. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38045. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38046. * @returns a PickingInfo
  38047. */
  38048. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38049. /** Use the given ray to pick a mesh in the scene
  38050. * @param ray The ray to use to pick meshes
  38051. * @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
  38052. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38053. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38054. * @returns a PickingInfo
  38055. */
  38056. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38057. /**
  38058. * Launch a ray to try to pick a mesh in the scene
  38059. * @param x X position on screen
  38060. * @param y Y position on screen
  38061. * @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
  38062. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38063. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38064. * @returns an array of PickingInfo
  38065. */
  38066. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38067. /**
  38068. * Launch a ray to try to pick a mesh in the scene
  38069. * @param ray Ray to use
  38070. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  38071. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38072. * @returns an array of PickingInfo
  38073. */
  38074. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38075. /**
  38076. * Force the value of meshUnderPointer
  38077. * @param mesh defines the mesh to use
  38078. */
  38079. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38080. /**
  38081. * Gets the mesh under the pointer
  38082. * @returns a Mesh or null if no mesh is under the pointer
  38083. */
  38084. getPointerOverMesh(): Nullable<AbstractMesh>;
  38085. /** @hidden */
  38086. _rebuildGeometries(): void;
  38087. /** @hidden */
  38088. _rebuildTextures(): void;
  38089. private _getByTags;
  38090. /**
  38091. * Get a list of meshes by tags
  38092. * @param tagsQuery defines the tags query to use
  38093. * @param forEach defines a predicate used to filter results
  38094. * @returns an array of Mesh
  38095. */
  38096. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38097. /**
  38098. * Get a list of cameras by tags
  38099. * @param tagsQuery defines the tags query to use
  38100. * @param forEach defines a predicate used to filter results
  38101. * @returns an array of Camera
  38102. */
  38103. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38104. /**
  38105. * Get a list of lights by tags
  38106. * @param tagsQuery defines the tags query to use
  38107. * @param forEach defines a predicate used to filter results
  38108. * @returns an array of Light
  38109. */
  38110. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38111. /**
  38112. * Get a list of materials by tags
  38113. * @param tagsQuery defines the tags query to use
  38114. * @param forEach defines a predicate used to filter results
  38115. * @returns an array of Material
  38116. */
  38117. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38118. /**
  38119. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38120. * This allowed control for front to back rendering or reversly depending of the special needs.
  38121. *
  38122. * @param renderingGroupId The rendering group id corresponding to its index
  38123. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38124. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38125. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38126. */
  38127. 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;
  38128. /**
  38129. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38130. *
  38131. * @param renderingGroupId The rendering group id corresponding to its index
  38132. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38133. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38134. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38135. */
  38136. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38137. /**
  38138. * Gets the current auto clear configuration for one rendering group of the rendering
  38139. * manager.
  38140. * @param index the rendering group index to get the information for
  38141. * @returns The auto clear setup for the requested rendering group
  38142. */
  38143. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38144. private _blockMaterialDirtyMechanism;
  38145. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38146. get blockMaterialDirtyMechanism(): boolean;
  38147. set blockMaterialDirtyMechanism(value: boolean);
  38148. /**
  38149. * Will flag all materials as dirty to trigger new shader compilation
  38150. * @param flag defines the flag used to specify which material part must be marked as dirty
  38151. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38152. */
  38153. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38154. /** @hidden */
  38155. _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;
  38156. /** @hidden */
  38157. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38158. /** @hidden */
  38159. _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;
  38160. /** @hidden */
  38161. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38162. /** @hidden */
  38163. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38164. /** @hidden */
  38165. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38166. }
  38167. }
  38168. declare module "babylonjs/assetContainer" {
  38169. import { AbstractScene } from "babylonjs/abstractScene";
  38170. import { Scene } from "babylonjs/scene";
  38171. import { Mesh } from "babylonjs/Meshes/mesh";
  38172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38173. import { Skeleton } from "babylonjs/Bones/skeleton";
  38174. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38175. import { Animatable } from "babylonjs/Animations/animatable";
  38176. import { Nullable } from "babylonjs/types";
  38177. import { Node } from "babylonjs/node";
  38178. /**
  38179. * Set of assets to keep when moving a scene into an asset container.
  38180. */
  38181. export class KeepAssets extends AbstractScene {
  38182. }
  38183. /**
  38184. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38185. */
  38186. export class InstantiatedEntries {
  38187. /**
  38188. * List of new root nodes (eg. nodes with no parent)
  38189. */
  38190. rootNodes: TransformNode[];
  38191. /**
  38192. * List of new skeletons
  38193. */
  38194. skeletons: Skeleton[];
  38195. /**
  38196. * List of new animation groups
  38197. */
  38198. animationGroups: AnimationGroup[];
  38199. }
  38200. /**
  38201. * Container with a set of assets that can be added or removed from a scene.
  38202. */
  38203. export class AssetContainer extends AbstractScene {
  38204. private _wasAddedToScene;
  38205. /**
  38206. * The scene the AssetContainer belongs to.
  38207. */
  38208. scene: Scene;
  38209. /**
  38210. * Instantiates an AssetContainer.
  38211. * @param scene The scene the AssetContainer belongs to.
  38212. */
  38213. constructor(scene: Scene);
  38214. /**
  38215. * Instantiate or clone all meshes and add the new ones to the scene.
  38216. * Skeletons and animation groups will all be cloned
  38217. * @param nameFunction defines an optional function used to get new names for clones
  38218. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38219. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38220. */
  38221. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38222. /**
  38223. * Adds all the assets from the container to the scene.
  38224. */
  38225. addAllToScene(): void;
  38226. /**
  38227. * Removes all the assets in the container from the scene
  38228. */
  38229. removeAllFromScene(): void;
  38230. /**
  38231. * Disposes all the assets in the container
  38232. */
  38233. dispose(): void;
  38234. private _moveAssets;
  38235. /**
  38236. * Removes all the assets contained in the scene and adds them to the container.
  38237. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38238. */
  38239. moveAllFromScene(keepAssets?: KeepAssets): void;
  38240. /**
  38241. * 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.
  38242. * @returns the root mesh
  38243. */
  38244. createRootMesh(): Mesh;
  38245. /**
  38246. * Merge animations from this asset container into a scene
  38247. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38248. * @param animatables set of animatables to retarget to a node from the scene
  38249. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38250. */
  38251. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38252. }
  38253. }
  38254. declare module "babylonjs/abstractScene" {
  38255. import { Scene } from "babylonjs/scene";
  38256. import { Nullable } from "babylonjs/types";
  38257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38258. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38259. import { Geometry } from "babylonjs/Meshes/geometry";
  38260. import { Skeleton } from "babylonjs/Bones/skeleton";
  38261. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38262. import { AssetContainer } from "babylonjs/assetContainer";
  38263. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38264. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38266. import { Material } from "babylonjs/Materials/material";
  38267. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38268. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38269. import { Camera } from "babylonjs/Cameras/camera";
  38270. import { Light } from "babylonjs/Lights/light";
  38271. import { Node } from "babylonjs/node";
  38272. import { Animation } from "babylonjs/Animations/animation";
  38273. /**
  38274. * Defines how the parser contract is defined.
  38275. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38276. */
  38277. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38278. /**
  38279. * Defines how the individual parser contract is defined.
  38280. * These parser can parse an individual asset
  38281. */
  38282. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38283. /**
  38284. * Base class of the scene acting as a container for the different elements composing a scene.
  38285. * This class is dynamically extended by the different components of the scene increasing
  38286. * flexibility and reducing coupling
  38287. */
  38288. export abstract class AbstractScene {
  38289. /**
  38290. * Stores the list of available parsers in the application.
  38291. */
  38292. private static _BabylonFileParsers;
  38293. /**
  38294. * Stores the list of available individual parsers in the application.
  38295. */
  38296. private static _IndividualBabylonFileParsers;
  38297. /**
  38298. * Adds a parser in the list of available ones
  38299. * @param name Defines the name of the parser
  38300. * @param parser Defines the parser to add
  38301. */
  38302. static AddParser(name: string, parser: BabylonFileParser): void;
  38303. /**
  38304. * Gets a general parser from the list of avaialble ones
  38305. * @param name Defines the name of the parser
  38306. * @returns the requested parser or null
  38307. */
  38308. static GetParser(name: string): Nullable<BabylonFileParser>;
  38309. /**
  38310. * Adds n individual parser in the list of available ones
  38311. * @param name Defines the name of the parser
  38312. * @param parser Defines the parser to add
  38313. */
  38314. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38315. /**
  38316. * Gets an individual parser from the list of avaialble ones
  38317. * @param name Defines the name of the parser
  38318. * @returns the requested parser or null
  38319. */
  38320. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38321. /**
  38322. * Parser json data and populate both a scene and its associated container object
  38323. * @param jsonData Defines the data to parse
  38324. * @param scene Defines the scene to parse the data for
  38325. * @param container Defines the container attached to the parsing sequence
  38326. * @param rootUrl Defines the root url of the data
  38327. */
  38328. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38329. /**
  38330. * Gets the list of root nodes (ie. nodes with no parent)
  38331. */
  38332. rootNodes: Node[];
  38333. /** All of the cameras added to this scene
  38334. * @see http://doc.babylonjs.com/babylon101/cameras
  38335. */
  38336. cameras: Camera[];
  38337. /**
  38338. * All of the lights added to this scene
  38339. * @see http://doc.babylonjs.com/babylon101/lights
  38340. */
  38341. lights: Light[];
  38342. /**
  38343. * All of the (abstract) meshes added to this scene
  38344. */
  38345. meshes: AbstractMesh[];
  38346. /**
  38347. * The list of skeletons added to the scene
  38348. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38349. */
  38350. skeletons: Skeleton[];
  38351. /**
  38352. * All of the particle systems added to this scene
  38353. * @see http://doc.babylonjs.com/babylon101/particles
  38354. */
  38355. particleSystems: IParticleSystem[];
  38356. /**
  38357. * Gets a list of Animations associated with the scene
  38358. */
  38359. animations: Animation[];
  38360. /**
  38361. * All of the animation groups added to this scene
  38362. * @see http://doc.babylonjs.com/how_to/group
  38363. */
  38364. animationGroups: AnimationGroup[];
  38365. /**
  38366. * All of the multi-materials added to this scene
  38367. * @see http://doc.babylonjs.com/how_to/multi_materials
  38368. */
  38369. multiMaterials: MultiMaterial[];
  38370. /**
  38371. * All of the materials added to this scene
  38372. * In the context of a Scene, it is not supposed to be modified manually.
  38373. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38374. * Note also that the order of the Material within the array is not significant and might change.
  38375. * @see http://doc.babylonjs.com/babylon101/materials
  38376. */
  38377. materials: Material[];
  38378. /**
  38379. * The list of morph target managers added to the scene
  38380. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38381. */
  38382. morphTargetManagers: MorphTargetManager[];
  38383. /**
  38384. * The list of geometries used in the scene.
  38385. */
  38386. geometries: Geometry[];
  38387. /**
  38388. * All of the tranform nodes added to this scene
  38389. * In the context of a Scene, it is not supposed to be modified manually.
  38390. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38391. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38392. * @see http://doc.babylonjs.com/how_to/transformnode
  38393. */
  38394. transformNodes: TransformNode[];
  38395. /**
  38396. * ActionManagers available on the scene.
  38397. */
  38398. actionManagers: AbstractActionManager[];
  38399. /**
  38400. * Textures to keep.
  38401. */
  38402. textures: BaseTexture[];
  38403. /**
  38404. * Environment texture for the scene
  38405. */
  38406. environmentTexture: Nullable<BaseTexture>;
  38407. /**
  38408. * @returns all meshes, lights, cameras, transformNodes and bones
  38409. */
  38410. getNodes(): Array<Node>;
  38411. }
  38412. }
  38413. declare module "babylonjs/Audio/sound" {
  38414. import { Observable } from "babylonjs/Misc/observable";
  38415. import { Vector3 } from "babylonjs/Maths/math.vector";
  38416. import { Nullable } from "babylonjs/types";
  38417. import { Scene } from "babylonjs/scene";
  38418. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38419. /**
  38420. * Interface used to define options for Sound class
  38421. */
  38422. export interface ISoundOptions {
  38423. /**
  38424. * Does the sound autoplay once loaded.
  38425. */
  38426. autoplay?: boolean;
  38427. /**
  38428. * Does the sound loop after it finishes playing once.
  38429. */
  38430. loop?: boolean;
  38431. /**
  38432. * Sound's volume
  38433. */
  38434. volume?: number;
  38435. /**
  38436. * Is it a spatial sound?
  38437. */
  38438. spatialSound?: boolean;
  38439. /**
  38440. * Maximum distance to hear that sound
  38441. */
  38442. maxDistance?: number;
  38443. /**
  38444. * Uses user defined attenuation function
  38445. */
  38446. useCustomAttenuation?: boolean;
  38447. /**
  38448. * Define the roll off factor of spatial sounds.
  38449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38450. */
  38451. rolloffFactor?: number;
  38452. /**
  38453. * Define the reference distance the sound should be heard perfectly.
  38454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38455. */
  38456. refDistance?: number;
  38457. /**
  38458. * Define the distance attenuation model the sound will follow.
  38459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38460. */
  38461. distanceModel?: string;
  38462. /**
  38463. * Defines the playback speed (1 by default)
  38464. */
  38465. playbackRate?: number;
  38466. /**
  38467. * Defines if the sound is from a streaming source
  38468. */
  38469. streaming?: boolean;
  38470. /**
  38471. * Defines an optional length (in seconds) inside the sound file
  38472. */
  38473. length?: number;
  38474. /**
  38475. * Defines an optional offset (in seconds) inside the sound file
  38476. */
  38477. offset?: number;
  38478. /**
  38479. * If true, URLs will not be required to state the audio file codec to use.
  38480. */
  38481. skipCodecCheck?: boolean;
  38482. }
  38483. /**
  38484. * Defines a sound that can be played in the application.
  38485. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38487. */
  38488. export class Sound {
  38489. /**
  38490. * The name of the sound in the scene.
  38491. */
  38492. name: string;
  38493. /**
  38494. * Does the sound autoplay once loaded.
  38495. */
  38496. autoplay: boolean;
  38497. /**
  38498. * Does the sound loop after it finishes playing once.
  38499. */
  38500. loop: boolean;
  38501. /**
  38502. * Does the sound use a custom attenuation curve to simulate the falloff
  38503. * happening when the source gets further away from the camera.
  38504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38505. */
  38506. useCustomAttenuation: boolean;
  38507. /**
  38508. * The sound track id this sound belongs to.
  38509. */
  38510. soundTrackId: number;
  38511. /**
  38512. * Is this sound currently played.
  38513. */
  38514. isPlaying: boolean;
  38515. /**
  38516. * Is this sound currently paused.
  38517. */
  38518. isPaused: boolean;
  38519. /**
  38520. * Does this sound enables spatial sound.
  38521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38522. */
  38523. spatialSound: boolean;
  38524. /**
  38525. * Define the reference distance the sound should be heard perfectly.
  38526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38527. */
  38528. refDistance: number;
  38529. /**
  38530. * Define the roll off factor of spatial sounds.
  38531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38532. */
  38533. rolloffFactor: number;
  38534. /**
  38535. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38537. */
  38538. maxDistance: number;
  38539. /**
  38540. * Define the distance attenuation model the sound will follow.
  38541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38542. */
  38543. distanceModel: string;
  38544. /**
  38545. * @hidden
  38546. * Back Compat
  38547. **/
  38548. onended: () => any;
  38549. /**
  38550. * Observable event when the current playing sound finishes.
  38551. */
  38552. onEndedObservable: Observable<Sound>;
  38553. private _panningModel;
  38554. private _playbackRate;
  38555. private _streaming;
  38556. private _startTime;
  38557. private _startOffset;
  38558. private _position;
  38559. /** @hidden */
  38560. _positionInEmitterSpace: boolean;
  38561. private _localDirection;
  38562. private _volume;
  38563. private _isReadyToPlay;
  38564. private _isDirectional;
  38565. private _readyToPlayCallback;
  38566. private _audioBuffer;
  38567. private _soundSource;
  38568. private _streamingSource;
  38569. private _soundPanner;
  38570. private _soundGain;
  38571. private _inputAudioNode;
  38572. private _outputAudioNode;
  38573. private _coneInnerAngle;
  38574. private _coneOuterAngle;
  38575. private _coneOuterGain;
  38576. private _scene;
  38577. private _connectedTransformNode;
  38578. private _customAttenuationFunction;
  38579. private _registerFunc;
  38580. private _isOutputConnected;
  38581. private _htmlAudioElement;
  38582. private _urlType;
  38583. private _length?;
  38584. private _offset?;
  38585. /** @hidden */
  38586. static _SceneComponentInitialization: (scene: Scene) => void;
  38587. /**
  38588. * Create a sound and attach it to a scene
  38589. * @param name Name of your sound
  38590. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38591. * @param scene defines the scene the sound belongs to
  38592. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38593. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38594. */
  38595. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38596. /**
  38597. * Release the sound and its associated resources
  38598. */
  38599. dispose(): void;
  38600. /**
  38601. * Gets if the sounds is ready to be played or not.
  38602. * @returns true if ready, otherwise false
  38603. */
  38604. isReady(): boolean;
  38605. private _soundLoaded;
  38606. /**
  38607. * Sets the data of the sound from an audiobuffer
  38608. * @param audioBuffer The audioBuffer containing the data
  38609. */
  38610. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38611. /**
  38612. * Updates the current sounds options such as maxdistance, loop...
  38613. * @param options A JSON object containing values named as the object properties
  38614. */
  38615. updateOptions(options: ISoundOptions): void;
  38616. private _createSpatialParameters;
  38617. private _updateSpatialParameters;
  38618. /**
  38619. * Switch the panning model to HRTF:
  38620. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38622. */
  38623. switchPanningModelToHRTF(): void;
  38624. /**
  38625. * Switch the panning model to Equal Power:
  38626. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38628. */
  38629. switchPanningModelToEqualPower(): void;
  38630. private _switchPanningModel;
  38631. /**
  38632. * Connect this sound to a sound track audio node like gain...
  38633. * @param soundTrackAudioNode the sound track audio node to connect to
  38634. */
  38635. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38636. /**
  38637. * Transform this sound into a directional source
  38638. * @param coneInnerAngle Size of the inner cone in degree
  38639. * @param coneOuterAngle Size of the outer cone in degree
  38640. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38641. */
  38642. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38643. /**
  38644. * Gets or sets the inner angle for the directional cone.
  38645. */
  38646. get directionalConeInnerAngle(): number;
  38647. /**
  38648. * Gets or sets the inner angle for the directional cone.
  38649. */
  38650. set directionalConeInnerAngle(value: number);
  38651. /**
  38652. * Gets or sets the outer angle for the directional cone.
  38653. */
  38654. get directionalConeOuterAngle(): number;
  38655. /**
  38656. * Gets or sets the outer angle for the directional cone.
  38657. */
  38658. set directionalConeOuterAngle(value: number);
  38659. /**
  38660. * Sets the position of the emitter if spatial sound is enabled
  38661. * @param newPosition Defines the new posisiton
  38662. */
  38663. setPosition(newPosition: Vector3): void;
  38664. /**
  38665. * Sets the local direction of the emitter if spatial sound is enabled
  38666. * @param newLocalDirection Defines the new local direction
  38667. */
  38668. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38669. private _updateDirection;
  38670. /** @hidden */
  38671. updateDistanceFromListener(): void;
  38672. /**
  38673. * Sets a new custom attenuation function for the sound.
  38674. * @param callback Defines the function used for the attenuation
  38675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38676. */
  38677. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38678. /**
  38679. * Play the sound
  38680. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38681. * @param offset (optional) Start the sound at a specific time in seconds
  38682. * @param length (optional) Sound duration (in seconds)
  38683. */
  38684. play(time?: number, offset?: number, length?: number): void;
  38685. private _onended;
  38686. /**
  38687. * Stop the sound
  38688. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38689. */
  38690. stop(time?: number): void;
  38691. /**
  38692. * Put the sound in pause
  38693. */
  38694. pause(): void;
  38695. /**
  38696. * Sets a dedicated volume for this sounds
  38697. * @param newVolume Define the new volume of the sound
  38698. * @param time Define time for gradual change to new volume
  38699. */
  38700. setVolume(newVolume: number, time?: number): void;
  38701. /**
  38702. * Set the sound play back rate
  38703. * @param newPlaybackRate Define the playback rate the sound should be played at
  38704. */
  38705. setPlaybackRate(newPlaybackRate: number): void;
  38706. /**
  38707. * Gets the volume of the sound.
  38708. * @returns the volume of the sound
  38709. */
  38710. getVolume(): number;
  38711. /**
  38712. * Attach the sound to a dedicated mesh
  38713. * @param transformNode The transform node to connect the sound with
  38714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38715. */
  38716. attachToMesh(transformNode: TransformNode): void;
  38717. /**
  38718. * Detach the sound from the previously attached mesh
  38719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38720. */
  38721. detachFromMesh(): void;
  38722. private _onRegisterAfterWorldMatrixUpdate;
  38723. /**
  38724. * Clone the current sound in the scene.
  38725. * @returns the new sound clone
  38726. */
  38727. clone(): Nullable<Sound>;
  38728. /**
  38729. * Gets the current underlying audio buffer containing the data
  38730. * @returns the audio buffer
  38731. */
  38732. getAudioBuffer(): Nullable<AudioBuffer>;
  38733. /**
  38734. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38735. * @returns the source node
  38736. */
  38737. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38738. /**
  38739. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38740. * @returns the gain node
  38741. */
  38742. getSoundGain(): Nullable<GainNode>;
  38743. /**
  38744. * Serializes the Sound in a JSON representation
  38745. * @returns the JSON representation of the sound
  38746. */
  38747. serialize(): any;
  38748. /**
  38749. * Parse a JSON representation of a sound to innstantiate in a given scene
  38750. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38751. * @param scene Define the scene the new parsed sound should be created in
  38752. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38753. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38754. * @returns the newly parsed sound
  38755. */
  38756. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38757. }
  38758. }
  38759. declare module "babylonjs/Actions/directAudioActions" {
  38760. import { Action } from "babylonjs/Actions/action";
  38761. import { Condition } from "babylonjs/Actions/condition";
  38762. import { Sound } from "babylonjs/Audio/sound";
  38763. /**
  38764. * This defines an action helpful to play a defined sound on a triggered action.
  38765. */
  38766. export class PlaySoundAction extends Action {
  38767. private _sound;
  38768. /**
  38769. * Instantiate the action
  38770. * @param triggerOptions defines the trigger options
  38771. * @param sound defines the sound to play
  38772. * @param condition defines the trigger related conditions
  38773. */
  38774. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38775. /** @hidden */
  38776. _prepare(): void;
  38777. /**
  38778. * Execute the action and play the sound.
  38779. */
  38780. execute(): void;
  38781. /**
  38782. * Serializes the actions and its related information.
  38783. * @param parent defines the object to serialize in
  38784. * @returns the serialized object
  38785. */
  38786. serialize(parent: any): any;
  38787. }
  38788. /**
  38789. * This defines an action helpful to stop a defined sound on a triggered action.
  38790. */
  38791. export class StopSoundAction extends Action {
  38792. private _sound;
  38793. /**
  38794. * Instantiate the action
  38795. * @param triggerOptions defines the trigger options
  38796. * @param sound defines the sound to stop
  38797. * @param condition defines the trigger related conditions
  38798. */
  38799. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38800. /** @hidden */
  38801. _prepare(): void;
  38802. /**
  38803. * Execute the action and stop the sound.
  38804. */
  38805. execute(): void;
  38806. /**
  38807. * Serializes the actions and its related information.
  38808. * @param parent defines the object to serialize in
  38809. * @returns the serialized object
  38810. */
  38811. serialize(parent: any): any;
  38812. }
  38813. }
  38814. declare module "babylonjs/Actions/interpolateValueAction" {
  38815. import { Action } from "babylonjs/Actions/action";
  38816. import { Condition } from "babylonjs/Actions/condition";
  38817. import { Observable } from "babylonjs/Misc/observable";
  38818. /**
  38819. * This defines an action responsible to change the value of a property
  38820. * by interpolating between its current value and the newly set one once triggered.
  38821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38822. */
  38823. export class InterpolateValueAction extends Action {
  38824. /**
  38825. * Defines the path of the property where the value should be interpolated
  38826. */
  38827. propertyPath: string;
  38828. /**
  38829. * Defines the target value at the end of the interpolation.
  38830. */
  38831. value: any;
  38832. /**
  38833. * Defines the time it will take for the property to interpolate to the value.
  38834. */
  38835. duration: number;
  38836. /**
  38837. * Defines if the other scene animations should be stopped when the action has been triggered
  38838. */
  38839. stopOtherAnimations?: boolean;
  38840. /**
  38841. * Defines a callback raised once the interpolation animation has been done.
  38842. */
  38843. onInterpolationDone?: () => void;
  38844. /**
  38845. * Observable triggered once the interpolation animation has been done.
  38846. */
  38847. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38848. private _target;
  38849. private _effectiveTarget;
  38850. private _property;
  38851. /**
  38852. * Instantiate the action
  38853. * @param triggerOptions defines the trigger options
  38854. * @param target defines the object containing the value to interpolate
  38855. * @param propertyPath defines the path to the property in the target object
  38856. * @param value defines the target value at the end of the interpolation
  38857. * @param duration deines the time it will take for the property to interpolate to the value.
  38858. * @param condition defines the trigger related conditions
  38859. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38860. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38861. */
  38862. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38863. /** @hidden */
  38864. _prepare(): void;
  38865. /**
  38866. * Execute the action starts the value interpolation.
  38867. */
  38868. execute(): void;
  38869. /**
  38870. * Serializes the actions and its related information.
  38871. * @param parent defines the object to serialize in
  38872. * @returns the serialized object
  38873. */
  38874. serialize(parent: any): any;
  38875. }
  38876. }
  38877. declare module "babylonjs/Actions/index" {
  38878. export * from "babylonjs/Actions/abstractActionManager";
  38879. export * from "babylonjs/Actions/action";
  38880. export * from "babylonjs/Actions/actionEvent";
  38881. export * from "babylonjs/Actions/actionManager";
  38882. export * from "babylonjs/Actions/condition";
  38883. export * from "babylonjs/Actions/directActions";
  38884. export * from "babylonjs/Actions/directAudioActions";
  38885. export * from "babylonjs/Actions/interpolateValueAction";
  38886. }
  38887. declare module "babylonjs/Animations/index" {
  38888. export * from "babylonjs/Animations/animatable";
  38889. export * from "babylonjs/Animations/animation";
  38890. export * from "babylonjs/Animations/animationGroup";
  38891. export * from "babylonjs/Animations/animationPropertiesOverride";
  38892. export * from "babylonjs/Animations/easing";
  38893. export * from "babylonjs/Animations/runtimeAnimation";
  38894. export * from "babylonjs/Animations/animationEvent";
  38895. export * from "babylonjs/Animations/animationGroup";
  38896. export * from "babylonjs/Animations/animationKey";
  38897. export * from "babylonjs/Animations/animationRange";
  38898. export * from "babylonjs/Animations/animatable.interface";
  38899. }
  38900. declare module "babylonjs/Audio/soundTrack" {
  38901. import { Sound } from "babylonjs/Audio/sound";
  38902. import { Analyser } from "babylonjs/Audio/analyser";
  38903. import { Scene } from "babylonjs/scene";
  38904. /**
  38905. * Options allowed during the creation of a sound track.
  38906. */
  38907. export interface ISoundTrackOptions {
  38908. /**
  38909. * The volume the sound track should take during creation
  38910. */
  38911. volume?: number;
  38912. /**
  38913. * Define if the sound track is the main sound track of the scene
  38914. */
  38915. mainTrack?: boolean;
  38916. }
  38917. /**
  38918. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38919. * It will be also used in a future release to apply effects on a specific track.
  38920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38921. */
  38922. export class SoundTrack {
  38923. /**
  38924. * The unique identifier of the sound track in the scene.
  38925. */
  38926. id: number;
  38927. /**
  38928. * The list of sounds included in the sound track.
  38929. */
  38930. soundCollection: Array<Sound>;
  38931. private _outputAudioNode;
  38932. private _scene;
  38933. private _connectedAnalyser;
  38934. private _options;
  38935. private _isInitialized;
  38936. /**
  38937. * Creates a new sound track.
  38938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38939. * @param scene Define the scene the sound track belongs to
  38940. * @param options
  38941. */
  38942. constructor(scene: Scene, options?: ISoundTrackOptions);
  38943. private _initializeSoundTrackAudioGraph;
  38944. /**
  38945. * Release the sound track and its associated resources
  38946. */
  38947. dispose(): void;
  38948. /**
  38949. * Adds a sound to this sound track
  38950. * @param sound define the cound to add
  38951. * @ignoreNaming
  38952. */
  38953. AddSound(sound: Sound): void;
  38954. /**
  38955. * Removes a sound to this sound track
  38956. * @param sound define the cound to remove
  38957. * @ignoreNaming
  38958. */
  38959. RemoveSound(sound: Sound): void;
  38960. /**
  38961. * Set a global volume for the full sound track.
  38962. * @param newVolume Define the new volume of the sound track
  38963. */
  38964. setVolume(newVolume: number): void;
  38965. /**
  38966. * Switch the panning model to HRTF:
  38967. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38969. */
  38970. switchPanningModelToHRTF(): void;
  38971. /**
  38972. * Switch the panning model to Equal Power:
  38973. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38975. */
  38976. switchPanningModelToEqualPower(): void;
  38977. /**
  38978. * Connect the sound track to an audio analyser allowing some amazing
  38979. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38981. * @param analyser The analyser to connect to the engine
  38982. */
  38983. connectToAnalyser(analyser: Analyser): void;
  38984. }
  38985. }
  38986. declare module "babylonjs/Audio/audioSceneComponent" {
  38987. import { Sound } from "babylonjs/Audio/sound";
  38988. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38989. import { Nullable } from "babylonjs/types";
  38990. import { Vector3 } from "babylonjs/Maths/math.vector";
  38991. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38992. import { Scene } from "babylonjs/scene";
  38993. import { AbstractScene } from "babylonjs/abstractScene";
  38994. import "babylonjs/Audio/audioEngine";
  38995. module "babylonjs/abstractScene" {
  38996. interface AbstractScene {
  38997. /**
  38998. * The list of sounds used in the scene.
  38999. */
  39000. sounds: Nullable<Array<Sound>>;
  39001. }
  39002. }
  39003. module "babylonjs/scene" {
  39004. interface Scene {
  39005. /**
  39006. * @hidden
  39007. * Backing field
  39008. */
  39009. _mainSoundTrack: SoundTrack;
  39010. /**
  39011. * The main sound track played by the scene.
  39012. * It cotains your primary collection of sounds.
  39013. */
  39014. mainSoundTrack: SoundTrack;
  39015. /**
  39016. * The list of sound tracks added to the scene
  39017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39018. */
  39019. soundTracks: Nullable<Array<SoundTrack>>;
  39020. /**
  39021. * Gets a sound using a given name
  39022. * @param name defines the name to search for
  39023. * @return the found sound or null if not found at all.
  39024. */
  39025. getSoundByName(name: string): Nullable<Sound>;
  39026. /**
  39027. * Gets or sets if audio support is enabled
  39028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39029. */
  39030. audioEnabled: boolean;
  39031. /**
  39032. * Gets or sets if audio will be output to headphones
  39033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39034. */
  39035. headphone: boolean;
  39036. /**
  39037. * Gets or sets custom audio listener position provider
  39038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39039. */
  39040. audioListenerPositionProvider: Nullable<() => Vector3>;
  39041. /**
  39042. * Gets or sets a refresh rate when using 3D audio positioning
  39043. */
  39044. audioPositioningRefreshRate: number;
  39045. }
  39046. }
  39047. /**
  39048. * Defines the sound scene component responsible to manage any sounds
  39049. * in a given scene.
  39050. */
  39051. export class AudioSceneComponent implements ISceneSerializableComponent {
  39052. /**
  39053. * The component name helpfull to identify the component in the list of scene components.
  39054. */
  39055. readonly name: string;
  39056. /**
  39057. * The scene the component belongs to.
  39058. */
  39059. scene: Scene;
  39060. private _audioEnabled;
  39061. /**
  39062. * Gets whether audio is enabled or not.
  39063. * Please use related enable/disable method to switch state.
  39064. */
  39065. get audioEnabled(): boolean;
  39066. private _headphone;
  39067. /**
  39068. * Gets whether audio is outputing to headphone or not.
  39069. * Please use the according Switch methods to change output.
  39070. */
  39071. get headphone(): boolean;
  39072. /**
  39073. * Gets or sets a refresh rate when using 3D audio positioning
  39074. */
  39075. audioPositioningRefreshRate: number;
  39076. private _audioListenerPositionProvider;
  39077. /**
  39078. * Gets the current audio listener position provider
  39079. */
  39080. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39081. /**
  39082. * Sets a custom listener position for all sounds in the scene
  39083. * By default, this is the position of the first active camera
  39084. */
  39085. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39086. /**
  39087. * Creates a new instance of the component for the given scene
  39088. * @param scene Defines the scene to register the component in
  39089. */
  39090. constructor(scene: Scene);
  39091. /**
  39092. * Registers the component in a given scene
  39093. */
  39094. register(): void;
  39095. /**
  39096. * Rebuilds the elements related to this component in case of
  39097. * context lost for instance.
  39098. */
  39099. rebuild(): void;
  39100. /**
  39101. * Serializes the component data to the specified json object
  39102. * @param serializationObject The object to serialize to
  39103. */
  39104. serialize(serializationObject: any): void;
  39105. /**
  39106. * Adds all the elements from the container to the scene
  39107. * @param container the container holding the elements
  39108. */
  39109. addFromContainer(container: AbstractScene): void;
  39110. /**
  39111. * Removes all the elements in the container from the scene
  39112. * @param container contains the elements to remove
  39113. * @param dispose if the removed element should be disposed (default: false)
  39114. */
  39115. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39116. /**
  39117. * Disposes the component and the associated ressources.
  39118. */
  39119. dispose(): void;
  39120. /**
  39121. * Disables audio in the associated scene.
  39122. */
  39123. disableAudio(): void;
  39124. /**
  39125. * Enables audio in the associated scene.
  39126. */
  39127. enableAudio(): void;
  39128. /**
  39129. * Switch audio to headphone output.
  39130. */
  39131. switchAudioModeForHeadphones(): void;
  39132. /**
  39133. * Switch audio to normal speakers.
  39134. */
  39135. switchAudioModeForNormalSpeakers(): void;
  39136. private _cachedCameraDirection;
  39137. private _cachedCameraPosition;
  39138. private _lastCheck;
  39139. private _afterRender;
  39140. }
  39141. }
  39142. declare module "babylonjs/Audio/weightedsound" {
  39143. import { Sound } from "babylonjs/Audio/sound";
  39144. /**
  39145. * Wraps one or more Sound objects and selects one with random weight for playback.
  39146. */
  39147. export class WeightedSound {
  39148. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39149. loop: boolean;
  39150. private _coneInnerAngle;
  39151. private _coneOuterAngle;
  39152. private _volume;
  39153. /** A Sound is currently playing. */
  39154. isPlaying: boolean;
  39155. /** A Sound is currently paused. */
  39156. isPaused: boolean;
  39157. private _sounds;
  39158. private _weights;
  39159. private _currentIndex?;
  39160. /**
  39161. * Creates a new WeightedSound from the list of sounds given.
  39162. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39163. * @param sounds Array of Sounds that will be selected from.
  39164. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39165. */
  39166. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39167. /**
  39168. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39169. */
  39170. get directionalConeInnerAngle(): number;
  39171. /**
  39172. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39173. */
  39174. set directionalConeInnerAngle(value: number);
  39175. /**
  39176. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39177. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39178. */
  39179. get directionalConeOuterAngle(): number;
  39180. /**
  39181. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39182. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39183. */
  39184. set directionalConeOuterAngle(value: number);
  39185. /**
  39186. * Playback volume.
  39187. */
  39188. get volume(): number;
  39189. /**
  39190. * Playback volume.
  39191. */
  39192. set volume(value: number);
  39193. private _onended;
  39194. /**
  39195. * Suspend playback
  39196. */
  39197. pause(): void;
  39198. /**
  39199. * Stop playback
  39200. */
  39201. stop(): void;
  39202. /**
  39203. * Start playback.
  39204. * @param startOffset Position the clip head at a specific time in seconds.
  39205. */
  39206. play(startOffset?: number): void;
  39207. }
  39208. }
  39209. declare module "babylonjs/Audio/index" {
  39210. export * from "babylonjs/Audio/analyser";
  39211. export * from "babylonjs/Audio/audioEngine";
  39212. export * from "babylonjs/Audio/audioSceneComponent";
  39213. export * from "babylonjs/Audio/sound";
  39214. export * from "babylonjs/Audio/soundTrack";
  39215. export * from "babylonjs/Audio/weightedsound";
  39216. }
  39217. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39218. import { Behavior } from "babylonjs/Behaviors/behavior";
  39219. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39220. import { BackEase } from "babylonjs/Animations/easing";
  39221. /**
  39222. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39223. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39224. */
  39225. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39226. /**
  39227. * Gets the name of the behavior.
  39228. */
  39229. get name(): string;
  39230. /**
  39231. * The easing function used by animations
  39232. */
  39233. static EasingFunction: BackEase;
  39234. /**
  39235. * The easing mode used by animations
  39236. */
  39237. static EasingMode: number;
  39238. /**
  39239. * The duration of the animation, in milliseconds
  39240. */
  39241. transitionDuration: number;
  39242. /**
  39243. * Length of the distance animated by the transition when lower radius is reached
  39244. */
  39245. lowerRadiusTransitionRange: number;
  39246. /**
  39247. * Length of the distance animated by the transition when upper radius is reached
  39248. */
  39249. upperRadiusTransitionRange: number;
  39250. private _autoTransitionRange;
  39251. /**
  39252. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39253. */
  39254. get autoTransitionRange(): boolean;
  39255. /**
  39256. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39257. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39258. */
  39259. set autoTransitionRange(value: boolean);
  39260. private _attachedCamera;
  39261. private _onAfterCheckInputsObserver;
  39262. private _onMeshTargetChangedObserver;
  39263. /**
  39264. * Initializes the behavior.
  39265. */
  39266. init(): void;
  39267. /**
  39268. * Attaches the behavior to its arc rotate camera.
  39269. * @param camera Defines the camera to attach the behavior to
  39270. */
  39271. attach(camera: ArcRotateCamera): void;
  39272. /**
  39273. * Detaches the behavior from its current arc rotate camera.
  39274. */
  39275. detach(): void;
  39276. private _radiusIsAnimating;
  39277. private _radiusBounceTransition;
  39278. private _animatables;
  39279. private _cachedWheelPrecision;
  39280. /**
  39281. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39282. * @param radiusLimit The limit to check against.
  39283. * @return Bool to indicate if at limit.
  39284. */
  39285. private _isRadiusAtLimit;
  39286. /**
  39287. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39288. * @param radiusDelta The delta by which to animate to. Can be negative.
  39289. */
  39290. private _applyBoundRadiusAnimation;
  39291. /**
  39292. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39293. */
  39294. protected _clearAnimationLocks(): void;
  39295. /**
  39296. * Stops and removes all animations that have been applied to the camera
  39297. */
  39298. stopAllAnimations(): void;
  39299. }
  39300. }
  39301. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39302. import { Behavior } from "babylonjs/Behaviors/behavior";
  39303. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39304. import { ExponentialEase } from "babylonjs/Animations/easing";
  39305. import { Nullable } from "babylonjs/types";
  39306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39307. import { Vector3 } from "babylonjs/Maths/math.vector";
  39308. /**
  39309. * 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.
  39310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39311. */
  39312. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39313. /**
  39314. * Gets the name of the behavior.
  39315. */
  39316. get name(): string;
  39317. private _mode;
  39318. private _radiusScale;
  39319. private _positionScale;
  39320. private _defaultElevation;
  39321. private _elevationReturnTime;
  39322. private _elevationReturnWaitTime;
  39323. private _zoomStopsAnimation;
  39324. private _framingTime;
  39325. /**
  39326. * The easing function used by animations
  39327. */
  39328. static EasingFunction: ExponentialEase;
  39329. /**
  39330. * The easing mode used by animations
  39331. */
  39332. static EasingMode: number;
  39333. /**
  39334. * Sets the current mode used by the behavior
  39335. */
  39336. set mode(mode: number);
  39337. /**
  39338. * Gets current mode used by the behavior.
  39339. */
  39340. get mode(): number;
  39341. /**
  39342. * Sets the scale applied to the radius (1 by default)
  39343. */
  39344. set radiusScale(radius: number);
  39345. /**
  39346. * Gets the scale applied to the radius
  39347. */
  39348. get radiusScale(): number;
  39349. /**
  39350. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39351. */
  39352. set positionScale(scale: number);
  39353. /**
  39354. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39355. */
  39356. get positionScale(): number;
  39357. /**
  39358. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39359. * behaviour is triggered, in radians.
  39360. */
  39361. set defaultElevation(elevation: number);
  39362. /**
  39363. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39364. * behaviour is triggered, in radians.
  39365. */
  39366. get defaultElevation(): number;
  39367. /**
  39368. * Sets the time (in milliseconds) taken to return to the default beta position.
  39369. * Negative value indicates camera should not return to default.
  39370. */
  39371. set elevationReturnTime(speed: number);
  39372. /**
  39373. * Gets the time (in milliseconds) taken to return to the default beta position.
  39374. * Negative value indicates camera should not return to default.
  39375. */
  39376. get elevationReturnTime(): number;
  39377. /**
  39378. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39379. */
  39380. set elevationReturnWaitTime(time: number);
  39381. /**
  39382. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39383. */
  39384. get elevationReturnWaitTime(): number;
  39385. /**
  39386. * Sets the flag that indicates if user zooming should stop animation.
  39387. */
  39388. set zoomStopsAnimation(flag: boolean);
  39389. /**
  39390. * Gets the flag that indicates if user zooming should stop animation.
  39391. */
  39392. get zoomStopsAnimation(): boolean;
  39393. /**
  39394. * Sets the transition time when framing the mesh, in milliseconds
  39395. */
  39396. set framingTime(time: number);
  39397. /**
  39398. * Gets the transition time when framing the mesh, in milliseconds
  39399. */
  39400. get framingTime(): number;
  39401. /**
  39402. * Define if the behavior should automatically change the configured
  39403. * camera limits and sensibilities.
  39404. */
  39405. autoCorrectCameraLimitsAndSensibility: boolean;
  39406. private _onPrePointerObservableObserver;
  39407. private _onAfterCheckInputsObserver;
  39408. private _onMeshTargetChangedObserver;
  39409. private _attachedCamera;
  39410. private _isPointerDown;
  39411. private _lastInteractionTime;
  39412. /**
  39413. * Initializes the behavior.
  39414. */
  39415. init(): void;
  39416. /**
  39417. * Attaches the behavior to its arc rotate camera.
  39418. * @param camera Defines the camera to attach the behavior to
  39419. */
  39420. attach(camera: ArcRotateCamera): void;
  39421. /**
  39422. * Detaches the behavior from its current arc rotate camera.
  39423. */
  39424. detach(): void;
  39425. private _animatables;
  39426. private _betaIsAnimating;
  39427. private _betaTransition;
  39428. private _radiusTransition;
  39429. private _vectorTransition;
  39430. /**
  39431. * Targets the given mesh and updates zoom level accordingly.
  39432. * @param mesh The mesh to target.
  39433. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39434. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39435. */
  39436. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39437. /**
  39438. * Targets the given mesh with its children and updates zoom level accordingly.
  39439. * @param mesh The mesh to target.
  39440. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39441. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39442. */
  39443. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39444. /**
  39445. * Targets the given meshes with their children and updates zoom level accordingly.
  39446. * @param meshes The mesh to target.
  39447. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39448. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39449. */
  39450. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39451. /**
  39452. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39453. * @param minimumWorld Determines the smaller position of the bounding box extend
  39454. * @param maximumWorld Determines the bigger position of the bounding box extend
  39455. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39456. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39457. */
  39458. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39459. /**
  39460. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39461. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39462. * frustum width.
  39463. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39464. * to fully enclose the mesh in the viewing frustum.
  39465. */
  39466. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39467. /**
  39468. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39469. * is automatically returned to its default position (expected to be above ground plane).
  39470. */
  39471. private _maintainCameraAboveGround;
  39472. /**
  39473. * Returns the frustum slope based on the canvas ratio and camera FOV
  39474. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39475. */
  39476. private _getFrustumSlope;
  39477. /**
  39478. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39479. */
  39480. private _clearAnimationLocks;
  39481. /**
  39482. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39483. */
  39484. private _applyUserInteraction;
  39485. /**
  39486. * Stops and removes all animations that have been applied to the camera
  39487. */
  39488. stopAllAnimations(): void;
  39489. /**
  39490. * Gets a value indicating if the user is moving the camera
  39491. */
  39492. get isUserIsMoving(): boolean;
  39493. /**
  39494. * The camera can move all the way towards the mesh.
  39495. */
  39496. static IgnoreBoundsSizeMode: number;
  39497. /**
  39498. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39499. */
  39500. static FitFrustumSidesMode: number;
  39501. }
  39502. }
  39503. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39504. import { Nullable } from "babylonjs/types";
  39505. import { Camera } from "babylonjs/Cameras/camera";
  39506. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39507. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39508. /**
  39509. * Base class for Camera Pointer Inputs.
  39510. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39511. * for example usage.
  39512. */
  39513. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39514. /**
  39515. * Defines the camera the input is attached to.
  39516. */
  39517. abstract camera: Camera;
  39518. /**
  39519. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39520. */
  39521. protected _altKey: boolean;
  39522. protected _ctrlKey: boolean;
  39523. protected _metaKey: boolean;
  39524. protected _shiftKey: boolean;
  39525. /**
  39526. * Which mouse buttons were pressed at time of last mouse event.
  39527. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39528. */
  39529. protected _buttonsPressed: number;
  39530. /**
  39531. * Defines the buttons associated with the input to handle camera move.
  39532. */
  39533. buttons: number[];
  39534. /**
  39535. * Attach the input controls to a specific dom element to get the input from.
  39536. * @param element Defines the element the controls should be listened from
  39537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39538. */
  39539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39540. /**
  39541. * Detach the current controls from the specified dom element.
  39542. * @param element Defines the element to stop listening the inputs from
  39543. */
  39544. detachControl(element: Nullable<HTMLElement>): void;
  39545. /**
  39546. * Gets the class name of the current input.
  39547. * @returns the class name
  39548. */
  39549. getClassName(): string;
  39550. /**
  39551. * Get the friendly name associated with the input class.
  39552. * @returns the input friendly name
  39553. */
  39554. getSimpleName(): string;
  39555. /**
  39556. * Called on pointer POINTERDOUBLETAP event.
  39557. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39558. */
  39559. protected onDoubleTap(type: string): void;
  39560. /**
  39561. * Called on pointer POINTERMOVE event if only a single touch is active.
  39562. * Override this method to provide functionality.
  39563. */
  39564. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39565. /**
  39566. * Called on pointer POINTERMOVE event if multiple touches are active.
  39567. * Override this method to provide functionality.
  39568. */
  39569. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39570. /**
  39571. * Called on JS contextmenu event.
  39572. * Override this method to provide functionality.
  39573. */
  39574. protected onContextMenu(evt: PointerEvent): void;
  39575. /**
  39576. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39577. * press.
  39578. * Override this method to provide functionality.
  39579. */
  39580. protected onButtonDown(evt: PointerEvent): void;
  39581. /**
  39582. * Called each time a new POINTERUP event occurs. Ie, for each button
  39583. * release.
  39584. * Override this method to provide functionality.
  39585. */
  39586. protected onButtonUp(evt: PointerEvent): void;
  39587. /**
  39588. * Called when window becomes inactive.
  39589. * Override this method to provide functionality.
  39590. */
  39591. protected onLostFocus(): void;
  39592. private _pointerInput;
  39593. private _observer;
  39594. private _onLostFocus;
  39595. private pointA;
  39596. private pointB;
  39597. }
  39598. }
  39599. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39600. import { Nullable } from "babylonjs/types";
  39601. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39602. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39603. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39604. /**
  39605. * Manage the pointers inputs to control an arc rotate camera.
  39606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39607. */
  39608. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39609. /**
  39610. * Defines the camera the input is attached to.
  39611. */
  39612. camera: ArcRotateCamera;
  39613. /**
  39614. * Gets the class name of the current input.
  39615. * @returns the class name
  39616. */
  39617. getClassName(): string;
  39618. /**
  39619. * Defines the buttons associated with the input to handle camera move.
  39620. */
  39621. buttons: number[];
  39622. /**
  39623. * Defines the pointer angular sensibility along the X axis or how fast is
  39624. * the camera rotating.
  39625. */
  39626. angularSensibilityX: number;
  39627. /**
  39628. * Defines the pointer angular sensibility along the Y axis or how fast is
  39629. * the camera rotating.
  39630. */
  39631. angularSensibilityY: number;
  39632. /**
  39633. * Defines the pointer pinch precision or how fast is the camera zooming.
  39634. */
  39635. pinchPrecision: number;
  39636. /**
  39637. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39638. * from 0.
  39639. * It defines the percentage of current camera.radius to use as delta when
  39640. * pinch zoom is used.
  39641. */
  39642. pinchDeltaPercentage: number;
  39643. /**
  39644. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39645. * that any object in the plane at the camera's target point will scale
  39646. * perfectly with finger motion.
  39647. * Overrides pinchDeltaPercentage and pinchPrecision.
  39648. */
  39649. useNaturalPinchZoom: boolean;
  39650. /**
  39651. * Defines the pointer panning sensibility or how fast is the camera moving.
  39652. */
  39653. panningSensibility: number;
  39654. /**
  39655. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39656. */
  39657. multiTouchPanning: boolean;
  39658. /**
  39659. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39660. * zoom (pinch) through multitouch.
  39661. */
  39662. multiTouchPanAndZoom: boolean;
  39663. /**
  39664. * Revers pinch action direction.
  39665. */
  39666. pinchInwards: boolean;
  39667. private _isPanClick;
  39668. private _twoFingerActivityCount;
  39669. private _isPinching;
  39670. /**
  39671. * Called on pointer POINTERMOVE event if only a single touch is active.
  39672. */
  39673. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39674. /**
  39675. * Called on pointer POINTERDOUBLETAP event.
  39676. */
  39677. protected onDoubleTap(type: string): void;
  39678. /**
  39679. * Called on pointer POINTERMOVE event if multiple touches are active.
  39680. */
  39681. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39682. /**
  39683. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39684. * press.
  39685. */
  39686. protected onButtonDown(evt: PointerEvent): void;
  39687. /**
  39688. * Called each time a new POINTERUP event occurs. Ie, for each button
  39689. * release.
  39690. */
  39691. protected onButtonUp(evt: PointerEvent): void;
  39692. /**
  39693. * Called when window becomes inactive.
  39694. */
  39695. protected onLostFocus(): void;
  39696. }
  39697. }
  39698. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39699. import { Nullable } from "babylonjs/types";
  39700. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39701. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39702. /**
  39703. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39705. */
  39706. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39707. /**
  39708. * Defines the camera the input is attached to.
  39709. */
  39710. camera: ArcRotateCamera;
  39711. /**
  39712. * Defines the list of key codes associated with the up action (increase alpha)
  39713. */
  39714. keysUp: number[];
  39715. /**
  39716. * Defines the list of key codes associated with the down action (decrease alpha)
  39717. */
  39718. keysDown: number[];
  39719. /**
  39720. * Defines the list of key codes associated with the left action (increase beta)
  39721. */
  39722. keysLeft: number[];
  39723. /**
  39724. * Defines the list of key codes associated with the right action (decrease beta)
  39725. */
  39726. keysRight: number[];
  39727. /**
  39728. * Defines the list of key codes associated with the reset action.
  39729. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39730. */
  39731. keysReset: number[];
  39732. /**
  39733. * Defines the panning sensibility of the inputs.
  39734. * (How fast is the camera panning)
  39735. */
  39736. panningSensibility: number;
  39737. /**
  39738. * Defines the zooming sensibility of the inputs.
  39739. * (How fast is the camera zooming)
  39740. */
  39741. zoomingSensibility: number;
  39742. /**
  39743. * Defines whether maintaining the alt key down switch the movement mode from
  39744. * orientation to zoom.
  39745. */
  39746. useAltToZoom: boolean;
  39747. /**
  39748. * Rotation speed of the camera
  39749. */
  39750. angularSpeed: number;
  39751. private _keys;
  39752. private _ctrlPressed;
  39753. private _altPressed;
  39754. private _onCanvasBlurObserver;
  39755. private _onKeyboardObserver;
  39756. private _engine;
  39757. private _scene;
  39758. /**
  39759. * Attach the input controls to a specific dom element to get the input from.
  39760. * @param element Defines the element the controls should be listened from
  39761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39762. */
  39763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39764. /**
  39765. * Detach the current controls from the specified dom element.
  39766. * @param element Defines the element to stop listening the inputs from
  39767. */
  39768. detachControl(element: Nullable<HTMLElement>): void;
  39769. /**
  39770. * Update the current camera state depending on the inputs that have been used this frame.
  39771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39772. */
  39773. checkInputs(): void;
  39774. /**
  39775. * Gets the class name of the current intput.
  39776. * @returns the class name
  39777. */
  39778. getClassName(): string;
  39779. /**
  39780. * Get the friendly name associated with the input class.
  39781. * @returns the input friendly name
  39782. */
  39783. getSimpleName(): string;
  39784. }
  39785. }
  39786. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39787. import { Nullable } from "babylonjs/types";
  39788. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39789. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39790. /**
  39791. * Manage the mouse wheel inputs to control an arc rotate camera.
  39792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39793. */
  39794. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39795. /**
  39796. * Defines the camera the input is attached to.
  39797. */
  39798. camera: ArcRotateCamera;
  39799. /**
  39800. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39801. */
  39802. wheelPrecision: number;
  39803. /**
  39804. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39805. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39806. */
  39807. wheelDeltaPercentage: number;
  39808. private _wheel;
  39809. private _observer;
  39810. private computeDeltaFromMouseWheelLegacyEvent;
  39811. /**
  39812. * Attach the input controls to a specific dom element to get the input from.
  39813. * @param element Defines the element the controls should be listened from
  39814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39815. */
  39816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39817. /**
  39818. * Detach the current controls from the specified dom element.
  39819. * @param element Defines the element to stop listening the inputs from
  39820. */
  39821. detachControl(element: Nullable<HTMLElement>): void;
  39822. /**
  39823. * Gets the class name of the current intput.
  39824. * @returns the class name
  39825. */
  39826. getClassName(): string;
  39827. /**
  39828. * Get the friendly name associated with the input class.
  39829. * @returns the input friendly name
  39830. */
  39831. getSimpleName(): string;
  39832. }
  39833. }
  39834. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39835. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39836. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39837. /**
  39838. * Default Inputs manager for the ArcRotateCamera.
  39839. * It groups all the default supported inputs for ease of use.
  39840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39841. */
  39842. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39843. /**
  39844. * Instantiates a new ArcRotateCameraInputsManager.
  39845. * @param camera Defines the camera the inputs belong to
  39846. */
  39847. constructor(camera: ArcRotateCamera);
  39848. /**
  39849. * Add mouse wheel input support to the input manager.
  39850. * @returns the current input manager
  39851. */
  39852. addMouseWheel(): ArcRotateCameraInputsManager;
  39853. /**
  39854. * Add pointers input support to the input manager.
  39855. * @returns the current input manager
  39856. */
  39857. addPointers(): ArcRotateCameraInputsManager;
  39858. /**
  39859. * Add keyboard input support to the input manager.
  39860. * @returns the current input manager
  39861. */
  39862. addKeyboard(): ArcRotateCameraInputsManager;
  39863. }
  39864. }
  39865. declare module "babylonjs/Cameras/arcRotateCamera" {
  39866. import { Observable } from "babylonjs/Misc/observable";
  39867. import { Nullable } from "babylonjs/types";
  39868. import { Scene } from "babylonjs/scene";
  39869. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39871. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39872. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39873. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39874. import { Camera } from "babylonjs/Cameras/camera";
  39875. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39876. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39877. import { Collider } from "babylonjs/Collisions/collider";
  39878. /**
  39879. * This represents an orbital type of camera.
  39880. *
  39881. * 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.
  39882. * 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.
  39883. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39884. */
  39885. export class ArcRotateCamera extends TargetCamera {
  39886. /**
  39887. * Defines the rotation angle of the camera along the longitudinal axis.
  39888. */
  39889. alpha: number;
  39890. /**
  39891. * Defines the rotation angle of the camera along the latitudinal axis.
  39892. */
  39893. beta: number;
  39894. /**
  39895. * Defines the radius of the camera from it s target point.
  39896. */
  39897. radius: number;
  39898. protected _target: Vector3;
  39899. protected _targetHost: Nullable<AbstractMesh>;
  39900. /**
  39901. * Defines the target point of the camera.
  39902. * The camera looks towards it form the radius distance.
  39903. */
  39904. get target(): Vector3;
  39905. set target(value: Vector3);
  39906. /**
  39907. * Define the current local position of the camera in the scene
  39908. */
  39909. get position(): Vector3;
  39910. set position(newPosition: Vector3);
  39911. protected _upVector: Vector3;
  39912. protected _upToYMatrix: Matrix;
  39913. protected _YToUpMatrix: Matrix;
  39914. /**
  39915. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39916. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39917. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39918. */
  39919. set upVector(vec: Vector3);
  39920. get upVector(): Vector3;
  39921. /**
  39922. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39923. */
  39924. setMatUp(): void;
  39925. /**
  39926. * Current inertia value on the longitudinal axis.
  39927. * The bigger this number the longer it will take for the camera to stop.
  39928. */
  39929. inertialAlphaOffset: number;
  39930. /**
  39931. * Current inertia value on the latitudinal axis.
  39932. * The bigger this number the longer it will take for the camera to stop.
  39933. */
  39934. inertialBetaOffset: number;
  39935. /**
  39936. * Current inertia value on the radius axis.
  39937. * The bigger this number the longer it will take for the camera to stop.
  39938. */
  39939. inertialRadiusOffset: number;
  39940. /**
  39941. * Minimum allowed angle on the longitudinal axis.
  39942. * This can help limiting how the Camera is able to move in the scene.
  39943. */
  39944. lowerAlphaLimit: Nullable<number>;
  39945. /**
  39946. * Maximum allowed angle on the longitudinal axis.
  39947. * This can help limiting how the Camera is able to move in the scene.
  39948. */
  39949. upperAlphaLimit: Nullable<number>;
  39950. /**
  39951. * Minimum allowed angle on the latitudinal axis.
  39952. * This can help limiting how the Camera is able to move in the scene.
  39953. */
  39954. lowerBetaLimit: number;
  39955. /**
  39956. * Maximum allowed angle on the latitudinal axis.
  39957. * This can help limiting how the Camera is able to move in the scene.
  39958. */
  39959. upperBetaLimit: number;
  39960. /**
  39961. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39962. * This can help limiting how the Camera is able to move in the scene.
  39963. */
  39964. lowerRadiusLimit: Nullable<number>;
  39965. /**
  39966. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39967. * This can help limiting how the Camera is able to move in the scene.
  39968. */
  39969. upperRadiusLimit: Nullable<number>;
  39970. /**
  39971. * Defines the current inertia value used during panning of the camera along the X axis.
  39972. */
  39973. inertialPanningX: number;
  39974. /**
  39975. * Defines the current inertia value used during panning of the camera along the Y axis.
  39976. */
  39977. inertialPanningY: number;
  39978. /**
  39979. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39980. * Basically if your fingers moves away from more than this distance you will be considered
  39981. * in pinch mode.
  39982. */
  39983. pinchToPanMaxDistance: number;
  39984. /**
  39985. * Defines the maximum distance the camera can pan.
  39986. * This could help keeping the cammera always in your scene.
  39987. */
  39988. panningDistanceLimit: Nullable<number>;
  39989. /**
  39990. * Defines the target of the camera before paning.
  39991. */
  39992. panningOriginTarget: Vector3;
  39993. /**
  39994. * Defines the value of the inertia used during panning.
  39995. * 0 would mean stop inertia and one would mean no decelleration at all.
  39996. */
  39997. panningInertia: number;
  39998. /**
  39999. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40000. */
  40001. get angularSensibilityX(): number;
  40002. set angularSensibilityX(value: number);
  40003. /**
  40004. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40005. */
  40006. get angularSensibilityY(): number;
  40007. set angularSensibilityY(value: number);
  40008. /**
  40009. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40010. */
  40011. get pinchPrecision(): number;
  40012. set pinchPrecision(value: number);
  40013. /**
  40014. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40015. * It will be used instead of pinchDeltaPrecision if different from 0.
  40016. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40017. */
  40018. get pinchDeltaPercentage(): number;
  40019. set pinchDeltaPercentage(value: number);
  40020. /**
  40021. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40022. * and pinch delta percentage.
  40023. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40024. * that any object in the plane at the camera's target point will scale
  40025. * perfectly with finger motion.
  40026. */
  40027. get useNaturalPinchZoom(): boolean;
  40028. set useNaturalPinchZoom(value: boolean);
  40029. /**
  40030. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40031. */
  40032. get panningSensibility(): number;
  40033. set panningSensibility(value: number);
  40034. /**
  40035. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40036. */
  40037. get keysUp(): number[];
  40038. set keysUp(value: number[]);
  40039. /**
  40040. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40041. */
  40042. get keysDown(): number[];
  40043. set keysDown(value: number[]);
  40044. /**
  40045. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40046. */
  40047. get keysLeft(): number[];
  40048. set keysLeft(value: number[]);
  40049. /**
  40050. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40051. */
  40052. get keysRight(): number[];
  40053. set keysRight(value: number[]);
  40054. /**
  40055. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40056. */
  40057. get wheelPrecision(): number;
  40058. set wheelPrecision(value: number);
  40059. /**
  40060. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40061. * It will be used instead of pinchDeltaPrecision if different from 0.
  40062. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40063. */
  40064. get wheelDeltaPercentage(): number;
  40065. set wheelDeltaPercentage(value: number);
  40066. /**
  40067. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40068. */
  40069. zoomOnFactor: number;
  40070. /**
  40071. * Defines a screen offset for the camera position.
  40072. */
  40073. targetScreenOffset: Vector2;
  40074. /**
  40075. * Allows the camera to be completely reversed.
  40076. * If false the camera can not arrive upside down.
  40077. */
  40078. allowUpsideDown: boolean;
  40079. /**
  40080. * Define if double tap/click is used to restore the previously saved state of the camera.
  40081. */
  40082. useInputToRestoreState: boolean;
  40083. /** @hidden */
  40084. _viewMatrix: Matrix;
  40085. /** @hidden */
  40086. _useCtrlForPanning: boolean;
  40087. /** @hidden */
  40088. _panningMouseButton: number;
  40089. /**
  40090. * Defines the input associated to the camera.
  40091. */
  40092. inputs: ArcRotateCameraInputsManager;
  40093. /** @hidden */
  40094. _reset: () => void;
  40095. /**
  40096. * Defines the allowed panning axis.
  40097. */
  40098. panningAxis: Vector3;
  40099. protected _localDirection: Vector3;
  40100. protected _transformedDirection: Vector3;
  40101. private _bouncingBehavior;
  40102. /**
  40103. * Gets the bouncing behavior of the camera if it has been enabled.
  40104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40105. */
  40106. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40107. /**
  40108. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40109. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40110. */
  40111. get useBouncingBehavior(): boolean;
  40112. set useBouncingBehavior(value: boolean);
  40113. private _framingBehavior;
  40114. /**
  40115. * Gets the framing behavior of the camera if it has been enabled.
  40116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40117. */
  40118. get framingBehavior(): Nullable<FramingBehavior>;
  40119. /**
  40120. * Defines if the framing behavior of the camera is enabled on the camera.
  40121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40122. */
  40123. get useFramingBehavior(): boolean;
  40124. set useFramingBehavior(value: boolean);
  40125. private _autoRotationBehavior;
  40126. /**
  40127. * Gets the auto rotation behavior of the camera if it has been enabled.
  40128. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40129. */
  40130. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40131. /**
  40132. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40134. */
  40135. get useAutoRotationBehavior(): boolean;
  40136. set useAutoRotationBehavior(value: boolean);
  40137. /**
  40138. * Observable triggered when the mesh target has been changed on the camera.
  40139. */
  40140. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40141. /**
  40142. * Event raised when the camera is colliding with a mesh.
  40143. */
  40144. onCollide: (collidedMesh: AbstractMesh) => void;
  40145. /**
  40146. * Defines whether the camera should check collision with the objects oh the scene.
  40147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40148. */
  40149. checkCollisions: boolean;
  40150. /**
  40151. * Defines the collision radius of the camera.
  40152. * This simulates a sphere around the camera.
  40153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40154. */
  40155. collisionRadius: Vector3;
  40156. protected _collider: Collider;
  40157. protected _previousPosition: Vector3;
  40158. protected _collisionVelocity: Vector3;
  40159. protected _newPosition: Vector3;
  40160. protected _previousAlpha: number;
  40161. protected _previousBeta: number;
  40162. protected _previousRadius: number;
  40163. protected _collisionTriggered: boolean;
  40164. protected _targetBoundingCenter: Nullable<Vector3>;
  40165. private _computationVector;
  40166. /**
  40167. * Instantiates a new ArcRotateCamera in a given scene
  40168. * @param name Defines the name of the camera
  40169. * @param alpha Defines the camera rotation along the logitudinal axis
  40170. * @param beta Defines the camera rotation along the latitudinal axis
  40171. * @param radius Defines the camera distance from its target
  40172. * @param target Defines the camera target
  40173. * @param scene Defines the scene the camera belongs to
  40174. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40175. */
  40176. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40177. /** @hidden */
  40178. _initCache(): void;
  40179. /** @hidden */
  40180. _updateCache(ignoreParentClass?: boolean): void;
  40181. protected _getTargetPosition(): Vector3;
  40182. private _storedAlpha;
  40183. private _storedBeta;
  40184. private _storedRadius;
  40185. private _storedTarget;
  40186. private _storedTargetScreenOffset;
  40187. /**
  40188. * Stores the current state of the camera (alpha, beta, radius and target)
  40189. * @returns the camera itself
  40190. */
  40191. storeState(): Camera;
  40192. /**
  40193. * @hidden
  40194. * Restored camera state. You must call storeState() first
  40195. */
  40196. _restoreStateValues(): boolean;
  40197. /** @hidden */
  40198. _isSynchronizedViewMatrix(): boolean;
  40199. /**
  40200. * Attached controls to the current camera.
  40201. * @param element Defines the element the controls should be listened from
  40202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40203. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40204. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40205. */
  40206. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40207. /**
  40208. * Detach the current controls from the camera.
  40209. * The camera will stop reacting to inputs.
  40210. * @param element Defines the element to stop listening the inputs from
  40211. */
  40212. detachControl(element: HTMLElement): void;
  40213. /** @hidden */
  40214. _checkInputs(): void;
  40215. protected _checkLimits(): void;
  40216. /**
  40217. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40218. */
  40219. rebuildAnglesAndRadius(): void;
  40220. /**
  40221. * Use a position to define the current camera related information like alpha, beta and radius
  40222. * @param position Defines the position to set the camera at
  40223. */
  40224. setPosition(position: Vector3): void;
  40225. /**
  40226. * Defines the target the camera should look at.
  40227. * This will automatically adapt alpha beta and radius to fit within the new target.
  40228. * @param target Defines the new target as a Vector or a mesh
  40229. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40230. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40231. */
  40232. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40233. /** @hidden */
  40234. _getViewMatrix(): Matrix;
  40235. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40236. /**
  40237. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40238. * @param meshes Defines the mesh to zoom on
  40239. * @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)
  40240. */
  40241. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40242. /**
  40243. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40244. * The target will be changed but the radius
  40245. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40246. * @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)
  40247. */
  40248. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40249. min: Vector3;
  40250. max: Vector3;
  40251. distance: number;
  40252. }, doNotUpdateMaxZ?: boolean): void;
  40253. /**
  40254. * @override
  40255. * Override Camera.createRigCamera
  40256. */
  40257. createRigCamera(name: string, cameraIndex: number): Camera;
  40258. /**
  40259. * @hidden
  40260. * @override
  40261. * Override Camera._updateRigCameras
  40262. */
  40263. _updateRigCameras(): void;
  40264. /**
  40265. * Destroy the camera and release the current resources hold by it.
  40266. */
  40267. dispose(): void;
  40268. /**
  40269. * Gets the current object class name.
  40270. * @return the class name
  40271. */
  40272. getClassName(): string;
  40273. }
  40274. }
  40275. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40276. import { Behavior } from "babylonjs/Behaviors/behavior";
  40277. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40278. /**
  40279. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40280. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40281. */
  40282. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40283. /**
  40284. * Gets the name of the behavior.
  40285. */
  40286. get name(): string;
  40287. private _zoomStopsAnimation;
  40288. private _idleRotationSpeed;
  40289. private _idleRotationWaitTime;
  40290. private _idleRotationSpinupTime;
  40291. /**
  40292. * Sets the flag that indicates if user zooming should stop animation.
  40293. */
  40294. set zoomStopsAnimation(flag: boolean);
  40295. /**
  40296. * Gets the flag that indicates if user zooming should stop animation.
  40297. */
  40298. get zoomStopsAnimation(): boolean;
  40299. /**
  40300. * Sets the default speed at which the camera rotates around the model.
  40301. */
  40302. set idleRotationSpeed(speed: number);
  40303. /**
  40304. * Gets the default speed at which the camera rotates around the model.
  40305. */
  40306. get idleRotationSpeed(): number;
  40307. /**
  40308. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40309. */
  40310. set idleRotationWaitTime(time: number);
  40311. /**
  40312. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40313. */
  40314. get idleRotationWaitTime(): number;
  40315. /**
  40316. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40317. */
  40318. set idleRotationSpinupTime(time: number);
  40319. /**
  40320. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40321. */
  40322. get idleRotationSpinupTime(): number;
  40323. /**
  40324. * Gets a value indicating if the camera is currently rotating because of this behavior
  40325. */
  40326. get rotationInProgress(): boolean;
  40327. private _onPrePointerObservableObserver;
  40328. private _onAfterCheckInputsObserver;
  40329. private _attachedCamera;
  40330. private _isPointerDown;
  40331. private _lastFrameTime;
  40332. private _lastInteractionTime;
  40333. private _cameraRotationSpeed;
  40334. /**
  40335. * Initializes the behavior.
  40336. */
  40337. init(): void;
  40338. /**
  40339. * Attaches the behavior to its arc rotate camera.
  40340. * @param camera Defines the camera to attach the behavior to
  40341. */
  40342. attach(camera: ArcRotateCamera): void;
  40343. /**
  40344. * Detaches the behavior from its current arc rotate camera.
  40345. */
  40346. detach(): void;
  40347. /**
  40348. * Returns true if user is scrolling.
  40349. * @return true if user is scrolling.
  40350. */
  40351. private _userIsZooming;
  40352. private _lastFrameRadius;
  40353. private _shouldAnimationStopForInteraction;
  40354. /**
  40355. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40356. */
  40357. private _applyUserInteraction;
  40358. private _userIsMoving;
  40359. }
  40360. }
  40361. declare module "babylonjs/Behaviors/Cameras/index" {
  40362. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40363. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40364. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40365. }
  40366. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40367. import { Mesh } from "babylonjs/Meshes/mesh";
  40368. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40369. import { Behavior } from "babylonjs/Behaviors/behavior";
  40370. /**
  40371. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40372. */
  40373. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40374. private ui;
  40375. /**
  40376. * The name of the behavior
  40377. */
  40378. name: string;
  40379. /**
  40380. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40381. */
  40382. distanceAwayFromFace: number;
  40383. /**
  40384. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40385. */
  40386. distanceAwayFromBottomOfFace: number;
  40387. private _faceVectors;
  40388. private _target;
  40389. private _scene;
  40390. private _onRenderObserver;
  40391. private _tmpMatrix;
  40392. private _tmpVector;
  40393. /**
  40394. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40395. * @param ui The transform node that should be attched to the mesh
  40396. */
  40397. constructor(ui: TransformNode);
  40398. /**
  40399. * Initializes the behavior
  40400. */
  40401. init(): void;
  40402. private _closestFace;
  40403. private _zeroVector;
  40404. private _lookAtTmpMatrix;
  40405. private _lookAtToRef;
  40406. /**
  40407. * Attaches the AttachToBoxBehavior to the passed in mesh
  40408. * @param target The mesh that the specified node will be attached to
  40409. */
  40410. attach(target: Mesh): void;
  40411. /**
  40412. * Detaches the behavior from the mesh
  40413. */
  40414. detach(): void;
  40415. }
  40416. }
  40417. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40418. import { Behavior } from "babylonjs/Behaviors/behavior";
  40419. import { Mesh } from "babylonjs/Meshes/mesh";
  40420. /**
  40421. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40422. */
  40423. export class FadeInOutBehavior implements Behavior<Mesh> {
  40424. /**
  40425. * Time in milliseconds to delay before fading in (Default: 0)
  40426. */
  40427. delay: number;
  40428. /**
  40429. * Time in milliseconds for the mesh to fade in (Default: 300)
  40430. */
  40431. fadeInTime: number;
  40432. private _millisecondsPerFrame;
  40433. private _hovered;
  40434. private _hoverValue;
  40435. private _ownerNode;
  40436. /**
  40437. * Instatiates the FadeInOutBehavior
  40438. */
  40439. constructor();
  40440. /**
  40441. * The name of the behavior
  40442. */
  40443. get name(): string;
  40444. /**
  40445. * Initializes the behavior
  40446. */
  40447. init(): void;
  40448. /**
  40449. * Attaches the fade behavior on the passed in mesh
  40450. * @param ownerNode The mesh that will be faded in/out once attached
  40451. */
  40452. attach(ownerNode: Mesh): void;
  40453. /**
  40454. * Detaches the behavior from the mesh
  40455. */
  40456. detach(): void;
  40457. /**
  40458. * Triggers the mesh to begin fading in or out
  40459. * @param value if the object should fade in or out (true to fade in)
  40460. */
  40461. fadeIn(value: boolean): void;
  40462. private _update;
  40463. private _setAllVisibility;
  40464. }
  40465. }
  40466. declare module "babylonjs/Misc/pivotTools" {
  40467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40468. /**
  40469. * Class containing a set of static utilities functions for managing Pivots
  40470. * @hidden
  40471. */
  40472. export class PivotTools {
  40473. private static _PivotCached;
  40474. private static _OldPivotPoint;
  40475. private static _PivotTranslation;
  40476. private static _PivotTmpVector;
  40477. /** @hidden */
  40478. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40479. /** @hidden */
  40480. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40481. }
  40482. }
  40483. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40484. import { Scene } from "babylonjs/scene";
  40485. import { Vector4 } from "babylonjs/Maths/math.vector";
  40486. import { Mesh } from "babylonjs/Meshes/mesh";
  40487. import { Nullable } from "babylonjs/types";
  40488. import { Plane } from "babylonjs/Maths/math.plane";
  40489. /**
  40490. * Class containing static functions to help procedurally build meshes
  40491. */
  40492. export class PlaneBuilder {
  40493. /**
  40494. * Creates a plane mesh
  40495. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40496. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40497. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40501. * @param name defines the name of the mesh
  40502. * @param options defines the options used to create the mesh
  40503. * @param scene defines the hosting scene
  40504. * @returns the plane mesh
  40505. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40506. */
  40507. static CreatePlane(name: string, options: {
  40508. size?: number;
  40509. width?: number;
  40510. height?: number;
  40511. sideOrientation?: number;
  40512. frontUVs?: Vector4;
  40513. backUVs?: Vector4;
  40514. updatable?: boolean;
  40515. sourcePlane?: Plane;
  40516. }, scene?: Nullable<Scene>): Mesh;
  40517. }
  40518. }
  40519. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40520. import { Behavior } from "babylonjs/Behaviors/behavior";
  40521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40522. import { Observable } from "babylonjs/Misc/observable";
  40523. import { Vector3 } from "babylonjs/Maths/math.vector";
  40524. import { Ray } from "babylonjs/Culling/ray";
  40525. import "babylonjs/Meshes/Builders/planeBuilder";
  40526. /**
  40527. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40528. */
  40529. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40530. private static _AnyMouseID;
  40531. /**
  40532. * Abstract mesh the behavior is set on
  40533. */
  40534. attachedNode: AbstractMesh;
  40535. private _dragPlane;
  40536. private _scene;
  40537. private _pointerObserver;
  40538. private _beforeRenderObserver;
  40539. private static _planeScene;
  40540. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40541. /**
  40542. * 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)
  40543. */
  40544. maxDragAngle: number;
  40545. /**
  40546. * @hidden
  40547. */
  40548. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40549. /**
  40550. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40551. */
  40552. currentDraggingPointerID: number;
  40553. /**
  40554. * The last position where the pointer hit the drag plane in world space
  40555. */
  40556. lastDragPosition: Vector3;
  40557. /**
  40558. * If the behavior is currently in a dragging state
  40559. */
  40560. dragging: boolean;
  40561. /**
  40562. * 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)
  40563. */
  40564. dragDeltaRatio: number;
  40565. /**
  40566. * If the drag plane orientation should be updated during the dragging (Default: true)
  40567. */
  40568. updateDragPlane: boolean;
  40569. private _debugMode;
  40570. private _moving;
  40571. /**
  40572. * Fires each time the attached mesh is dragged with the pointer
  40573. * * delta between last drag position and current drag position in world space
  40574. * * dragDistance along the drag axis
  40575. * * dragPlaneNormal normal of the current drag plane used during the drag
  40576. * * dragPlanePoint in world space where the drag intersects the drag plane
  40577. */
  40578. onDragObservable: Observable<{
  40579. delta: Vector3;
  40580. dragPlanePoint: Vector3;
  40581. dragPlaneNormal: Vector3;
  40582. dragDistance: number;
  40583. pointerId: number;
  40584. }>;
  40585. /**
  40586. * Fires each time a drag begins (eg. mouse down on mesh)
  40587. */
  40588. onDragStartObservable: Observable<{
  40589. dragPlanePoint: Vector3;
  40590. pointerId: number;
  40591. }>;
  40592. /**
  40593. * Fires each time a drag ends (eg. mouse release after drag)
  40594. */
  40595. onDragEndObservable: Observable<{
  40596. dragPlanePoint: Vector3;
  40597. pointerId: number;
  40598. }>;
  40599. /**
  40600. * If the attached mesh should be moved when dragged
  40601. */
  40602. moveAttached: boolean;
  40603. /**
  40604. * If the drag behavior will react to drag events (Default: true)
  40605. */
  40606. enabled: boolean;
  40607. /**
  40608. * If pointer events should start and release the drag (Default: true)
  40609. */
  40610. startAndReleaseDragOnPointerEvents: boolean;
  40611. /**
  40612. * If camera controls should be detached during the drag
  40613. */
  40614. detachCameraControls: boolean;
  40615. /**
  40616. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40617. */
  40618. useObjectOrientationForDragging: boolean;
  40619. private _options;
  40620. /**
  40621. * Gets the options used by the behavior
  40622. */
  40623. get options(): {
  40624. dragAxis?: Vector3;
  40625. dragPlaneNormal?: Vector3;
  40626. };
  40627. /**
  40628. * Sets the options used by the behavior
  40629. */
  40630. set options(options: {
  40631. dragAxis?: Vector3;
  40632. dragPlaneNormal?: Vector3;
  40633. });
  40634. /**
  40635. * Creates a pointer drag behavior that can be attached to a mesh
  40636. * @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)
  40637. */
  40638. constructor(options?: {
  40639. dragAxis?: Vector3;
  40640. dragPlaneNormal?: Vector3;
  40641. });
  40642. /**
  40643. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40644. */
  40645. validateDrag: (targetPosition: Vector3) => boolean;
  40646. /**
  40647. * The name of the behavior
  40648. */
  40649. get name(): string;
  40650. /**
  40651. * Initializes the behavior
  40652. */
  40653. init(): void;
  40654. private _tmpVector;
  40655. private _alternatePickedPoint;
  40656. private _worldDragAxis;
  40657. private _targetPosition;
  40658. private _attachedElement;
  40659. /**
  40660. * Attaches the drag behavior the passed in mesh
  40661. * @param ownerNode The mesh that will be dragged around once attached
  40662. * @param predicate Predicate to use for pick filtering
  40663. */
  40664. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40665. /**
  40666. * Force relase the drag action by code.
  40667. */
  40668. releaseDrag(): void;
  40669. private _startDragRay;
  40670. private _lastPointerRay;
  40671. /**
  40672. * Simulates the start of a pointer drag event on the behavior
  40673. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40674. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40675. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40676. */
  40677. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40678. private _startDrag;
  40679. private _dragDelta;
  40680. private _moveDrag;
  40681. private _pickWithRayOnDragPlane;
  40682. private _pointA;
  40683. private _pointB;
  40684. private _pointC;
  40685. private _lineA;
  40686. private _lineB;
  40687. private _localAxis;
  40688. private _lookAt;
  40689. private _updateDragPlanePosition;
  40690. /**
  40691. * Detaches the behavior from the mesh
  40692. */
  40693. detach(): void;
  40694. }
  40695. }
  40696. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40697. import { Mesh } from "babylonjs/Meshes/mesh";
  40698. import { Behavior } from "babylonjs/Behaviors/behavior";
  40699. /**
  40700. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40701. */
  40702. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40703. private _dragBehaviorA;
  40704. private _dragBehaviorB;
  40705. private _startDistance;
  40706. private _initialScale;
  40707. private _targetScale;
  40708. private _ownerNode;
  40709. private _sceneRenderObserver;
  40710. /**
  40711. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40712. */
  40713. constructor();
  40714. /**
  40715. * The name of the behavior
  40716. */
  40717. get name(): string;
  40718. /**
  40719. * Initializes the behavior
  40720. */
  40721. init(): void;
  40722. private _getCurrentDistance;
  40723. /**
  40724. * Attaches the scale behavior the passed in mesh
  40725. * @param ownerNode The mesh that will be scaled around once attached
  40726. */
  40727. attach(ownerNode: Mesh): void;
  40728. /**
  40729. * Detaches the behavior from the mesh
  40730. */
  40731. detach(): void;
  40732. }
  40733. }
  40734. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40735. import { Behavior } from "babylonjs/Behaviors/behavior";
  40736. import { Mesh } from "babylonjs/Meshes/mesh";
  40737. import { Observable } from "babylonjs/Misc/observable";
  40738. /**
  40739. * 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
  40740. */
  40741. export class SixDofDragBehavior implements Behavior<Mesh> {
  40742. private static _virtualScene;
  40743. private _ownerNode;
  40744. private _sceneRenderObserver;
  40745. private _scene;
  40746. private _targetPosition;
  40747. private _virtualOriginMesh;
  40748. private _virtualDragMesh;
  40749. private _pointerObserver;
  40750. private _moving;
  40751. private _startingOrientation;
  40752. /**
  40753. * 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)
  40754. */
  40755. private zDragFactor;
  40756. /**
  40757. * If the object should rotate to face the drag origin
  40758. */
  40759. rotateDraggedObject: boolean;
  40760. /**
  40761. * If the behavior is currently in a dragging state
  40762. */
  40763. dragging: boolean;
  40764. /**
  40765. * 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)
  40766. */
  40767. dragDeltaRatio: number;
  40768. /**
  40769. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40770. */
  40771. currentDraggingPointerID: number;
  40772. /**
  40773. * If camera controls should be detached during the drag
  40774. */
  40775. detachCameraControls: boolean;
  40776. /**
  40777. * Fires each time a drag starts
  40778. */
  40779. onDragStartObservable: Observable<{}>;
  40780. /**
  40781. * Fires each time a drag ends (eg. mouse release after drag)
  40782. */
  40783. onDragEndObservable: Observable<{}>;
  40784. /**
  40785. * 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
  40786. */
  40787. constructor();
  40788. /**
  40789. * The name of the behavior
  40790. */
  40791. get name(): string;
  40792. /**
  40793. * Initializes the behavior
  40794. */
  40795. init(): void;
  40796. /**
  40797. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40798. */
  40799. private get _pointerCamera();
  40800. /**
  40801. * Attaches the scale behavior the passed in mesh
  40802. * @param ownerNode The mesh that will be scaled around once attached
  40803. */
  40804. attach(ownerNode: Mesh): void;
  40805. /**
  40806. * Detaches the behavior from the mesh
  40807. */
  40808. detach(): void;
  40809. }
  40810. }
  40811. declare module "babylonjs/Behaviors/Meshes/index" {
  40812. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40813. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40814. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40815. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40816. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40817. }
  40818. declare module "babylonjs/Behaviors/index" {
  40819. export * from "babylonjs/Behaviors/behavior";
  40820. export * from "babylonjs/Behaviors/Cameras/index";
  40821. export * from "babylonjs/Behaviors/Meshes/index";
  40822. }
  40823. declare module "babylonjs/Bones/boneIKController" {
  40824. import { Bone } from "babylonjs/Bones/bone";
  40825. import { Vector3 } from "babylonjs/Maths/math.vector";
  40826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40827. import { Nullable } from "babylonjs/types";
  40828. /**
  40829. * Class used to apply inverse kinematics to bones
  40830. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40831. */
  40832. export class BoneIKController {
  40833. private static _tmpVecs;
  40834. private static _tmpQuat;
  40835. private static _tmpMats;
  40836. /**
  40837. * Gets or sets the target mesh
  40838. */
  40839. targetMesh: AbstractMesh;
  40840. /** Gets or sets the mesh used as pole */
  40841. poleTargetMesh: AbstractMesh;
  40842. /**
  40843. * Gets or sets the bone used as pole
  40844. */
  40845. poleTargetBone: Nullable<Bone>;
  40846. /**
  40847. * Gets or sets the target position
  40848. */
  40849. targetPosition: Vector3;
  40850. /**
  40851. * Gets or sets the pole target position
  40852. */
  40853. poleTargetPosition: Vector3;
  40854. /**
  40855. * Gets or sets the pole target local offset
  40856. */
  40857. poleTargetLocalOffset: Vector3;
  40858. /**
  40859. * Gets or sets the pole angle
  40860. */
  40861. poleAngle: number;
  40862. /**
  40863. * Gets or sets the mesh associated with the controller
  40864. */
  40865. mesh: AbstractMesh;
  40866. /**
  40867. * 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)
  40868. */
  40869. slerpAmount: number;
  40870. private _bone1Quat;
  40871. private _bone1Mat;
  40872. private _bone2Ang;
  40873. private _bone1;
  40874. private _bone2;
  40875. private _bone1Length;
  40876. private _bone2Length;
  40877. private _maxAngle;
  40878. private _maxReach;
  40879. private _rightHandedSystem;
  40880. private _bendAxis;
  40881. private _slerping;
  40882. private _adjustRoll;
  40883. /**
  40884. * Gets or sets maximum allowed angle
  40885. */
  40886. get maxAngle(): number;
  40887. set maxAngle(value: number);
  40888. /**
  40889. * Creates a new BoneIKController
  40890. * @param mesh defines the mesh to control
  40891. * @param bone defines the bone to control
  40892. * @param options defines options to set up the controller
  40893. */
  40894. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40895. targetMesh?: AbstractMesh;
  40896. poleTargetMesh?: AbstractMesh;
  40897. poleTargetBone?: Bone;
  40898. poleTargetLocalOffset?: Vector3;
  40899. poleAngle?: number;
  40900. bendAxis?: Vector3;
  40901. maxAngle?: number;
  40902. slerpAmount?: number;
  40903. });
  40904. private _setMaxAngle;
  40905. /**
  40906. * Force the controller to update the bones
  40907. */
  40908. update(): void;
  40909. }
  40910. }
  40911. declare module "babylonjs/Bones/boneLookController" {
  40912. import { Vector3 } from "babylonjs/Maths/math.vector";
  40913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40914. import { Bone } from "babylonjs/Bones/bone";
  40915. import { Space } from "babylonjs/Maths/math.axis";
  40916. /**
  40917. * Class used to make a bone look toward a point in space
  40918. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40919. */
  40920. export class BoneLookController {
  40921. private static _tmpVecs;
  40922. private static _tmpQuat;
  40923. private static _tmpMats;
  40924. /**
  40925. * The target Vector3 that the bone will look at
  40926. */
  40927. target: Vector3;
  40928. /**
  40929. * The mesh that the bone is attached to
  40930. */
  40931. mesh: AbstractMesh;
  40932. /**
  40933. * The bone that will be looking to the target
  40934. */
  40935. bone: Bone;
  40936. /**
  40937. * The up axis of the coordinate system that is used when the bone is rotated
  40938. */
  40939. upAxis: Vector3;
  40940. /**
  40941. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40942. */
  40943. upAxisSpace: Space;
  40944. /**
  40945. * Used to make an adjustment to the yaw of the bone
  40946. */
  40947. adjustYaw: number;
  40948. /**
  40949. * Used to make an adjustment to the pitch of the bone
  40950. */
  40951. adjustPitch: number;
  40952. /**
  40953. * Used to make an adjustment to the roll of the bone
  40954. */
  40955. adjustRoll: number;
  40956. /**
  40957. * 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)
  40958. */
  40959. slerpAmount: number;
  40960. private _minYaw;
  40961. private _maxYaw;
  40962. private _minPitch;
  40963. private _maxPitch;
  40964. private _minYawSin;
  40965. private _minYawCos;
  40966. private _maxYawSin;
  40967. private _maxYawCos;
  40968. private _midYawConstraint;
  40969. private _minPitchTan;
  40970. private _maxPitchTan;
  40971. private _boneQuat;
  40972. private _slerping;
  40973. private _transformYawPitch;
  40974. private _transformYawPitchInv;
  40975. private _firstFrameSkipped;
  40976. private _yawRange;
  40977. private _fowardAxis;
  40978. /**
  40979. * Gets or sets the minimum yaw angle that the bone can look to
  40980. */
  40981. get minYaw(): number;
  40982. set minYaw(value: number);
  40983. /**
  40984. * Gets or sets the maximum yaw angle that the bone can look to
  40985. */
  40986. get maxYaw(): number;
  40987. set maxYaw(value: number);
  40988. /**
  40989. * Gets or sets the minimum pitch angle that the bone can look to
  40990. */
  40991. get minPitch(): number;
  40992. set minPitch(value: number);
  40993. /**
  40994. * Gets or sets the maximum pitch angle that the bone can look to
  40995. */
  40996. get maxPitch(): number;
  40997. set maxPitch(value: number);
  40998. /**
  40999. * Create a BoneLookController
  41000. * @param mesh the mesh that the bone belongs to
  41001. * @param bone the bone that will be looking to the target
  41002. * @param target the target Vector3 to look at
  41003. * @param options optional settings:
  41004. * * maxYaw: the maximum angle the bone will yaw to
  41005. * * minYaw: the minimum angle the bone will yaw to
  41006. * * maxPitch: the maximum angle the bone will pitch to
  41007. * * minPitch: the minimum angle the bone will yaw to
  41008. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41009. * * upAxis: the up axis of the coordinate system
  41010. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41011. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41012. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41013. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41014. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41015. * * adjustRoll: used to make an adjustment to the roll of the bone
  41016. **/
  41017. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41018. maxYaw?: number;
  41019. minYaw?: number;
  41020. maxPitch?: number;
  41021. minPitch?: number;
  41022. slerpAmount?: number;
  41023. upAxis?: Vector3;
  41024. upAxisSpace?: Space;
  41025. yawAxis?: Vector3;
  41026. pitchAxis?: Vector3;
  41027. adjustYaw?: number;
  41028. adjustPitch?: number;
  41029. adjustRoll?: number;
  41030. });
  41031. /**
  41032. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41033. */
  41034. update(): void;
  41035. private _getAngleDiff;
  41036. private _getAngleBetween;
  41037. private _isAngleBetween;
  41038. }
  41039. }
  41040. declare module "babylonjs/Bones/index" {
  41041. export * from "babylonjs/Bones/bone";
  41042. export * from "babylonjs/Bones/boneIKController";
  41043. export * from "babylonjs/Bones/boneLookController";
  41044. export * from "babylonjs/Bones/skeleton";
  41045. }
  41046. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41047. import { Nullable } from "babylonjs/types";
  41048. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41050. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41051. /**
  41052. * Manage the gamepad inputs to control an arc rotate camera.
  41053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41054. */
  41055. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41056. /**
  41057. * Defines the camera the input is attached to.
  41058. */
  41059. camera: ArcRotateCamera;
  41060. /**
  41061. * Defines the gamepad the input is gathering event from.
  41062. */
  41063. gamepad: Nullable<Gamepad>;
  41064. /**
  41065. * Defines the gamepad rotation sensiblity.
  41066. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41067. */
  41068. gamepadRotationSensibility: number;
  41069. /**
  41070. * Defines the gamepad move sensiblity.
  41071. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41072. */
  41073. gamepadMoveSensibility: number;
  41074. private _yAxisScale;
  41075. /**
  41076. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41077. */
  41078. get invertYAxis(): boolean;
  41079. set invertYAxis(value: boolean);
  41080. private _onGamepadConnectedObserver;
  41081. private _onGamepadDisconnectedObserver;
  41082. /**
  41083. * Attach the input controls to a specific dom element to get the input from.
  41084. * @param element Defines the element the controls should be listened from
  41085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41086. */
  41087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41088. /**
  41089. * Detach the current controls from the specified dom element.
  41090. * @param element Defines the element to stop listening the inputs from
  41091. */
  41092. detachControl(element: Nullable<HTMLElement>): void;
  41093. /**
  41094. * Update the current camera state depending on the inputs that have been used this frame.
  41095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41096. */
  41097. checkInputs(): void;
  41098. /**
  41099. * Gets the class name of the current intput.
  41100. * @returns the class name
  41101. */
  41102. getClassName(): string;
  41103. /**
  41104. * Get the friendly name associated with the input class.
  41105. * @returns the input friendly name
  41106. */
  41107. getSimpleName(): string;
  41108. }
  41109. }
  41110. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41111. import { Nullable } from "babylonjs/types";
  41112. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41113. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41114. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41115. interface ArcRotateCameraInputsManager {
  41116. /**
  41117. * Add orientation input support to the input manager.
  41118. * @returns the current input manager
  41119. */
  41120. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41121. }
  41122. }
  41123. /**
  41124. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41126. */
  41127. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41128. /**
  41129. * Defines the camera the input is attached to.
  41130. */
  41131. camera: ArcRotateCamera;
  41132. /**
  41133. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41134. */
  41135. alphaCorrection: number;
  41136. /**
  41137. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41138. */
  41139. gammaCorrection: number;
  41140. private _alpha;
  41141. private _gamma;
  41142. private _dirty;
  41143. private _deviceOrientationHandler;
  41144. /**
  41145. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41146. */
  41147. constructor();
  41148. /**
  41149. * Attach the input controls to a specific dom element to get the input from.
  41150. * @param element Defines the element the controls should be listened from
  41151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41152. */
  41153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41154. /** @hidden */
  41155. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41156. /**
  41157. * Update the current camera state depending on the inputs that have been used this frame.
  41158. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41159. */
  41160. checkInputs(): void;
  41161. /**
  41162. * Detach the current controls from the specified dom element.
  41163. * @param element Defines the element to stop listening the inputs from
  41164. */
  41165. detachControl(element: Nullable<HTMLElement>): void;
  41166. /**
  41167. * Gets the class name of the current intput.
  41168. * @returns the class name
  41169. */
  41170. getClassName(): string;
  41171. /**
  41172. * Get the friendly name associated with the input class.
  41173. * @returns the input friendly name
  41174. */
  41175. getSimpleName(): string;
  41176. }
  41177. }
  41178. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41179. import { Nullable } from "babylonjs/types";
  41180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41181. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41182. /**
  41183. * Listen to mouse events to control the camera.
  41184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41185. */
  41186. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41187. /**
  41188. * Defines the camera the input is attached to.
  41189. */
  41190. camera: FlyCamera;
  41191. /**
  41192. * Defines if touch is enabled. (Default is true.)
  41193. */
  41194. touchEnabled: boolean;
  41195. /**
  41196. * Defines the buttons associated with the input to handle camera rotation.
  41197. */
  41198. buttons: number[];
  41199. /**
  41200. * Assign buttons for Yaw control.
  41201. */
  41202. buttonsYaw: number[];
  41203. /**
  41204. * Assign buttons for Pitch control.
  41205. */
  41206. buttonsPitch: number[];
  41207. /**
  41208. * Assign buttons for Roll control.
  41209. */
  41210. buttonsRoll: number[];
  41211. /**
  41212. * Detect if any button is being pressed while mouse is moved.
  41213. * -1 = Mouse locked.
  41214. * 0 = Left button.
  41215. * 1 = Middle Button.
  41216. * 2 = Right Button.
  41217. */
  41218. activeButton: number;
  41219. /**
  41220. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41221. * Higher values reduce its sensitivity.
  41222. */
  41223. angularSensibility: number;
  41224. private _mousemoveCallback;
  41225. private _observer;
  41226. private _rollObserver;
  41227. private previousPosition;
  41228. private noPreventDefault;
  41229. private element;
  41230. /**
  41231. * Listen to mouse events to control the camera.
  41232. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41234. */
  41235. constructor(touchEnabled?: boolean);
  41236. /**
  41237. * Attach the mouse control to the HTML DOM element.
  41238. * @param element Defines the element that listens to the input events.
  41239. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41240. */
  41241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41242. /**
  41243. * Detach the current controls from the specified dom element.
  41244. * @param element Defines the element to stop listening the inputs from
  41245. */
  41246. detachControl(element: Nullable<HTMLElement>): void;
  41247. /**
  41248. * Gets the class name of the current input.
  41249. * @returns the class name.
  41250. */
  41251. getClassName(): string;
  41252. /**
  41253. * Get the friendly name associated with the input class.
  41254. * @returns the input's friendly name.
  41255. */
  41256. getSimpleName(): string;
  41257. private _pointerInput;
  41258. private _onMouseMove;
  41259. /**
  41260. * Rotate camera by mouse offset.
  41261. */
  41262. private rotateCamera;
  41263. }
  41264. }
  41265. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41266. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41267. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41268. /**
  41269. * Default Inputs manager for the FlyCamera.
  41270. * It groups all the default supported inputs for ease of use.
  41271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41272. */
  41273. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41274. /**
  41275. * Instantiates a new FlyCameraInputsManager.
  41276. * @param camera Defines the camera the inputs belong to.
  41277. */
  41278. constructor(camera: FlyCamera);
  41279. /**
  41280. * Add keyboard input support to the input manager.
  41281. * @returns the new FlyCameraKeyboardMoveInput().
  41282. */
  41283. addKeyboard(): FlyCameraInputsManager;
  41284. /**
  41285. * Add mouse input support to the input manager.
  41286. * @param touchEnabled Enable touch screen support.
  41287. * @returns the new FlyCameraMouseInput().
  41288. */
  41289. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41290. }
  41291. }
  41292. declare module "babylonjs/Cameras/flyCamera" {
  41293. import { Scene } from "babylonjs/scene";
  41294. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41296. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41297. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41298. /**
  41299. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41300. * such as in a 3D Space Shooter or a Flight Simulator.
  41301. */
  41302. export class FlyCamera extends TargetCamera {
  41303. /**
  41304. * Define the collision ellipsoid of the camera.
  41305. * This is helpful for simulating a camera body, like a player's body.
  41306. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41307. */
  41308. ellipsoid: Vector3;
  41309. /**
  41310. * Define an offset for the position of the ellipsoid around the camera.
  41311. * This can be helpful if the camera is attached away from the player's body center,
  41312. * such as at its head.
  41313. */
  41314. ellipsoidOffset: Vector3;
  41315. /**
  41316. * Enable or disable collisions of the camera with the rest of the scene objects.
  41317. */
  41318. checkCollisions: boolean;
  41319. /**
  41320. * Enable or disable gravity on the camera.
  41321. */
  41322. applyGravity: boolean;
  41323. /**
  41324. * Define the current direction the camera is moving to.
  41325. */
  41326. cameraDirection: Vector3;
  41327. /**
  41328. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41329. * This overrides and empties cameraRotation.
  41330. */
  41331. rotationQuaternion: Quaternion;
  41332. /**
  41333. * Track Roll to maintain the wanted Rolling when looking around.
  41334. */
  41335. _trackRoll: number;
  41336. /**
  41337. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41338. */
  41339. rollCorrect: number;
  41340. /**
  41341. * Mimic a banked turn, Rolling the camera when Yawing.
  41342. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41343. */
  41344. bankedTurn: boolean;
  41345. /**
  41346. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41347. */
  41348. bankedTurnLimit: number;
  41349. /**
  41350. * Value of 0 disables the banked Roll.
  41351. * Value of 1 is equal to the Yaw angle in radians.
  41352. */
  41353. bankedTurnMultiplier: number;
  41354. /**
  41355. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41356. */
  41357. inputs: FlyCameraInputsManager;
  41358. /**
  41359. * Gets the input sensibility for mouse input.
  41360. * Higher values reduce sensitivity.
  41361. */
  41362. get angularSensibility(): number;
  41363. /**
  41364. * Sets the input sensibility for a mouse input.
  41365. * Higher values reduce sensitivity.
  41366. */
  41367. set angularSensibility(value: number);
  41368. /**
  41369. * Get the keys for camera movement forward.
  41370. */
  41371. get keysForward(): number[];
  41372. /**
  41373. * Set the keys for camera movement forward.
  41374. */
  41375. set keysForward(value: number[]);
  41376. /**
  41377. * Get the keys for camera movement backward.
  41378. */
  41379. get keysBackward(): number[];
  41380. set keysBackward(value: number[]);
  41381. /**
  41382. * Get the keys for camera movement up.
  41383. */
  41384. get keysUp(): number[];
  41385. /**
  41386. * Set the keys for camera movement up.
  41387. */
  41388. set keysUp(value: number[]);
  41389. /**
  41390. * Get the keys for camera movement down.
  41391. */
  41392. get keysDown(): number[];
  41393. /**
  41394. * Set the keys for camera movement down.
  41395. */
  41396. set keysDown(value: number[]);
  41397. /**
  41398. * Get the keys for camera movement left.
  41399. */
  41400. get keysLeft(): number[];
  41401. /**
  41402. * Set the keys for camera movement left.
  41403. */
  41404. set keysLeft(value: number[]);
  41405. /**
  41406. * Set the keys for camera movement right.
  41407. */
  41408. get keysRight(): number[];
  41409. /**
  41410. * Set the keys for camera movement right.
  41411. */
  41412. set keysRight(value: number[]);
  41413. /**
  41414. * Event raised when the camera collides with a mesh in the scene.
  41415. */
  41416. onCollide: (collidedMesh: AbstractMesh) => void;
  41417. private _collider;
  41418. private _needMoveForGravity;
  41419. private _oldPosition;
  41420. private _diffPosition;
  41421. private _newPosition;
  41422. /** @hidden */
  41423. _localDirection: Vector3;
  41424. /** @hidden */
  41425. _transformedDirection: Vector3;
  41426. /**
  41427. * Instantiates a FlyCamera.
  41428. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41429. * such as in a 3D Space Shooter or a Flight Simulator.
  41430. * @param name Define the name of the camera in the scene.
  41431. * @param position Define the starting position of the camera in the scene.
  41432. * @param scene Define the scene the camera belongs to.
  41433. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41434. */
  41435. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41436. /**
  41437. * Attach a control to the HTML DOM element.
  41438. * @param element Defines the element that listens to the input events.
  41439. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41440. */
  41441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41442. /**
  41443. * Detach a control from the HTML DOM element.
  41444. * The camera will stop reacting to that input.
  41445. * @param element Defines the element that listens to the input events.
  41446. */
  41447. detachControl(element: HTMLElement): void;
  41448. private _collisionMask;
  41449. /**
  41450. * Get the mask that the camera ignores in collision events.
  41451. */
  41452. get collisionMask(): number;
  41453. /**
  41454. * Set the mask that the camera ignores in collision events.
  41455. */
  41456. set collisionMask(mask: number);
  41457. /** @hidden */
  41458. _collideWithWorld(displacement: Vector3): void;
  41459. /** @hidden */
  41460. private _onCollisionPositionChange;
  41461. /** @hidden */
  41462. _checkInputs(): void;
  41463. /** @hidden */
  41464. _decideIfNeedsToMove(): boolean;
  41465. /** @hidden */
  41466. _updatePosition(): void;
  41467. /**
  41468. * Restore the Roll to its target value at the rate specified.
  41469. * @param rate - Higher means slower restoring.
  41470. * @hidden
  41471. */
  41472. restoreRoll(rate: number): void;
  41473. /**
  41474. * Destroy the camera and release the current resources held by it.
  41475. */
  41476. dispose(): void;
  41477. /**
  41478. * Get the current object class name.
  41479. * @returns the class name.
  41480. */
  41481. getClassName(): string;
  41482. }
  41483. }
  41484. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41485. import { Nullable } from "babylonjs/types";
  41486. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41487. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41488. /**
  41489. * Listen to keyboard events to control the camera.
  41490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41491. */
  41492. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41493. /**
  41494. * Defines the camera the input is attached to.
  41495. */
  41496. camera: FlyCamera;
  41497. /**
  41498. * The list of keyboard keys used to control the forward move of the camera.
  41499. */
  41500. keysForward: number[];
  41501. /**
  41502. * The list of keyboard keys used to control the backward move of the camera.
  41503. */
  41504. keysBackward: number[];
  41505. /**
  41506. * The list of keyboard keys used to control the forward move of the camera.
  41507. */
  41508. keysUp: number[];
  41509. /**
  41510. * The list of keyboard keys used to control the backward move of the camera.
  41511. */
  41512. keysDown: number[];
  41513. /**
  41514. * The list of keyboard keys used to control the right strafe move of the camera.
  41515. */
  41516. keysRight: number[];
  41517. /**
  41518. * The list of keyboard keys used to control the left strafe move of the camera.
  41519. */
  41520. keysLeft: number[];
  41521. private _keys;
  41522. private _onCanvasBlurObserver;
  41523. private _onKeyboardObserver;
  41524. private _engine;
  41525. private _scene;
  41526. /**
  41527. * Attach the input controls to a specific dom element to get the input from.
  41528. * @param element Defines the element the controls should be listened from
  41529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41530. */
  41531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41532. /**
  41533. * Detach the current controls from the specified dom element.
  41534. * @param element Defines the element to stop listening the inputs from
  41535. */
  41536. detachControl(element: Nullable<HTMLElement>): void;
  41537. /**
  41538. * Gets the class name of the current intput.
  41539. * @returns the class name
  41540. */
  41541. getClassName(): string;
  41542. /** @hidden */
  41543. _onLostFocus(e: FocusEvent): void;
  41544. /**
  41545. * Get the friendly name associated with the input class.
  41546. * @returns the input friendly name
  41547. */
  41548. getSimpleName(): string;
  41549. /**
  41550. * Update the current camera state depending on the inputs that have been used this frame.
  41551. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41552. */
  41553. checkInputs(): void;
  41554. }
  41555. }
  41556. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41557. import { Nullable } from "babylonjs/types";
  41558. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41559. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41560. /**
  41561. * Manage the mouse wheel inputs to control a follow camera.
  41562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41563. */
  41564. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41565. /**
  41566. * Defines the camera the input is attached to.
  41567. */
  41568. camera: FollowCamera;
  41569. /**
  41570. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41571. */
  41572. axisControlRadius: boolean;
  41573. /**
  41574. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41575. */
  41576. axisControlHeight: boolean;
  41577. /**
  41578. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41579. */
  41580. axisControlRotation: boolean;
  41581. /**
  41582. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41583. * relation to mouseWheel events.
  41584. */
  41585. wheelPrecision: number;
  41586. /**
  41587. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41588. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41589. */
  41590. wheelDeltaPercentage: number;
  41591. private _wheel;
  41592. private _observer;
  41593. /**
  41594. * Attach the input controls to a specific dom element to get the input from.
  41595. * @param element Defines the element the controls should be listened from
  41596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41597. */
  41598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41599. /**
  41600. * Detach the current controls from the specified dom element.
  41601. * @param element Defines the element to stop listening the inputs from
  41602. */
  41603. detachControl(element: Nullable<HTMLElement>): void;
  41604. /**
  41605. * Gets the class name of the current intput.
  41606. * @returns the class name
  41607. */
  41608. getClassName(): string;
  41609. /**
  41610. * Get the friendly name associated with the input class.
  41611. * @returns the input friendly name
  41612. */
  41613. getSimpleName(): string;
  41614. }
  41615. }
  41616. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41617. import { Nullable } from "babylonjs/types";
  41618. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41619. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41620. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41621. /**
  41622. * Manage the pointers inputs to control an follow camera.
  41623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41624. */
  41625. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41626. /**
  41627. * Defines the camera the input is attached to.
  41628. */
  41629. camera: FollowCamera;
  41630. /**
  41631. * Gets the class name of the current input.
  41632. * @returns the class name
  41633. */
  41634. getClassName(): string;
  41635. /**
  41636. * Defines the pointer angular sensibility along the X axis or how fast is
  41637. * the camera rotating.
  41638. * A negative number will reverse the axis direction.
  41639. */
  41640. angularSensibilityX: number;
  41641. /**
  41642. * Defines the pointer angular sensibility along the Y axis or how fast is
  41643. * the camera rotating.
  41644. * A negative number will reverse the axis direction.
  41645. */
  41646. angularSensibilityY: number;
  41647. /**
  41648. * Defines the pointer pinch precision or how fast is the camera zooming.
  41649. * A negative number will reverse the axis direction.
  41650. */
  41651. pinchPrecision: number;
  41652. /**
  41653. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41654. * from 0.
  41655. * It defines the percentage of current camera.radius to use as delta when
  41656. * pinch zoom is used.
  41657. */
  41658. pinchDeltaPercentage: number;
  41659. /**
  41660. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41661. */
  41662. axisXControlRadius: boolean;
  41663. /**
  41664. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41665. */
  41666. axisXControlHeight: boolean;
  41667. /**
  41668. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41669. */
  41670. axisXControlRotation: boolean;
  41671. /**
  41672. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41673. */
  41674. axisYControlRadius: boolean;
  41675. /**
  41676. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41677. */
  41678. axisYControlHeight: boolean;
  41679. /**
  41680. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41681. */
  41682. axisYControlRotation: boolean;
  41683. /**
  41684. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41685. */
  41686. axisPinchControlRadius: boolean;
  41687. /**
  41688. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41689. */
  41690. axisPinchControlHeight: boolean;
  41691. /**
  41692. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41693. */
  41694. axisPinchControlRotation: boolean;
  41695. /**
  41696. * Log error messages if basic misconfiguration has occurred.
  41697. */
  41698. warningEnable: boolean;
  41699. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41700. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41701. private _warningCounter;
  41702. private _warning;
  41703. }
  41704. }
  41705. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41706. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41707. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41708. /**
  41709. * Default Inputs manager for the FollowCamera.
  41710. * It groups all the default supported inputs for ease of use.
  41711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41712. */
  41713. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41714. /**
  41715. * Instantiates a new FollowCameraInputsManager.
  41716. * @param camera Defines the camera the inputs belong to
  41717. */
  41718. constructor(camera: FollowCamera);
  41719. /**
  41720. * Add keyboard input support to the input manager.
  41721. * @returns the current input manager
  41722. */
  41723. addKeyboard(): FollowCameraInputsManager;
  41724. /**
  41725. * Add mouse wheel input support to the input manager.
  41726. * @returns the current input manager
  41727. */
  41728. addMouseWheel(): FollowCameraInputsManager;
  41729. /**
  41730. * Add pointers input support to the input manager.
  41731. * @returns the current input manager
  41732. */
  41733. addPointers(): FollowCameraInputsManager;
  41734. /**
  41735. * Add orientation input support to the input manager.
  41736. * @returns the current input manager
  41737. */
  41738. addVRDeviceOrientation(): FollowCameraInputsManager;
  41739. }
  41740. }
  41741. declare module "babylonjs/Cameras/followCamera" {
  41742. import { Nullable } from "babylonjs/types";
  41743. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41744. import { Scene } from "babylonjs/scene";
  41745. import { Vector3 } from "babylonjs/Maths/math.vector";
  41746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41747. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41748. /**
  41749. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41750. * an arc rotate version arcFollowCamera are available.
  41751. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41752. */
  41753. export class FollowCamera extends TargetCamera {
  41754. /**
  41755. * Distance the follow camera should follow an object at
  41756. */
  41757. radius: number;
  41758. /**
  41759. * Minimum allowed distance of the camera to the axis of rotation
  41760. * (The camera can not get closer).
  41761. * This can help limiting how the Camera is able to move in the scene.
  41762. */
  41763. lowerRadiusLimit: Nullable<number>;
  41764. /**
  41765. * Maximum allowed distance of the camera to the axis of rotation
  41766. * (The camera can not get further).
  41767. * This can help limiting how the Camera is able to move in the scene.
  41768. */
  41769. upperRadiusLimit: Nullable<number>;
  41770. /**
  41771. * Define a rotation offset between the camera and the object it follows
  41772. */
  41773. rotationOffset: number;
  41774. /**
  41775. * Minimum allowed angle to camera position relative to target object.
  41776. * This can help limiting how the Camera is able to move in the scene.
  41777. */
  41778. lowerRotationOffsetLimit: Nullable<number>;
  41779. /**
  41780. * Maximum allowed angle to camera position relative to target object.
  41781. * This can help limiting how the Camera is able to move in the scene.
  41782. */
  41783. upperRotationOffsetLimit: Nullable<number>;
  41784. /**
  41785. * Define a height offset between the camera and the object it follows.
  41786. * It can help following an object from the top (like a car chaing a plane)
  41787. */
  41788. heightOffset: number;
  41789. /**
  41790. * Minimum allowed height of camera position relative to target object.
  41791. * This can help limiting how the Camera is able to move in the scene.
  41792. */
  41793. lowerHeightOffsetLimit: Nullable<number>;
  41794. /**
  41795. * Maximum allowed height of camera position relative to target object.
  41796. * This can help limiting how the Camera is able to move in the scene.
  41797. */
  41798. upperHeightOffsetLimit: Nullable<number>;
  41799. /**
  41800. * Define how fast the camera can accelerate to follow it s target.
  41801. */
  41802. cameraAcceleration: number;
  41803. /**
  41804. * Define the speed limit of the camera following an object.
  41805. */
  41806. maxCameraSpeed: number;
  41807. /**
  41808. * Define the target of the camera.
  41809. */
  41810. lockedTarget: Nullable<AbstractMesh>;
  41811. /**
  41812. * Defines the input associated with the camera.
  41813. */
  41814. inputs: FollowCameraInputsManager;
  41815. /**
  41816. * Instantiates the follow camera.
  41817. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41818. * @param name Define the name of the camera in the scene
  41819. * @param position Define the position of the camera
  41820. * @param scene Define the scene the camera belong to
  41821. * @param lockedTarget Define the target of the camera
  41822. */
  41823. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41824. private _follow;
  41825. /**
  41826. * Attached controls to the current camera.
  41827. * @param element Defines the element the controls should be listened from
  41828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41829. */
  41830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41831. /**
  41832. * Detach the current controls from the camera.
  41833. * The camera will stop reacting to inputs.
  41834. * @param element Defines the element to stop listening the inputs from
  41835. */
  41836. detachControl(element: HTMLElement): void;
  41837. /** @hidden */
  41838. _checkInputs(): void;
  41839. private _checkLimits;
  41840. /**
  41841. * Gets the camera class name.
  41842. * @returns the class name
  41843. */
  41844. getClassName(): string;
  41845. }
  41846. /**
  41847. * Arc Rotate version of the follow camera.
  41848. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41849. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41850. */
  41851. export class ArcFollowCamera extends TargetCamera {
  41852. /** The longitudinal angle of the camera */
  41853. alpha: number;
  41854. /** The latitudinal angle of the camera */
  41855. beta: number;
  41856. /** The radius of the camera from its target */
  41857. radius: number;
  41858. /** Define the camera target (the messh it should follow) */
  41859. target: Nullable<AbstractMesh>;
  41860. private _cartesianCoordinates;
  41861. /**
  41862. * Instantiates a new ArcFollowCamera
  41863. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41864. * @param name Define the name of the camera
  41865. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41866. * @param beta Define the rotation angle of the camera around the elevation axis
  41867. * @param radius Define the radius of the camera from its target point
  41868. * @param target Define the target of the camera
  41869. * @param scene Define the scene the camera belongs to
  41870. */
  41871. constructor(name: string,
  41872. /** The longitudinal angle of the camera */
  41873. alpha: number,
  41874. /** The latitudinal angle of the camera */
  41875. beta: number,
  41876. /** The radius of the camera from its target */
  41877. radius: number,
  41878. /** Define the camera target (the messh it should follow) */
  41879. target: Nullable<AbstractMesh>, scene: Scene);
  41880. private _follow;
  41881. /** @hidden */
  41882. _checkInputs(): void;
  41883. /**
  41884. * Returns the class name of the object.
  41885. * It is mostly used internally for serialization purposes.
  41886. */
  41887. getClassName(): string;
  41888. }
  41889. }
  41890. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41891. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41892. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41893. import { Nullable } from "babylonjs/types";
  41894. /**
  41895. * Manage the keyboard inputs to control the movement of a follow camera.
  41896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41897. */
  41898. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41899. /**
  41900. * Defines the camera the input is attached to.
  41901. */
  41902. camera: FollowCamera;
  41903. /**
  41904. * Defines the list of key codes associated with the up action (increase heightOffset)
  41905. */
  41906. keysHeightOffsetIncr: number[];
  41907. /**
  41908. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41909. */
  41910. keysHeightOffsetDecr: number[];
  41911. /**
  41912. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41913. */
  41914. keysHeightOffsetModifierAlt: boolean;
  41915. /**
  41916. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41917. */
  41918. keysHeightOffsetModifierCtrl: boolean;
  41919. /**
  41920. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41921. */
  41922. keysHeightOffsetModifierShift: boolean;
  41923. /**
  41924. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41925. */
  41926. keysRotationOffsetIncr: number[];
  41927. /**
  41928. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41929. */
  41930. keysRotationOffsetDecr: number[];
  41931. /**
  41932. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41933. */
  41934. keysRotationOffsetModifierAlt: boolean;
  41935. /**
  41936. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41937. */
  41938. keysRotationOffsetModifierCtrl: boolean;
  41939. /**
  41940. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41941. */
  41942. keysRotationOffsetModifierShift: boolean;
  41943. /**
  41944. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41945. */
  41946. keysRadiusIncr: number[];
  41947. /**
  41948. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41949. */
  41950. keysRadiusDecr: number[];
  41951. /**
  41952. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41953. */
  41954. keysRadiusModifierAlt: boolean;
  41955. /**
  41956. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41957. */
  41958. keysRadiusModifierCtrl: boolean;
  41959. /**
  41960. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41961. */
  41962. keysRadiusModifierShift: boolean;
  41963. /**
  41964. * Defines the rate of change of heightOffset.
  41965. */
  41966. heightSensibility: number;
  41967. /**
  41968. * Defines the rate of change of rotationOffset.
  41969. */
  41970. rotationSensibility: number;
  41971. /**
  41972. * Defines the rate of change of radius.
  41973. */
  41974. radiusSensibility: number;
  41975. private _keys;
  41976. private _ctrlPressed;
  41977. private _altPressed;
  41978. private _shiftPressed;
  41979. private _onCanvasBlurObserver;
  41980. private _onKeyboardObserver;
  41981. private _engine;
  41982. private _scene;
  41983. /**
  41984. * Attach the input controls to a specific dom element to get the input from.
  41985. * @param element Defines the element the controls should be listened from
  41986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41987. */
  41988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41989. /**
  41990. * Detach the current controls from the specified dom element.
  41991. * @param element Defines the element to stop listening the inputs from
  41992. */
  41993. detachControl(element: Nullable<HTMLElement>): void;
  41994. /**
  41995. * Update the current camera state depending on the inputs that have been used this frame.
  41996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41997. */
  41998. checkInputs(): void;
  41999. /**
  42000. * Gets the class name of the current input.
  42001. * @returns the class name
  42002. */
  42003. getClassName(): string;
  42004. /**
  42005. * Get the friendly name associated with the input class.
  42006. * @returns the input friendly name
  42007. */
  42008. getSimpleName(): string;
  42009. /**
  42010. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42011. * allow modification of the heightOffset value.
  42012. */
  42013. private _modifierHeightOffset;
  42014. /**
  42015. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42016. * allow modification of the rotationOffset value.
  42017. */
  42018. private _modifierRotationOffset;
  42019. /**
  42020. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42021. * allow modification of the radius value.
  42022. */
  42023. private _modifierRadius;
  42024. }
  42025. }
  42026. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42027. import { Nullable } from "babylonjs/types";
  42028. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42029. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42030. import { Observable } from "babylonjs/Misc/observable";
  42031. module "babylonjs/Cameras/freeCameraInputsManager" {
  42032. interface FreeCameraInputsManager {
  42033. /**
  42034. * @hidden
  42035. */
  42036. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42037. /**
  42038. * Add orientation input support to the input manager.
  42039. * @returns the current input manager
  42040. */
  42041. addDeviceOrientation(): FreeCameraInputsManager;
  42042. }
  42043. }
  42044. /**
  42045. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42046. * Screen rotation is taken into account.
  42047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42048. */
  42049. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42050. private _camera;
  42051. private _screenOrientationAngle;
  42052. private _constantTranform;
  42053. private _screenQuaternion;
  42054. private _alpha;
  42055. private _beta;
  42056. private _gamma;
  42057. /**
  42058. * Can be used to detect if a device orientation sensor is available on a device
  42059. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42060. * @returns a promise that will resolve on orientation change
  42061. */
  42062. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42063. /**
  42064. * @hidden
  42065. */
  42066. _onDeviceOrientationChangedObservable: Observable<void>;
  42067. /**
  42068. * Instantiates a new input
  42069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42070. */
  42071. constructor();
  42072. /**
  42073. * Define the camera controlled by the input.
  42074. */
  42075. get camera(): FreeCamera;
  42076. set camera(camera: FreeCamera);
  42077. /**
  42078. * Attach the input controls to a specific dom element to get the input from.
  42079. * @param element Defines the element the controls should be listened from
  42080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42081. */
  42082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42083. private _orientationChanged;
  42084. private _deviceOrientation;
  42085. /**
  42086. * Detach the current controls from the specified dom element.
  42087. * @param element Defines the element to stop listening the inputs from
  42088. */
  42089. detachControl(element: Nullable<HTMLElement>): void;
  42090. /**
  42091. * Update the current camera state depending on the inputs that have been used this frame.
  42092. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42093. */
  42094. checkInputs(): void;
  42095. /**
  42096. * Gets the class name of the current intput.
  42097. * @returns the class name
  42098. */
  42099. getClassName(): string;
  42100. /**
  42101. * Get the friendly name associated with the input class.
  42102. * @returns the input friendly name
  42103. */
  42104. getSimpleName(): string;
  42105. }
  42106. }
  42107. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42108. import { Nullable } from "babylonjs/types";
  42109. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42110. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42111. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42112. /**
  42113. * Manage the gamepad inputs to control a free camera.
  42114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42115. */
  42116. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42117. /**
  42118. * Define the camera the input is attached to.
  42119. */
  42120. camera: FreeCamera;
  42121. /**
  42122. * Define the Gamepad controlling the input
  42123. */
  42124. gamepad: Nullable<Gamepad>;
  42125. /**
  42126. * Defines the gamepad rotation sensiblity.
  42127. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42128. */
  42129. gamepadAngularSensibility: number;
  42130. /**
  42131. * Defines the gamepad move sensiblity.
  42132. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42133. */
  42134. gamepadMoveSensibility: number;
  42135. private _yAxisScale;
  42136. /**
  42137. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42138. */
  42139. get invertYAxis(): boolean;
  42140. set invertYAxis(value: boolean);
  42141. private _onGamepadConnectedObserver;
  42142. private _onGamepadDisconnectedObserver;
  42143. private _cameraTransform;
  42144. private _deltaTransform;
  42145. private _vector3;
  42146. private _vector2;
  42147. /**
  42148. * Attach the input controls to a specific dom element to get the input from.
  42149. * @param element Defines the element the controls should be listened from
  42150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42151. */
  42152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42153. /**
  42154. * Detach the current controls from the specified dom element.
  42155. * @param element Defines the element to stop listening the inputs from
  42156. */
  42157. detachControl(element: Nullable<HTMLElement>): void;
  42158. /**
  42159. * Update the current camera state depending on the inputs that have been used this frame.
  42160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42161. */
  42162. checkInputs(): void;
  42163. /**
  42164. * Gets the class name of the current intput.
  42165. * @returns the class name
  42166. */
  42167. getClassName(): string;
  42168. /**
  42169. * Get the friendly name associated with the input class.
  42170. * @returns the input friendly name
  42171. */
  42172. getSimpleName(): string;
  42173. }
  42174. }
  42175. declare module "babylonjs/Misc/virtualJoystick" {
  42176. import { Nullable } from "babylonjs/types";
  42177. import { Vector3 } from "babylonjs/Maths/math.vector";
  42178. /**
  42179. * Defines the potential axis of a Joystick
  42180. */
  42181. export enum JoystickAxis {
  42182. /** X axis */
  42183. X = 0,
  42184. /** Y axis */
  42185. Y = 1,
  42186. /** Z axis */
  42187. Z = 2
  42188. }
  42189. /**
  42190. * Class used to define virtual joystick (used in touch mode)
  42191. */
  42192. export class VirtualJoystick {
  42193. /**
  42194. * Gets or sets a boolean indicating that left and right values must be inverted
  42195. */
  42196. reverseLeftRight: boolean;
  42197. /**
  42198. * Gets or sets a boolean indicating that up and down values must be inverted
  42199. */
  42200. reverseUpDown: boolean;
  42201. /**
  42202. * Gets the offset value for the position (ie. the change of the position value)
  42203. */
  42204. deltaPosition: Vector3;
  42205. /**
  42206. * Gets a boolean indicating if the virtual joystick was pressed
  42207. */
  42208. pressed: boolean;
  42209. /**
  42210. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42211. */
  42212. static Canvas: Nullable<HTMLCanvasElement>;
  42213. private static _globalJoystickIndex;
  42214. private static vjCanvasContext;
  42215. private static vjCanvasWidth;
  42216. private static vjCanvasHeight;
  42217. private static halfWidth;
  42218. private _action;
  42219. private _axisTargetedByLeftAndRight;
  42220. private _axisTargetedByUpAndDown;
  42221. private _joystickSensibility;
  42222. private _inversedSensibility;
  42223. private _joystickPointerID;
  42224. private _joystickColor;
  42225. private _joystickPointerPos;
  42226. private _joystickPreviousPointerPos;
  42227. private _joystickPointerStartPos;
  42228. private _deltaJoystickVector;
  42229. private _leftJoystick;
  42230. private _touches;
  42231. private _onPointerDownHandlerRef;
  42232. private _onPointerMoveHandlerRef;
  42233. private _onPointerUpHandlerRef;
  42234. private _onResize;
  42235. /**
  42236. * Creates a new virtual joystick
  42237. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42238. */
  42239. constructor(leftJoystick?: boolean);
  42240. /**
  42241. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42242. * @param newJoystickSensibility defines the new sensibility
  42243. */
  42244. setJoystickSensibility(newJoystickSensibility: number): void;
  42245. private _onPointerDown;
  42246. private _onPointerMove;
  42247. private _onPointerUp;
  42248. /**
  42249. * Change the color of the virtual joystick
  42250. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42251. */
  42252. setJoystickColor(newColor: string): void;
  42253. /**
  42254. * Defines a callback to call when the joystick is touched
  42255. * @param action defines the callback
  42256. */
  42257. setActionOnTouch(action: () => any): void;
  42258. /**
  42259. * Defines which axis you'd like to control for left & right
  42260. * @param axis defines the axis to use
  42261. */
  42262. setAxisForLeftRight(axis: JoystickAxis): void;
  42263. /**
  42264. * Defines which axis you'd like to control for up & down
  42265. * @param axis defines the axis to use
  42266. */
  42267. setAxisForUpDown(axis: JoystickAxis): void;
  42268. private _drawVirtualJoystick;
  42269. /**
  42270. * Release internal HTML canvas
  42271. */
  42272. releaseCanvas(): void;
  42273. }
  42274. }
  42275. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42276. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42277. import { Nullable } from "babylonjs/types";
  42278. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42279. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42280. module "babylonjs/Cameras/freeCameraInputsManager" {
  42281. interface FreeCameraInputsManager {
  42282. /**
  42283. * Add virtual joystick input support to the input manager.
  42284. * @returns the current input manager
  42285. */
  42286. addVirtualJoystick(): FreeCameraInputsManager;
  42287. }
  42288. }
  42289. /**
  42290. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42292. */
  42293. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42294. /**
  42295. * Defines the camera the input is attached to.
  42296. */
  42297. camera: FreeCamera;
  42298. private _leftjoystick;
  42299. private _rightjoystick;
  42300. /**
  42301. * Gets the left stick of the virtual joystick.
  42302. * @returns The virtual Joystick
  42303. */
  42304. getLeftJoystick(): VirtualJoystick;
  42305. /**
  42306. * Gets the right stick of the virtual joystick.
  42307. * @returns The virtual Joystick
  42308. */
  42309. getRightJoystick(): VirtualJoystick;
  42310. /**
  42311. * Update the current camera state depending on the inputs that have been used this frame.
  42312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42313. */
  42314. checkInputs(): void;
  42315. /**
  42316. * Attach the input controls to a specific dom element to get the input from.
  42317. * @param element Defines the element the controls should be listened from
  42318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42319. */
  42320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42321. /**
  42322. * Detach the current controls from the specified dom element.
  42323. * @param element Defines the element to stop listening the inputs from
  42324. */
  42325. detachControl(element: Nullable<HTMLElement>): void;
  42326. /**
  42327. * Gets the class name of the current intput.
  42328. * @returns the class name
  42329. */
  42330. getClassName(): string;
  42331. /**
  42332. * Get the friendly name associated with the input class.
  42333. * @returns the input friendly name
  42334. */
  42335. getSimpleName(): string;
  42336. }
  42337. }
  42338. declare module "babylonjs/Cameras/Inputs/index" {
  42339. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42340. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42341. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42342. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42343. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42344. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42345. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42346. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42347. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42348. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42349. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42350. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42351. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42352. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42353. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42354. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42355. }
  42356. declare module "babylonjs/Cameras/touchCamera" {
  42357. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42358. import { Scene } from "babylonjs/scene";
  42359. import { Vector3 } from "babylonjs/Maths/math.vector";
  42360. /**
  42361. * This represents a FPS type of camera controlled by touch.
  42362. * This is like a universal camera minus the Gamepad controls.
  42363. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42364. */
  42365. export class TouchCamera extends FreeCamera {
  42366. /**
  42367. * Defines the touch sensibility for rotation.
  42368. * The higher the faster.
  42369. */
  42370. get touchAngularSensibility(): number;
  42371. set touchAngularSensibility(value: number);
  42372. /**
  42373. * Defines the touch sensibility for move.
  42374. * The higher the faster.
  42375. */
  42376. get touchMoveSensibility(): number;
  42377. set touchMoveSensibility(value: number);
  42378. /**
  42379. * Instantiates a new touch camera.
  42380. * This represents a FPS type of camera controlled by touch.
  42381. * This is like a universal camera minus the Gamepad controls.
  42382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42383. * @param name Define the name of the camera in the scene
  42384. * @param position Define the start position of the camera in the scene
  42385. * @param scene Define the scene the camera belongs to
  42386. */
  42387. constructor(name: string, position: Vector3, scene: Scene);
  42388. /**
  42389. * Gets the current object class name.
  42390. * @return the class name
  42391. */
  42392. getClassName(): string;
  42393. /** @hidden */
  42394. _setupInputs(): void;
  42395. }
  42396. }
  42397. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42398. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42399. import { Scene } from "babylonjs/scene";
  42400. import { Vector3 } from "babylonjs/Maths/math.vector";
  42401. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42402. import { Axis } from "babylonjs/Maths/math.axis";
  42403. /**
  42404. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42405. * being tilted forward or back and left or right.
  42406. */
  42407. export class DeviceOrientationCamera extends FreeCamera {
  42408. private _initialQuaternion;
  42409. private _quaternionCache;
  42410. private _tmpDragQuaternion;
  42411. private _disablePointerInputWhenUsingDeviceOrientation;
  42412. /**
  42413. * Creates a new device orientation camera
  42414. * @param name The name of the camera
  42415. * @param position The start position camera
  42416. * @param scene The scene the camera belongs to
  42417. */
  42418. constructor(name: string, position: Vector3, scene: Scene);
  42419. /**
  42420. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42421. */
  42422. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42423. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42424. private _dragFactor;
  42425. /**
  42426. * Enabled turning on the y axis when the orientation sensor is active
  42427. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42428. */
  42429. enableHorizontalDragging(dragFactor?: number): void;
  42430. /**
  42431. * Gets the current instance class name ("DeviceOrientationCamera").
  42432. * This helps avoiding instanceof at run time.
  42433. * @returns the class name
  42434. */
  42435. getClassName(): string;
  42436. /**
  42437. * @hidden
  42438. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42439. */
  42440. _checkInputs(): void;
  42441. /**
  42442. * Reset the camera to its default orientation on the specified axis only.
  42443. * @param axis The axis to reset
  42444. */
  42445. resetToCurrentRotation(axis?: Axis): void;
  42446. }
  42447. }
  42448. declare module "babylonjs/Gamepads/xboxGamepad" {
  42449. import { Observable } from "babylonjs/Misc/observable";
  42450. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42451. /**
  42452. * Defines supported buttons for XBox360 compatible gamepads
  42453. */
  42454. export enum Xbox360Button {
  42455. /** A */
  42456. A = 0,
  42457. /** B */
  42458. B = 1,
  42459. /** X */
  42460. X = 2,
  42461. /** Y */
  42462. Y = 3,
  42463. /** Left button */
  42464. LB = 4,
  42465. /** Right button */
  42466. RB = 5,
  42467. /** Back */
  42468. Back = 8,
  42469. /** Start */
  42470. Start = 9,
  42471. /** Left stick */
  42472. LeftStick = 10,
  42473. /** Right stick */
  42474. RightStick = 11
  42475. }
  42476. /** Defines values for XBox360 DPad */
  42477. export enum Xbox360Dpad {
  42478. /** Up */
  42479. Up = 12,
  42480. /** Down */
  42481. Down = 13,
  42482. /** Left */
  42483. Left = 14,
  42484. /** Right */
  42485. Right = 15
  42486. }
  42487. /**
  42488. * Defines a XBox360 gamepad
  42489. */
  42490. export class Xbox360Pad extends Gamepad {
  42491. private _leftTrigger;
  42492. private _rightTrigger;
  42493. private _onlefttriggerchanged;
  42494. private _onrighttriggerchanged;
  42495. private _onbuttondown;
  42496. private _onbuttonup;
  42497. private _ondpaddown;
  42498. private _ondpadup;
  42499. /** Observable raised when a button is pressed */
  42500. onButtonDownObservable: Observable<Xbox360Button>;
  42501. /** Observable raised when a button is released */
  42502. onButtonUpObservable: Observable<Xbox360Button>;
  42503. /** Observable raised when a pad is pressed */
  42504. onPadDownObservable: Observable<Xbox360Dpad>;
  42505. /** Observable raised when a pad is released */
  42506. onPadUpObservable: Observable<Xbox360Dpad>;
  42507. private _buttonA;
  42508. private _buttonB;
  42509. private _buttonX;
  42510. private _buttonY;
  42511. private _buttonBack;
  42512. private _buttonStart;
  42513. private _buttonLB;
  42514. private _buttonRB;
  42515. private _buttonLeftStick;
  42516. private _buttonRightStick;
  42517. private _dPadUp;
  42518. private _dPadDown;
  42519. private _dPadLeft;
  42520. private _dPadRight;
  42521. private _isXboxOnePad;
  42522. /**
  42523. * Creates a new XBox360 gamepad object
  42524. * @param id defines the id of this gamepad
  42525. * @param index defines its index
  42526. * @param gamepad defines the internal HTML gamepad object
  42527. * @param xboxOne defines if it is a XBox One gamepad
  42528. */
  42529. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42530. /**
  42531. * Defines the callback to call when left trigger is pressed
  42532. * @param callback defines the callback to use
  42533. */
  42534. onlefttriggerchanged(callback: (value: number) => void): void;
  42535. /**
  42536. * Defines the callback to call when right trigger is pressed
  42537. * @param callback defines the callback to use
  42538. */
  42539. onrighttriggerchanged(callback: (value: number) => void): void;
  42540. /**
  42541. * Gets the left trigger value
  42542. */
  42543. get leftTrigger(): number;
  42544. /**
  42545. * Sets the left trigger value
  42546. */
  42547. set leftTrigger(newValue: number);
  42548. /**
  42549. * Gets the right trigger value
  42550. */
  42551. get rightTrigger(): number;
  42552. /**
  42553. * Sets the right trigger value
  42554. */
  42555. set rightTrigger(newValue: number);
  42556. /**
  42557. * Defines the callback to call when a button is pressed
  42558. * @param callback defines the callback to use
  42559. */
  42560. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42561. /**
  42562. * Defines the callback to call when a button is released
  42563. * @param callback defines the callback to use
  42564. */
  42565. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42566. /**
  42567. * Defines the callback to call when a pad is pressed
  42568. * @param callback defines the callback to use
  42569. */
  42570. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42571. /**
  42572. * Defines the callback to call when a pad is released
  42573. * @param callback defines the callback to use
  42574. */
  42575. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42576. private _setButtonValue;
  42577. private _setDPadValue;
  42578. /**
  42579. * Gets the value of the `A` button
  42580. */
  42581. get buttonA(): number;
  42582. /**
  42583. * Sets the value of the `A` button
  42584. */
  42585. set buttonA(value: number);
  42586. /**
  42587. * Gets the value of the `B` button
  42588. */
  42589. get buttonB(): number;
  42590. /**
  42591. * Sets the value of the `B` button
  42592. */
  42593. set buttonB(value: number);
  42594. /**
  42595. * Gets the value of the `X` button
  42596. */
  42597. get buttonX(): number;
  42598. /**
  42599. * Sets the value of the `X` button
  42600. */
  42601. set buttonX(value: number);
  42602. /**
  42603. * Gets the value of the `Y` button
  42604. */
  42605. get buttonY(): number;
  42606. /**
  42607. * Sets the value of the `Y` button
  42608. */
  42609. set buttonY(value: number);
  42610. /**
  42611. * Gets the value of the `Start` button
  42612. */
  42613. get buttonStart(): number;
  42614. /**
  42615. * Sets the value of the `Start` button
  42616. */
  42617. set buttonStart(value: number);
  42618. /**
  42619. * Gets the value of the `Back` button
  42620. */
  42621. get buttonBack(): number;
  42622. /**
  42623. * Sets the value of the `Back` button
  42624. */
  42625. set buttonBack(value: number);
  42626. /**
  42627. * Gets the value of the `Left` button
  42628. */
  42629. get buttonLB(): number;
  42630. /**
  42631. * Sets the value of the `Left` button
  42632. */
  42633. set buttonLB(value: number);
  42634. /**
  42635. * Gets the value of the `Right` button
  42636. */
  42637. get buttonRB(): number;
  42638. /**
  42639. * Sets the value of the `Right` button
  42640. */
  42641. set buttonRB(value: number);
  42642. /**
  42643. * Gets the value of the Left joystick
  42644. */
  42645. get buttonLeftStick(): number;
  42646. /**
  42647. * Sets the value of the Left joystick
  42648. */
  42649. set buttonLeftStick(value: number);
  42650. /**
  42651. * Gets the value of the Right joystick
  42652. */
  42653. get buttonRightStick(): number;
  42654. /**
  42655. * Sets the value of the Right joystick
  42656. */
  42657. set buttonRightStick(value: number);
  42658. /**
  42659. * Gets the value of D-pad up
  42660. */
  42661. get dPadUp(): number;
  42662. /**
  42663. * Sets the value of D-pad up
  42664. */
  42665. set dPadUp(value: number);
  42666. /**
  42667. * Gets the value of D-pad down
  42668. */
  42669. get dPadDown(): number;
  42670. /**
  42671. * Sets the value of D-pad down
  42672. */
  42673. set dPadDown(value: number);
  42674. /**
  42675. * Gets the value of D-pad left
  42676. */
  42677. get dPadLeft(): number;
  42678. /**
  42679. * Sets the value of D-pad left
  42680. */
  42681. set dPadLeft(value: number);
  42682. /**
  42683. * Gets the value of D-pad right
  42684. */
  42685. get dPadRight(): number;
  42686. /**
  42687. * Sets the value of D-pad right
  42688. */
  42689. set dPadRight(value: number);
  42690. /**
  42691. * Force the gamepad to synchronize with device values
  42692. */
  42693. update(): void;
  42694. /**
  42695. * Disposes the gamepad
  42696. */
  42697. dispose(): void;
  42698. }
  42699. }
  42700. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42701. import { Observable } from "babylonjs/Misc/observable";
  42702. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42703. /**
  42704. * Defines supported buttons for DualShock compatible gamepads
  42705. */
  42706. export enum DualShockButton {
  42707. /** Cross */
  42708. Cross = 0,
  42709. /** Circle */
  42710. Circle = 1,
  42711. /** Square */
  42712. Square = 2,
  42713. /** Triangle */
  42714. Triangle = 3,
  42715. /** L1 */
  42716. L1 = 4,
  42717. /** R1 */
  42718. R1 = 5,
  42719. /** Share */
  42720. Share = 8,
  42721. /** Options */
  42722. Options = 9,
  42723. /** Left stick */
  42724. LeftStick = 10,
  42725. /** Right stick */
  42726. RightStick = 11
  42727. }
  42728. /** Defines values for DualShock DPad */
  42729. export enum DualShockDpad {
  42730. /** Up */
  42731. Up = 12,
  42732. /** Down */
  42733. Down = 13,
  42734. /** Left */
  42735. Left = 14,
  42736. /** Right */
  42737. Right = 15
  42738. }
  42739. /**
  42740. * Defines a DualShock gamepad
  42741. */
  42742. export class DualShockPad extends Gamepad {
  42743. private _leftTrigger;
  42744. private _rightTrigger;
  42745. private _onlefttriggerchanged;
  42746. private _onrighttriggerchanged;
  42747. private _onbuttondown;
  42748. private _onbuttonup;
  42749. private _ondpaddown;
  42750. private _ondpadup;
  42751. /** Observable raised when a button is pressed */
  42752. onButtonDownObservable: Observable<DualShockButton>;
  42753. /** Observable raised when a button is released */
  42754. onButtonUpObservable: Observable<DualShockButton>;
  42755. /** Observable raised when a pad is pressed */
  42756. onPadDownObservable: Observable<DualShockDpad>;
  42757. /** Observable raised when a pad is released */
  42758. onPadUpObservable: Observable<DualShockDpad>;
  42759. private _buttonCross;
  42760. private _buttonCircle;
  42761. private _buttonSquare;
  42762. private _buttonTriangle;
  42763. private _buttonShare;
  42764. private _buttonOptions;
  42765. private _buttonL1;
  42766. private _buttonR1;
  42767. private _buttonLeftStick;
  42768. private _buttonRightStick;
  42769. private _dPadUp;
  42770. private _dPadDown;
  42771. private _dPadLeft;
  42772. private _dPadRight;
  42773. /**
  42774. * Creates a new DualShock gamepad object
  42775. * @param id defines the id of this gamepad
  42776. * @param index defines its index
  42777. * @param gamepad defines the internal HTML gamepad object
  42778. */
  42779. constructor(id: string, index: number, gamepad: any);
  42780. /**
  42781. * Defines the callback to call when left trigger is pressed
  42782. * @param callback defines the callback to use
  42783. */
  42784. onlefttriggerchanged(callback: (value: number) => void): void;
  42785. /**
  42786. * Defines the callback to call when right trigger is pressed
  42787. * @param callback defines the callback to use
  42788. */
  42789. onrighttriggerchanged(callback: (value: number) => void): void;
  42790. /**
  42791. * Gets the left trigger value
  42792. */
  42793. get leftTrigger(): number;
  42794. /**
  42795. * Sets the left trigger value
  42796. */
  42797. set leftTrigger(newValue: number);
  42798. /**
  42799. * Gets the right trigger value
  42800. */
  42801. get rightTrigger(): number;
  42802. /**
  42803. * Sets the right trigger value
  42804. */
  42805. set rightTrigger(newValue: number);
  42806. /**
  42807. * Defines the callback to call when a button is pressed
  42808. * @param callback defines the callback to use
  42809. */
  42810. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42811. /**
  42812. * Defines the callback to call when a button is released
  42813. * @param callback defines the callback to use
  42814. */
  42815. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42816. /**
  42817. * Defines the callback to call when a pad is pressed
  42818. * @param callback defines the callback to use
  42819. */
  42820. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42821. /**
  42822. * Defines the callback to call when a pad is released
  42823. * @param callback defines the callback to use
  42824. */
  42825. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42826. private _setButtonValue;
  42827. private _setDPadValue;
  42828. /**
  42829. * Gets the value of the `Cross` button
  42830. */
  42831. get buttonCross(): number;
  42832. /**
  42833. * Sets the value of the `Cross` button
  42834. */
  42835. set buttonCross(value: number);
  42836. /**
  42837. * Gets the value of the `Circle` button
  42838. */
  42839. get buttonCircle(): number;
  42840. /**
  42841. * Sets the value of the `Circle` button
  42842. */
  42843. set buttonCircle(value: number);
  42844. /**
  42845. * Gets the value of the `Square` button
  42846. */
  42847. get buttonSquare(): number;
  42848. /**
  42849. * Sets the value of the `Square` button
  42850. */
  42851. set buttonSquare(value: number);
  42852. /**
  42853. * Gets the value of the `Triangle` button
  42854. */
  42855. get buttonTriangle(): number;
  42856. /**
  42857. * Sets the value of the `Triangle` button
  42858. */
  42859. set buttonTriangle(value: number);
  42860. /**
  42861. * Gets the value of the `Options` button
  42862. */
  42863. get buttonOptions(): number;
  42864. /**
  42865. * Sets the value of the `Options` button
  42866. */
  42867. set buttonOptions(value: number);
  42868. /**
  42869. * Gets the value of the `Share` button
  42870. */
  42871. get buttonShare(): number;
  42872. /**
  42873. * Sets the value of the `Share` button
  42874. */
  42875. set buttonShare(value: number);
  42876. /**
  42877. * Gets the value of the `L1` button
  42878. */
  42879. get buttonL1(): number;
  42880. /**
  42881. * Sets the value of the `L1` button
  42882. */
  42883. set buttonL1(value: number);
  42884. /**
  42885. * Gets the value of the `R1` button
  42886. */
  42887. get buttonR1(): number;
  42888. /**
  42889. * Sets the value of the `R1` button
  42890. */
  42891. set buttonR1(value: number);
  42892. /**
  42893. * Gets the value of the Left joystick
  42894. */
  42895. get buttonLeftStick(): number;
  42896. /**
  42897. * Sets the value of the Left joystick
  42898. */
  42899. set buttonLeftStick(value: number);
  42900. /**
  42901. * Gets the value of the Right joystick
  42902. */
  42903. get buttonRightStick(): number;
  42904. /**
  42905. * Sets the value of the Right joystick
  42906. */
  42907. set buttonRightStick(value: number);
  42908. /**
  42909. * Gets the value of D-pad up
  42910. */
  42911. get dPadUp(): number;
  42912. /**
  42913. * Sets the value of D-pad up
  42914. */
  42915. set dPadUp(value: number);
  42916. /**
  42917. * Gets the value of D-pad down
  42918. */
  42919. get dPadDown(): number;
  42920. /**
  42921. * Sets the value of D-pad down
  42922. */
  42923. set dPadDown(value: number);
  42924. /**
  42925. * Gets the value of D-pad left
  42926. */
  42927. get dPadLeft(): number;
  42928. /**
  42929. * Sets the value of D-pad left
  42930. */
  42931. set dPadLeft(value: number);
  42932. /**
  42933. * Gets the value of D-pad right
  42934. */
  42935. get dPadRight(): number;
  42936. /**
  42937. * Sets the value of D-pad right
  42938. */
  42939. set dPadRight(value: number);
  42940. /**
  42941. * Force the gamepad to synchronize with device values
  42942. */
  42943. update(): void;
  42944. /**
  42945. * Disposes the gamepad
  42946. */
  42947. dispose(): void;
  42948. }
  42949. }
  42950. declare module "babylonjs/Gamepads/gamepadManager" {
  42951. import { Observable } from "babylonjs/Misc/observable";
  42952. import { Nullable } from "babylonjs/types";
  42953. import { Scene } from "babylonjs/scene";
  42954. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42955. /**
  42956. * Manager for handling gamepads
  42957. */
  42958. export class GamepadManager {
  42959. private _scene?;
  42960. private _babylonGamepads;
  42961. private _oneGamepadConnected;
  42962. /** @hidden */
  42963. _isMonitoring: boolean;
  42964. private _gamepadEventSupported;
  42965. private _gamepadSupport?;
  42966. /**
  42967. * observable to be triggered when the gamepad controller has been connected
  42968. */
  42969. onGamepadConnectedObservable: Observable<Gamepad>;
  42970. /**
  42971. * observable to be triggered when the gamepad controller has been disconnected
  42972. */
  42973. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42974. private _onGamepadConnectedEvent;
  42975. private _onGamepadDisconnectedEvent;
  42976. /**
  42977. * Initializes the gamepad manager
  42978. * @param _scene BabylonJS scene
  42979. */
  42980. constructor(_scene?: Scene | undefined);
  42981. /**
  42982. * The gamepads in the game pad manager
  42983. */
  42984. get gamepads(): Gamepad[];
  42985. /**
  42986. * Get the gamepad controllers based on type
  42987. * @param type The type of gamepad controller
  42988. * @returns Nullable gamepad
  42989. */
  42990. getGamepadByType(type?: number): Nullable<Gamepad>;
  42991. /**
  42992. * Disposes the gamepad manager
  42993. */
  42994. dispose(): void;
  42995. private _addNewGamepad;
  42996. private _startMonitoringGamepads;
  42997. private _stopMonitoringGamepads;
  42998. /** @hidden */
  42999. _checkGamepadsStatus(): void;
  43000. private _updateGamepadObjects;
  43001. }
  43002. }
  43003. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43004. import { Nullable } from "babylonjs/types";
  43005. import { Scene } from "babylonjs/scene";
  43006. import { ISceneComponent } from "babylonjs/sceneComponent";
  43007. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43008. module "babylonjs/scene" {
  43009. interface Scene {
  43010. /** @hidden */
  43011. _gamepadManager: Nullable<GamepadManager>;
  43012. /**
  43013. * Gets the gamepad manager associated with the scene
  43014. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43015. */
  43016. gamepadManager: GamepadManager;
  43017. }
  43018. }
  43019. module "babylonjs/Cameras/freeCameraInputsManager" {
  43020. /**
  43021. * Interface representing a free camera inputs manager
  43022. */
  43023. interface FreeCameraInputsManager {
  43024. /**
  43025. * Adds gamepad input support to the FreeCameraInputsManager.
  43026. * @returns the FreeCameraInputsManager
  43027. */
  43028. addGamepad(): FreeCameraInputsManager;
  43029. }
  43030. }
  43031. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43032. /**
  43033. * Interface representing an arc rotate camera inputs manager
  43034. */
  43035. interface ArcRotateCameraInputsManager {
  43036. /**
  43037. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43038. * @returns the camera inputs manager
  43039. */
  43040. addGamepad(): ArcRotateCameraInputsManager;
  43041. }
  43042. }
  43043. /**
  43044. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43045. */
  43046. export class GamepadSystemSceneComponent implements ISceneComponent {
  43047. /**
  43048. * The component name helpfull to identify the component in the list of scene components.
  43049. */
  43050. readonly name: string;
  43051. /**
  43052. * The scene the component belongs to.
  43053. */
  43054. scene: Scene;
  43055. /**
  43056. * Creates a new instance of the component for the given scene
  43057. * @param scene Defines the scene to register the component in
  43058. */
  43059. constructor(scene: Scene);
  43060. /**
  43061. * Registers the component in a given scene
  43062. */
  43063. register(): void;
  43064. /**
  43065. * Rebuilds the elements related to this component in case of
  43066. * context lost for instance.
  43067. */
  43068. rebuild(): void;
  43069. /**
  43070. * Disposes the component and the associated ressources
  43071. */
  43072. dispose(): void;
  43073. private _beforeCameraUpdate;
  43074. }
  43075. }
  43076. declare module "babylonjs/Cameras/universalCamera" {
  43077. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43078. import { Scene } from "babylonjs/scene";
  43079. import { Vector3 } from "babylonjs/Maths/math.vector";
  43080. import "babylonjs/Gamepads/gamepadSceneComponent";
  43081. /**
  43082. * 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,
  43083. * which still works and will still be found in many Playgrounds.
  43084. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43085. */
  43086. export class UniversalCamera extends TouchCamera {
  43087. /**
  43088. * Defines the gamepad rotation sensiblity.
  43089. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43090. */
  43091. get gamepadAngularSensibility(): number;
  43092. set gamepadAngularSensibility(value: number);
  43093. /**
  43094. * Defines the gamepad move sensiblity.
  43095. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43096. */
  43097. get gamepadMoveSensibility(): number;
  43098. set gamepadMoveSensibility(value: number);
  43099. /**
  43100. * 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,
  43101. * which still works and will still be found in many Playgrounds.
  43102. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43103. * @param name Define the name of the camera in the scene
  43104. * @param position Define the start position of the camera in the scene
  43105. * @param scene Define the scene the camera belongs to
  43106. */
  43107. constructor(name: string, position: Vector3, scene: Scene);
  43108. /**
  43109. * Gets the current object class name.
  43110. * @return the class name
  43111. */
  43112. getClassName(): string;
  43113. }
  43114. }
  43115. declare module "babylonjs/Cameras/gamepadCamera" {
  43116. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43117. import { Scene } from "babylonjs/scene";
  43118. import { Vector3 } from "babylonjs/Maths/math.vector";
  43119. /**
  43120. * This represents a FPS type of camera. This is only here for back compat purpose.
  43121. * Please use the UniversalCamera instead as both are identical.
  43122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43123. */
  43124. export class GamepadCamera extends UniversalCamera {
  43125. /**
  43126. * Instantiates a new Gamepad Camera
  43127. * This represents a FPS type of camera. This is only here for back compat purpose.
  43128. * Please use the UniversalCamera instead as both are identical.
  43129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43130. * @param name Define the name of the camera in the scene
  43131. * @param position Define the start position of the camera in the scene
  43132. * @param scene Define the scene the camera belongs to
  43133. */
  43134. constructor(name: string, position: Vector3, scene: Scene);
  43135. /**
  43136. * Gets the current object class name.
  43137. * @return the class name
  43138. */
  43139. getClassName(): string;
  43140. }
  43141. }
  43142. declare module "babylonjs/Shaders/pass.fragment" {
  43143. /** @hidden */
  43144. export var passPixelShader: {
  43145. name: string;
  43146. shader: string;
  43147. };
  43148. }
  43149. declare module "babylonjs/Shaders/passCube.fragment" {
  43150. /** @hidden */
  43151. export var passCubePixelShader: {
  43152. name: string;
  43153. shader: string;
  43154. };
  43155. }
  43156. declare module "babylonjs/PostProcesses/passPostProcess" {
  43157. import { Nullable } from "babylonjs/types";
  43158. import { Camera } from "babylonjs/Cameras/camera";
  43159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43160. import { Engine } from "babylonjs/Engines/engine";
  43161. import "babylonjs/Shaders/pass.fragment";
  43162. import "babylonjs/Shaders/passCube.fragment";
  43163. /**
  43164. * PassPostProcess which produces an output the same as it's input
  43165. */
  43166. export class PassPostProcess extends PostProcess {
  43167. /**
  43168. * Creates the PassPostProcess
  43169. * @param name The name of the effect.
  43170. * @param options The required width/height ratio to downsize to before computing the render pass.
  43171. * @param camera The camera to apply the render pass to.
  43172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43173. * @param engine The engine which the post process will be applied. (default: current engine)
  43174. * @param reusable If the post process can be reused on the same frame. (default: false)
  43175. * @param textureType The type of texture to be used when performing the post processing.
  43176. * @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)
  43177. */
  43178. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43179. }
  43180. /**
  43181. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43182. */
  43183. export class PassCubePostProcess extends PostProcess {
  43184. private _face;
  43185. /**
  43186. * Gets or sets the cube face to display.
  43187. * * 0 is +X
  43188. * * 1 is -X
  43189. * * 2 is +Y
  43190. * * 3 is -Y
  43191. * * 4 is +Z
  43192. * * 5 is -Z
  43193. */
  43194. get face(): number;
  43195. set face(value: number);
  43196. /**
  43197. * Creates the PassCubePostProcess
  43198. * @param name The name of the effect.
  43199. * @param options The required width/height ratio to downsize to before computing the render pass.
  43200. * @param camera The camera to apply the render pass to.
  43201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43202. * @param engine The engine which the post process will be applied. (default: current engine)
  43203. * @param reusable If the post process can be reused on the same frame. (default: false)
  43204. * @param textureType The type of texture to be used when performing the post processing.
  43205. * @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)
  43206. */
  43207. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43208. }
  43209. }
  43210. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43211. /** @hidden */
  43212. export var anaglyphPixelShader: {
  43213. name: string;
  43214. shader: string;
  43215. };
  43216. }
  43217. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43218. import { Engine } from "babylonjs/Engines/engine";
  43219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43220. import { Camera } from "babylonjs/Cameras/camera";
  43221. import "babylonjs/Shaders/anaglyph.fragment";
  43222. /**
  43223. * Postprocess used to generate anaglyphic rendering
  43224. */
  43225. export class AnaglyphPostProcess extends PostProcess {
  43226. private _passedProcess;
  43227. /**
  43228. * Creates a new AnaglyphPostProcess
  43229. * @param name defines postprocess name
  43230. * @param options defines creation options or target ratio scale
  43231. * @param rigCameras defines cameras using this postprocess
  43232. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43233. * @param engine defines hosting engine
  43234. * @param reusable defines if the postprocess will be reused multiple times per frame
  43235. */
  43236. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43237. }
  43238. }
  43239. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43240. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43241. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43242. import { Scene } from "babylonjs/scene";
  43243. import { Vector3 } from "babylonjs/Maths/math.vector";
  43244. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43245. /**
  43246. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43247. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43248. */
  43249. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43250. /**
  43251. * Creates a new AnaglyphArcRotateCamera
  43252. * @param name defines camera name
  43253. * @param alpha defines alpha angle (in radians)
  43254. * @param beta defines beta angle (in radians)
  43255. * @param radius defines radius
  43256. * @param target defines camera target
  43257. * @param interaxialDistance defines distance between each color axis
  43258. * @param scene defines the hosting scene
  43259. */
  43260. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43261. /**
  43262. * Gets camera class name
  43263. * @returns AnaglyphArcRotateCamera
  43264. */
  43265. getClassName(): string;
  43266. }
  43267. }
  43268. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43269. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43270. import { Scene } from "babylonjs/scene";
  43271. import { Vector3 } from "babylonjs/Maths/math.vector";
  43272. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43273. /**
  43274. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43275. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43276. */
  43277. export class AnaglyphFreeCamera extends FreeCamera {
  43278. /**
  43279. * Creates a new AnaglyphFreeCamera
  43280. * @param name defines camera name
  43281. * @param position defines initial position
  43282. * @param interaxialDistance defines distance between each color axis
  43283. * @param scene defines the hosting scene
  43284. */
  43285. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43286. /**
  43287. * Gets camera class name
  43288. * @returns AnaglyphFreeCamera
  43289. */
  43290. getClassName(): string;
  43291. }
  43292. }
  43293. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43294. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43295. import { Scene } from "babylonjs/scene";
  43296. import { Vector3 } from "babylonjs/Maths/math.vector";
  43297. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43298. /**
  43299. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43300. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43301. */
  43302. export class AnaglyphGamepadCamera extends GamepadCamera {
  43303. /**
  43304. * Creates a new AnaglyphGamepadCamera
  43305. * @param name defines camera name
  43306. * @param position defines initial position
  43307. * @param interaxialDistance defines distance between each color axis
  43308. * @param scene defines the hosting scene
  43309. */
  43310. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43311. /**
  43312. * Gets camera class name
  43313. * @returns AnaglyphGamepadCamera
  43314. */
  43315. getClassName(): string;
  43316. }
  43317. }
  43318. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43319. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43320. import { Scene } from "babylonjs/scene";
  43321. import { Vector3 } from "babylonjs/Maths/math.vector";
  43322. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43323. /**
  43324. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43325. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43326. */
  43327. export class AnaglyphUniversalCamera extends UniversalCamera {
  43328. /**
  43329. * Creates a new AnaglyphUniversalCamera
  43330. * @param name defines camera name
  43331. * @param position defines initial position
  43332. * @param interaxialDistance defines distance between each color axis
  43333. * @param scene defines the hosting scene
  43334. */
  43335. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43336. /**
  43337. * Gets camera class name
  43338. * @returns AnaglyphUniversalCamera
  43339. */
  43340. getClassName(): string;
  43341. }
  43342. }
  43343. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43344. /** @hidden */
  43345. export var stereoscopicInterlacePixelShader: {
  43346. name: string;
  43347. shader: string;
  43348. };
  43349. }
  43350. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43351. import { Camera } from "babylonjs/Cameras/camera";
  43352. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43353. import { Engine } from "babylonjs/Engines/engine";
  43354. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43355. /**
  43356. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43357. */
  43358. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43359. private _stepSize;
  43360. private _passedProcess;
  43361. /**
  43362. * Initializes a StereoscopicInterlacePostProcessI
  43363. * @param name The name of the effect.
  43364. * @param rigCameras The rig cameras to be appled to the post process
  43365. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43366. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43368. * @param engine The engine which the post process will be applied. (default: current engine)
  43369. * @param reusable If the post process can be reused on the same frame. (default: false)
  43370. */
  43371. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43372. }
  43373. /**
  43374. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43375. */
  43376. export class StereoscopicInterlacePostProcess extends PostProcess {
  43377. private _stepSize;
  43378. private _passedProcess;
  43379. /**
  43380. * Initializes a StereoscopicInterlacePostProcess
  43381. * @param name The name of the effect.
  43382. * @param rigCameras The rig cameras to be appled to the post process
  43383. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43385. * @param engine The engine which the post process will be applied. (default: current engine)
  43386. * @param reusable If the post process can be reused on the same frame. (default: false)
  43387. */
  43388. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43389. }
  43390. }
  43391. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43392. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43393. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43394. import { Scene } from "babylonjs/scene";
  43395. import { Vector3 } from "babylonjs/Maths/math.vector";
  43396. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43397. /**
  43398. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43399. * @see http://doc.babylonjs.com/features/cameras
  43400. */
  43401. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43402. /**
  43403. * Creates a new StereoscopicArcRotateCamera
  43404. * @param name defines camera name
  43405. * @param alpha defines alpha angle (in radians)
  43406. * @param beta defines beta angle (in radians)
  43407. * @param radius defines radius
  43408. * @param target defines camera target
  43409. * @param interaxialDistance defines distance between each color axis
  43410. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43411. * @param scene defines the hosting scene
  43412. */
  43413. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43414. /**
  43415. * Gets camera class name
  43416. * @returns StereoscopicArcRotateCamera
  43417. */
  43418. getClassName(): string;
  43419. }
  43420. }
  43421. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43422. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43423. import { Scene } from "babylonjs/scene";
  43424. import { Vector3 } from "babylonjs/Maths/math.vector";
  43425. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43426. /**
  43427. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43428. * @see http://doc.babylonjs.com/features/cameras
  43429. */
  43430. export class StereoscopicFreeCamera extends FreeCamera {
  43431. /**
  43432. * Creates a new StereoscopicFreeCamera
  43433. * @param name defines camera name
  43434. * @param position defines initial position
  43435. * @param interaxialDistance defines distance between each color axis
  43436. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43437. * @param scene defines the hosting scene
  43438. */
  43439. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43440. /**
  43441. * Gets camera class name
  43442. * @returns StereoscopicFreeCamera
  43443. */
  43444. getClassName(): string;
  43445. }
  43446. }
  43447. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43448. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43449. import { Scene } from "babylonjs/scene";
  43450. import { Vector3 } from "babylonjs/Maths/math.vector";
  43451. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43452. /**
  43453. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43454. * @see http://doc.babylonjs.com/features/cameras
  43455. */
  43456. export class StereoscopicGamepadCamera extends GamepadCamera {
  43457. /**
  43458. * Creates a new StereoscopicGamepadCamera
  43459. * @param name defines camera name
  43460. * @param position defines initial position
  43461. * @param interaxialDistance defines distance between each color axis
  43462. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43463. * @param scene defines the hosting scene
  43464. */
  43465. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43466. /**
  43467. * Gets camera class name
  43468. * @returns StereoscopicGamepadCamera
  43469. */
  43470. getClassName(): string;
  43471. }
  43472. }
  43473. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43474. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43475. import { Scene } from "babylonjs/scene";
  43476. import { Vector3 } from "babylonjs/Maths/math.vector";
  43477. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43478. /**
  43479. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43480. * @see http://doc.babylonjs.com/features/cameras
  43481. */
  43482. export class StereoscopicUniversalCamera extends UniversalCamera {
  43483. /**
  43484. * Creates a new StereoscopicUniversalCamera
  43485. * @param name defines camera name
  43486. * @param position defines initial position
  43487. * @param interaxialDistance defines distance between each color axis
  43488. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43489. * @param scene defines the hosting scene
  43490. */
  43491. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43492. /**
  43493. * Gets camera class name
  43494. * @returns StereoscopicUniversalCamera
  43495. */
  43496. getClassName(): string;
  43497. }
  43498. }
  43499. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43500. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43501. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43502. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43503. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43504. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43505. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43506. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43507. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43508. }
  43509. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43510. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43511. import { Scene } from "babylonjs/scene";
  43512. import { Vector3 } from "babylonjs/Maths/math.vector";
  43513. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43514. /**
  43515. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43516. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43517. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43518. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43519. */
  43520. export class VirtualJoysticksCamera extends FreeCamera {
  43521. /**
  43522. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43523. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43524. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43525. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43526. * @param name Define the name of the camera in the scene
  43527. * @param position Define the start position of the camera in the scene
  43528. * @param scene Define the scene the camera belongs to
  43529. */
  43530. constructor(name: string, position: Vector3, scene: Scene);
  43531. /**
  43532. * Gets the current object class name.
  43533. * @return the class name
  43534. */
  43535. getClassName(): string;
  43536. }
  43537. }
  43538. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43539. import { Matrix } from "babylonjs/Maths/math.vector";
  43540. /**
  43541. * This represents all the required metrics to create a VR camera.
  43542. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43543. */
  43544. export class VRCameraMetrics {
  43545. /**
  43546. * Define the horizontal resolution off the screen.
  43547. */
  43548. hResolution: number;
  43549. /**
  43550. * Define the vertical resolution off the screen.
  43551. */
  43552. vResolution: number;
  43553. /**
  43554. * Define the horizontal screen size.
  43555. */
  43556. hScreenSize: number;
  43557. /**
  43558. * Define the vertical screen size.
  43559. */
  43560. vScreenSize: number;
  43561. /**
  43562. * Define the vertical screen center position.
  43563. */
  43564. vScreenCenter: number;
  43565. /**
  43566. * Define the distance of the eyes to the screen.
  43567. */
  43568. eyeToScreenDistance: number;
  43569. /**
  43570. * Define the distance between both lenses
  43571. */
  43572. lensSeparationDistance: number;
  43573. /**
  43574. * Define the distance between both viewer's eyes.
  43575. */
  43576. interpupillaryDistance: number;
  43577. /**
  43578. * Define the distortion factor of the VR postprocess.
  43579. * Please, touch with care.
  43580. */
  43581. distortionK: number[];
  43582. /**
  43583. * Define the chromatic aberration correction factors for the VR post process.
  43584. */
  43585. chromaAbCorrection: number[];
  43586. /**
  43587. * Define the scale factor of the post process.
  43588. * The smaller the better but the slower.
  43589. */
  43590. postProcessScaleFactor: number;
  43591. /**
  43592. * Define an offset for the lens center.
  43593. */
  43594. lensCenterOffset: number;
  43595. /**
  43596. * Define if the current vr camera should compensate the distortion of the lense or not.
  43597. */
  43598. compensateDistortion: boolean;
  43599. /**
  43600. * Defines if multiview should be enabled when rendering (Default: false)
  43601. */
  43602. multiviewEnabled: boolean;
  43603. /**
  43604. * Gets the rendering aspect ratio based on the provided resolutions.
  43605. */
  43606. get aspectRatio(): number;
  43607. /**
  43608. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43609. */
  43610. get aspectRatioFov(): number;
  43611. /**
  43612. * @hidden
  43613. */
  43614. get leftHMatrix(): Matrix;
  43615. /**
  43616. * @hidden
  43617. */
  43618. get rightHMatrix(): Matrix;
  43619. /**
  43620. * @hidden
  43621. */
  43622. get leftPreViewMatrix(): Matrix;
  43623. /**
  43624. * @hidden
  43625. */
  43626. get rightPreViewMatrix(): Matrix;
  43627. /**
  43628. * Get the default VRMetrics based on the most generic setup.
  43629. * @returns the default vr metrics
  43630. */
  43631. static GetDefault(): VRCameraMetrics;
  43632. }
  43633. }
  43634. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43635. /** @hidden */
  43636. export var vrDistortionCorrectionPixelShader: {
  43637. name: string;
  43638. shader: string;
  43639. };
  43640. }
  43641. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43642. import { Camera } from "babylonjs/Cameras/camera";
  43643. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43644. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43645. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43646. /**
  43647. * VRDistortionCorrectionPostProcess used for mobile VR
  43648. */
  43649. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43650. private _isRightEye;
  43651. private _distortionFactors;
  43652. private _postProcessScaleFactor;
  43653. private _lensCenterOffset;
  43654. private _scaleIn;
  43655. private _scaleFactor;
  43656. private _lensCenter;
  43657. /**
  43658. * Initializes the VRDistortionCorrectionPostProcess
  43659. * @param name The name of the effect.
  43660. * @param camera The camera to apply the render pass to.
  43661. * @param isRightEye If this is for the right eye distortion
  43662. * @param vrMetrics All the required metrics for the VR camera
  43663. */
  43664. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43665. }
  43666. }
  43667. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43668. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43669. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43670. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43671. import { Scene } from "babylonjs/scene";
  43672. import { Vector3 } from "babylonjs/Maths/math.vector";
  43673. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43674. import "babylonjs/Cameras/RigModes/vrRigMode";
  43675. /**
  43676. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43677. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43678. */
  43679. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43680. /**
  43681. * Creates a new VRDeviceOrientationArcRotateCamera
  43682. * @param name defines camera name
  43683. * @param alpha defines the camera rotation along the logitudinal axis
  43684. * @param beta defines the camera rotation along the latitudinal axis
  43685. * @param radius defines the camera distance from its target
  43686. * @param target defines the camera target
  43687. * @param scene defines the scene the camera belongs to
  43688. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43689. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43690. */
  43691. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43692. /**
  43693. * Gets camera class name
  43694. * @returns VRDeviceOrientationArcRotateCamera
  43695. */
  43696. getClassName(): string;
  43697. }
  43698. }
  43699. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43700. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43701. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43702. import { Scene } from "babylonjs/scene";
  43703. import { Vector3 } from "babylonjs/Maths/math.vector";
  43704. import "babylonjs/Cameras/RigModes/vrRigMode";
  43705. /**
  43706. * Camera used to simulate VR rendering (based on FreeCamera)
  43707. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43708. */
  43709. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43710. /**
  43711. * Creates a new VRDeviceOrientationFreeCamera
  43712. * @param name defines camera name
  43713. * @param position defines the start position of the camera
  43714. * @param scene defines the scene the camera belongs to
  43715. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43716. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43717. */
  43718. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43719. /**
  43720. * Gets camera class name
  43721. * @returns VRDeviceOrientationFreeCamera
  43722. */
  43723. getClassName(): string;
  43724. }
  43725. }
  43726. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43727. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43728. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43729. import { Scene } from "babylonjs/scene";
  43730. import { Vector3 } from "babylonjs/Maths/math.vector";
  43731. import "babylonjs/Gamepads/gamepadSceneComponent";
  43732. /**
  43733. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43734. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43735. */
  43736. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43737. /**
  43738. * Creates a new VRDeviceOrientationGamepadCamera
  43739. * @param name defines camera name
  43740. * @param position defines the start position of the camera
  43741. * @param scene defines the scene the camera belongs to
  43742. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43743. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43744. */
  43745. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43746. /**
  43747. * Gets camera class name
  43748. * @returns VRDeviceOrientationGamepadCamera
  43749. */
  43750. getClassName(): string;
  43751. }
  43752. }
  43753. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43754. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43755. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43756. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43757. /** @hidden */
  43758. export var imageProcessingPixelShader: {
  43759. name: string;
  43760. shader: string;
  43761. };
  43762. }
  43763. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43764. import { Nullable } from "babylonjs/types";
  43765. import { Color4 } from "babylonjs/Maths/math.color";
  43766. import { Camera } from "babylonjs/Cameras/camera";
  43767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43768. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43769. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43770. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43771. import { Engine } from "babylonjs/Engines/engine";
  43772. import "babylonjs/Shaders/imageProcessing.fragment";
  43773. import "babylonjs/Shaders/postprocess.vertex";
  43774. /**
  43775. * ImageProcessingPostProcess
  43776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43777. */
  43778. export class ImageProcessingPostProcess extends PostProcess {
  43779. /**
  43780. * Default configuration related to image processing available in the PBR Material.
  43781. */
  43782. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43783. /**
  43784. * Gets the image processing configuration used either in this material.
  43785. */
  43786. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43787. /**
  43788. * Sets the Default image processing configuration used either in the this material.
  43789. *
  43790. * If sets to null, the scene one is in use.
  43791. */
  43792. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43793. /**
  43794. * Keep track of the image processing observer to allow dispose and replace.
  43795. */
  43796. private _imageProcessingObserver;
  43797. /**
  43798. * Attaches a new image processing configuration to the PBR Material.
  43799. * @param configuration
  43800. */
  43801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43802. /**
  43803. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43804. */
  43805. get colorCurves(): Nullable<ColorCurves>;
  43806. /**
  43807. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43808. */
  43809. set colorCurves(value: Nullable<ColorCurves>);
  43810. /**
  43811. * Gets wether the color curves effect is enabled.
  43812. */
  43813. get colorCurvesEnabled(): boolean;
  43814. /**
  43815. * Sets wether the color curves effect is enabled.
  43816. */
  43817. set colorCurvesEnabled(value: boolean);
  43818. /**
  43819. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43820. */
  43821. get colorGradingTexture(): Nullable<BaseTexture>;
  43822. /**
  43823. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43824. */
  43825. set colorGradingTexture(value: Nullable<BaseTexture>);
  43826. /**
  43827. * Gets wether the color grading effect is enabled.
  43828. */
  43829. get colorGradingEnabled(): boolean;
  43830. /**
  43831. * Gets wether the color grading effect is enabled.
  43832. */
  43833. set colorGradingEnabled(value: boolean);
  43834. /**
  43835. * Gets exposure used in the effect.
  43836. */
  43837. get exposure(): number;
  43838. /**
  43839. * Sets exposure used in the effect.
  43840. */
  43841. set exposure(value: number);
  43842. /**
  43843. * Gets wether tonemapping is enabled or not.
  43844. */
  43845. get toneMappingEnabled(): boolean;
  43846. /**
  43847. * Sets wether tonemapping is enabled or not
  43848. */
  43849. set toneMappingEnabled(value: boolean);
  43850. /**
  43851. * Gets the type of tone mapping effect.
  43852. */
  43853. get toneMappingType(): number;
  43854. /**
  43855. * Sets the type of tone mapping effect.
  43856. */
  43857. set toneMappingType(value: number);
  43858. /**
  43859. * Gets contrast used in the effect.
  43860. */
  43861. get contrast(): number;
  43862. /**
  43863. * Sets contrast used in the effect.
  43864. */
  43865. set contrast(value: number);
  43866. /**
  43867. * Gets Vignette stretch size.
  43868. */
  43869. get vignetteStretch(): number;
  43870. /**
  43871. * Sets Vignette stretch size.
  43872. */
  43873. set vignetteStretch(value: number);
  43874. /**
  43875. * Gets Vignette centre X Offset.
  43876. */
  43877. get vignetteCentreX(): number;
  43878. /**
  43879. * Sets Vignette centre X Offset.
  43880. */
  43881. set vignetteCentreX(value: number);
  43882. /**
  43883. * Gets Vignette centre Y Offset.
  43884. */
  43885. get vignetteCentreY(): number;
  43886. /**
  43887. * Sets Vignette centre Y Offset.
  43888. */
  43889. set vignetteCentreY(value: number);
  43890. /**
  43891. * Gets Vignette weight or intensity of the vignette effect.
  43892. */
  43893. get vignetteWeight(): number;
  43894. /**
  43895. * Sets Vignette weight or intensity of the vignette effect.
  43896. */
  43897. set vignetteWeight(value: number);
  43898. /**
  43899. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43900. * if vignetteEnabled is set to true.
  43901. */
  43902. get vignetteColor(): Color4;
  43903. /**
  43904. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43905. * if vignetteEnabled is set to true.
  43906. */
  43907. set vignetteColor(value: Color4);
  43908. /**
  43909. * Gets Camera field of view used by the Vignette effect.
  43910. */
  43911. get vignetteCameraFov(): number;
  43912. /**
  43913. * Sets Camera field of view used by the Vignette effect.
  43914. */
  43915. set vignetteCameraFov(value: number);
  43916. /**
  43917. * Gets the vignette blend mode allowing different kind of effect.
  43918. */
  43919. get vignetteBlendMode(): number;
  43920. /**
  43921. * Sets the vignette blend mode allowing different kind of effect.
  43922. */
  43923. set vignetteBlendMode(value: number);
  43924. /**
  43925. * Gets wether the vignette effect is enabled.
  43926. */
  43927. get vignetteEnabled(): boolean;
  43928. /**
  43929. * Sets wether the vignette effect is enabled.
  43930. */
  43931. set vignetteEnabled(value: boolean);
  43932. private _fromLinearSpace;
  43933. /**
  43934. * Gets wether the input of the processing is in Gamma or Linear Space.
  43935. */
  43936. get fromLinearSpace(): boolean;
  43937. /**
  43938. * Sets wether the input of the processing is in Gamma or Linear Space.
  43939. */
  43940. set fromLinearSpace(value: boolean);
  43941. /**
  43942. * Defines cache preventing GC.
  43943. */
  43944. private _defines;
  43945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43946. /**
  43947. * "ImageProcessingPostProcess"
  43948. * @returns "ImageProcessingPostProcess"
  43949. */
  43950. getClassName(): string;
  43951. protected _updateParameters(): void;
  43952. dispose(camera?: Camera): void;
  43953. }
  43954. }
  43955. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43956. import { Scene } from "babylonjs/scene";
  43957. import { Color3 } from "babylonjs/Maths/math.color";
  43958. import { Mesh } from "babylonjs/Meshes/mesh";
  43959. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43960. import { Nullable } from "babylonjs/types";
  43961. /**
  43962. * Class containing static functions to help procedurally build meshes
  43963. */
  43964. export class GroundBuilder {
  43965. /**
  43966. * Creates a ground mesh
  43967. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43968. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43970. * @param name defines the name of the mesh
  43971. * @param options defines the options used to create the mesh
  43972. * @param scene defines the hosting scene
  43973. * @returns the ground mesh
  43974. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43975. */
  43976. static CreateGround(name: string, options: {
  43977. width?: number;
  43978. height?: number;
  43979. subdivisions?: number;
  43980. subdivisionsX?: number;
  43981. subdivisionsY?: number;
  43982. updatable?: boolean;
  43983. }, scene: any): Mesh;
  43984. /**
  43985. * Creates a tiled ground mesh
  43986. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43987. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43988. * * 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
  43989. * * 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
  43990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43991. * @param name defines the name of the mesh
  43992. * @param options defines the options used to create the mesh
  43993. * @param scene defines the hosting scene
  43994. * @returns the tiled ground mesh
  43995. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43996. */
  43997. static CreateTiledGround(name: string, options: {
  43998. xmin: number;
  43999. zmin: number;
  44000. xmax: number;
  44001. zmax: number;
  44002. subdivisions?: {
  44003. w: number;
  44004. h: number;
  44005. };
  44006. precision?: {
  44007. w: number;
  44008. h: number;
  44009. };
  44010. updatable?: boolean;
  44011. }, scene?: Nullable<Scene>): Mesh;
  44012. /**
  44013. * Creates a ground mesh from a height map
  44014. * * The parameter `url` sets the URL of the height map image resource.
  44015. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44016. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44017. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44018. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44019. * * 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.
  44020. * * 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).
  44021. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44023. * @param name defines the name of the mesh
  44024. * @param url defines the url to the height map
  44025. * @param options defines the options used to create the mesh
  44026. * @param scene defines the hosting scene
  44027. * @returns the ground mesh
  44028. * @see https://doc.babylonjs.com/babylon101/height_map
  44029. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44030. */
  44031. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44032. width?: number;
  44033. height?: number;
  44034. subdivisions?: number;
  44035. minHeight?: number;
  44036. maxHeight?: number;
  44037. colorFilter?: Color3;
  44038. alphaFilter?: number;
  44039. updatable?: boolean;
  44040. onReady?: (mesh: GroundMesh) => void;
  44041. }, scene?: Nullable<Scene>): GroundMesh;
  44042. }
  44043. }
  44044. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44045. import { Vector4 } from "babylonjs/Maths/math.vector";
  44046. import { Mesh } from "babylonjs/Meshes/mesh";
  44047. /**
  44048. * Class containing static functions to help procedurally build meshes
  44049. */
  44050. export class TorusBuilder {
  44051. /**
  44052. * Creates a torus mesh
  44053. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44054. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44055. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44059. * @param name defines the name of the mesh
  44060. * @param options defines the options used to create the mesh
  44061. * @param scene defines the hosting scene
  44062. * @returns the torus mesh
  44063. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44064. */
  44065. static CreateTorus(name: string, options: {
  44066. diameter?: number;
  44067. thickness?: number;
  44068. tessellation?: number;
  44069. updatable?: boolean;
  44070. sideOrientation?: number;
  44071. frontUVs?: Vector4;
  44072. backUVs?: Vector4;
  44073. }, scene: any): Mesh;
  44074. }
  44075. }
  44076. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44077. import { Vector4 } from "babylonjs/Maths/math.vector";
  44078. import { Color4 } from "babylonjs/Maths/math.color";
  44079. import { Mesh } from "babylonjs/Meshes/mesh";
  44080. /**
  44081. * Class containing static functions to help procedurally build meshes
  44082. */
  44083. export class CylinderBuilder {
  44084. /**
  44085. * Creates a cylinder or a cone mesh
  44086. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44087. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44088. * * 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.
  44089. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44090. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44091. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44092. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44093. * * 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).
  44094. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44095. * * 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).
  44096. * * 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
  44097. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44098. * * 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
  44099. * * 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.
  44100. * * If `enclose` is false, a ring surface is one element.
  44101. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44102. * * 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
  44103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44106. * @param name defines the name of the mesh
  44107. * @param options defines the options used to create the mesh
  44108. * @param scene defines the hosting scene
  44109. * @returns the cylinder mesh
  44110. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44111. */
  44112. static CreateCylinder(name: string, options: {
  44113. height?: number;
  44114. diameterTop?: number;
  44115. diameterBottom?: number;
  44116. diameter?: number;
  44117. tessellation?: number;
  44118. subdivisions?: number;
  44119. arc?: number;
  44120. faceColors?: Color4[];
  44121. faceUV?: Vector4[];
  44122. updatable?: boolean;
  44123. hasRings?: boolean;
  44124. enclose?: boolean;
  44125. cap?: number;
  44126. sideOrientation?: number;
  44127. frontUVs?: Vector4;
  44128. backUVs?: Vector4;
  44129. }, scene: any): Mesh;
  44130. }
  44131. }
  44132. declare module "babylonjs/XR/webXRTypes" {
  44133. import { Nullable } from "babylonjs/types";
  44134. import { IDisposable } from "babylonjs/scene";
  44135. /**
  44136. * States of the webXR experience
  44137. */
  44138. export enum WebXRState {
  44139. /**
  44140. * Transitioning to being in XR mode
  44141. */
  44142. ENTERING_XR = 0,
  44143. /**
  44144. * Transitioning to non XR mode
  44145. */
  44146. EXITING_XR = 1,
  44147. /**
  44148. * In XR mode and presenting
  44149. */
  44150. IN_XR = 2,
  44151. /**
  44152. * Not entered XR mode
  44153. */
  44154. NOT_IN_XR = 3
  44155. }
  44156. /**
  44157. * Abstraction of the XR render target
  44158. */
  44159. export interface WebXRRenderTarget extends IDisposable {
  44160. /**
  44161. * xrpresent context of the canvas which can be used to display/mirror xr content
  44162. */
  44163. canvasContext: WebGLRenderingContext;
  44164. /**
  44165. * xr layer for the canvas
  44166. */
  44167. xrLayer: Nullable<XRWebGLLayer>;
  44168. /**
  44169. * Initializes the xr layer for the session
  44170. * @param xrSession xr session
  44171. * @returns a promise that will resolve once the XR Layer has been created
  44172. */
  44173. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44174. }
  44175. }
  44176. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44177. import { Nullable } from "babylonjs/types";
  44178. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44179. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44180. /**
  44181. * COnfiguration object for WebXR output canvas
  44182. */
  44183. export class WebXRManagedOutputCanvasOptions {
  44184. /**
  44185. * An optional canvas in case you wish to create it yourself and provide it here.
  44186. * If not provided, a new canvas will be created
  44187. */
  44188. canvasElement?: HTMLCanvasElement;
  44189. /**
  44190. * Options for this XR Layer output
  44191. */
  44192. canvasOptions?: XRWebGLLayerOptions;
  44193. /**
  44194. * CSS styling for a newly created canvas (if not provided)
  44195. */
  44196. newCanvasCssStyle?: string;
  44197. /**
  44198. * Get the default values of the configuration object
  44199. * @returns default values of this configuration object
  44200. */
  44201. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44202. }
  44203. /**
  44204. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44205. */
  44206. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44207. private _options;
  44208. private _canvas;
  44209. private _engine;
  44210. /**
  44211. * Rendering context of the canvas which can be used to display/mirror xr content
  44212. */
  44213. canvasContext: WebGLRenderingContext;
  44214. /**
  44215. * xr layer for the canvas
  44216. */
  44217. xrLayer: Nullable<XRWebGLLayer>;
  44218. /**
  44219. * Initializes the canvas to be added/removed upon entering/exiting xr
  44220. * @param _xrSessionManager The XR Session manager
  44221. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44222. */
  44223. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44224. /**
  44225. * Disposes of the object
  44226. */
  44227. dispose(): void;
  44228. /**
  44229. * Initializes the xr layer for the session
  44230. * @param xrSession xr session
  44231. * @returns a promise that will resolve once the XR Layer has been created
  44232. */
  44233. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44234. private _addCanvas;
  44235. private _removeCanvas;
  44236. private _setManagedOutputCanvas;
  44237. }
  44238. }
  44239. declare module "babylonjs/XR/webXRSessionManager" {
  44240. import { Observable } from "babylonjs/Misc/observable";
  44241. import { Nullable } from "babylonjs/types";
  44242. import { IDisposable, Scene } from "babylonjs/scene";
  44243. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44244. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44245. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44246. /**
  44247. * Manages an XRSession to work with Babylon's engine
  44248. * @see https://doc.babylonjs.com/how_to/webxr
  44249. */
  44250. export class WebXRSessionManager implements IDisposable {
  44251. /** The scene which the session should be created for */
  44252. scene: Scene;
  44253. private _referenceSpace;
  44254. private _rttProvider;
  44255. private _sessionEnded;
  44256. private _xrNavigator;
  44257. private baseLayer;
  44258. /**
  44259. * The base reference space from which the session started. good if you want to reset your
  44260. * reference space
  44261. */
  44262. baseReferenceSpace: XRReferenceSpace;
  44263. /**
  44264. * Current XR frame
  44265. */
  44266. currentFrame: Nullable<XRFrame>;
  44267. /** WebXR timestamp updated every frame */
  44268. currentTimestamp: number;
  44269. /**
  44270. * Used just in case of a failure to initialize an immersive session.
  44271. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44272. */
  44273. defaultHeightCompensation: number;
  44274. /**
  44275. * Fires every time a new xrFrame arrives which can be used to update the camera
  44276. */
  44277. onXRFrameObservable: Observable<XRFrame>;
  44278. /**
  44279. * Fires when the reference space changed
  44280. */
  44281. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44282. /**
  44283. * Fires when the xr session is ended either by the device or manually done
  44284. */
  44285. onXRSessionEnded: Observable<any>;
  44286. /**
  44287. * Fires when the xr session is ended either by the device or manually done
  44288. */
  44289. onXRSessionInit: Observable<XRSession>;
  44290. /**
  44291. * Underlying xr session
  44292. */
  44293. session: XRSession;
  44294. /**
  44295. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44296. * or get the offset the player is currently at.
  44297. */
  44298. viewerReferenceSpace: XRReferenceSpace;
  44299. /**
  44300. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44301. * @param scene The scene which the session should be created for
  44302. */
  44303. constructor(
  44304. /** The scene which the session should be created for */
  44305. scene: Scene);
  44306. /**
  44307. * The current reference space used in this session. This reference space can constantly change!
  44308. * It is mainly used to offset the camera's position.
  44309. */
  44310. get referenceSpace(): XRReferenceSpace;
  44311. /**
  44312. * Set a new reference space and triggers the observable
  44313. */
  44314. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44315. /**
  44316. * Disposes of the session manager
  44317. */
  44318. dispose(): void;
  44319. /**
  44320. * Stops the xrSession and restores the render loop
  44321. * @returns Promise which resolves after it exits XR
  44322. */
  44323. exitXRAsync(): Promise<void>;
  44324. /**
  44325. * Gets the correct render target texture to be rendered this frame for this eye
  44326. * @param eye the eye for which to get the render target
  44327. * @returns the render target for the specified eye
  44328. */
  44329. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44330. /**
  44331. * Creates a WebXRRenderTarget object for the XR session
  44332. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44333. * @param options optional options to provide when creating a new render target
  44334. * @returns a WebXR render target to which the session can render
  44335. */
  44336. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44337. /**
  44338. * Initializes the manager
  44339. * After initialization enterXR can be called to start an XR session
  44340. * @returns Promise which resolves after it is initialized
  44341. */
  44342. initializeAsync(): Promise<void>;
  44343. /**
  44344. * Initializes an xr session
  44345. * @param xrSessionMode mode to initialize
  44346. * @param xrSessionInit defines optional and required values to pass to the session builder
  44347. * @returns a promise which will resolve once the session has been initialized
  44348. */
  44349. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44350. /**
  44351. * Checks if a session would be supported for the creation options specified
  44352. * @param sessionMode session mode to check if supported eg. immersive-vr
  44353. * @returns A Promise that resolves to true if supported and false if not
  44354. */
  44355. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44356. /**
  44357. * Resets the reference space to the one started the session
  44358. */
  44359. resetReferenceSpace(): void;
  44360. /**
  44361. * Starts rendering to the xr layer
  44362. */
  44363. runXRRenderLoop(): void;
  44364. /**
  44365. * Sets the reference space on the xr session
  44366. * @param referenceSpaceType space to set
  44367. * @returns a promise that will resolve once the reference space has been set
  44368. */
  44369. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44370. /**
  44371. * Updates the render state of the session
  44372. * @param state state to set
  44373. * @returns a promise that resolves once the render state has been updated
  44374. */
  44375. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44376. /**
  44377. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44378. * @param sessionMode defines the session to test
  44379. * @returns a promise with boolean as final value
  44380. */
  44381. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44382. private _createRenderTargetTexture;
  44383. }
  44384. }
  44385. declare module "babylonjs/XR/webXRCamera" {
  44386. import { Scene } from "babylonjs/scene";
  44387. import { Camera } from "babylonjs/Cameras/camera";
  44388. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44389. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44390. /**
  44391. * WebXR Camera which holds the views for the xrSession
  44392. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44393. */
  44394. export class WebXRCamera extends FreeCamera {
  44395. private _xrSessionManager;
  44396. private _firstFrame;
  44397. private _referenceQuaternion;
  44398. private _referencedPosition;
  44399. private _xrInvPositionCache;
  44400. private _xrInvQuaternionCache;
  44401. /**
  44402. * Should position compensation execute on first frame.
  44403. * This is used when copying the position from a native (non XR) camera
  44404. */
  44405. compensateOnFirstFrame: boolean;
  44406. /**
  44407. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44408. * @param name the name of the camera
  44409. * @param scene the scene to add the camera to
  44410. * @param _xrSessionManager a constructed xr session manager
  44411. */
  44412. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44413. /**
  44414. * Return the user's height, unrelated to the current ground.
  44415. * This will be the y position of this camera, when ground level is 0.
  44416. */
  44417. get realWorldHeight(): number;
  44418. /** @hidden */
  44419. _updateForDualEyeDebugging(): void;
  44420. /**
  44421. * Sets this camera's transformation based on a non-vr camera
  44422. * @param otherCamera the non-vr camera to copy the transformation from
  44423. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44424. */
  44425. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44426. /**
  44427. * Gets the current instance class name ("WebXRCamera").
  44428. * @returns the class name
  44429. */
  44430. getClassName(): string;
  44431. private _updateFromXRSession;
  44432. private _updateNumberOfRigCameras;
  44433. private _updateReferenceSpace;
  44434. private _updateReferenceSpaceOffset;
  44435. }
  44436. }
  44437. declare module "babylonjs/XR/webXRFeaturesManager" {
  44438. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44439. import { IDisposable } from "babylonjs/scene";
  44440. /**
  44441. * Defining the interface required for a (webxr) feature
  44442. */
  44443. export interface IWebXRFeature extends IDisposable {
  44444. /**
  44445. * Is this feature attached
  44446. */
  44447. attached: boolean;
  44448. /**
  44449. * Should auto-attach be disabled?
  44450. */
  44451. disableAutoAttach: boolean;
  44452. /**
  44453. * Attach the feature to the session
  44454. * Will usually be called by the features manager
  44455. *
  44456. * @param force should attachment be forced (even when already attached)
  44457. * @returns true if successful.
  44458. */
  44459. attach(force?: boolean): boolean;
  44460. /**
  44461. * Detach the feature from the session
  44462. * Will usually be called by the features manager
  44463. *
  44464. * @returns true if successful.
  44465. */
  44466. detach(): boolean;
  44467. }
  44468. /**
  44469. * A list of the currently available features without referencing them
  44470. */
  44471. export class WebXRFeatureName {
  44472. /**
  44473. * The name of the anchor system feature
  44474. */
  44475. static ANCHOR_SYSTEM: string;
  44476. /**
  44477. * The name of the background remover feature
  44478. */
  44479. static BACKGROUND_REMOVER: string;
  44480. /**
  44481. * The name of the hit test feature
  44482. */
  44483. static HIT_TEST: string;
  44484. /**
  44485. * physics impostors for xr controllers feature
  44486. */
  44487. static PHYSICS_CONTROLLERS: string;
  44488. /**
  44489. * The name of the plane detection feature
  44490. */
  44491. static PLANE_DETECTION: string;
  44492. /**
  44493. * The name of the pointer selection feature
  44494. */
  44495. static POINTER_SELECTION: string;
  44496. /**
  44497. * The name of the teleportation feature
  44498. */
  44499. static TELEPORTATION: string;
  44500. }
  44501. /**
  44502. * Defining the constructor of a feature. Used to register the modules.
  44503. */
  44504. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44505. /**
  44506. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44507. * It is mainly used in AR sessions.
  44508. *
  44509. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44510. */
  44511. export class WebXRFeaturesManager implements IDisposable {
  44512. private _xrSessionManager;
  44513. private static readonly _AvailableFeatures;
  44514. private _features;
  44515. /**
  44516. * constructs a new features manages.
  44517. *
  44518. * @param _xrSessionManager an instance of WebXRSessionManager
  44519. */
  44520. constructor(_xrSessionManager: WebXRSessionManager);
  44521. /**
  44522. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44523. * Mainly used internally.
  44524. *
  44525. * @param featureName the name of the feature to register
  44526. * @param constructorFunction the function used to construct the module
  44527. * @param version the (babylon) version of the module
  44528. * @param stable is that a stable version of this module
  44529. */
  44530. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44531. /**
  44532. * Returns a constructor of a specific feature.
  44533. *
  44534. * @param featureName the name of the feature to construct
  44535. * @param version the version of the feature to load
  44536. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44537. * @param options optional options provided to the module.
  44538. * @returns a function that, when called, will return a new instance of this feature
  44539. */
  44540. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44541. /**
  44542. * Can be used to return the list of features currently registered
  44543. *
  44544. * @returns an Array of available features
  44545. */
  44546. static GetAvailableFeatures(): string[];
  44547. /**
  44548. * Gets the versions available for a specific feature
  44549. * @param featureName the name of the feature
  44550. * @returns an array with the available versions
  44551. */
  44552. static GetAvailableVersions(featureName: string): string[];
  44553. /**
  44554. * Return the latest unstable version of this feature
  44555. * @param featureName the name of the feature to search
  44556. * @returns the version number. if not found will return -1
  44557. */
  44558. static GetLatestVersionOfFeature(featureName: string): number;
  44559. /**
  44560. * Return the latest stable version of this feature
  44561. * @param featureName the name of the feature to search
  44562. * @returns the version number. if not found will return -1
  44563. */
  44564. static GetStableVersionOfFeature(featureName: string): number;
  44565. /**
  44566. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44567. * Can be used during a session to start a feature
  44568. * @param featureName the name of feature to attach
  44569. */
  44570. attachFeature(featureName: string): void;
  44571. /**
  44572. * Can be used inside a session or when the session ends to detach a specific feature
  44573. * @param featureName the name of the feature to detach
  44574. */
  44575. detachFeature(featureName: string): void;
  44576. /**
  44577. * Used to disable an already-enabled feature
  44578. * The feature will be disposed and will be recreated once enabled.
  44579. * @param featureName the feature to disable
  44580. * @returns true if disable was successful
  44581. */
  44582. disableFeature(featureName: string | {
  44583. Name: string;
  44584. }): boolean;
  44585. /**
  44586. * dispose this features manager
  44587. */
  44588. dispose(): void;
  44589. /**
  44590. * 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.
  44591. * 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.
  44592. *
  44593. * @param featureName the name of the feature to load or the class of the feature
  44594. * @param version optional version to load. if not provided the latest version will be enabled
  44595. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44596. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44597. * @returns a new constructed feature or throws an error if feature not found.
  44598. */
  44599. enableFeature(featureName: string | {
  44600. Name: string;
  44601. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44602. /**
  44603. * get the implementation of an enabled feature.
  44604. * @param featureName the name of the feature to load
  44605. * @returns the feature class, if found
  44606. */
  44607. getEnabledFeature(featureName: string): IWebXRFeature;
  44608. /**
  44609. * Get the list of enabled features
  44610. * @returns an array of enabled features
  44611. */
  44612. getEnabledFeatures(): string[];
  44613. }
  44614. }
  44615. declare module "babylonjs/XR/webXRExperienceHelper" {
  44616. import { Observable } from "babylonjs/Misc/observable";
  44617. import { IDisposable, Scene } from "babylonjs/scene";
  44618. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44619. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44620. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44621. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44622. /**
  44623. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44624. * @see https://doc.babylonjs.com/how_to/webxr
  44625. */
  44626. export class WebXRExperienceHelper implements IDisposable {
  44627. private scene;
  44628. private _nonVRCamera;
  44629. private _originalSceneAutoClear;
  44630. private _supported;
  44631. /**
  44632. * Camera used to render xr content
  44633. */
  44634. camera: WebXRCamera;
  44635. /** A features manager for this xr session */
  44636. featuresManager: WebXRFeaturesManager;
  44637. /**
  44638. * Observers registered here will be triggered after the camera's initial transformation is set
  44639. * This can be used to set a different ground level or an extra rotation.
  44640. *
  44641. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44642. * to the position set after this observable is done executing.
  44643. */
  44644. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44645. /**
  44646. * Fires when the state of the experience helper has changed
  44647. */
  44648. onStateChangedObservable: Observable<WebXRState>;
  44649. /** Session manager used to keep track of xr session */
  44650. sessionManager: WebXRSessionManager;
  44651. /**
  44652. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44653. */
  44654. state: WebXRState;
  44655. /**
  44656. * Creates a WebXRExperienceHelper
  44657. * @param scene The scene the helper should be created in
  44658. */
  44659. private constructor();
  44660. /**
  44661. * Creates the experience helper
  44662. * @param scene the scene to attach the experience helper to
  44663. * @returns a promise for the experience helper
  44664. */
  44665. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44666. /**
  44667. * Disposes of the experience helper
  44668. */
  44669. dispose(): void;
  44670. /**
  44671. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44672. * @param sessionMode options for the XR session
  44673. * @param referenceSpaceType frame of reference of the XR session
  44674. * @param renderTarget the output canvas that will be used to enter XR mode
  44675. * @returns promise that resolves after xr mode has entered
  44676. */
  44677. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44678. /**
  44679. * Exits XR mode and returns the scene to its original state
  44680. * @returns promise that resolves after xr mode has exited
  44681. */
  44682. exitXRAsync(): Promise<void>;
  44683. private _nonXRToXRCamera;
  44684. private _setState;
  44685. }
  44686. }
  44687. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44688. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44689. import { Observable } from "babylonjs/Misc/observable";
  44690. import { IDisposable } from "babylonjs/scene";
  44691. /**
  44692. * X-Y values for axes in WebXR
  44693. */
  44694. export interface IWebXRMotionControllerAxesValue {
  44695. /**
  44696. * The value of the x axis
  44697. */
  44698. x: number;
  44699. /**
  44700. * The value of the y-axis
  44701. */
  44702. y: number;
  44703. }
  44704. /**
  44705. * changed / previous values for the values of this component
  44706. */
  44707. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44708. /**
  44709. * current (this frame) value
  44710. */
  44711. current: T;
  44712. /**
  44713. * previous (last change) value
  44714. */
  44715. previous: T;
  44716. }
  44717. /**
  44718. * Represents changes in the component between current frame and last values recorded
  44719. */
  44720. export interface IWebXRMotionControllerComponentChanges {
  44721. /**
  44722. * will be populated with previous and current values if axes changed
  44723. */
  44724. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44725. /**
  44726. * will be populated with previous and current values if pressed changed
  44727. */
  44728. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44729. /**
  44730. * will be populated with previous and current values if touched changed
  44731. */
  44732. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44733. /**
  44734. * will be populated with previous and current values if value changed
  44735. */
  44736. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44737. }
  44738. /**
  44739. * This class represents a single component (for example button or thumbstick) of a motion controller
  44740. */
  44741. export class WebXRControllerComponent implements IDisposable {
  44742. /**
  44743. * the id of this component
  44744. */
  44745. id: string;
  44746. /**
  44747. * the type of the component
  44748. */
  44749. type: MotionControllerComponentType;
  44750. private _buttonIndex;
  44751. private _axesIndices;
  44752. private _axes;
  44753. private _changes;
  44754. private _currentValue;
  44755. private _hasChanges;
  44756. private _pressed;
  44757. private _touched;
  44758. /**
  44759. * button component type
  44760. */
  44761. static BUTTON_TYPE: MotionControllerComponentType;
  44762. /**
  44763. * squeeze component type
  44764. */
  44765. static SQUEEZE_TYPE: MotionControllerComponentType;
  44766. /**
  44767. * Thumbstick component type
  44768. */
  44769. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44770. /**
  44771. * Touchpad component type
  44772. */
  44773. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44774. /**
  44775. * trigger component type
  44776. */
  44777. static TRIGGER_TYPE: MotionControllerComponentType;
  44778. /**
  44779. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44780. * the axes data changes
  44781. */
  44782. onAxisValueChangedObservable: Observable<{
  44783. x: number;
  44784. y: number;
  44785. }>;
  44786. /**
  44787. * Observers registered here will be triggered when the state of a button changes
  44788. * State change is either pressed / touched / value
  44789. */
  44790. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44791. /**
  44792. * Creates a new component for a motion controller.
  44793. * It is created by the motion controller itself
  44794. *
  44795. * @param id the id of this component
  44796. * @param type the type of the component
  44797. * @param _buttonIndex index in the buttons array of the gamepad
  44798. * @param _axesIndices indices of the values in the axes array of the gamepad
  44799. */
  44800. constructor(
  44801. /**
  44802. * the id of this component
  44803. */
  44804. id: string,
  44805. /**
  44806. * the type of the component
  44807. */
  44808. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44809. /**
  44810. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44811. */
  44812. get axes(): IWebXRMotionControllerAxesValue;
  44813. /**
  44814. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44815. */
  44816. get changes(): IWebXRMotionControllerComponentChanges;
  44817. /**
  44818. * Return whether or not the component changed the last frame
  44819. */
  44820. get hasChanges(): boolean;
  44821. /**
  44822. * is the button currently pressed
  44823. */
  44824. get pressed(): boolean;
  44825. /**
  44826. * is the button currently touched
  44827. */
  44828. get touched(): boolean;
  44829. /**
  44830. * Get the current value of this component
  44831. */
  44832. get value(): number;
  44833. /**
  44834. * Dispose this component
  44835. */
  44836. dispose(): void;
  44837. /**
  44838. * Are there axes correlating to this component
  44839. * @return true is axes data is available
  44840. */
  44841. isAxes(): boolean;
  44842. /**
  44843. * Is this component a button (hence - pressable)
  44844. * @returns true if can be pressed
  44845. */
  44846. isButton(): boolean;
  44847. /**
  44848. * update this component using the gamepad object it is in. Called on every frame
  44849. * @param nativeController the native gamepad controller object
  44850. */
  44851. update(nativeController: IMinimalMotionControllerObject): void;
  44852. }
  44853. }
  44854. declare module "babylonjs/Loading/sceneLoader" {
  44855. import { Observable } from "babylonjs/Misc/observable";
  44856. import { Nullable } from "babylonjs/types";
  44857. import { Scene } from "babylonjs/scene";
  44858. import { Engine } from "babylonjs/Engines/engine";
  44859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44860. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44861. import { AssetContainer } from "babylonjs/assetContainer";
  44862. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44863. import { Skeleton } from "babylonjs/Bones/skeleton";
  44864. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44865. import { WebRequest } from "babylonjs/Misc/webRequest";
  44866. /**
  44867. * Class used to represent data loading progression
  44868. */
  44869. export class SceneLoaderProgressEvent {
  44870. /** defines if data length to load can be evaluated */
  44871. readonly lengthComputable: boolean;
  44872. /** defines the loaded data length */
  44873. readonly loaded: number;
  44874. /** defines the data length to load */
  44875. readonly total: number;
  44876. /**
  44877. * Create a new progress event
  44878. * @param lengthComputable defines if data length to load can be evaluated
  44879. * @param loaded defines the loaded data length
  44880. * @param total defines the data length to load
  44881. */
  44882. constructor(
  44883. /** defines if data length to load can be evaluated */
  44884. lengthComputable: boolean,
  44885. /** defines the loaded data length */
  44886. loaded: number,
  44887. /** defines the data length to load */
  44888. total: number);
  44889. /**
  44890. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44891. * @param event defines the source event
  44892. * @returns a new SceneLoaderProgressEvent
  44893. */
  44894. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44895. }
  44896. /**
  44897. * Interface used by SceneLoader plugins to define supported file extensions
  44898. */
  44899. export interface ISceneLoaderPluginExtensions {
  44900. /**
  44901. * Defines the list of supported extensions
  44902. */
  44903. [extension: string]: {
  44904. isBinary: boolean;
  44905. };
  44906. }
  44907. /**
  44908. * Interface used by SceneLoader plugin factory
  44909. */
  44910. export interface ISceneLoaderPluginFactory {
  44911. /**
  44912. * Defines the name of the factory
  44913. */
  44914. name: string;
  44915. /**
  44916. * Function called to create a new plugin
  44917. * @return the new plugin
  44918. */
  44919. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44920. /**
  44921. * The callback that returns true if the data can be directly loaded.
  44922. * @param data string containing the file data
  44923. * @returns if the data can be loaded directly
  44924. */
  44925. canDirectLoad?(data: string): boolean;
  44926. }
  44927. /**
  44928. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44929. */
  44930. export interface ISceneLoaderPluginBase {
  44931. /**
  44932. * The friendly name of this plugin.
  44933. */
  44934. name: string;
  44935. /**
  44936. * The file extensions supported by this plugin.
  44937. */
  44938. extensions: string | ISceneLoaderPluginExtensions;
  44939. /**
  44940. * The callback called when loading from a url.
  44941. * @param scene scene loading this url
  44942. * @param url url to load
  44943. * @param onSuccess callback called when the file successfully loads
  44944. * @param onProgress callback called while file is loading (if the server supports this mode)
  44945. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44946. * @param onError callback called when the file fails to load
  44947. * @returns a file request object
  44948. */
  44949. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44950. /**
  44951. * The callback called when loading from a file object.
  44952. * @param scene scene loading this file
  44953. * @param file defines the file to load
  44954. * @param onSuccess defines the callback to call when data is loaded
  44955. * @param onProgress defines the callback to call during loading process
  44956. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44957. * @param onError defines the callback to call when an error occurs
  44958. * @returns a file request object
  44959. */
  44960. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44961. /**
  44962. * The callback that returns true if the data can be directly loaded.
  44963. * @param data string containing the file data
  44964. * @returns if the data can be loaded directly
  44965. */
  44966. canDirectLoad?(data: string): boolean;
  44967. /**
  44968. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44969. * @param scene scene loading this data
  44970. * @param data string containing the data
  44971. * @returns data to pass to the plugin
  44972. */
  44973. directLoad?(scene: Scene, data: string): any;
  44974. /**
  44975. * The callback that allows custom handling of the root url based on the response url.
  44976. * @param rootUrl the original root url
  44977. * @param responseURL the response url if available
  44978. * @returns the new root url
  44979. */
  44980. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44981. }
  44982. /**
  44983. * Interface used to define a SceneLoader plugin
  44984. */
  44985. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44986. /**
  44987. * Import meshes into a scene.
  44988. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44989. * @param scene The scene to import into
  44990. * @param data The data to import
  44991. * @param rootUrl The root url for scene and resources
  44992. * @param meshes The meshes array to import into
  44993. * @param particleSystems The particle systems array to import into
  44994. * @param skeletons The skeletons array to import into
  44995. * @param onError The callback when import fails
  44996. * @returns True if successful or false otherwise
  44997. */
  44998. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44999. /**
  45000. * Load into a scene.
  45001. * @param scene The scene to load into
  45002. * @param data The data to import
  45003. * @param rootUrl The root url for scene and resources
  45004. * @param onError The callback when import fails
  45005. * @returns True if successful or false otherwise
  45006. */
  45007. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45008. /**
  45009. * Load into an asset container.
  45010. * @param scene The scene to load into
  45011. * @param data The data to import
  45012. * @param rootUrl The root url for scene and resources
  45013. * @param onError The callback when import fails
  45014. * @returns The loaded asset container
  45015. */
  45016. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45017. }
  45018. /**
  45019. * Interface used to define an async SceneLoader plugin
  45020. */
  45021. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45022. /**
  45023. * Import meshes into a scene.
  45024. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45025. * @param scene The scene to import into
  45026. * @param data The data to import
  45027. * @param rootUrl The root url for scene and resources
  45028. * @param onProgress The callback when the load progresses
  45029. * @param fileName Defines the name of the file to load
  45030. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45031. */
  45032. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45033. meshes: AbstractMesh[];
  45034. particleSystems: IParticleSystem[];
  45035. skeletons: Skeleton[];
  45036. animationGroups: AnimationGroup[];
  45037. }>;
  45038. /**
  45039. * Load into a scene.
  45040. * @param scene The scene to load into
  45041. * @param data The data to import
  45042. * @param rootUrl The root url for scene and resources
  45043. * @param onProgress The callback when the load progresses
  45044. * @param fileName Defines the name of the file to load
  45045. * @returns Nothing
  45046. */
  45047. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45048. /**
  45049. * Load into an asset container.
  45050. * @param scene The scene to load into
  45051. * @param data The data to import
  45052. * @param rootUrl The root url for scene and resources
  45053. * @param onProgress The callback when the load progresses
  45054. * @param fileName Defines the name of the file to load
  45055. * @returns The loaded asset container
  45056. */
  45057. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45058. }
  45059. /**
  45060. * Mode that determines how to handle old animation groups before loading new ones.
  45061. */
  45062. export enum SceneLoaderAnimationGroupLoadingMode {
  45063. /**
  45064. * Reset all old animations to initial state then dispose them.
  45065. */
  45066. Clean = 0,
  45067. /**
  45068. * Stop all old animations.
  45069. */
  45070. Stop = 1,
  45071. /**
  45072. * Restart old animations from first frame.
  45073. */
  45074. Sync = 2,
  45075. /**
  45076. * Old animations remains untouched.
  45077. */
  45078. NoSync = 3
  45079. }
  45080. /**
  45081. * Class used to load scene from various file formats using registered plugins
  45082. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45083. */
  45084. export class SceneLoader {
  45085. /**
  45086. * No logging while loading
  45087. */
  45088. static readonly NO_LOGGING: number;
  45089. /**
  45090. * Minimal logging while loading
  45091. */
  45092. static readonly MINIMAL_LOGGING: number;
  45093. /**
  45094. * Summary logging while loading
  45095. */
  45096. static readonly SUMMARY_LOGGING: number;
  45097. /**
  45098. * Detailled logging while loading
  45099. */
  45100. static readonly DETAILED_LOGGING: number;
  45101. /**
  45102. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45103. */
  45104. static get ForceFullSceneLoadingForIncremental(): boolean;
  45105. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45106. /**
  45107. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45108. */
  45109. static get ShowLoadingScreen(): boolean;
  45110. static set ShowLoadingScreen(value: boolean);
  45111. /**
  45112. * Defines the current logging level (while loading the scene)
  45113. * @ignorenaming
  45114. */
  45115. static get loggingLevel(): number;
  45116. static set loggingLevel(value: number);
  45117. /**
  45118. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45119. */
  45120. static get CleanBoneMatrixWeights(): boolean;
  45121. static set CleanBoneMatrixWeights(value: boolean);
  45122. /**
  45123. * Event raised when a plugin is used to load a scene
  45124. */
  45125. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45126. private static _registeredPlugins;
  45127. private static _getDefaultPlugin;
  45128. private static _getPluginForExtension;
  45129. private static _getPluginForDirectLoad;
  45130. private static _getPluginForFilename;
  45131. private static _getDirectLoad;
  45132. private static _loadData;
  45133. private static _getFileInfo;
  45134. /**
  45135. * Gets a plugin that can load the given extension
  45136. * @param extension defines the extension to load
  45137. * @returns a plugin or null if none works
  45138. */
  45139. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45140. /**
  45141. * Gets a boolean indicating that the given extension can be loaded
  45142. * @param extension defines the extension to load
  45143. * @returns true if the extension is supported
  45144. */
  45145. static IsPluginForExtensionAvailable(extension: string): boolean;
  45146. /**
  45147. * Adds a new plugin to the list of registered plugins
  45148. * @param plugin defines the plugin to add
  45149. */
  45150. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45151. /**
  45152. * Import meshes into a scene
  45153. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45154. * @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)
  45155. * @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)
  45156. * @param scene the instance of BABYLON.Scene to append to
  45157. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45158. * @param onProgress a callback with a progress event for each file being loaded
  45159. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45160. * @param pluginExtension the extension used to determine the plugin
  45161. * @returns The loaded plugin
  45162. */
  45163. 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>;
  45164. /**
  45165. * Import meshes into a scene
  45166. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45167. * @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)
  45168. * @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)
  45169. * @param scene the instance of BABYLON.Scene to append to
  45170. * @param onProgress a callback with a progress event for each file being loaded
  45171. * @param pluginExtension the extension used to determine the plugin
  45172. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45173. */
  45174. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45175. meshes: AbstractMesh[];
  45176. particleSystems: IParticleSystem[];
  45177. skeletons: Skeleton[];
  45178. animationGroups: AnimationGroup[];
  45179. }>;
  45180. /**
  45181. * Load a scene
  45182. * @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)
  45183. * @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)
  45184. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45185. * @param onSuccess a callback with the scene when import succeeds
  45186. * @param onProgress a callback with a progress event for each file being loaded
  45187. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45188. * @param pluginExtension the extension used to determine the plugin
  45189. * @returns The loaded plugin
  45190. */
  45191. 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>;
  45192. /**
  45193. * Load a scene
  45194. * @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)
  45195. * @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)
  45196. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45197. * @param onProgress a callback with a progress event for each file being loaded
  45198. * @param pluginExtension the extension used to determine the plugin
  45199. * @returns The loaded scene
  45200. */
  45201. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45202. /**
  45203. * Append a scene
  45204. * @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)
  45205. * @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)
  45206. * @param scene is the instance of BABYLON.Scene to append to
  45207. * @param onSuccess a callback with the scene when import succeeds
  45208. * @param onProgress a callback with a progress event for each file being loaded
  45209. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45210. * @param pluginExtension the extension used to determine the plugin
  45211. * @returns The loaded plugin
  45212. */
  45213. 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>;
  45214. /**
  45215. * Append a scene
  45216. * @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)
  45217. * @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)
  45218. * @param scene is the instance of BABYLON.Scene to append to
  45219. * @param onProgress a callback with a progress event for each file being loaded
  45220. * @param pluginExtension the extension used to determine the plugin
  45221. * @returns The given scene
  45222. */
  45223. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45224. /**
  45225. * Load a scene into an asset container
  45226. * @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)
  45227. * @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)
  45228. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45229. * @param onSuccess a callback with the scene when import succeeds
  45230. * @param onProgress a callback with a progress event for each file being loaded
  45231. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45232. * @param pluginExtension the extension used to determine the plugin
  45233. * @returns The loaded plugin
  45234. */
  45235. 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>;
  45236. /**
  45237. * Load a scene into an asset container
  45238. * @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)
  45239. * @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)
  45240. * @param scene is the instance of Scene to append to
  45241. * @param onProgress a callback with a progress event for each file being loaded
  45242. * @param pluginExtension the extension used to determine the plugin
  45243. * @returns The loaded asset container
  45244. */
  45245. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45246. /**
  45247. * Import animations from a file into a scene
  45248. * @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)
  45249. * @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)
  45250. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45251. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45252. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45253. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45254. * @param onSuccess a callback with the scene when import succeeds
  45255. * @param onProgress a callback with a progress event for each file being loaded
  45256. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45257. */
  45258. 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;
  45259. /**
  45260. * Import animations from a file into a scene
  45261. * @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)
  45262. * @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)
  45263. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45264. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45265. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45266. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45267. * @param onSuccess a callback with the scene when import succeeds
  45268. * @param onProgress a callback with a progress event for each file being loaded
  45269. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45270. * @returns the updated scene with imported animations
  45271. */
  45272. 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>;
  45273. }
  45274. }
  45275. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45276. import { IDisposable, Scene } from "babylonjs/scene";
  45277. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45278. import { Observable } from "babylonjs/Misc/observable";
  45279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45280. import { Nullable } from "babylonjs/types";
  45281. /**
  45282. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45283. */
  45284. export type MotionControllerHandness = "none" | "left" | "right";
  45285. /**
  45286. * The type of components available in motion controllers.
  45287. * This is not the name of the component.
  45288. */
  45289. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45290. /**
  45291. * The state of a controller component
  45292. */
  45293. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45294. /**
  45295. * The schema of motion controller layout.
  45296. * No object will be initialized using this interface
  45297. * This is used just to define the profile.
  45298. */
  45299. export interface IMotionControllerLayout {
  45300. /**
  45301. * Path to load the assets. Usually relative to the base path
  45302. */
  45303. assetPath: string;
  45304. /**
  45305. * Available components (unsorted)
  45306. */
  45307. components: {
  45308. /**
  45309. * A map of component Ids
  45310. */
  45311. [componentId: string]: {
  45312. /**
  45313. * The type of input the component outputs
  45314. */
  45315. type: MotionControllerComponentType;
  45316. /**
  45317. * The indices of this component in the gamepad object
  45318. */
  45319. gamepadIndices: {
  45320. /**
  45321. * Index of button
  45322. */
  45323. button?: number;
  45324. /**
  45325. * If available, index of x-axis
  45326. */
  45327. xAxis?: number;
  45328. /**
  45329. * If available, index of y-axis
  45330. */
  45331. yAxis?: number;
  45332. };
  45333. /**
  45334. * The mesh's root node name
  45335. */
  45336. rootNodeName: string;
  45337. /**
  45338. * Animation definitions for this model
  45339. */
  45340. visualResponses: {
  45341. [stateKey: string]: {
  45342. /**
  45343. * What property will be animated
  45344. */
  45345. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45346. /**
  45347. * What states influence this visual response
  45348. */
  45349. states: MotionControllerComponentStateType[];
  45350. /**
  45351. * Type of animation - movement or visibility
  45352. */
  45353. valueNodeProperty: "transform" | "visibility";
  45354. /**
  45355. * Base node name to move. Its position will be calculated according to the min and max nodes
  45356. */
  45357. valueNodeName?: string;
  45358. /**
  45359. * Minimum movement node
  45360. */
  45361. minNodeName?: string;
  45362. /**
  45363. * Max movement node
  45364. */
  45365. maxNodeName?: string;
  45366. };
  45367. };
  45368. /**
  45369. * If touch enabled, what is the name of node to display user feedback
  45370. */
  45371. touchPointNodeName?: string;
  45372. };
  45373. };
  45374. /**
  45375. * Is it xr standard mapping or not
  45376. */
  45377. gamepadMapping: "" | "xr-standard";
  45378. /**
  45379. * Base root node of this entire model
  45380. */
  45381. rootNodeName: string;
  45382. /**
  45383. * Defines the main button component id
  45384. */
  45385. selectComponentId: string;
  45386. }
  45387. /**
  45388. * A definition for the layout map in the input profile
  45389. */
  45390. export interface IMotionControllerLayoutMap {
  45391. /**
  45392. * Layouts with handness type as a key
  45393. */
  45394. [handness: string]: IMotionControllerLayout;
  45395. }
  45396. /**
  45397. * The XR Input profile schema
  45398. * Profiles can be found here:
  45399. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45400. */
  45401. export interface IMotionControllerProfile {
  45402. /**
  45403. * fallback profiles for this profileId
  45404. */
  45405. fallbackProfileIds: string[];
  45406. /**
  45407. * The layout map, with handness as key
  45408. */
  45409. layouts: IMotionControllerLayoutMap;
  45410. /**
  45411. * The id of this profile
  45412. * correlates to the profile(s) in the xrInput.profiles array
  45413. */
  45414. profileId: string;
  45415. }
  45416. /**
  45417. * A helper-interface for the 3 meshes needed for controller button animation
  45418. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45419. */
  45420. export interface IMotionControllerButtonMeshMap {
  45421. /**
  45422. * the mesh that defines the pressed value mesh position.
  45423. * This is used to find the max-position of this button
  45424. */
  45425. pressedMesh: AbstractMesh;
  45426. /**
  45427. * the mesh that defines the unpressed value mesh position.
  45428. * This is used to find the min (or initial) position of this button
  45429. */
  45430. unpressedMesh: AbstractMesh;
  45431. /**
  45432. * The mesh that will be changed when value changes
  45433. */
  45434. valueMesh: AbstractMesh;
  45435. }
  45436. /**
  45437. * A helper-interface for the 3 meshes needed for controller axis animation.
  45438. * This will be expanded when touchpad animations are fully supported
  45439. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45440. */
  45441. export interface IMotionControllerMeshMap {
  45442. /**
  45443. * the mesh that defines the maximum value mesh position.
  45444. */
  45445. maxMesh?: AbstractMesh;
  45446. /**
  45447. * the mesh that defines the minimum value mesh position.
  45448. */
  45449. minMesh?: AbstractMesh;
  45450. /**
  45451. * The mesh that will be changed when axis value changes
  45452. */
  45453. valueMesh: AbstractMesh;
  45454. }
  45455. /**
  45456. * The elements needed for change-detection of the gamepad objects in motion controllers
  45457. */
  45458. export interface IMinimalMotionControllerObject {
  45459. /**
  45460. * Available axes of this controller
  45461. */
  45462. axes: number[];
  45463. /**
  45464. * An array of available buttons
  45465. */
  45466. buttons: Array<{
  45467. /**
  45468. * Value of the button/trigger
  45469. */
  45470. value: number;
  45471. /**
  45472. * If the button/trigger is currently touched
  45473. */
  45474. touched: boolean;
  45475. /**
  45476. * If the button/trigger is currently pressed
  45477. */
  45478. pressed: boolean;
  45479. }>;
  45480. }
  45481. /**
  45482. * An Abstract Motion controller
  45483. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45484. * Each component has an observable to check for changes in value and state
  45485. */
  45486. export abstract class WebXRAbstractMotionController implements IDisposable {
  45487. protected scene: Scene;
  45488. protected layout: IMotionControllerLayout;
  45489. /**
  45490. * The gamepad object correlating to this controller
  45491. */
  45492. gamepadObject: IMinimalMotionControllerObject;
  45493. /**
  45494. * handness (left/right/none) of this controller
  45495. */
  45496. handness: MotionControllerHandness;
  45497. private _initComponent;
  45498. private _modelReady;
  45499. /**
  45500. * A map of components (WebXRControllerComponent) in this motion controller
  45501. * Components have a ComponentType and can also have both button and axis definitions
  45502. */
  45503. readonly components: {
  45504. [id: string]: WebXRControllerComponent;
  45505. };
  45506. /**
  45507. * Disable the model's animation. Can be set at any time.
  45508. */
  45509. disableAnimation: boolean;
  45510. /**
  45511. * Observers registered here will be triggered when the model of this controller is done loading
  45512. */
  45513. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45514. /**
  45515. * The profile id of this motion controller
  45516. */
  45517. abstract profileId: string;
  45518. /**
  45519. * The root mesh of the model. It is null if the model was not yet initialized
  45520. */
  45521. rootMesh: Nullable<AbstractMesh>;
  45522. /**
  45523. * constructs a new abstract motion controller
  45524. * @param scene the scene to which the model of the controller will be added
  45525. * @param layout The profile layout to load
  45526. * @param gamepadObject The gamepad object correlating to this controller
  45527. * @param handness handness (left/right/none) of this controller
  45528. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45529. */
  45530. constructor(scene: Scene, layout: IMotionControllerLayout,
  45531. /**
  45532. * The gamepad object correlating to this controller
  45533. */
  45534. gamepadObject: IMinimalMotionControllerObject,
  45535. /**
  45536. * handness (left/right/none) of this controller
  45537. */
  45538. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45539. /**
  45540. * Dispose this controller, the model mesh and all its components
  45541. */
  45542. dispose(): void;
  45543. /**
  45544. * Returns all components of specific type
  45545. * @param type the type to search for
  45546. * @return an array of components with this type
  45547. */
  45548. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45549. /**
  45550. * get a component based an its component id as defined in layout.components
  45551. * @param id the id of the component
  45552. * @returns the component correlates to the id or undefined if not found
  45553. */
  45554. getComponent(id: string): WebXRControllerComponent;
  45555. /**
  45556. * Get the list of components available in this motion controller
  45557. * @returns an array of strings correlating to available components
  45558. */
  45559. getComponentIds(): string[];
  45560. /**
  45561. * Get the first component of specific type
  45562. * @param type type of component to find
  45563. * @return a controller component or null if not found
  45564. */
  45565. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45566. /**
  45567. * Get the main (Select) component of this controller as defined in the layout
  45568. * @returns the main component of this controller
  45569. */
  45570. getMainComponent(): WebXRControllerComponent;
  45571. /**
  45572. * Loads the model correlating to this controller
  45573. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45574. * @returns A promise fulfilled with the result of the model loading
  45575. */
  45576. loadModel(): Promise<boolean>;
  45577. /**
  45578. * Update this model using the current XRFrame
  45579. * @param xrFrame the current xr frame to use and update the model
  45580. */
  45581. updateFromXRFrame(xrFrame: XRFrame): void;
  45582. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45583. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45584. /**
  45585. * Moves the axis on the controller mesh based on its current state
  45586. * @param axis the index of the axis
  45587. * @param axisValue the value of the axis which determines the meshes new position
  45588. * @hidden
  45589. */
  45590. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45591. /**
  45592. * Update the model itself with the current frame data
  45593. * @param xrFrame the frame to use for updating the model mesh
  45594. */
  45595. protected updateModel(xrFrame: XRFrame): void;
  45596. /**
  45597. * Get the filename and path for this controller's model
  45598. * @returns a map of filename and path
  45599. */
  45600. protected abstract _getFilenameAndPath(): {
  45601. filename: string;
  45602. path: string;
  45603. };
  45604. /**
  45605. * This function is called before the mesh is loaded. It checks for loading constraints.
  45606. * For example, this function can check if the GLB loader is available
  45607. * If this function returns false, the generic controller will be loaded instead
  45608. * @returns Is the client ready to load the mesh
  45609. */
  45610. protected abstract _getModelLoadingConstraints(): boolean;
  45611. /**
  45612. * This function will be called after the model was successfully loaded and can be used
  45613. * for mesh transformations before it is available for the user
  45614. * @param meshes the loaded meshes
  45615. */
  45616. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45617. /**
  45618. * Set the root mesh for this controller. Important for the WebXR controller class
  45619. * @param meshes the loaded meshes
  45620. */
  45621. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45622. /**
  45623. * A function executed each frame that updates the mesh (if needed)
  45624. * @param xrFrame the current xrFrame
  45625. */
  45626. protected abstract _updateModel(xrFrame: XRFrame): void;
  45627. private _getGenericFilenameAndPath;
  45628. private _getGenericParentMesh;
  45629. }
  45630. }
  45631. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45632. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45634. import { Scene } from "babylonjs/scene";
  45635. /**
  45636. * A generic trigger-only motion controller for WebXR
  45637. */
  45638. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45639. /**
  45640. * Static version of the profile id of this controller
  45641. */
  45642. static ProfileId: string;
  45643. profileId: string;
  45644. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45645. protected _getFilenameAndPath(): {
  45646. filename: string;
  45647. path: string;
  45648. };
  45649. protected _getModelLoadingConstraints(): boolean;
  45650. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45651. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45652. protected _updateModel(): void;
  45653. }
  45654. }
  45655. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45656. import { Vector4 } from "babylonjs/Maths/math.vector";
  45657. import { Mesh } from "babylonjs/Meshes/mesh";
  45658. import { Scene } from "babylonjs/scene";
  45659. import { Nullable } from "babylonjs/types";
  45660. /**
  45661. * Class containing static functions to help procedurally build meshes
  45662. */
  45663. export class SphereBuilder {
  45664. /**
  45665. * Creates a sphere mesh
  45666. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45667. * * 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`)
  45668. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45669. * * 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
  45670. * * 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)
  45671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45674. * @param name defines the name of the mesh
  45675. * @param options defines the options used to create the mesh
  45676. * @param scene defines the hosting scene
  45677. * @returns the sphere mesh
  45678. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45679. */
  45680. static CreateSphere(name: string, options: {
  45681. segments?: number;
  45682. diameter?: number;
  45683. diameterX?: number;
  45684. diameterY?: number;
  45685. diameterZ?: number;
  45686. arc?: number;
  45687. slice?: number;
  45688. sideOrientation?: number;
  45689. frontUVs?: Vector4;
  45690. backUVs?: Vector4;
  45691. updatable?: boolean;
  45692. }, scene?: Nullable<Scene>): Mesh;
  45693. }
  45694. }
  45695. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45697. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45698. import { Scene } from "babylonjs/scene";
  45699. /**
  45700. * A profiled motion controller has its profile loaded from an online repository.
  45701. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45702. */
  45703. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45704. private _repositoryUrl;
  45705. private _buttonMeshMapping;
  45706. private _touchDots;
  45707. /**
  45708. * The profile ID of this controller. Will be populated when the controller initializes.
  45709. */
  45710. profileId: string;
  45711. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45712. dispose(): void;
  45713. protected _getFilenameAndPath(): {
  45714. filename: string;
  45715. path: string;
  45716. };
  45717. protected _getModelLoadingConstraints(): boolean;
  45718. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45719. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45720. protected _updateModel(_xrFrame: XRFrame): void;
  45721. }
  45722. }
  45723. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45724. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45725. import { Scene } from "babylonjs/scene";
  45726. /**
  45727. * A construction function type to create a new controller based on an xrInput object
  45728. */
  45729. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45730. /**
  45731. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45732. *
  45733. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45734. * it should be replaced with auto-loaded controllers.
  45735. *
  45736. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45737. */
  45738. export class WebXRMotionControllerManager {
  45739. private static _AvailableControllers;
  45740. private static _Fallbacks;
  45741. private static _ProfileLoadingPromises;
  45742. private static _ProfilesList;
  45743. /**
  45744. * The base URL of the online controller repository. Can be changed at any time.
  45745. */
  45746. static BaseRepositoryUrl: string;
  45747. /**
  45748. * Which repository gets priority - local or online
  45749. */
  45750. static PrioritizeOnlineRepository: boolean;
  45751. /**
  45752. * Use the online repository, or use only locally-defined controllers
  45753. */
  45754. static UseOnlineRepository: boolean;
  45755. /**
  45756. * Clear the cache used for profile loading and reload when requested again
  45757. */
  45758. static ClearProfilesCache(): void;
  45759. /**
  45760. * Register the default fallbacks.
  45761. * This function is called automatically when this file is imported.
  45762. */
  45763. static DefaultFallbacks(): void;
  45764. /**
  45765. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45766. * @param profileId the profile to which a fallback needs to be found
  45767. * @return an array with corresponding fallback profiles
  45768. */
  45769. static FindFallbackWithProfileId(profileId: string): string[];
  45770. /**
  45771. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45772. * The order of search:
  45773. *
  45774. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45775. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45776. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45777. * 4) return the generic trigger controller if none were found
  45778. *
  45779. * @param xrInput the xrInput to which a new controller is initialized
  45780. * @param scene the scene to which the model will be added
  45781. * @param forceProfile force a certain profile for this controller
  45782. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45783. */
  45784. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45785. /**
  45786. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45787. *
  45788. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45789. *
  45790. * @param type the profile type to register
  45791. * @param constructFunction the function to be called when loading this profile
  45792. */
  45793. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45794. /**
  45795. * Register a fallback to a specific profile.
  45796. * @param profileId the profileId that will receive the fallbacks
  45797. * @param fallbacks A list of fallback profiles
  45798. */
  45799. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45800. /**
  45801. * Will update the list of profiles available in the repository
  45802. * @return a promise that resolves to a map of profiles available online
  45803. */
  45804. static UpdateProfilesList(): Promise<{
  45805. [profile: string]: string;
  45806. }>;
  45807. private static _LoadProfileFromRepository;
  45808. private static _LoadProfilesFromAvailableControllers;
  45809. }
  45810. }
  45811. declare module "babylonjs/XR/webXRInputSource" {
  45812. import { Observable } from "babylonjs/Misc/observable";
  45813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45814. import { Ray } from "babylonjs/Culling/ray";
  45815. import { Scene } from "babylonjs/scene";
  45816. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45817. /**
  45818. * Configuration options for the WebXR controller creation
  45819. */
  45820. export interface IWebXRControllerOptions {
  45821. /**
  45822. * Should the controller mesh be animated when a user interacts with it
  45823. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45824. */
  45825. disableMotionControllerAnimation?: boolean;
  45826. /**
  45827. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45828. */
  45829. doNotLoadControllerMesh?: boolean;
  45830. /**
  45831. * Force a specific controller type for this controller.
  45832. * This can be used when creating your own profile or when testing different controllers
  45833. */
  45834. forceControllerProfile?: string;
  45835. }
  45836. /**
  45837. * Represents an XR controller
  45838. */
  45839. export class WebXRInputSource {
  45840. private _scene;
  45841. /** The underlying input source for the controller */
  45842. inputSource: XRInputSource;
  45843. private _options;
  45844. private _tmpQuaternion;
  45845. private _tmpVector;
  45846. private _uniqueId;
  45847. /**
  45848. * 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
  45849. */
  45850. grip?: AbstractMesh;
  45851. /**
  45852. * If available, this is the gamepad object related to this controller.
  45853. * Using this object it is possible to get click events and trackpad changes of the
  45854. * webxr controller that is currently being used.
  45855. */
  45856. motionController?: WebXRAbstractMotionController;
  45857. /**
  45858. * Event that fires when the controller is removed/disposed.
  45859. * The object provided as event data is this controller, after associated assets were disposed.
  45860. * uniqueId is still available.
  45861. */
  45862. onDisposeObservable: Observable<WebXRInputSource>;
  45863. /**
  45864. * Will be triggered when the mesh associated with the motion controller is done loading.
  45865. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45866. * A shortened version of controller -> motion controller -> on mesh loaded.
  45867. */
  45868. onMeshLoadedObservable: Observable<AbstractMesh>;
  45869. /**
  45870. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45871. */
  45872. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45873. /**
  45874. * Pointer which can be used to select objects or attach a visible laser to
  45875. */
  45876. pointer: AbstractMesh;
  45877. /**
  45878. * Creates the controller
  45879. * @see https://doc.babylonjs.com/how_to/webxr
  45880. * @param _scene the scene which the controller should be associated to
  45881. * @param inputSource the underlying input source for the controller
  45882. * @param _options options for this controller creation
  45883. */
  45884. constructor(_scene: Scene,
  45885. /** The underlying input source for the controller */
  45886. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45887. /**
  45888. * Get this controllers unique id
  45889. */
  45890. get uniqueId(): string;
  45891. /**
  45892. * Disposes of the object
  45893. */
  45894. dispose(): void;
  45895. /**
  45896. * Gets a world space ray coming from the pointer or grip
  45897. * @param result the resulting ray
  45898. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45899. */
  45900. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45901. /**
  45902. * Updates the controller pose based on the given XRFrame
  45903. * @param xrFrame xr frame to update the pose with
  45904. * @param referenceSpace reference space to use
  45905. */
  45906. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45907. }
  45908. }
  45909. declare module "babylonjs/XR/webXRInput" {
  45910. import { Observable } from "babylonjs/Misc/observable";
  45911. import { IDisposable } from "babylonjs/scene";
  45912. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45913. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45914. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45915. /**
  45916. * The schema for initialization options of the XR Input class
  45917. */
  45918. export interface IWebXRInputOptions {
  45919. /**
  45920. * If set to true no model will be automatically loaded
  45921. */
  45922. doNotLoadControllerMeshes?: boolean;
  45923. /**
  45924. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45925. * If not found, the xr input profile data will be used.
  45926. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45927. */
  45928. forceInputProfile?: string;
  45929. /**
  45930. * Do not send a request to the controller repository to load the profile.
  45931. *
  45932. * Instead, use the controllers available in babylon itself.
  45933. */
  45934. disableOnlineControllerRepository?: boolean;
  45935. /**
  45936. * A custom URL for the controllers repository
  45937. */
  45938. customControllersRepositoryURL?: string;
  45939. /**
  45940. * Should the controller model's components not move according to the user input
  45941. */
  45942. disableControllerAnimation?: boolean;
  45943. }
  45944. /**
  45945. * XR input used to track XR inputs such as controllers/rays
  45946. */
  45947. export class WebXRInput implements IDisposable {
  45948. /**
  45949. * the xr session manager for this session
  45950. */
  45951. xrSessionManager: WebXRSessionManager;
  45952. /**
  45953. * the WebXR camera for this session. Mainly used for teleportation
  45954. */
  45955. xrCamera: WebXRCamera;
  45956. private readonly options;
  45957. /**
  45958. * XR controllers being tracked
  45959. */
  45960. controllers: Array<WebXRInputSource>;
  45961. private _frameObserver;
  45962. private _sessionEndedObserver;
  45963. private _sessionInitObserver;
  45964. /**
  45965. * Event when a controller has been connected/added
  45966. */
  45967. onControllerAddedObservable: Observable<WebXRInputSource>;
  45968. /**
  45969. * Event when a controller has been removed/disconnected
  45970. */
  45971. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45972. /**
  45973. * Initializes the WebXRInput
  45974. * @param xrSessionManager the xr session manager for this session
  45975. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45976. * @param options = initialization options for this xr input
  45977. */
  45978. constructor(
  45979. /**
  45980. * the xr session manager for this session
  45981. */
  45982. xrSessionManager: WebXRSessionManager,
  45983. /**
  45984. * the WebXR camera for this session. Mainly used for teleportation
  45985. */
  45986. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45987. private _onInputSourcesChange;
  45988. private _addAndRemoveControllers;
  45989. /**
  45990. * Disposes of the object
  45991. */
  45992. dispose(): void;
  45993. }
  45994. }
  45995. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45996. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45997. import { Observable, EventState } from "babylonjs/Misc/observable";
  45998. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45999. /**
  46000. * This is the base class for all WebXR features.
  46001. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46002. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46003. */
  46004. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46005. protected _xrSessionManager: WebXRSessionManager;
  46006. private _attached;
  46007. private _removeOnDetach;
  46008. /**
  46009. * Should auto-attach be disabled?
  46010. */
  46011. disableAutoAttach: boolean;
  46012. /**
  46013. * Construct a new (abstract) WebXR feature
  46014. * @param _xrSessionManager the xr session manager for this feature
  46015. */
  46016. constructor(_xrSessionManager: WebXRSessionManager);
  46017. /**
  46018. * Is this feature attached
  46019. */
  46020. get attached(): boolean;
  46021. /**
  46022. * attach this feature
  46023. *
  46024. * @param force should attachment be forced (even when already attached)
  46025. * @returns true if successful, false is failed or already attached
  46026. */
  46027. attach(force?: boolean): boolean;
  46028. /**
  46029. * detach this feature.
  46030. *
  46031. * @returns true if successful, false if failed or already detached
  46032. */
  46033. detach(): boolean;
  46034. /**
  46035. * Dispose this feature and all of the resources attached
  46036. */
  46037. dispose(): void;
  46038. /**
  46039. * This is used to register callbacks that will automatically be removed when detach is called.
  46040. * @param observable the observable to which the observer will be attached
  46041. * @param callback the callback to register
  46042. */
  46043. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46044. /**
  46045. * Code in this function will be executed on each xrFrame received from the browser.
  46046. * This function will not execute after the feature is detached.
  46047. * @param _xrFrame the current frame
  46048. */
  46049. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46050. }
  46051. }
  46052. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46053. import { IDisposable, Scene } from "babylonjs/scene";
  46054. import { Nullable } from "babylonjs/types";
  46055. import { Observable } from "babylonjs/Misc/observable";
  46056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46057. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46058. import { Camera } from "babylonjs/Cameras/camera";
  46059. /**
  46060. * Renders a layer on top of an existing scene
  46061. */
  46062. export class UtilityLayerRenderer implements IDisposable {
  46063. /** the original scene that will be rendered on top of */
  46064. originalScene: Scene;
  46065. private _pointerCaptures;
  46066. private _lastPointerEvents;
  46067. private static _DefaultUtilityLayer;
  46068. private static _DefaultKeepDepthUtilityLayer;
  46069. private _sharedGizmoLight;
  46070. private _renderCamera;
  46071. /**
  46072. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46073. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46074. * @returns the camera that is used when rendering the utility layer
  46075. */
  46076. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46077. /**
  46078. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46079. * @param cam the camera that should be used when rendering the utility layer
  46080. */
  46081. setRenderCamera(cam: Nullable<Camera>): void;
  46082. /**
  46083. * @hidden
  46084. * Light which used by gizmos to get light shading
  46085. */
  46086. _getSharedGizmoLight(): HemisphericLight;
  46087. /**
  46088. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46089. */
  46090. pickUtilitySceneFirst: boolean;
  46091. /**
  46092. * 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)
  46093. */
  46094. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46095. /**
  46096. * 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)
  46097. */
  46098. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46099. /**
  46100. * The scene that is rendered on top of the original scene
  46101. */
  46102. utilityLayerScene: Scene;
  46103. /**
  46104. * If the utility layer should automatically be rendered on top of existing scene
  46105. */
  46106. shouldRender: boolean;
  46107. /**
  46108. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46109. */
  46110. onlyCheckPointerDownEvents: boolean;
  46111. /**
  46112. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46113. */
  46114. processAllEvents: boolean;
  46115. /**
  46116. * Observable raised when the pointer move from the utility layer scene to the main scene
  46117. */
  46118. onPointerOutObservable: Observable<number>;
  46119. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46120. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46121. private _afterRenderObserver;
  46122. private _sceneDisposeObserver;
  46123. private _originalPointerObserver;
  46124. /**
  46125. * Instantiates a UtilityLayerRenderer
  46126. * @param originalScene the original scene that will be rendered on top of
  46127. * @param handleEvents boolean indicating if the utility layer should handle events
  46128. */
  46129. constructor(
  46130. /** the original scene that will be rendered on top of */
  46131. originalScene: Scene, handleEvents?: boolean);
  46132. private _notifyObservers;
  46133. /**
  46134. * Renders the utility layers scene on top of the original scene
  46135. */
  46136. render(): void;
  46137. /**
  46138. * Disposes of the renderer
  46139. */
  46140. dispose(): void;
  46141. private _updateCamera;
  46142. }
  46143. }
  46144. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46145. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46147. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46148. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46149. import { Scene } from "babylonjs/scene";
  46150. import { Nullable } from "babylonjs/types";
  46151. import { Color3 } from "babylonjs/Maths/math.color";
  46152. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46153. /**
  46154. * Options interface for the pointer selection module
  46155. */
  46156. export interface IWebXRControllerPointerSelectionOptions {
  46157. /**
  46158. * if provided, this scene will be used to render meshes.
  46159. */
  46160. customUtilityLayerScene?: Scene;
  46161. /**
  46162. * 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)
  46163. * If not disabled, the last picked point will be used to execute a pointer up event
  46164. * If disabled, pointer up event will be triggered right after the pointer down event.
  46165. * Used in screen and gaze target ray mode only
  46166. */
  46167. disablePointerUpOnTouchOut: boolean;
  46168. /**
  46169. * For gaze mode (time to select instead of press)
  46170. */
  46171. forceGazeMode: boolean;
  46172. /**
  46173. * 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
  46174. * to start a new countdown to the pointer down event.
  46175. * Defaults to 1.
  46176. */
  46177. gazeModePointerMovedFactor?: number;
  46178. /**
  46179. * Different button type to use instead of the main component
  46180. */
  46181. overrideButtonId?: string;
  46182. /**
  46183. * use this rendering group id for the meshes (optional)
  46184. */
  46185. renderingGroupId?: number;
  46186. /**
  46187. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46188. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46189. * 3000 means 3 seconds between pointing at something and selecting it
  46190. */
  46191. timeToSelect?: number;
  46192. /**
  46193. * Should meshes created here be added to a utility layer or the main scene
  46194. */
  46195. useUtilityLayer?: boolean;
  46196. /**
  46197. * the xr input to use with this pointer selection
  46198. */
  46199. xrInput: WebXRInput;
  46200. }
  46201. /**
  46202. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46203. */
  46204. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46205. private readonly _options;
  46206. private static _idCounter;
  46207. private _attachController;
  46208. private _controllers;
  46209. private _scene;
  46210. private _tmpVectorForPickCompare;
  46211. /**
  46212. * The module's name
  46213. */
  46214. static readonly Name: string;
  46215. /**
  46216. * The (Babylon) version of this module.
  46217. * This is an integer representing the implementation version.
  46218. * This number does not correspond to the WebXR specs version
  46219. */
  46220. static readonly Version: number;
  46221. /**
  46222. * Disable lighting on the laser pointer (so it will always be visible)
  46223. */
  46224. disablePointerLighting: boolean;
  46225. /**
  46226. * Disable lighting on the selection mesh (so it will always be visible)
  46227. */
  46228. disableSelectionMeshLighting: boolean;
  46229. /**
  46230. * Should the laser pointer be displayed
  46231. */
  46232. displayLaserPointer: boolean;
  46233. /**
  46234. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46235. */
  46236. displaySelectionMesh: boolean;
  46237. /**
  46238. * This color will be set to the laser pointer when selection is triggered
  46239. */
  46240. laserPointerPickedColor: Color3;
  46241. /**
  46242. * Default color of the laser pointer
  46243. */
  46244. lasterPointerDefaultColor: Color3;
  46245. /**
  46246. * default color of the selection ring
  46247. */
  46248. selectionMeshDefaultColor: Color3;
  46249. /**
  46250. * This color will be applied to the selection ring when selection is triggered
  46251. */
  46252. selectionMeshPickedColor: Color3;
  46253. /**
  46254. * Optional filter to be used for ray selection. This predicate shares behavior with
  46255. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46256. */
  46257. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46258. /**
  46259. * constructs a new background remover module
  46260. * @param _xrSessionManager the session manager for this module
  46261. * @param _options read-only options to be used in this module
  46262. */
  46263. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46264. /**
  46265. * attach this feature
  46266. * Will usually be called by the features manager
  46267. *
  46268. * @returns true if successful.
  46269. */
  46270. attach(): boolean;
  46271. /**
  46272. * detach this feature.
  46273. * Will usually be called by the features manager
  46274. *
  46275. * @returns true if successful.
  46276. */
  46277. detach(): boolean;
  46278. /**
  46279. * Will get the mesh under a specific pointer.
  46280. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46281. * @param controllerId the controllerId to check
  46282. * @returns The mesh under pointer or null if no mesh is under the pointer
  46283. */
  46284. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46285. /**
  46286. * Get the xr controller that correlates to the pointer id in the pointer event
  46287. *
  46288. * @param id the pointer id to search for
  46289. * @returns the controller that correlates to this id or null if not found
  46290. */
  46291. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46292. protected _onXRFrame(_xrFrame: XRFrame): void;
  46293. private _attachGazeMode;
  46294. private _attachScreenRayMode;
  46295. private _attachTrackedPointerRayMode;
  46296. private _convertNormalToDirectionOfRay;
  46297. private _detachController;
  46298. private _generateNewMeshPair;
  46299. private _pickingMoved;
  46300. private _updatePointerDistance;
  46301. }
  46302. }
  46303. declare module "babylonjs/XR/webXREnterExitUI" {
  46304. import { Nullable } from "babylonjs/types";
  46305. import { Observable } from "babylonjs/Misc/observable";
  46306. import { IDisposable, Scene } from "babylonjs/scene";
  46307. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46308. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46309. /**
  46310. * Button which can be used to enter a different mode of XR
  46311. */
  46312. export class WebXREnterExitUIButton {
  46313. /** button element */
  46314. element: HTMLElement;
  46315. /** XR initialization options for the button */
  46316. sessionMode: XRSessionMode;
  46317. /** Reference space type */
  46318. referenceSpaceType: XRReferenceSpaceType;
  46319. /**
  46320. * Creates a WebXREnterExitUIButton
  46321. * @param element button element
  46322. * @param sessionMode XR initialization session mode
  46323. * @param referenceSpaceType the type of reference space to be used
  46324. */
  46325. constructor(
  46326. /** button element */
  46327. element: HTMLElement,
  46328. /** XR initialization options for the button */
  46329. sessionMode: XRSessionMode,
  46330. /** Reference space type */
  46331. referenceSpaceType: XRReferenceSpaceType);
  46332. /**
  46333. * Extendable function which can be used to update the button's visuals when the state changes
  46334. * @param activeButton the current active button in the UI
  46335. */
  46336. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46337. }
  46338. /**
  46339. * Options to create the webXR UI
  46340. */
  46341. export class WebXREnterExitUIOptions {
  46342. /**
  46343. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46344. */
  46345. customButtons?: Array<WebXREnterExitUIButton>;
  46346. /**
  46347. * A reference space type to use when creating the default button.
  46348. * Default is local-floor
  46349. */
  46350. referenceSpaceType?: XRReferenceSpaceType;
  46351. /**
  46352. * Context to enter xr with
  46353. */
  46354. renderTarget?: Nullable<WebXRRenderTarget>;
  46355. /**
  46356. * A session mode to use when creating the default button.
  46357. * Default is immersive-vr
  46358. */
  46359. sessionMode?: XRSessionMode;
  46360. }
  46361. /**
  46362. * UI to allow the user to enter/exit XR mode
  46363. */
  46364. export class WebXREnterExitUI implements IDisposable {
  46365. private scene;
  46366. /** version of the options passed to this UI */
  46367. options: WebXREnterExitUIOptions;
  46368. private _activeButton;
  46369. private _buttons;
  46370. private _overlay;
  46371. /**
  46372. * Fired every time the active button is changed.
  46373. *
  46374. * When xr is entered via a button that launches xr that button will be the callback parameter
  46375. *
  46376. * When exiting xr the callback parameter will be null)
  46377. */
  46378. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46379. /**
  46380. *
  46381. * @param scene babylon scene object to use
  46382. * @param options (read-only) version of the options passed to this UI
  46383. */
  46384. private constructor();
  46385. /**
  46386. * Creates UI to allow the user to enter/exit XR mode
  46387. * @param scene the scene to add the ui to
  46388. * @param helper the xr experience helper to enter/exit xr with
  46389. * @param options options to configure the UI
  46390. * @returns the created ui
  46391. */
  46392. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46393. /**
  46394. * Disposes of the XR UI component
  46395. */
  46396. dispose(): void;
  46397. private _updateButtons;
  46398. }
  46399. }
  46400. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46401. import { Vector3 } from "babylonjs/Maths/math.vector";
  46402. import { Color4 } from "babylonjs/Maths/math.color";
  46403. import { Nullable } from "babylonjs/types";
  46404. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46405. import { Scene } from "babylonjs/scene";
  46406. /**
  46407. * Class containing static functions to help procedurally build meshes
  46408. */
  46409. export class LinesBuilder {
  46410. /**
  46411. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46412. * * 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
  46413. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46414. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46415. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46416. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46417. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46418. * * 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
  46419. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46422. * @param name defines the name of the new line system
  46423. * @param options defines the options used to create the line system
  46424. * @param scene defines the hosting scene
  46425. * @returns a new line system mesh
  46426. */
  46427. static CreateLineSystem(name: string, options: {
  46428. lines: Vector3[][];
  46429. updatable?: boolean;
  46430. instance?: Nullable<LinesMesh>;
  46431. colors?: Nullable<Color4[][]>;
  46432. useVertexAlpha?: boolean;
  46433. }, scene: Nullable<Scene>): LinesMesh;
  46434. /**
  46435. * Creates a line mesh
  46436. * 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
  46437. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46438. * * The parameter `points` is an array successive Vector3
  46439. * * 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
  46440. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46441. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46442. * * When updating an instance, remember that only point positions can change, not the number of points
  46443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46445. * @param name defines the name of the new line system
  46446. * @param options defines the options used to create the line system
  46447. * @param scene defines the hosting scene
  46448. * @returns a new line mesh
  46449. */
  46450. static CreateLines(name: string, options: {
  46451. points: Vector3[];
  46452. updatable?: boolean;
  46453. instance?: Nullable<LinesMesh>;
  46454. colors?: Color4[];
  46455. useVertexAlpha?: boolean;
  46456. }, scene?: Nullable<Scene>): LinesMesh;
  46457. /**
  46458. * Creates a dashed line mesh
  46459. * * 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
  46460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46461. * * The parameter `points` is an array successive Vector3
  46462. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46463. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46464. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46465. * * 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
  46466. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46467. * * When updating an instance, remember that only point positions can change, not the number of points
  46468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46469. * @param name defines the name of the mesh
  46470. * @param options defines the options used to create the mesh
  46471. * @param scene defines the hosting scene
  46472. * @returns the dashed line mesh
  46473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46474. */
  46475. static CreateDashedLines(name: string, options: {
  46476. points: Vector3[];
  46477. dashSize?: number;
  46478. gapSize?: number;
  46479. dashNb?: number;
  46480. updatable?: boolean;
  46481. instance?: LinesMesh;
  46482. useVertexAlpha?: boolean;
  46483. }, scene?: Nullable<Scene>): LinesMesh;
  46484. }
  46485. }
  46486. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46487. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46488. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46489. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46491. import { Vector3 } from "babylonjs/Maths/math.vector";
  46492. import { Material } from "babylonjs/Materials/material";
  46493. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46494. import { Scene } from "babylonjs/scene";
  46495. /**
  46496. * The options container for the teleportation module
  46497. */
  46498. export interface IWebXRTeleportationOptions {
  46499. /**
  46500. * if provided, this scene will be used to render meshes.
  46501. */
  46502. customUtilityLayerScene?: Scene;
  46503. /**
  46504. * Values to configure the default target mesh
  46505. */
  46506. defaultTargetMeshOptions?: {
  46507. /**
  46508. * Fill color of the teleportation area
  46509. */
  46510. teleportationFillColor?: string;
  46511. /**
  46512. * Border color for the teleportation area
  46513. */
  46514. teleportationBorderColor?: string;
  46515. /**
  46516. * Disable the mesh's animation sequence
  46517. */
  46518. disableAnimation?: boolean;
  46519. /**
  46520. * Disable lighting on the material or the ring and arrow
  46521. */
  46522. disableLighting?: boolean;
  46523. /**
  46524. * Override the default material of the torus and arrow
  46525. */
  46526. torusArrowMaterial?: Material;
  46527. };
  46528. /**
  46529. * A list of meshes to use as floor meshes.
  46530. * Meshes can be added and removed after initializing the feature using the
  46531. * addFloorMesh and removeFloorMesh functions
  46532. * If empty, rotation will still work
  46533. */
  46534. floorMeshes?: AbstractMesh[];
  46535. /**
  46536. * use this rendering group id for the meshes (optional)
  46537. */
  46538. renderingGroupId?: number;
  46539. /**
  46540. * Should teleportation move only to snap points
  46541. */
  46542. snapPointsOnly?: boolean;
  46543. /**
  46544. * An array of points to which the teleportation will snap to.
  46545. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46546. */
  46547. snapPositions?: Vector3[];
  46548. /**
  46549. * How close should the teleportation ray be in order to snap to position.
  46550. * Default to 0.8 units (meters)
  46551. */
  46552. snapToPositionRadius?: number;
  46553. /**
  46554. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46555. * If you want to support rotation, make sure your mesh has a direction indicator.
  46556. *
  46557. * When left untouched, the default mesh will be initialized.
  46558. */
  46559. teleportationTargetMesh?: AbstractMesh;
  46560. /**
  46561. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46562. */
  46563. timeToTeleport?: number;
  46564. /**
  46565. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46566. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46567. */
  46568. useMainComponentOnly?: boolean;
  46569. /**
  46570. * Should meshes created here be added to a utility layer or the main scene
  46571. */
  46572. useUtilityLayer?: boolean;
  46573. /**
  46574. * Babylon XR Input class for controller
  46575. */
  46576. xrInput: WebXRInput;
  46577. }
  46578. /**
  46579. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46580. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46581. * the input of the attached controllers.
  46582. */
  46583. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46584. private _options;
  46585. private _controllers;
  46586. private _currentTeleportationControllerId;
  46587. private _floorMeshes;
  46588. private _quadraticBezierCurve;
  46589. private _selectionFeature;
  46590. private _snapToPositions;
  46591. private _snappedToPoint;
  46592. private _teleportationRingMaterial?;
  46593. private _tmpRay;
  46594. private _tmpVector;
  46595. /**
  46596. * The module's name
  46597. */
  46598. static readonly Name: string;
  46599. /**
  46600. * The (Babylon) version of this module.
  46601. * This is an integer representing the implementation version.
  46602. * This number does not correspond to the webxr specs version
  46603. */
  46604. static readonly Version: number;
  46605. /**
  46606. * Is movement backwards enabled
  46607. */
  46608. backwardsMovementEnabled: boolean;
  46609. /**
  46610. * Distance to travel when moving backwards
  46611. */
  46612. backwardsTeleportationDistance: number;
  46613. /**
  46614. * The distance from the user to the inspection point in the direction of the controller
  46615. * A higher number will allow the user to move further
  46616. * defaults to 5 (meters, in xr units)
  46617. */
  46618. parabolicCheckRadius: number;
  46619. /**
  46620. * Should the module support parabolic ray on top of direct ray
  46621. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46622. * Very helpful when moving between floors / different heights
  46623. */
  46624. parabolicRayEnabled: boolean;
  46625. /**
  46626. * How much rotation should be applied when rotating right and left
  46627. */
  46628. rotationAngle: number;
  46629. /**
  46630. * Is rotation enabled when moving forward?
  46631. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46632. */
  46633. rotationEnabled: boolean;
  46634. /**
  46635. * constructs a new anchor system
  46636. * @param _xrSessionManager an instance of WebXRSessionManager
  46637. * @param _options configuration object for this feature
  46638. */
  46639. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46640. /**
  46641. * Get the snapPointsOnly flag
  46642. */
  46643. get snapPointsOnly(): boolean;
  46644. /**
  46645. * Sets the snapPointsOnly flag
  46646. * @param snapToPoints should teleportation be exclusively to snap points
  46647. */
  46648. set snapPointsOnly(snapToPoints: boolean);
  46649. /**
  46650. * Add a new mesh to the floor meshes array
  46651. * @param mesh the mesh to use as floor mesh
  46652. */
  46653. addFloorMesh(mesh: AbstractMesh): void;
  46654. /**
  46655. * Add a new snap-to point to fix teleportation to this position
  46656. * @param newSnapPoint The new Snap-To point
  46657. */
  46658. addSnapPoint(newSnapPoint: Vector3): void;
  46659. attach(): boolean;
  46660. detach(): boolean;
  46661. dispose(): void;
  46662. /**
  46663. * Remove a mesh from the floor meshes array
  46664. * @param mesh the mesh to remove
  46665. */
  46666. removeFloorMesh(mesh: AbstractMesh): void;
  46667. /**
  46668. * Remove a mesh from the floor meshes array using its name
  46669. * @param name the mesh name to remove
  46670. */
  46671. removeFloorMeshByName(name: string): void;
  46672. /**
  46673. * 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
  46674. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46675. * @returns was the point found and removed or not
  46676. */
  46677. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46678. /**
  46679. * This function sets a selection feature that will be disabled when
  46680. * the forward ray is shown and will be reattached when hidden.
  46681. * This is used to remove the selection rays when moving.
  46682. * @param selectionFeature the feature to disable when forward movement is enabled
  46683. */
  46684. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46685. protected _onXRFrame(_xrFrame: XRFrame): void;
  46686. private _attachController;
  46687. private _createDefaultTargetMesh;
  46688. private _detachController;
  46689. private _findClosestSnapPointWithRadius;
  46690. private _setTargetMeshPosition;
  46691. private _setTargetMeshVisibility;
  46692. private _showParabolicPath;
  46693. private _teleportForward;
  46694. }
  46695. }
  46696. declare module "babylonjs/XR/webXRDefaultExperience" {
  46697. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46698. import { Scene } from "babylonjs/scene";
  46699. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46700. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46701. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46702. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46704. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46705. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46706. /**
  46707. * Options for the default xr helper
  46708. */
  46709. export class WebXRDefaultExperienceOptions {
  46710. /**
  46711. * Enable or disable default UI to enter XR
  46712. */
  46713. disableDefaultUI?: boolean;
  46714. /**
  46715. * Should teleportation not initialize. defaults to false.
  46716. */
  46717. disableTeleportation?: boolean;
  46718. /**
  46719. * Floor meshes that will be used for teleport
  46720. */
  46721. floorMeshes?: Array<AbstractMesh>;
  46722. /**
  46723. * If set to true, the first frame will not be used to reset position
  46724. * The first frame is mainly used when copying transformation from the old camera
  46725. * Mainly used in AR
  46726. */
  46727. ignoreNativeCameraTransformation?: boolean;
  46728. /**
  46729. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46730. */
  46731. inputOptions?: IWebXRInputOptions;
  46732. /**
  46733. * optional configuration for the output canvas
  46734. */
  46735. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46736. /**
  46737. * optional UI options. This can be used among other to change session mode and reference space type
  46738. */
  46739. uiOptions?: WebXREnterExitUIOptions;
  46740. /**
  46741. * When loading teleportation and pointer select, use stable versions instead of latest.
  46742. */
  46743. useStablePlugins?: boolean;
  46744. }
  46745. /**
  46746. * Default experience which provides a similar setup to the previous webVRExperience
  46747. */
  46748. export class WebXRDefaultExperience {
  46749. /**
  46750. * Base experience
  46751. */
  46752. baseExperience: WebXRExperienceHelper;
  46753. /**
  46754. * Enables ui for entering/exiting xr
  46755. */
  46756. enterExitUI: WebXREnterExitUI;
  46757. /**
  46758. * Input experience extension
  46759. */
  46760. input: WebXRInput;
  46761. /**
  46762. * Enables laser pointer and selection
  46763. */
  46764. pointerSelection: WebXRControllerPointerSelection;
  46765. /**
  46766. * Default target xr should render to
  46767. */
  46768. renderTarget: WebXRRenderTarget;
  46769. /**
  46770. * Enables teleportation
  46771. */
  46772. teleportation: WebXRMotionControllerTeleportation;
  46773. private constructor();
  46774. /**
  46775. * Creates the default xr experience
  46776. * @param scene scene
  46777. * @param options options for basic configuration
  46778. * @returns resulting WebXRDefaultExperience
  46779. */
  46780. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46781. /**
  46782. * DIsposes of the experience helper
  46783. */
  46784. dispose(): void;
  46785. }
  46786. }
  46787. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46788. import { Observable } from "babylonjs/Misc/observable";
  46789. import { Nullable } from "babylonjs/types";
  46790. import { Camera } from "babylonjs/Cameras/camera";
  46791. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46792. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46793. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46794. import { Scene } from "babylonjs/scene";
  46795. import { Vector3 } from "babylonjs/Maths/math.vector";
  46796. import { Color3 } from "babylonjs/Maths/math.color";
  46797. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46799. import { Mesh } from "babylonjs/Meshes/mesh";
  46800. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46801. import { EasingFunction } from "babylonjs/Animations/easing";
  46802. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46803. import "babylonjs/Meshes/Builders/groundBuilder";
  46804. import "babylonjs/Meshes/Builders/torusBuilder";
  46805. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46806. import "babylonjs/Gamepads/gamepadSceneComponent";
  46807. import "babylonjs/Animations/animatable";
  46808. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46809. /**
  46810. * Options to modify the vr teleportation behavior.
  46811. */
  46812. export interface VRTeleportationOptions {
  46813. /**
  46814. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46815. */
  46816. floorMeshName?: string;
  46817. /**
  46818. * A list of meshes to be used as the teleportation floor. (default: empty)
  46819. */
  46820. floorMeshes?: Mesh[];
  46821. /**
  46822. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46823. */
  46824. teleportationMode?: number;
  46825. /**
  46826. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46827. */
  46828. teleportationTime?: number;
  46829. /**
  46830. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46831. */
  46832. teleportationSpeed?: number;
  46833. /**
  46834. * The easing function used in the animation or null for Linear. (default CircleEase)
  46835. */
  46836. easingFunction?: EasingFunction;
  46837. }
  46838. /**
  46839. * Options to modify the vr experience helper's behavior.
  46840. */
  46841. export interface VRExperienceHelperOptions extends WebVROptions {
  46842. /**
  46843. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46844. */
  46845. createDeviceOrientationCamera?: boolean;
  46846. /**
  46847. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46848. */
  46849. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46850. /**
  46851. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46852. */
  46853. laserToggle?: boolean;
  46854. /**
  46855. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46856. */
  46857. floorMeshes?: Mesh[];
  46858. /**
  46859. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46860. */
  46861. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46862. /**
  46863. * Defines if WebXR should be used instead of WebVR (if available)
  46864. */
  46865. useXR?: boolean;
  46866. }
  46867. /**
  46868. * Event containing information after VR has been entered
  46869. */
  46870. export class OnAfterEnteringVRObservableEvent {
  46871. /**
  46872. * If entering vr was successful
  46873. */
  46874. success: boolean;
  46875. }
  46876. /**
  46877. * Helps to quickly add VR support to an existing scene.
  46878. * See http://doc.babylonjs.com/how_to/webvr_helper
  46879. */
  46880. export class VRExperienceHelper {
  46881. /** Options to modify the vr experience helper's behavior. */
  46882. webVROptions: VRExperienceHelperOptions;
  46883. private _scene;
  46884. private _position;
  46885. private _btnVR;
  46886. private _btnVRDisplayed;
  46887. private _webVRsupported;
  46888. private _webVRready;
  46889. private _webVRrequesting;
  46890. private _webVRpresenting;
  46891. private _hasEnteredVR;
  46892. private _fullscreenVRpresenting;
  46893. private _inputElement;
  46894. private _webVRCamera;
  46895. private _vrDeviceOrientationCamera;
  46896. private _deviceOrientationCamera;
  46897. private _existingCamera;
  46898. private _onKeyDown;
  46899. private _onVrDisplayPresentChange;
  46900. private _onVRDisplayChanged;
  46901. private _onVRRequestPresentStart;
  46902. private _onVRRequestPresentComplete;
  46903. /**
  46904. * 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)
  46905. */
  46906. enableGazeEvenWhenNoPointerLock: boolean;
  46907. /**
  46908. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46909. */
  46910. exitVROnDoubleTap: boolean;
  46911. /**
  46912. * Observable raised right before entering VR.
  46913. */
  46914. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46915. /**
  46916. * Observable raised when entering VR has completed.
  46917. */
  46918. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46919. /**
  46920. * Observable raised when exiting VR.
  46921. */
  46922. onExitingVRObservable: Observable<VRExperienceHelper>;
  46923. /**
  46924. * Observable raised when controller mesh is loaded.
  46925. */
  46926. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46927. /** Return this.onEnteringVRObservable
  46928. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46929. */
  46930. get onEnteringVR(): Observable<VRExperienceHelper>;
  46931. /** Return this.onExitingVRObservable
  46932. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46933. */
  46934. get onExitingVR(): Observable<VRExperienceHelper>;
  46935. /** Return this.onControllerMeshLoadedObservable
  46936. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46937. */
  46938. get onControllerMeshLoaded(): Observable<WebVRController>;
  46939. private _rayLength;
  46940. private _useCustomVRButton;
  46941. private _teleportationRequested;
  46942. private _teleportActive;
  46943. private _floorMeshName;
  46944. private _floorMeshesCollection;
  46945. private _teleportationMode;
  46946. private _teleportationTime;
  46947. private _teleportationSpeed;
  46948. private _teleportationEasing;
  46949. private _rotationAllowed;
  46950. private _teleportBackwardsVector;
  46951. private _teleportationTarget;
  46952. private _isDefaultTeleportationTarget;
  46953. private _postProcessMove;
  46954. private _teleportationFillColor;
  46955. private _teleportationBorderColor;
  46956. private _rotationAngle;
  46957. private _haloCenter;
  46958. private _cameraGazer;
  46959. private _padSensibilityUp;
  46960. private _padSensibilityDown;
  46961. private _leftController;
  46962. private _rightController;
  46963. private _gazeColor;
  46964. private _laserColor;
  46965. private _pickedLaserColor;
  46966. private _pickedGazeColor;
  46967. /**
  46968. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46969. */
  46970. onNewMeshSelected: Observable<AbstractMesh>;
  46971. /**
  46972. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46973. * This observable will provide the mesh and the controller used to select the mesh
  46974. */
  46975. onMeshSelectedWithController: Observable<{
  46976. mesh: AbstractMesh;
  46977. controller: WebVRController;
  46978. }>;
  46979. /**
  46980. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46981. */
  46982. onNewMeshPicked: Observable<PickingInfo>;
  46983. private _circleEase;
  46984. /**
  46985. * Observable raised before camera teleportation
  46986. */
  46987. onBeforeCameraTeleport: Observable<Vector3>;
  46988. /**
  46989. * Observable raised after camera teleportation
  46990. */
  46991. onAfterCameraTeleport: Observable<Vector3>;
  46992. /**
  46993. * Observable raised when current selected mesh gets unselected
  46994. */
  46995. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46996. private _raySelectionPredicate;
  46997. /**
  46998. * To be optionaly changed by user to define custom ray selection
  46999. */
  47000. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47001. /**
  47002. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47003. */
  47004. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47005. /**
  47006. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47007. */
  47008. teleportationEnabled: boolean;
  47009. private _defaultHeight;
  47010. private _teleportationInitialized;
  47011. private _interactionsEnabled;
  47012. private _interactionsRequested;
  47013. private _displayGaze;
  47014. private _displayLaserPointer;
  47015. /**
  47016. * The mesh used to display where the user is going to teleport.
  47017. */
  47018. get teleportationTarget(): Mesh;
  47019. /**
  47020. * Sets the mesh to be used to display where the user is going to teleport.
  47021. */
  47022. set teleportationTarget(value: Mesh);
  47023. /**
  47024. * 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
  47025. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47026. * See http://doc.babylonjs.com/resources/baking_transformations
  47027. */
  47028. get gazeTrackerMesh(): Mesh;
  47029. set gazeTrackerMesh(value: Mesh);
  47030. /**
  47031. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47032. */
  47033. updateGazeTrackerScale: boolean;
  47034. /**
  47035. * If the gaze trackers color should be updated when selecting meshes
  47036. */
  47037. updateGazeTrackerColor: boolean;
  47038. /**
  47039. * If the controller laser color should be updated when selecting meshes
  47040. */
  47041. updateControllerLaserColor: boolean;
  47042. /**
  47043. * The gaze tracking mesh corresponding to the left controller
  47044. */
  47045. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47046. /**
  47047. * The gaze tracking mesh corresponding to the right controller
  47048. */
  47049. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47050. /**
  47051. * If the ray of the gaze should be displayed.
  47052. */
  47053. get displayGaze(): boolean;
  47054. /**
  47055. * Sets if the ray of the gaze should be displayed.
  47056. */
  47057. set displayGaze(value: boolean);
  47058. /**
  47059. * If the ray of the LaserPointer should be displayed.
  47060. */
  47061. get displayLaserPointer(): boolean;
  47062. /**
  47063. * Sets if the ray of the LaserPointer should be displayed.
  47064. */
  47065. set displayLaserPointer(value: boolean);
  47066. /**
  47067. * The deviceOrientationCamera used as the camera when not in VR.
  47068. */
  47069. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47070. /**
  47071. * Based on the current WebVR support, returns the current VR camera used.
  47072. */
  47073. get currentVRCamera(): Nullable<Camera>;
  47074. /**
  47075. * The webVRCamera which is used when in VR.
  47076. */
  47077. get webVRCamera(): WebVRFreeCamera;
  47078. /**
  47079. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47080. */
  47081. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47082. /**
  47083. * The html button that is used to trigger entering into VR.
  47084. */
  47085. get vrButton(): Nullable<HTMLButtonElement>;
  47086. private get _teleportationRequestInitiated();
  47087. /**
  47088. * Defines whether or not Pointer lock should be requested when switching to
  47089. * full screen.
  47090. */
  47091. requestPointerLockOnFullScreen: boolean;
  47092. /**
  47093. * If asking to force XR, this will be populated with the default xr experience
  47094. */
  47095. xr: WebXRDefaultExperience;
  47096. /**
  47097. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47098. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47099. */
  47100. xrTestDone: boolean;
  47101. /**
  47102. * Instantiates a VRExperienceHelper.
  47103. * Helps to quickly add VR support to an existing scene.
  47104. * @param scene The scene the VRExperienceHelper belongs to.
  47105. * @param webVROptions Options to modify the vr experience helper's behavior.
  47106. */
  47107. constructor(scene: Scene,
  47108. /** Options to modify the vr experience helper's behavior. */
  47109. webVROptions?: VRExperienceHelperOptions);
  47110. private completeVRInit;
  47111. private _onDefaultMeshLoaded;
  47112. private _onResize;
  47113. private _onFullscreenChange;
  47114. /**
  47115. * Gets a value indicating if we are currently in VR mode.
  47116. */
  47117. get isInVRMode(): boolean;
  47118. private onVrDisplayPresentChange;
  47119. private onVRDisplayChanged;
  47120. private moveButtonToBottomRight;
  47121. private displayVRButton;
  47122. private updateButtonVisibility;
  47123. private _cachedAngularSensibility;
  47124. /**
  47125. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47126. * Otherwise, will use the fullscreen API.
  47127. */
  47128. enterVR(): void;
  47129. /**
  47130. * Attempt to exit VR, or fullscreen.
  47131. */
  47132. exitVR(): void;
  47133. /**
  47134. * The position of the vr experience helper.
  47135. */
  47136. get position(): Vector3;
  47137. /**
  47138. * Sets the position of the vr experience helper.
  47139. */
  47140. set position(value: Vector3);
  47141. /**
  47142. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47143. */
  47144. enableInteractions(): void;
  47145. private get _noControllerIsActive();
  47146. private beforeRender;
  47147. private _isTeleportationFloor;
  47148. /**
  47149. * Adds a floor mesh to be used for teleportation.
  47150. * @param floorMesh the mesh to be used for teleportation.
  47151. */
  47152. addFloorMesh(floorMesh: Mesh): void;
  47153. /**
  47154. * Removes a floor mesh from being used for teleportation.
  47155. * @param floorMesh the mesh to be removed.
  47156. */
  47157. removeFloorMesh(floorMesh: Mesh): void;
  47158. /**
  47159. * Enables interactions and teleportation using the VR controllers and gaze.
  47160. * @param vrTeleportationOptions options to modify teleportation behavior.
  47161. */
  47162. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47163. private _onNewGamepadConnected;
  47164. private _tryEnableInteractionOnController;
  47165. private _onNewGamepadDisconnected;
  47166. private _enableInteractionOnController;
  47167. private _checkTeleportWithRay;
  47168. private _checkRotate;
  47169. private _checkTeleportBackwards;
  47170. private _enableTeleportationOnController;
  47171. private _createTeleportationCircles;
  47172. private _displayTeleportationTarget;
  47173. private _hideTeleportationTarget;
  47174. private _rotateCamera;
  47175. private _moveTeleportationSelectorTo;
  47176. private _workingVector;
  47177. private _workingQuaternion;
  47178. private _workingMatrix;
  47179. /**
  47180. * Time Constant Teleportation Mode
  47181. */
  47182. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47183. /**
  47184. * Speed Constant Teleportation Mode
  47185. */
  47186. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47187. /**
  47188. * Teleports the users feet to the desired location
  47189. * @param location The location where the user's feet should be placed
  47190. */
  47191. teleportCamera(location: Vector3): void;
  47192. private _convertNormalToDirectionOfRay;
  47193. private _castRayAndSelectObject;
  47194. private _notifySelectedMeshUnselected;
  47195. /**
  47196. * Permanently set new colors for the laser pointer
  47197. * @param color the new laser color
  47198. * @param pickedColor the new laser color when picked mesh detected
  47199. */
  47200. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47201. /**
  47202. * Set lighting enabled / disabled on the laser pointer of both controllers
  47203. * @param enabled should the lighting be enabled on the laser pointer
  47204. */
  47205. setLaserLightingState(enabled?: boolean): void;
  47206. /**
  47207. * Permanently set new colors for the gaze pointer
  47208. * @param color the new gaze color
  47209. * @param pickedColor the new gaze color when picked mesh detected
  47210. */
  47211. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47212. /**
  47213. * Sets the color of the laser ray from the vr controllers.
  47214. * @param color new color for the ray.
  47215. */
  47216. changeLaserColor(color: Color3): void;
  47217. /**
  47218. * Sets the color of the ray from the vr headsets gaze.
  47219. * @param color new color for the ray.
  47220. */
  47221. changeGazeColor(color: Color3): void;
  47222. /**
  47223. * Exits VR and disposes of the vr experience helper
  47224. */
  47225. dispose(): void;
  47226. /**
  47227. * Gets the name of the VRExperienceHelper class
  47228. * @returns "VRExperienceHelper"
  47229. */
  47230. getClassName(): string;
  47231. }
  47232. }
  47233. declare module "babylonjs/Cameras/VR/index" {
  47234. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47235. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47236. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47237. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47238. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47239. export * from "babylonjs/Cameras/VR/webVRCamera";
  47240. }
  47241. declare module "babylonjs/Cameras/RigModes/index" {
  47242. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47243. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47244. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47245. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47246. }
  47247. declare module "babylonjs/Cameras/index" {
  47248. export * from "babylonjs/Cameras/Inputs/index";
  47249. export * from "babylonjs/Cameras/cameraInputsManager";
  47250. export * from "babylonjs/Cameras/camera";
  47251. export * from "babylonjs/Cameras/targetCamera";
  47252. export * from "babylonjs/Cameras/freeCamera";
  47253. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47254. export * from "babylonjs/Cameras/touchCamera";
  47255. export * from "babylonjs/Cameras/arcRotateCamera";
  47256. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47257. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47258. export * from "babylonjs/Cameras/flyCamera";
  47259. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47260. export * from "babylonjs/Cameras/followCamera";
  47261. export * from "babylonjs/Cameras/followCameraInputsManager";
  47262. export * from "babylonjs/Cameras/gamepadCamera";
  47263. export * from "babylonjs/Cameras/Stereoscopic/index";
  47264. export * from "babylonjs/Cameras/universalCamera";
  47265. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47266. export * from "babylonjs/Cameras/VR/index";
  47267. export * from "babylonjs/Cameras/RigModes/index";
  47268. }
  47269. declare module "babylonjs/Collisions/index" {
  47270. export * from "babylonjs/Collisions/collider";
  47271. export * from "babylonjs/Collisions/collisionCoordinator";
  47272. export * from "babylonjs/Collisions/pickingInfo";
  47273. export * from "babylonjs/Collisions/intersectionInfo";
  47274. export * from "babylonjs/Collisions/meshCollisionData";
  47275. }
  47276. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47277. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47278. import { Vector3 } from "babylonjs/Maths/math.vector";
  47279. import { Ray } from "babylonjs/Culling/ray";
  47280. import { Plane } from "babylonjs/Maths/math.plane";
  47281. /**
  47282. * Contains an array of blocks representing the octree
  47283. */
  47284. export interface IOctreeContainer<T> {
  47285. /**
  47286. * Blocks within the octree
  47287. */
  47288. blocks: Array<OctreeBlock<T>>;
  47289. }
  47290. /**
  47291. * Class used to store a cell in an octree
  47292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47293. */
  47294. export class OctreeBlock<T> {
  47295. /**
  47296. * Gets the content of the current block
  47297. */
  47298. entries: T[];
  47299. /**
  47300. * Gets the list of block children
  47301. */
  47302. blocks: Array<OctreeBlock<T>>;
  47303. private _depth;
  47304. private _maxDepth;
  47305. private _capacity;
  47306. private _minPoint;
  47307. private _maxPoint;
  47308. private _boundingVectors;
  47309. private _creationFunc;
  47310. /**
  47311. * Creates a new block
  47312. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47313. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47314. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47315. * @param depth defines the current depth of this block in the octree
  47316. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47317. * @param creationFunc defines a callback to call when an element is added to the block
  47318. */
  47319. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47320. /**
  47321. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47322. */
  47323. get capacity(): number;
  47324. /**
  47325. * Gets the minimum vector (in world space) of the block's bounding box
  47326. */
  47327. get minPoint(): Vector3;
  47328. /**
  47329. * Gets the maximum vector (in world space) of the block's bounding box
  47330. */
  47331. get maxPoint(): Vector3;
  47332. /**
  47333. * Add a new element to this block
  47334. * @param entry defines the element to add
  47335. */
  47336. addEntry(entry: T): void;
  47337. /**
  47338. * Remove an element from this block
  47339. * @param entry defines the element to remove
  47340. */
  47341. removeEntry(entry: T): void;
  47342. /**
  47343. * Add an array of elements to this block
  47344. * @param entries defines the array of elements to add
  47345. */
  47346. addEntries(entries: T[]): void;
  47347. /**
  47348. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47349. * @param frustumPlanes defines the frustum planes to test
  47350. * @param selection defines the array to store current content if selection is positive
  47351. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47352. */
  47353. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47354. /**
  47355. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47356. * @param sphereCenter defines the bounding sphere center
  47357. * @param sphereRadius defines the bounding sphere radius
  47358. * @param selection defines the array to store current content if selection is positive
  47359. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47360. */
  47361. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47362. /**
  47363. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47364. * @param ray defines the ray to test with
  47365. * @param selection defines the array to store current content if selection is positive
  47366. */
  47367. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47368. /**
  47369. * Subdivide the content into child blocks (this block will then be empty)
  47370. */
  47371. createInnerBlocks(): void;
  47372. /**
  47373. * @hidden
  47374. */
  47375. 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;
  47376. }
  47377. }
  47378. declare module "babylonjs/Culling/Octrees/octree" {
  47379. import { SmartArray } from "babylonjs/Misc/smartArray";
  47380. import { Vector3 } from "babylonjs/Maths/math.vector";
  47381. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47383. import { Ray } from "babylonjs/Culling/ray";
  47384. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47385. import { Plane } from "babylonjs/Maths/math.plane";
  47386. /**
  47387. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47388. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47389. */
  47390. export class Octree<T> {
  47391. /** 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.) */
  47392. maxDepth: number;
  47393. /**
  47394. * Blocks within the octree containing objects
  47395. */
  47396. blocks: Array<OctreeBlock<T>>;
  47397. /**
  47398. * Content stored in the octree
  47399. */
  47400. dynamicContent: T[];
  47401. private _maxBlockCapacity;
  47402. private _selectionContent;
  47403. private _creationFunc;
  47404. /**
  47405. * Creates a octree
  47406. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47407. * @param creationFunc function to be used to instatiate the octree
  47408. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47409. * @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.)
  47410. */
  47411. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47412. /** 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.) */
  47413. maxDepth?: number);
  47414. /**
  47415. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47416. * @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);
  47417. * @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);
  47418. * @param entries meshes to be added to the octree blocks
  47419. */
  47420. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47421. /**
  47422. * Adds a mesh to the octree
  47423. * @param entry Mesh to add to the octree
  47424. */
  47425. addMesh(entry: T): void;
  47426. /**
  47427. * Remove an element from the octree
  47428. * @param entry defines the element to remove
  47429. */
  47430. removeMesh(entry: T): void;
  47431. /**
  47432. * Selects an array of meshes within the frustum
  47433. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47434. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47435. * @returns array of meshes within the frustum
  47436. */
  47437. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47438. /**
  47439. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47440. * @param sphereCenter defines the bounding sphere center
  47441. * @param sphereRadius defines the bounding sphere radius
  47442. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47443. * @returns an array of objects that intersect the sphere
  47444. */
  47445. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47446. /**
  47447. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47448. * @param ray defines the ray to test with
  47449. * @returns array of intersected objects
  47450. */
  47451. intersectsRay(ray: Ray): SmartArray<T>;
  47452. /**
  47453. * Adds a mesh into the octree block if it intersects the block
  47454. */
  47455. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47456. /**
  47457. * Adds a submesh into the octree block if it intersects the block
  47458. */
  47459. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47460. }
  47461. }
  47462. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47463. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47464. import { Scene } from "babylonjs/scene";
  47465. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47467. import { Ray } from "babylonjs/Culling/ray";
  47468. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47469. import { Collider } from "babylonjs/Collisions/collider";
  47470. module "babylonjs/scene" {
  47471. interface Scene {
  47472. /**
  47473. * @hidden
  47474. * Backing Filed
  47475. */
  47476. _selectionOctree: Octree<AbstractMesh>;
  47477. /**
  47478. * Gets the octree used to boost mesh selection (picking)
  47479. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47480. */
  47481. selectionOctree: Octree<AbstractMesh>;
  47482. /**
  47483. * Creates or updates the octree used to boost selection (picking)
  47484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47485. * @param maxCapacity defines the maximum capacity per leaf
  47486. * @param maxDepth defines the maximum depth of the octree
  47487. * @returns an octree of AbstractMesh
  47488. */
  47489. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47490. }
  47491. }
  47492. module "babylonjs/Meshes/abstractMesh" {
  47493. interface AbstractMesh {
  47494. /**
  47495. * @hidden
  47496. * Backing Field
  47497. */
  47498. _submeshesOctree: Octree<SubMesh>;
  47499. /**
  47500. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47501. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47502. * @param maxCapacity defines the maximum size of each block (64 by default)
  47503. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47504. * @returns the new octree
  47505. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47506. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47507. */
  47508. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47509. }
  47510. }
  47511. /**
  47512. * Defines the octree scene component responsible to manage any octrees
  47513. * in a given scene.
  47514. */
  47515. export class OctreeSceneComponent {
  47516. /**
  47517. * The component name help to identify the component in the list of scene components.
  47518. */
  47519. readonly name: string;
  47520. /**
  47521. * The scene the component belongs to.
  47522. */
  47523. scene: Scene;
  47524. /**
  47525. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47526. */
  47527. readonly checksIsEnabled: boolean;
  47528. /**
  47529. * Creates a new instance of the component for the given scene
  47530. * @param scene Defines the scene to register the component in
  47531. */
  47532. constructor(scene: Scene);
  47533. /**
  47534. * Registers the component in a given scene
  47535. */
  47536. register(): void;
  47537. /**
  47538. * Return the list of active meshes
  47539. * @returns the list of active meshes
  47540. */
  47541. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47542. /**
  47543. * Return the list of active sub meshes
  47544. * @param mesh The mesh to get the candidates sub meshes from
  47545. * @returns the list of active sub meshes
  47546. */
  47547. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47548. private _tempRay;
  47549. /**
  47550. * Return the list of sub meshes intersecting with a given local ray
  47551. * @param mesh defines the mesh to find the submesh for
  47552. * @param localRay defines the ray in local space
  47553. * @returns the list of intersecting sub meshes
  47554. */
  47555. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47556. /**
  47557. * Return the list of sub meshes colliding with a collider
  47558. * @param mesh defines the mesh to find the submesh for
  47559. * @param collider defines the collider to evaluate the collision against
  47560. * @returns the list of colliding sub meshes
  47561. */
  47562. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47563. /**
  47564. * Rebuilds the elements related to this component in case of
  47565. * context lost for instance.
  47566. */
  47567. rebuild(): void;
  47568. /**
  47569. * Disposes the component and the associated ressources.
  47570. */
  47571. dispose(): void;
  47572. }
  47573. }
  47574. declare module "babylonjs/Culling/Octrees/index" {
  47575. export * from "babylonjs/Culling/Octrees/octree";
  47576. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47577. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47578. }
  47579. declare module "babylonjs/Culling/index" {
  47580. export * from "babylonjs/Culling/boundingBox";
  47581. export * from "babylonjs/Culling/boundingInfo";
  47582. export * from "babylonjs/Culling/boundingSphere";
  47583. export * from "babylonjs/Culling/Octrees/index";
  47584. export * from "babylonjs/Culling/ray";
  47585. }
  47586. declare module "babylonjs/Gizmos/gizmo" {
  47587. import { Nullable } from "babylonjs/types";
  47588. import { IDisposable } from "babylonjs/scene";
  47589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47590. import { Mesh } from "babylonjs/Meshes/mesh";
  47591. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47592. /**
  47593. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47594. */
  47595. export class Gizmo implements IDisposable {
  47596. /** The utility layer the gizmo will be added to */
  47597. gizmoLayer: UtilityLayerRenderer;
  47598. /**
  47599. * The root mesh of the gizmo
  47600. */
  47601. _rootMesh: Mesh;
  47602. private _attachedMesh;
  47603. /**
  47604. * Ratio for the scale of the gizmo (Default: 1)
  47605. */
  47606. scaleRatio: number;
  47607. /**
  47608. * If a custom mesh has been set (Default: false)
  47609. */
  47610. protected _customMeshSet: boolean;
  47611. /**
  47612. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47613. * * When set, interactions will be enabled
  47614. */
  47615. get attachedMesh(): Nullable<AbstractMesh>;
  47616. set attachedMesh(value: Nullable<AbstractMesh>);
  47617. /**
  47618. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47619. * @param mesh The mesh to replace the default mesh of the gizmo
  47620. */
  47621. setCustomMesh(mesh: Mesh): void;
  47622. /**
  47623. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47624. */
  47625. updateGizmoRotationToMatchAttachedMesh: boolean;
  47626. /**
  47627. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47628. */
  47629. updateGizmoPositionToMatchAttachedMesh: boolean;
  47630. /**
  47631. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47632. */
  47633. updateScale: boolean;
  47634. protected _interactionsEnabled: boolean;
  47635. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47636. private _beforeRenderObserver;
  47637. private _tempVector;
  47638. /**
  47639. * Creates a gizmo
  47640. * @param gizmoLayer The utility layer the gizmo will be added to
  47641. */
  47642. constructor(
  47643. /** The utility layer the gizmo will be added to */
  47644. gizmoLayer?: UtilityLayerRenderer);
  47645. /**
  47646. * Updates the gizmo to match the attached mesh's position/rotation
  47647. */
  47648. protected _update(): void;
  47649. /**
  47650. * Disposes of the gizmo
  47651. */
  47652. dispose(): void;
  47653. }
  47654. }
  47655. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47656. import { Observable } from "babylonjs/Misc/observable";
  47657. import { Nullable } from "babylonjs/types";
  47658. import { Vector3 } from "babylonjs/Maths/math.vector";
  47659. import { Color3 } from "babylonjs/Maths/math.color";
  47660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47662. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47663. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47664. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47665. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47666. import { Scene } from "babylonjs/scene";
  47667. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47668. /**
  47669. * Single plane drag gizmo
  47670. */
  47671. export class PlaneDragGizmo extends Gizmo {
  47672. /**
  47673. * Drag behavior responsible for the gizmos dragging interactions
  47674. */
  47675. dragBehavior: PointerDragBehavior;
  47676. private _pointerObserver;
  47677. /**
  47678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47679. */
  47680. snapDistance: number;
  47681. /**
  47682. * Event that fires each time the gizmo snaps to a new location.
  47683. * * snapDistance is the the change in distance
  47684. */
  47685. onSnapObservable: Observable<{
  47686. snapDistance: number;
  47687. }>;
  47688. private _plane;
  47689. private _coloredMaterial;
  47690. private _hoverMaterial;
  47691. private _isEnabled;
  47692. private _parent;
  47693. /** @hidden */
  47694. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47695. /** @hidden */
  47696. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47697. /**
  47698. * Creates a PlaneDragGizmo
  47699. * @param gizmoLayer The utility layer the gizmo will be added to
  47700. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47701. * @param color The color of the gizmo
  47702. */
  47703. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47704. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47705. /**
  47706. * If the gizmo is enabled
  47707. */
  47708. set isEnabled(value: boolean);
  47709. get isEnabled(): boolean;
  47710. /**
  47711. * Disposes of the gizmo
  47712. */
  47713. dispose(): void;
  47714. }
  47715. }
  47716. declare module "babylonjs/Gizmos/positionGizmo" {
  47717. import { Observable } from "babylonjs/Misc/observable";
  47718. import { Nullable } from "babylonjs/types";
  47719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47720. import { Mesh } from "babylonjs/Meshes/mesh";
  47721. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47722. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47723. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47724. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47725. /**
  47726. * Gizmo that enables dragging a mesh along 3 axis
  47727. */
  47728. export class PositionGizmo extends Gizmo {
  47729. /**
  47730. * Internal gizmo used for interactions on the x axis
  47731. */
  47732. xGizmo: AxisDragGizmo;
  47733. /**
  47734. * Internal gizmo used for interactions on the y axis
  47735. */
  47736. yGizmo: AxisDragGizmo;
  47737. /**
  47738. * Internal gizmo used for interactions on the z axis
  47739. */
  47740. zGizmo: AxisDragGizmo;
  47741. /**
  47742. * Internal gizmo used for interactions on the yz plane
  47743. */
  47744. xPlaneGizmo: PlaneDragGizmo;
  47745. /**
  47746. * Internal gizmo used for interactions on the xz plane
  47747. */
  47748. yPlaneGizmo: PlaneDragGizmo;
  47749. /**
  47750. * Internal gizmo used for interactions on the xy plane
  47751. */
  47752. zPlaneGizmo: PlaneDragGizmo;
  47753. /**
  47754. * private variables
  47755. */
  47756. private _meshAttached;
  47757. private _updateGizmoRotationToMatchAttachedMesh;
  47758. private _snapDistance;
  47759. private _scaleRatio;
  47760. /** Fires an event when any of it's sub gizmos are dragged */
  47761. onDragStartObservable: Observable<unknown>;
  47762. /** Fires an event when any of it's sub gizmos are released from dragging */
  47763. onDragEndObservable: Observable<unknown>;
  47764. /**
  47765. * If set to true, planar drag is enabled
  47766. */
  47767. private _planarGizmoEnabled;
  47768. get attachedMesh(): Nullable<AbstractMesh>;
  47769. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47770. /**
  47771. * Creates a PositionGizmo
  47772. * @param gizmoLayer The utility layer the gizmo will be added to
  47773. */
  47774. constructor(gizmoLayer?: UtilityLayerRenderer);
  47775. /**
  47776. * If the planar drag gizmo is enabled
  47777. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47778. */
  47779. set planarGizmoEnabled(value: boolean);
  47780. get planarGizmoEnabled(): boolean;
  47781. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47782. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47783. /**
  47784. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47785. */
  47786. set snapDistance(value: number);
  47787. get snapDistance(): number;
  47788. /**
  47789. * Ratio for the scale of the gizmo (Default: 1)
  47790. */
  47791. set scaleRatio(value: number);
  47792. get scaleRatio(): number;
  47793. /**
  47794. * Disposes of the gizmo
  47795. */
  47796. dispose(): void;
  47797. /**
  47798. * CustomMeshes are not supported by this gizmo
  47799. * @param mesh The mesh to replace the default mesh of the gizmo
  47800. */
  47801. setCustomMesh(mesh: Mesh): void;
  47802. }
  47803. }
  47804. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47805. import { Observable } from "babylonjs/Misc/observable";
  47806. import { Nullable } from "babylonjs/types";
  47807. import { Vector3 } from "babylonjs/Maths/math.vector";
  47808. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47810. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47811. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47812. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47813. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47814. import { Scene } from "babylonjs/scene";
  47815. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47816. import { Color3 } from "babylonjs/Maths/math.color";
  47817. /**
  47818. * Single axis drag gizmo
  47819. */
  47820. export class AxisDragGizmo extends Gizmo {
  47821. /**
  47822. * Drag behavior responsible for the gizmos dragging interactions
  47823. */
  47824. dragBehavior: PointerDragBehavior;
  47825. private _pointerObserver;
  47826. /**
  47827. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47828. */
  47829. snapDistance: number;
  47830. /**
  47831. * Event that fires each time the gizmo snaps to a new location.
  47832. * * snapDistance is the the change in distance
  47833. */
  47834. onSnapObservable: Observable<{
  47835. snapDistance: number;
  47836. }>;
  47837. private _isEnabled;
  47838. private _parent;
  47839. private _arrow;
  47840. private _coloredMaterial;
  47841. private _hoverMaterial;
  47842. /** @hidden */
  47843. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47844. /** @hidden */
  47845. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47846. /**
  47847. * Creates an AxisDragGizmo
  47848. * @param gizmoLayer The utility layer the gizmo will be added to
  47849. * @param dragAxis The axis which the gizmo will be able to drag on
  47850. * @param color The color of the gizmo
  47851. */
  47852. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47854. /**
  47855. * If the gizmo is enabled
  47856. */
  47857. set isEnabled(value: boolean);
  47858. get isEnabled(): boolean;
  47859. /**
  47860. * Disposes of the gizmo
  47861. */
  47862. dispose(): void;
  47863. }
  47864. }
  47865. declare module "babylonjs/Debug/axesViewer" {
  47866. import { Vector3 } from "babylonjs/Maths/math.vector";
  47867. import { Nullable } from "babylonjs/types";
  47868. import { Scene } from "babylonjs/scene";
  47869. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47870. /**
  47871. * The Axes viewer will show 3 axes in a specific point in space
  47872. */
  47873. export class AxesViewer {
  47874. private _xAxis;
  47875. private _yAxis;
  47876. private _zAxis;
  47877. private _scaleLinesFactor;
  47878. private _instanced;
  47879. /**
  47880. * Gets the hosting scene
  47881. */
  47882. scene: Scene;
  47883. /**
  47884. * Gets or sets a number used to scale line length
  47885. */
  47886. scaleLines: number;
  47887. /** Gets the node hierarchy used to render x-axis */
  47888. get xAxis(): TransformNode;
  47889. /** Gets the node hierarchy used to render y-axis */
  47890. get yAxis(): TransformNode;
  47891. /** Gets the node hierarchy used to render z-axis */
  47892. get zAxis(): TransformNode;
  47893. /**
  47894. * Creates a new AxesViewer
  47895. * @param scene defines the hosting scene
  47896. * @param scaleLines defines a number used to scale line length (1 by default)
  47897. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47898. * @param xAxis defines the node hierarchy used to render the x-axis
  47899. * @param yAxis defines the node hierarchy used to render the y-axis
  47900. * @param zAxis defines the node hierarchy used to render the z-axis
  47901. */
  47902. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47903. /**
  47904. * Force the viewer to update
  47905. * @param position defines the position of the viewer
  47906. * @param xaxis defines the x axis of the viewer
  47907. * @param yaxis defines the y axis of the viewer
  47908. * @param zaxis defines the z axis of the viewer
  47909. */
  47910. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47911. /**
  47912. * Creates an instance of this axes viewer.
  47913. * @returns a new axes viewer with instanced meshes
  47914. */
  47915. createInstance(): AxesViewer;
  47916. /** Releases resources */
  47917. dispose(): void;
  47918. private static _SetRenderingGroupId;
  47919. }
  47920. }
  47921. declare module "babylonjs/Debug/boneAxesViewer" {
  47922. import { Nullable } from "babylonjs/types";
  47923. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47924. import { Vector3 } from "babylonjs/Maths/math.vector";
  47925. import { Mesh } from "babylonjs/Meshes/mesh";
  47926. import { Bone } from "babylonjs/Bones/bone";
  47927. import { Scene } from "babylonjs/scene";
  47928. /**
  47929. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47930. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47931. */
  47932. export class BoneAxesViewer extends AxesViewer {
  47933. /**
  47934. * Gets or sets the target mesh where to display the axes viewer
  47935. */
  47936. mesh: Nullable<Mesh>;
  47937. /**
  47938. * Gets or sets the target bone where to display the axes viewer
  47939. */
  47940. bone: Nullable<Bone>;
  47941. /** Gets current position */
  47942. pos: Vector3;
  47943. /** Gets direction of X axis */
  47944. xaxis: Vector3;
  47945. /** Gets direction of Y axis */
  47946. yaxis: Vector3;
  47947. /** Gets direction of Z axis */
  47948. zaxis: Vector3;
  47949. /**
  47950. * Creates a new BoneAxesViewer
  47951. * @param scene defines the hosting scene
  47952. * @param bone defines the target bone
  47953. * @param mesh defines the target mesh
  47954. * @param scaleLines defines a scaling factor for line length (1 by default)
  47955. */
  47956. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47957. /**
  47958. * Force the viewer to update
  47959. */
  47960. update(): void;
  47961. /** Releases resources */
  47962. dispose(): void;
  47963. }
  47964. }
  47965. declare module "babylonjs/Debug/debugLayer" {
  47966. import { Scene } from "babylonjs/scene";
  47967. /**
  47968. * Interface used to define scene explorer extensibility option
  47969. */
  47970. export interface IExplorerExtensibilityOption {
  47971. /**
  47972. * Define the option label
  47973. */
  47974. label: string;
  47975. /**
  47976. * Defines the action to execute on click
  47977. */
  47978. action: (entity: any) => void;
  47979. }
  47980. /**
  47981. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47982. */
  47983. export interface IExplorerExtensibilityGroup {
  47984. /**
  47985. * Defines a predicate to test if a given type mut be extended
  47986. */
  47987. predicate: (entity: any) => boolean;
  47988. /**
  47989. * Gets the list of options added to a type
  47990. */
  47991. entries: IExplorerExtensibilityOption[];
  47992. }
  47993. /**
  47994. * Interface used to define the options to use to create the Inspector
  47995. */
  47996. export interface IInspectorOptions {
  47997. /**
  47998. * Display in overlay mode (default: false)
  47999. */
  48000. overlay?: boolean;
  48001. /**
  48002. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48003. */
  48004. globalRoot?: HTMLElement;
  48005. /**
  48006. * Display the Scene explorer
  48007. */
  48008. showExplorer?: boolean;
  48009. /**
  48010. * Display the property inspector
  48011. */
  48012. showInspector?: boolean;
  48013. /**
  48014. * Display in embed mode (both panes on the right)
  48015. */
  48016. embedMode?: boolean;
  48017. /**
  48018. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48019. */
  48020. handleResize?: boolean;
  48021. /**
  48022. * Allow the panes to popup (default: true)
  48023. */
  48024. enablePopup?: boolean;
  48025. /**
  48026. * Allow the panes to be closed by users (default: true)
  48027. */
  48028. enableClose?: boolean;
  48029. /**
  48030. * Optional list of extensibility entries
  48031. */
  48032. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48033. /**
  48034. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48035. */
  48036. inspectorURL?: string;
  48037. /**
  48038. * Optional initial tab (default to DebugLayerTab.Properties)
  48039. */
  48040. initialTab?: DebugLayerTab;
  48041. }
  48042. module "babylonjs/scene" {
  48043. interface Scene {
  48044. /**
  48045. * @hidden
  48046. * Backing field
  48047. */
  48048. _debugLayer: DebugLayer;
  48049. /**
  48050. * Gets the debug layer (aka Inspector) associated with the scene
  48051. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48052. */
  48053. debugLayer: DebugLayer;
  48054. }
  48055. }
  48056. /**
  48057. * Enum of inspector action tab
  48058. */
  48059. export enum DebugLayerTab {
  48060. /**
  48061. * Properties tag (default)
  48062. */
  48063. Properties = 0,
  48064. /**
  48065. * Debug tab
  48066. */
  48067. Debug = 1,
  48068. /**
  48069. * Statistics tab
  48070. */
  48071. Statistics = 2,
  48072. /**
  48073. * Tools tab
  48074. */
  48075. Tools = 3,
  48076. /**
  48077. * Settings tab
  48078. */
  48079. Settings = 4
  48080. }
  48081. /**
  48082. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48083. * what is happening in your scene
  48084. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48085. */
  48086. export class DebugLayer {
  48087. /**
  48088. * Define the url to get the inspector script from.
  48089. * By default it uses the babylonjs CDN.
  48090. * @ignoreNaming
  48091. */
  48092. static InspectorURL: string;
  48093. private _scene;
  48094. private BJSINSPECTOR;
  48095. private _onPropertyChangedObservable?;
  48096. /**
  48097. * Observable triggered when a property is changed through the inspector.
  48098. */
  48099. get onPropertyChangedObservable(): any;
  48100. /**
  48101. * Instantiates a new debug layer.
  48102. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48103. * what is happening in your scene
  48104. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48105. * @param scene Defines the scene to inspect
  48106. */
  48107. constructor(scene: Scene);
  48108. /** Creates the inspector window. */
  48109. private _createInspector;
  48110. /**
  48111. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48112. * @param entity defines the entity to select
  48113. * @param lineContainerTitle defines the specific block to highlight
  48114. */
  48115. select(entity: any, lineContainerTitle?: string): void;
  48116. /** Get the inspector from bundle or global */
  48117. private _getGlobalInspector;
  48118. /**
  48119. * Get if the inspector is visible or not.
  48120. * @returns true if visible otherwise, false
  48121. */
  48122. isVisible(): boolean;
  48123. /**
  48124. * Hide the inspector and close its window.
  48125. */
  48126. hide(): void;
  48127. /**
  48128. * Launch the debugLayer.
  48129. * @param config Define the configuration of the inspector
  48130. * @return a promise fulfilled when the debug layer is visible
  48131. */
  48132. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48133. }
  48134. }
  48135. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48136. import { Nullable } from "babylonjs/types";
  48137. import { Scene } from "babylonjs/scene";
  48138. import { Vector4 } from "babylonjs/Maths/math.vector";
  48139. import { Color4 } from "babylonjs/Maths/math.color";
  48140. import { Mesh } from "babylonjs/Meshes/mesh";
  48141. /**
  48142. * Class containing static functions to help procedurally build meshes
  48143. */
  48144. export class BoxBuilder {
  48145. /**
  48146. * Creates a box mesh
  48147. * * The parameter `size` sets the size (float) of each box side (default 1)
  48148. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48149. * * 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)
  48150. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48154. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48155. * @param name defines the name of the mesh
  48156. * @param options defines the options used to create the mesh
  48157. * @param scene defines the hosting scene
  48158. * @returns the box mesh
  48159. */
  48160. static CreateBox(name: string, options: {
  48161. size?: number;
  48162. width?: number;
  48163. height?: number;
  48164. depth?: number;
  48165. faceUV?: Vector4[];
  48166. faceColors?: Color4[];
  48167. sideOrientation?: number;
  48168. frontUVs?: Vector4;
  48169. backUVs?: Vector4;
  48170. wrap?: boolean;
  48171. topBaseAt?: number;
  48172. bottomBaseAt?: number;
  48173. updatable?: boolean;
  48174. }, scene?: Nullable<Scene>): Mesh;
  48175. }
  48176. }
  48177. declare module "babylonjs/Debug/physicsViewer" {
  48178. import { Nullable } from "babylonjs/types";
  48179. import { Scene } from "babylonjs/scene";
  48180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48181. import { Mesh } from "babylonjs/Meshes/mesh";
  48182. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48183. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48184. /**
  48185. * Used to show the physics impostor around the specific mesh
  48186. */
  48187. export class PhysicsViewer {
  48188. /** @hidden */
  48189. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48190. /** @hidden */
  48191. protected _meshes: Array<Nullable<AbstractMesh>>;
  48192. /** @hidden */
  48193. protected _scene: Nullable<Scene>;
  48194. /** @hidden */
  48195. protected _numMeshes: number;
  48196. /** @hidden */
  48197. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48198. private _renderFunction;
  48199. private _utilityLayer;
  48200. private _debugBoxMesh;
  48201. private _debugSphereMesh;
  48202. private _debugCylinderMesh;
  48203. private _debugMaterial;
  48204. private _debugMeshMeshes;
  48205. /**
  48206. * Creates a new PhysicsViewer
  48207. * @param scene defines the hosting scene
  48208. */
  48209. constructor(scene: Scene);
  48210. /** @hidden */
  48211. protected _updateDebugMeshes(): void;
  48212. /**
  48213. * Renders a specified physic impostor
  48214. * @param impostor defines the impostor to render
  48215. * @param targetMesh defines the mesh represented by the impostor
  48216. * @returns the new debug mesh used to render the impostor
  48217. */
  48218. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48219. /**
  48220. * Hides a specified physic impostor
  48221. * @param impostor defines the impostor to hide
  48222. */
  48223. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48224. private _getDebugMaterial;
  48225. private _getDebugBoxMesh;
  48226. private _getDebugSphereMesh;
  48227. private _getDebugCylinderMesh;
  48228. private _getDebugMeshMesh;
  48229. private _getDebugMesh;
  48230. /** Releases all resources */
  48231. dispose(): void;
  48232. }
  48233. }
  48234. declare module "babylonjs/Debug/rayHelper" {
  48235. import { Nullable } from "babylonjs/types";
  48236. import { Ray } from "babylonjs/Culling/ray";
  48237. import { Vector3 } from "babylonjs/Maths/math.vector";
  48238. import { Color3 } from "babylonjs/Maths/math.color";
  48239. import { Scene } from "babylonjs/scene";
  48240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48241. import "babylonjs/Meshes/Builders/linesBuilder";
  48242. /**
  48243. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48244. * in order to better appreciate the issue one might have.
  48245. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48246. */
  48247. export class RayHelper {
  48248. /**
  48249. * Defines the ray we are currently tryin to visualize.
  48250. */
  48251. ray: Nullable<Ray>;
  48252. private _renderPoints;
  48253. private _renderLine;
  48254. private _renderFunction;
  48255. private _scene;
  48256. private _updateToMeshFunction;
  48257. private _attachedToMesh;
  48258. private _meshSpaceDirection;
  48259. private _meshSpaceOrigin;
  48260. /**
  48261. * Helper function to create a colored helper in a scene in one line.
  48262. * @param ray Defines the ray we are currently tryin to visualize
  48263. * @param scene Defines the scene the ray is used in
  48264. * @param color Defines the color we want to see the ray in
  48265. * @returns The newly created ray helper.
  48266. */
  48267. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48268. /**
  48269. * Instantiate a new ray helper.
  48270. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48271. * in order to better appreciate the issue one might have.
  48272. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48273. * @param ray Defines the ray we are currently tryin to visualize
  48274. */
  48275. constructor(ray: Ray);
  48276. /**
  48277. * Shows the ray we are willing to debug.
  48278. * @param scene Defines the scene the ray needs to be rendered in
  48279. * @param color Defines the color the ray needs to be rendered in
  48280. */
  48281. show(scene: Scene, color?: Color3): void;
  48282. /**
  48283. * Hides the ray we are debugging.
  48284. */
  48285. hide(): void;
  48286. private _render;
  48287. /**
  48288. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48289. * @param mesh Defines the mesh we want the helper attached to
  48290. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48291. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48292. * @param length Defines the length of the ray
  48293. */
  48294. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48295. /**
  48296. * Detach the ray helper from the mesh it has previously been attached to.
  48297. */
  48298. detachFromMesh(): void;
  48299. private _updateToMesh;
  48300. /**
  48301. * Dispose the helper and release its associated resources.
  48302. */
  48303. dispose(): void;
  48304. }
  48305. }
  48306. declare module "babylonjs/Debug/skeletonViewer" {
  48307. import { Color3 } from "babylonjs/Maths/math.color";
  48308. import { Scene } from "babylonjs/scene";
  48309. import { Nullable } from "babylonjs/types";
  48310. import { Skeleton } from "babylonjs/Bones/skeleton";
  48311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48312. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48313. /**
  48314. * Class used to render a debug view of a given skeleton
  48315. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48316. */
  48317. export class SkeletonViewer {
  48318. /** defines the skeleton to render */
  48319. skeleton: Skeleton;
  48320. /** defines the mesh attached to the skeleton */
  48321. mesh: AbstractMesh;
  48322. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48323. autoUpdateBonesMatrices: boolean;
  48324. /** defines the rendering group id to use with the viewer */
  48325. renderingGroupId: number;
  48326. /** Gets or sets the color used to render the skeleton */
  48327. color: Color3;
  48328. private _scene;
  48329. private _debugLines;
  48330. private _debugMesh;
  48331. private _isEnabled;
  48332. private _renderFunction;
  48333. private _utilityLayer;
  48334. /**
  48335. * Returns the mesh used to render the bones
  48336. */
  48337. get debugMesh(): Nullable<LinesMesh>;
  48338. /**
  48339. * Creates a new SkeletonViewer
  48340. * @param skeleton defines the skeleton to render
  48341. * @param mesh defines the mesh attached to the skeleton
  48342. * @param scene defines the hosting scene
  48343. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48344. * @param renderingGroupId defines the rendering group id to use with the viewer
  48345. */
  48346. constructor(
  48347. /** defines the skeleton to render */
  48348. skeleton: Skeleton,
  48349. /** defines the mesh attached to the skeleton */
  48350. mesh: AbstractMesh, scene: Scene,
  48351. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48352. autoUpdateBonesMatrices?: boolean,
  48353. /** defines the rendering group id to use with the viewer */
  48354. renderingGroupId?: number);
  48355. /** Gets or sets a boolean indicating if the viewer is enabled */
  48356. set isEnabled(value: boolean);
  48357. get isEnabled(): boolean;
  48358. private _getBonePosition;
  48359. private _getLinesForBonesWithLength;
  48360. private _getLinesForBonesNoLength;
  48361. /** Update the viewer to sync with current skeleton state */
  48362. update(): void;
  48363. /** Release associated resources */
  48364. dispose(): void;
  48365. }
  48366. }
  48367. declare module "babylonjs/Debug/index" {
  48368. export * from "babylonjs/Debug/axesViewer";
  48369. export * from "babylonjs/Debug/boneAxesViewer";
  48370. export * from "babylonjs/Debug/debugLayer";
  48371. export * from "babylonjs/Debug/physicsViewer";
  48372. export * from "babylonjs/Debug/rayHelper";
  48373. export * from "babylonjs/Debug/skeletonViewer";
  48374. }
  48375. declare module "babylonjs/Engines/nullEngine" {
  48376. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48377. import { Engine } from "babylonjs/Engines/engine";
  48378. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48379. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48381. import { Effect } from "babylonjs/Materials/effect";
  48382. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48383. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48384. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48385. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48386. /**
  48387. * Options to create the null engine
  48388. */
  48389. export class NullEngineOptions {
  48390. /**
  48391. * Render width (Default: 512)
  48392. */
  48393. renderWidth: number;
  48394. /**
  48395. * Render height (Default: 256)
  48396. */
  48397. renderHeight: number;
  48398. /**
  48399. * Texture size (Default: 512)
  48400. */
  48401. textureSize: number;
  48402. /**
  48403. * If delta time between frames should be constant
  48404. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48405. */
  48406. deterministicLockstep: boolean;
  48407. /**
  48408. * Maximum about of steps between frames (Default: 4)
  48409. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48410. */
  48411. lockstepMaxSteps: number;
  48412. }
  48413. /**
  48414. * The null engine class provides support for headless version of babylon.js.
  48415. * This can be used in server side scenario or for testing purposes
  48416. */
  48417. export class NullEngine extends Engine {
  48418. private _options;
  48419. /**
  48420. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48422. * @returns true if engine is in deterministic lock step mode
  48423. */
  48424. isDeterministicLockStep(): boolean;
  48425. /**
  48426. * Gets the max steps when engine is running in deterministic lock step
  48427. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48428. * @returns the max steps
  48429. */
  48430. getLockstepMaxSteps(): number;
  48431. /**
  48432. * Gets the current hardware scaling level.
  48433. * By default the hardware scaling level is computed from the window device ratio.
  48434. * 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.
  48435. * @returns a number indicating the current hardware scaling level
  48436. */
  48437. getHardwareScalingLevel(): number;
  48438. constructor(options?: NullEngineOptions);
  48439. /**
  48440. * Creates a vertex buffer
  48441. * @param vertices the data for the vertex buffer
  48442. * @returns the new WebGL static buffer
  48443. */
  48444. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48445. /**
  48446. * Creates a new index buffer
  48447. * @param indices defines the content of the index buffer
  48448. * @param updatable defines if the index buffer must be updatable
  48449. * @returns a new webGL buffer
  48450. */
  48451. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48452. /**
  48453. * Clear the current render buffer or the current render target (if any is set up)
  48454. * @param color defines the color to use
  48455. * @param backBuffer defines if the back buffer must be cleared
  48456. * @param depth defines if the depth buffer must be cleared
  48457. * @param stencil defines if the stencil buffer must be cleared
  48458. */
  48459. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48460. /**
  48461. * Gets the current render width
  48462. * @param useScreen defines if screen size must be used (or the current render target if any)
  48463. * @returns a number defining the current render width
  48464. */
  48465. getRenderWidth(useScreen?: boolean): number;
  48466. /**
  48467. * Gets the current render height
  48468. * @param useScreen defines if screen size must be used (or the current render target if any)
  48469. * @returns a number defining the current render height
  48470. */
  48471. getRenderHeight(useScreen?: boolean): number;
  48472. /**
  48473. * Set the WebGL's viewport
  48474. * @param viewport defines the viewport element to be used
  48475. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48476. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48477. */
  48478. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48479. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48480. /**
  48481. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48482. * @param pipelineContext defines the pipeline context to use
  48483. * @param uniformsNames defines the list of uniform names
  48484. * @returns an array of webGL uniform locations
  48485. */
  48486. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48487. /**
  48488. * Gets the lsit of active attributes for a given webGL program
  48489. * @param pipelineContext defines the pipeline context to use
  48490. * @param attributesNames defines the list of attribute names to get
  48491. * @returns an array of indices indicating the offset of each attribute
  48492. */
  48493. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48494. /**
  48495. * Binds an effect to the webGL context
  48496. * @param effect defines the effect to bind
  48497. */
  48498. bindSamplers(effect: Effect): void;
  48499. /**
  48500. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48501. * @param effect defines the effect to activate
  48502. */
  48503. enableEffect(effect: Effect): void;
  48504. /**
  48505. * Set various states to the webGL context
  48506. * @param culling defines backface culling state
  48507. * @param zOffset defines the value to apply to zOffset (0 by default)
  48508. * @param force defines if states must be applied even if cache is up to date
  48509. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48510. */
  48511. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48512. /**
  48513. * Set the value of an uniform to an array of int32
  48514. * @param uniform defines the webGL uniform location where to store the value
  48515. * @param array defines the array of int32 to store
  48516. */
  48517. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48518. /**
  48519. * Set the value of an uniform to an array of int32 (stored as vec2)
  48520. * @param uniform defines the webGL uniform location where to store the value
  48521. * @param array defines the array of int32 to store
  48522. */
  48523. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48524. /**
  48525. * Set the value of an uniform to an array of int32 (stored as vec3)
  48526. * @param uniform defines the webGL uniform location where to store the value
  48527. * @param array defines the array of int32 to store
  48528. */
  48529. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48530. /**
  48531. * Set the value of an uniform to an array of int32 (stored as vec4)
  48532. * @param uniform defines the webGL uniform location where to store the value
  48533. * @param array defines the array of int32 to store
  48534. */
  48535. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48536. /**
  48537. * Set the value of an uniform to an array of float32
  48538. * @param uniform defines the webGL uniform location where to store the value
  48539. * @param array defines the array of float32 to store
  48540. */
  48541. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48542. /**
  48543. * Set the value of an uniform to an array of float32 (stored as vec2)
  48544. * @param uniform defines the webGL uniform location where to store the value
  48545. * @param array defines the array of float32 to store
  48546. */
  48547. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48548. /**
  48549. * Set the value of an uniform to an array of float32 (stored as vec3)
  48550. * @param uniform defines the webGL uniform location where to store the value
  48551. * @param array defines the array of float32 to store
  48552. */
  48553. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48554. /**
  48555. * Set the value of an uniform to an array of float32 (stored as vec4)
  48556. * @param uniform defines the webGL uniform location where to store the value
  48557. * @param array defines the array of float32 to store
  48558. */
  48559. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48560. /**
  48561. * Set the value of an uniform to an array of number
  48562. * @param uniform defines the webGL uniform location where to store the value
  48563. * @param array defines the array of number to store
  48564. */
  48565. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48566. /**
  48567. * Set the value of an uniform to an array of number (stored as vec2)
  48568. * @param uniform defines the webGL uniform location where to store the value
  48569. * @param array defines the array of number to store
  48570. */
  48571. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48572. /**
  48573. * Set the value of an uniform to an array of number (stored as vec3)
  48574. * @param uniform defines the webGL uniform location where to store the value
  48575. * @param array defines the array of number to store
  48576. */
  48577. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48578. /**
  48579. * Set the value of an uniform to an array of number (stored as vec4)
  48580. * @param uniform defines the webGL uniform location where to store the value
  48581. * @param array defines the array of number to store
  48582. */
  48583. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48584. /**
  48585. * Set the value of an uniform to an array of float32 (stored as matrices)
  48586. * @param uniform defines the webGL uniform location where to store the value
  48587. * @param matrices defines the array of float32 to store
  48588. */
  48589. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48590. /**
  48591. * Set the value of an uniform to a matrix (3x3)
  48592. * @param uniform defines the webGL uniform location where to store the value
  48593. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48594. */
  48595. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48596. /**
  48597. * Set the value of an uniform to a matrix (2x2)
  48598. * @param uniform defines the webGL uniform location where to store the value
  48599. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48600. */
  48601. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48602. /**
  48603. * Set the value of an uniform to a number (float)
  48604. * @param uniform defines the webGL uniform location where to store the value
  48605. * @param value defines the float number to store
  48606. */
  48607. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48608. /**
  48609. * Set the value of an uniform to a vec2
  48610. * @param uniform defines the webGL uniform location where to store the value
  48611. * @param x defines the 1st component of the value
  48612. * @param y defines the 2nd component of the value
  48613. */
  48614. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48615. /**
  48616. * Set the value of an uniform to a vec3
  48617. * @param uniform defines the webGL uniform location where to store the value
  48618. * @param x defines the 1st component of the value
  48619. * @param y defines the 2nd component of the value
  48620. * @param z defines the 3rd component of the value
  48621. */
  48622. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48623. /**
  48624. * Set the value of an uniform to a boolean
  48625. * @param uniform defines the webGL uniform location where to store the value
  48626. * @param bool defines the boolean to store
  48627. */
  48628. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48629. /**
  48630. * Set the value of an uniform to a vec4
  48631. * @param uniform defines the webGL uniform location where to store the value
  48632. * @param x defines the 1st component of the value
  48633. * @param y defines the 2nd component of the value
  48634. * @param z defines the 3rd component of the value
  48635. * @param w defines the 4th component of the value
  48636. */
  48637. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48638. /**
  48639. * Sets the current alpha mode
  48640. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48641. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48642. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48643. */
  48644. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48645. /**
  48646. * Bind webGl buffers directly to the webGL context
  48647. * @param vertexBuffers defines the vertex buffer to bind
  48648. * @param indexBuffer defines the index buffer to bind
  48649. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48650. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48651. * @param effect defines the effect associated with the vertex buffer
  48652. */
  48653. bindBuffers(vertexBuffers: {
  48654. [key: string]: VertexBuffer;
  48655. }, indexBuffer: DataBuffer, effect: Effect): void;
  48656. /**
  48657. * Force the entire cache to be cleared
  48658. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48659. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48660. */
  48661. wipeCaches(bruteForce?: boolean): void;
  48662. /**
  48663. * Send a draw order
  48664. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48665. * @param indexStart defines the starting index
  48666. * @param indexCount defines the number of index to draw
  48667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48668. */
  48669. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48670. /**
  48671. * Draw a list of indexed primitives
  48672. * @param fillMode defines the primitive to use
  48673. * @param indexStart defines the starting index
  48674. * @param indexCount defines the number of index to draw
  48675. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48676. */
  48677. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48678. /**
  48679. * Draw a list of unindexed primitives
  48680. * @param fillMode defines the primitive to use
  48681. * @param verticesStart defines the index of first vertex to draw
  48682. * @param verticesCount defines the count of vertices to draw
  48683. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48684. */
  48685. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48686. /** @hidden */
  48687. _createTexture(): WebGLTexture;
  48688. /** @hidden */
  48689. _releaseTexture(texture: InternalTexture): void;
  48690. /**
  48691. * Usually called from Texture.ts.
  48692. * Passed information to create a WebGLTexture
  48693. * @param urlArg defines a value which contains one of the following:
  48694. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48695. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48696. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48698. * @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)
  48699. * @param scene needed for loading to the correct scene
  48700. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48701. * @param onLoad optional callback to be called upon successful completion
  48702. * @param onError optional callback to be called upon failure
  48703. * @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
  48704. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48705. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48706. * @param forcedExtension defines the extension to use to pick the right loader
  48707. * @param mimeType defines an optional mime type
  48708. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48709. */
  48710. 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;
  48711. /**
  48712. * Creates a new render target texture
  48713. * @param size defines the size of the texture
  48714. * @param options defines the options used to create the texture
  48715. * @returns a new render target texture stored in an InternalTexture
  48716. */
  48717. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48718. /**
  48719. * Update the sampling mode of a given texture
  48720. * @param samplingMode defines the required sampling mode
  48721. * @param texture defines the texture to update
  48722. */
  48723. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48724. /**
  48725. * Binds the frame buffer to the specified texture.
  48726. * @param texture The texture to render to or null for the default canvas
  48727. * @param faceIndex The face of the texture to render to in case of cube texture
  48728. * @param requiredWidth The width of the target to render to
  48729. * @param requiredHeight The height of the target to render to
  48730. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48731. * @param lodLevel defines le lod level to bind to the frame buffer
  48732. */
  48733. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48734. /**
  48735. * Unbind the current render target texture from the webGL context
  48736. * @param texture defines the render target texture to unbind
  48737. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48738. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48739. */
  48740. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48741. /**
  48742. * Creates a dynamic vertex buffer
  48743. * @param vertices the data for the dynamic vertex buffer
  48744. * @returns the new WebGL dynamic buffer
  48745. */
  48746. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48747. /**
  48748. * Update the content of a dynamic texture
  48749. * @param texture defines the texture to update
  48750. * @param canvas defines the canvas containing the source
  48751. * @param invertY defines if data must be stored with Y axis inverted
  48752. * @param premulAlpha defines if alpha is stored as premultiplied
  48753. * @param format defines the format of the data
  48754. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48755. */
  48756. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48757. /**
  48758. * Gets a boolean indicating if all created effects are ready
  48759. * @returns true if all effects are ready
  48760. */
  48761. areAllEffectsReady(): boolean;
  48762. /**
  48763. * @hidden
  48764. * Get the current error code of the webGL context
  48765. * @returns the error code
  48766. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48767. */
  48768. getError(): number;
  48769. /** @hidden */
  48770. _getUnpackAlignement(): number;
  48771. /** @hidden */
  48772. _unpackFlipY(value: boolean): void;
  48773. /**
  48774. * Update a dynamic index buffer
  48775. * @param indexBuffer defines the target index buffer
  48776. * @param indices defines the data to update
  48777. * @param offset defines the offset in the target index buffer where update should start
  48778. */
  48779. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48780. /**
  48781. * Updates a dynamic vertex buffer.
  48782. * @param vertexBuffer the vertex buffer to update
  48783. * @param vertices the data used to update the vertex buffer
  48784. * @param byteOffset the byte offset of the data (optional)
  48785. * @param byteLength the byte length of the data (optional)
  48786. */
  48787. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48788. /** @hidden */
  48789. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48790. /** @hidden */
  48791. _bindTexture(channel: number, texture: InternalTexture): void;
  48792. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48793. /**
  48794. * 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
  48795. */
  48796. releaseEffects(): void;
  48797. displayLoadingUI(): void;
  48798. hideLoadingUI(): void;
  48799. /** @hidden */
  48800. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48801. /** @hidden */
  48802. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48803. /** @hidden */
  48804. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48805. /** @hidden */
  48806. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48807. }
  48808. }
  48809. declare module "babylonjs/Instrumentation/timeToken" {
  48810. import { Nullable } from "babylonjs/types";
  48811. /**
  48812. * @hidden
  48813. **/
  48814. export class _TimeToken {
  48815. _startTimeQuery: Nullable<WebGLQuery>;
  48816. _endTimeQuery: Nullable<WebGLQuery>;
  48817. _timeElapsedQuery: Nullable<WebGLQuery>;
  48818. _timeElapsedQueryEnded: boolean;
  48819. }
  48820. }
  48821. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48822. import { Nullable, int } from "babylonjs/types";
  48823. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48824. /** @hidden */
  48825. export class _OcclusionDataStorage {
  48826. /** @hidden */
  48827. occlusionInternalRetryCounter: number;
  48828. /** @hidden */
  48829. isOcclusionQueryInProgress: boolean;
  48830. /** @hidden */
  48831. isOccluded: boolean;
  48832. /** @hidden */
  48833. occlusionRetryCount: number;
  48834. /** @hidden */
  48835. occlusionType: number;
  48836. /** @hidden */
  48837. occlusionQueryAlgorithmType: number;
  48838. }
  48839. module "babylonjs/Engines/engine" {
  48840. interface Engine {
  48841. /**
  48842. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48843. * @return the new query
  48844. */
  48845. createQuery(): WebGLQuery;
  48846. /**
  48847. * Delete and release a webGL query
  48848. * @param query defines the query to delete
  48849. * @return the current engine
  48850. */
  48851. deleteQuery(query: WebGLQuery): Engine;
  48852. /**
  48853. * Check if a given query has resolved and got its value
  48854. * @param query defines the query to check
  48855. * @returns true if the query got its value
  48856. */
  48857. isQueryResultAvailable(query: WebGLQuery): boolean;
  48858. /**
  48859. * Gets the value of a given query
  48860. * @param query defines the query to check
  48861. * @returns the value of the query
  48862. */
  48863. getQueryResult(query: WebGLQuery): number;
  48864. /**
  48865. * Initiates an occlusion query
  48866. * @param algorithmType defines the algorithm to use
  48867. * @param query defines the query to use
  48868. * @returns the current engine
  48869. * @see http://doc.babylonjs.com/features/occlusionquery
  48870. */
  48871. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48872. /**
  48873. * Ends an occlusion query
  48874. * @see http://doc.babylonjs.com/features/occlusionquery
  48875. * @param algorithmType defines the algorithm to use
  48876. * @returns the current engine
  48877. */
  48878. endOcclusionQuery(algorithmType: number): Engine;
  48879. /**
  48880. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48881. * Please note that only one query can be issued at a time
  48882. * @returns a time token used to track the time span
  48883. */
  48884. startTimeQuery(): Nullable<_TimeToken>;
  48885. /**
  48886. * Ends a time query
  48887. * @param token defines the token used to measure the time span
  48888. * @returns the time spent (in ns)
  48889. */
  48890. endTimeQuery(token: _TimeToken): int;
  48891. /** @hidden */
  48892. _currentNonTimestampToken: Nullable<_TimeToken>;
  48893. /** @hidden */
  48894. _createTimeQuery(): WebGLQuery;
  48895. /** @hidden */
  48896. _deleteTimeQuery(query: WebGLQuery): void;
  48897. /** @hidden */
  48898. _getGlAlgorithmType(algorithmType: number): number;
  48899. /** @hidden */
  48900. _getTimeQueryResult(query: WebGLQuery): any;
  48901. /** @hidden */
  48902. _getTimeQueryAvailability(query: WebGLQuery): any;
  48903. }
  48904. }
  48905. module "babylonjs/Meshes/abstractMesh" {
  48906. interface AbstractMesh {
  48907. /**
  48908. * Backing filed
  48909. * @hidden
  48910. */
  48911. __occlusionDataStorage: _OcclusionDataStorage;
  48912. /**
  48913. * Access property
  48914. * @hidden
  48915. */
  48916. _occlusionDataStorage: _OcclusionDataStorage;
  48917. /**
  48918. * 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.
  48919. * The default value is -1 which means don't break the query and wait till the result
  48920. * @see http://doc.babylonjs.com/features/occlusionquery
  48921. */
  48922. occlusionRetryCount: number;
  48923. /**
  48924. * 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:
  48925. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48926. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48927. * * 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.
  48928. * @see http://doc.babylonjs.com/features/occlusionquery
  48929. */
  48930. occlusionType: number;
  48931. /**
  48932. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48933. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48934. * * 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.
  48935. * @see http://doc.babylonjs.com/features/occlusionquery
  48936. */
  48937. occlusionQueryAlgorithmType: number;
  48938. /**
  48939. * 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
  48940. * @see http://doc.babylonjs.com/features/occlusionquery
  48941. */
  48942. isOccluded: boolean;
  48943. /**
  48944. * Flag to check the progress status of the query
  48945. * @see http://doc.babylonjs.com/features/occlusionquery
  48946. */
  48947. isOcclusionQueryInProgress: boolean;
  48948. }
  48949. }
  48950. }
  48951. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48952. import { Nullable } from "babylonjs/types";
  48953. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48954. /** @hidden */
  48955. export var _forceTransformFeedbackToBundle: boolean;
  48956. module "babylonjs/Engines/engine" {
  48957. interface Engine {
  48958. /**
  48959. * Creates a webGL transform feedback object
  48960. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48961. * @returns the webGL transform feedback object
  48962. */
  48963. createTransformFeedback(): WebGLTransformFeedback;
  48964. /**
  48965. * Delete a webGL transform feedback object
  48966. * @param value defines the webGL transform feedback object to delete
  48967. */
  48968. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48969. /**
  48970. * Bind a webGL transform feedback object to the webgl context
  48971. * @param value defines the webGL transform feedback object to bind
  48972. */
  48973. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48974. /**
  48975. * Begins a transform feedback operation
  48976. * @param usePoints defines if points or triangles must be used
  48977. */
  48978. beginTransformFeedback(usePoints: boolean): void;
  48979. /**
  48980. * Ends a transform feedback operation
  48981. */
  48982. endTransformFeedback(): void;
  48983. /**
  48984. * Specify the varyings to use with transform feedback
  48985. * @param program defines the associated webGL program
  48986. * @param value defines the list of strings representing the varying names
  48987. */
  48988. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48989. /**
  48990. * Bind a webGL buffer for a transform feedback operation
  48991. * @param value defines the webGL buffer to bind
  48992. */
  48993. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48994. }
  48995. }
  48996. }
  48997. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48998. import { Scene } from "babylonjs/scene";
  48999. import { Engine } from "babylonjs/Engines/engine";
  49000. import { Texture } from "babylonjs/Materials/Textures/texture";
  49001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49002. import "babylonjs/Engines/Extensions/engine.multiRender";
  49003. /**
  49004. * Creation options of the multi render target texture.
  49005. */
  49006. export interface IMultiRenderTargetOptions {
  49007. /**
  49008. * Define if the texture needs to create mip maps after render.
  49009. */
  49010. generateMipMaps?: boolean;
  49011. /**
  49012. * Define the types of all the draw buffers we want to create
  49013. */
  49014. types?: number[];
  49015. /**
  49016. * Define the sampling modes of all the draw buffers we want to create
  49017. */
  49018. samplingModes?: number[];
  49019. /**
  49020. * Define if a depth buffer is required
  49021. */
  49022. generateDepthBuffer?: boolean;
  49023. /**
  49024. * Define if a stencil buffer is required
  49025. */
  49026. generateStencilBuffer?: boolean;
  49027. /**
  49028. * Define if a depth texture is required instead of a depth buffer
  49029. */
  49030. generateDepthTexture?: boolean;
  49031. /**
  49032. * Define the number of desired draw buffers
  49033. */
  49034. textureCount?: number;
  49035. /**
  49036. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49037. */
  49038. doNotChangeAspectRatio?: boolean;
  49039. /**
  49040. * Define the default type of the buffers we are creating
  49041. */
  49042. defaultType?: number;
  49043. }
  49044. /**
  49045. * A multi render target, like a render target provides the ability to render to a texture.
  49046. * Unlike the render target, it can render to several draw buffers in one draw.
  49047. * This is specially interesting in deferred rendering or for any effects requiring more than
  49048. * just one color from a single pass.
  49049. */
  49050. export class MultiRenderTarget extends RenderTargetTexture {
  49051. private _internalTextures;
  49052. private _textures;
  49053. private _multiRenderTargetOptions;
  49054. /**
  49055. * Get if draw buffers are currently supported by the used hardware and browser.
  49056. */
  49057. get isSupported(): boolean;
  49058. /**
  49059. * Get the list of textures generated by the multi render target.
  49060. */
  49061. get textures(): Texture[];
  49062. /**
  49063. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49064. */
  49065. get depthTexture(): Texture;
  49066. /**
  49067. * Set the wrapping mode on U of all the textures we are rendering to.
  49068. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49069. */
  49070. set wrapU(wrap: number);
  49071. /**
  49072. * Set the wrapping mode on V of all the textures we are rendering to.
  49073. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49074. */
  49075. set wrapV(wrap: number);
  49076. /**
  49077. * Instantiate a new multi render target texture.
  49078. * A multi render target, like a render target provides the ability to render to a texture.
  49079. * Unlike the render target, it can render to several draw buffers in one draw.
  49080. * This is specially interesting in deferred rendering or for any effects requiring more than
  49081. * just one color from a single pass.
  49082. * @param name Define the name of the texture
  49083. * @param size Define the size of the buffers to render to
  49084. * @param count Define the number of target we are rendering into
  49085. * @param scene Define the scene the texture belongs to
  49086. * @param options Define the options used to create the multi render target
  49087. */
  49088. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49089. /** @hidden */
  49090. _rebuild(): void;
  49091. private _createInternalTextures;
  49092. private _createTextures;
  49093. /**
  49094. * Define the number of samples used if MSAA is enabled.
  49095. */
  49096. get samples(): number;
  49097. set samples(value: number);
  49098. /**
  49099. * Resize all the textures in the multi render target.
  49100. * Be carrefull as it will recreate all the data in the new texture.
  49101. * @param size Define the new size
  49102. */
  49103. resize(size: any): void;
  49104. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49105. /**
  49106. * Dispose the render targets and their associated resources
  49107. */
  49108. dispose(): void;
  49109. /**
  49110. * Release all the underlying texture used as draw buffers.
  49111. */
  49112. releaseInternalTextures(): void;
  49113. }
  49114. }
  49115. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49116. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49117. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49118. import { Nullable } from "babylonjs/types";
  49119. module "babylonjs/Engines/thinEngine" {
  49120. interface ThinEngine {
  49121. /**
  49122. * Unbind a list of render target textures from the webGL context
  49123. * This is used only when drawBuffer extension or webGL2 are active
  49124. * @param textures defines the render target textures to unbind
  49125. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49126. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49127. */
  49128. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49129. /**
  49130. * Create a multi render target texture
  49131. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49132. * @param size defines the size of the texture
  49133. * @param options defines the creation options
  49134. * @returns the cube texture as an InternalTexture
  49135. */
  49136. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49137. /**
  49138. * Update the sample count for a given multiple render target texture
  49139. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49140. * @param textures defines the textures to update
  49141. * @param samples defines the sample count to set
  49142. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49143. */
  49144. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49145. }
  49146. }
  49147. }
  49148. declare module "babylonjs/Engines/Extensions/engine.views" {
  49149. import { Camera } from "babylonjs/Cameras/camera";
  49150. import { Nullable } from "babylonjs/types";
  49151. /**
  49152. * Class used to define an additional view for the engine
  49153. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49154. */
  49155. export class EngineView {
  49156. /** Defines the canvas where to render the view */
  49157. target: HTMLCanvasElement;
  49158. /** Defines an optional camera used to render the view (will use active camera else) */
  49159. camera?: Camera;
  49160. }
  49161. module "babylonjs/Engines/engine" {
  49162. interface Engine {
  49163. /**
  49164. * Gets or sets the HTML element to use for attaching events
  49165. */
  49166. inputElement: Nullable<HTMLElement>;
  49167. /**
  49168. * Gets the current engine view
  49169. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49170. */
  49171. activeView: Nullable<EngineView>;
  49172. /** Gets or sets the list of views */
  49173. views: EngineView[];
  49174. /**
  49175. * Register a new child canvas
  49176. * @param canvas defines the canvas to register
  49177. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49178. * @returns the associated view
  49179. */
  49180. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49181. /**
  49182. * Remove a registered child canvas
  49183. * @param canvas defines the canvas to remove
  49184. * @returns the current engine
  49185. */
  49186. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49187. }
  49188. }
  49189. }
  49190. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49191. import { Nullable } from "babylonjs/types";
  49192. module "babylonjs/Engines/engine" {
  49193. interface Engine {
  49194. /** @hidden */
  49195. _excludedCompressedTextures: string[];
  49196. /** @hidden */
  49197. _textureFormatInUse: string;
  49198. /**
  49199. * Gets the list of texture formats supported
  49200. */
  49201. readonly texturesSupported: Array<string>;
  49202. /**
  49203. * Gets the texture format in use
  49204. */
  49205. readonly textureFormatInUse: Nullable<string>;
  49206. /**
  49207. * Set the compressed texture extensions or file names to skip.
  49208. *
  49209. * @param skippedFiles defines the list of those texture files you want to skip
  49210. * Example: [".dds", ".env", "myfile.png"]
  49211. */
  49212. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49213. /**
  49214. * Set the compressed texture format to use, based on the formats you have, and the formats
  49215. * supported by the hardware / browser.
  49216. *
  49217. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49218. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49219. * to API arguments needed to compressed textures. This puts the burden on the container
  49220. * generator to house the arcane code for determining these for current & future formats.
  49221. *
  49222. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49223. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49224. *
  49225. * Note: The result of this call is not taken into account when a texture is base64.
  49226. *
  49227. * @param formatsAvailable defines the list of those format families you have created
  49228. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49229. *
  49230. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49231. * @returns The extension selected.
  49232. */
  49233. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49234. }
  49235. }
  49236. }
  49237. declare module "babylonjs/Engines/Extensions/index" {
  49238. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49239. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49240. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49241. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49242. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49243. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49244. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49245. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49246. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49247. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49248. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49249. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49250. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49251. export * from "babylonjs/Engines/Extensions/engine.views";
  49252. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49253. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49254. }
  49255. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49256. import { Nullable } from "babylonjs/types";
  49257. /**
  49258. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49259. */
  49260. export interface CubeMapInfo {
  49261. /**
  49262. * The pixel array for the front face.
  49263. * This is stored in format, left to right, up to down format.
  49264. */
  49265. front: Nullable<ArrayBufferView>;
  49266. /**
  49267. * The pixel array for the back face.
  49268. * This is stored in format, left to right, up to down format.
  49269. */
  49270. back: Nullable<ArrayBufferView>;
  49271. /**
  49272. * The pixel array for the left face.
  49273. * This is stored in format, left to right, up to down format.
  49274. */
  49275. left: Nullable<ArrayBufferView>;
  49276. /**
  49277. * The pixel array for the right face.
  49278. * This is stored in format, left to right, up to down format.
  49279. */
  49280. right: Nullable<ArrayBufferView>;
  49281. /**
  49282. * The pixel array for the up face.
  49283. * This is stored in format, left to right, up to down format.
  49284. */
  49285. up: Nullable<ArrayBufferView>;
  49286. /**
  49287. * The pixel array for the down face.
  49288. * This is stored in format, left to right, up to down format.
  49289. */
  49290. down: Nullable<ArrayBufferView>;
  49291. /**
  49292. * The size of the cubemap stored.
  49293. *
  49294. * Each faces will be size * size pixels.
  49295. */
  49296. size: number;
  49297. /**
  49298. * The format of the texture.
  49299. *
  49300. * RGBA, RGB.
  49301. */
  49302. format: number;
  49303. /**
  49304. * The type of the texture data.
  49305. *
  49306. * UNSIGNED_INT, FLOAT.
  49307. */
  49308. type: number;
  49309. /**
  49310. * Specifies whether the texture is in gamma space.
  49311. */
  49312. gammaSpace: boolean;
  49313. }
  49314. /**
  49315. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49316. */
  49317. export class PanoramaToCubeMapTools {
  49318. private static FACE_FRONT;
  49319. private static FACE_BACK;
  49320. private static FACE_RIGHT;
  49321. private static FACE_LEFT;
  49322. private static FACE_DOWN;
  49323. private static FACE_UP;
  49324. /**
  49325. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49326. *
  49327. * @param float32Array The source data.
  49328. * @param inputWidth The width of the input panorama.
  49329. * @param inputHeight The height of the input panorama.
  49330. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49331. * @return The cubemap data
  49332. */
  49333. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49334. private static CreateCubemapTexture;
  49335. private static CalcProjectionSpherical;
  49336. }
  49337. }
  49338. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49339. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49341. import { Nullable } from "babylonjs/types";
  49342. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49343. /**
  49344. * Helper class dealing with the extraction of spherical polynomial dataArray
  49345. * from a cube map.
  49346. */
  49347. export class CubeMapToSphericalPolynomialTools {
  49348. private static FileFaces;
  49349. /**
  49350. * Converts a texture to the according Spherical Polynomial data.
  49351. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49352. *
  49353. * @param texture The texture to extract the information from.
  49354. * @return The Spherical Polynomial data.
  49355. */
  49356. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49357. /**
  49358. * Converts a cubemap to the according Spherical Polynomial data.
  49359. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49360. *
  49361. * @param cubeInfo The Cube map to extract the information from.
  49362. * @return The Spherical Polynomial data.
  49363. */
  49364. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49365. }
  49366. }
  49367. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49368. import { Nullable } from "babylonjs/types";
  49369. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49370. module "babylonjs/Materials/Textures/baseTexture" {
  49371. interface BaseTexture {
  49372. /**
  49373. * Get the polynomial representation of the texture data.
  49374. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49375. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49376. */
  49377. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49378. }
  49379. }
  49380. }
  49381. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49382. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49383. /** @hidden */
  49384. export var rgbdEncodePixelShader: {
  49385. name: string;
  49386. shader: string;
  49387. };
  49388. }
  49389. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49390. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49391. /** @hidden */
  49392. export var rgbdDecodePixelShader: {
  49393. name: string;
  49394. shader: string;
  49395. };
  49396. }
  49397. declare module "babylonjs/Misc/environmentTextureTools" {
  49398. import { Nullable } from "babylonjs/types";
  49399. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49400. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49401. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49402. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49403. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49404. import "babylonjs/Shaders/rgbdEncode.fragment";
  49405. import "babylonjs/Shaders/rgbdDecode.fragment";
  49406. /**
  49407. * Raw texture data and descriptor sufficient for WebGL texture upload
  49408. */
  49409. export interface EnvironmentTextureInfo {
  49410. /**
  49411. * Version of the environment map
  49412. */
  49413. version: number;
  49414. /**
  49415. * Width of image
  49416. */
  49417. width: number;
  49418. /**
  49419. * Irradiance information stored in the file.
  49420. */
  49421. irradiance: any;
  49422. /**
  49423. * Specular information stored in the file.
  49424. */
  49425. specular: any;
  49426. }
  49427. /**
  49428. * Defines One Image in the file. It requires only the position in the file
  49429. * as well as the length.
  49430. */
  49431. interface BufferImageData {
  49432. /**
  49433. * Length of the image data.
  49434. */
  49435. length: number;
  49436. /**
  49437. * Position of the data from the null terminator delimiting the end of the JSON.
  49438. */
  49439. position: number;
  49440. }
  49441. /**
  49442. * Defines the specular data enclosed in the file.
  49443. * This corresponds to the version 1 of the data.
  49444. */
  49445. export interface EnvironmentTextureSpecularInfoV1 {
  49446. /**
  49447. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49448. */
  49449. specularDataPosition?: number;
  49450. /**
  49451. * This contains all the images data needed to reconstruct the cubemap.
  49452. */
  49453. mipmaps: Array<BufferImageData>;
  49454. /**
  49455. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49456. */
  49457. lodGenerationScale: number;
  49458. }
  49459. /**
  49460. * Sets of helpers addressing the serialization and deserialization of environment texture
  49461. * stored in a BabylonJS env file.
  49462. * Those files are usually stored as .env files.
  49463. */
  49464. export class EnvironmentTextureTools {
  49465. /**
  49466. * Magic number identifying the env file.
  49467. */
  49468. private static _MagicBytes;
  49469. /**
  49470. * Gets the environment info from an env file.
  49471. * @param data The array buffer containing the .env bytes.
  49472. * @returns the environment file info (the json header) if successfully parsed.
  49473. */
  49474. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49475. /**
  49476. * Creates an environment texture from a loaded cube texture.
  49477. * @param texture defines the cube texture to convert in env file
  49478. * @return a promise containing the environment data if succesfull.
  49479. */
  49480. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49481. /**
  49482. * Creates a JSON representation of the spherical data.
  49483. * @param texture defines the texture containing the polynomials
  49484. * @return the JSON representation of the spherical info
  49485. */
  49486. private static _CreateEnvTextureIrradiance;
  49487. /**
  49488. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49489. * @param data the image data
  49490. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49491. * @return the views described by info providing access to the underlying buffer
  49492. */
  49493. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49494. /**
  49495. * Uploads the texture info contained in the env file to the GPU.
  49496. * @param texture defines the internal texture to upload to
  49497. * @param data defines the data to load
  49498. * @param info defines the texture info retrieved through the GetEnvInfo method
  49499. * @returns a promise
  49500. */
  49501. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49502. private static _OnImageReadyAsync;
  49503. /**
  49504. * Uploads the levels of image data to the GPU.
  49505. * @param texture defines the internal texture to upload to
  49506. * @param imageData defines the array buffer views of image data [mipmap][face]
  49507. * @returns a promise
  49508. */
  49509. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49510. /**
  49511. * Uploads spherical polynomials information to the texture.
  49512. * @param texture defines the texture we are trying to upload the information to
  49513. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49514. */
  49515. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49516. /** @hidden */
  49517. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49518. }
  49519. }
  49520. declare module "babylonjs/Maths/math.vertexFormat" {
  49521. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49522. /**
  49523. * Contains position and normal vectors for a vertex
  49524. */
  49525. export class PositionNormalVertex {
  49526. /** the position of the vertex (defaut: 0,0,0) */
  49527. position: Vector3;
  49528. /** the normal of the vertex (defaut: 0,1,0) */
  49529. normal: Vector3;
  49530. /**
  49531. * Creates a PositionNormalVertex
  49532. * @param position the position of the vertex (defaut: 0,0,0)
  49533. * @param normal the normal of the vertex (defaut: 0,1,0)
  49534. */
  49535. constructor(
  49536. /** the position of the vertex (defaut: 0,0,0) */
  49537. position?: Vector3,
  49538. /** the normal of the vertex (defaut: 0,1,0) */
  49539. normal?: Vector3);
  49540. /**
  49541. * Clones the PositionNormalVertex
  49542. * @returns the cloned PositionNormalVertex
  49543. */
  49544. clone(): PositionNormalVertex;
  49545. }
  49546. /**
  49547. * Contains position, normal and uv vectors for a vertex
  49548. */
  49549. export class PositionNormalTextureVertex {
  49550. /** the position of the vertex (defaut: 0,0,0) */
  49551. position: Vector3;
  49552. /** the normal of the vertex (defaut: 0,1,0) */
  49553. normal: Vector3;
  49554. /** the uv of the vertex (default: 0,0) */
  49555. uv: Vector2;
  49556. /**
  49557. * Creates a PositionNormalTextureVertex
  49558. * @param position the position of the vertex (defaut: 0,0,0)
  49559. * @param normal the normal of the vertex (defaut: 0,1,0)
  49560. * @param uv the uv of the vertex (default: 0,0)
  49561. */
  49562. constructor(
  49563. /** the position of the vertex (defaut: 0,0,0) */
  49564. position?: Vector3,
  49565. /** the normal of the vertex (defaut: 0,1,0) */
  49566. normal?: Vector3,
  49567. /** the uv of the vertex (default: 0,0) */
  49568. uv?: Vector2);
  49569. /**
  49570. * Clones the PositionNormalTextureVertex
  49571. * @returns the cloned PositionNormalTextureVertex
  49572. */
  49573. clone(): PositionNormalTextureVertex;
  49574. }
  49575. }
  49576. declare module "babylonjs/Maths/math" {
  49577. export * from "babylonjs/Maths/math.axis";
  49578. export * from "babylonjs/Maths/math.color";
  49579. export * from "babylonjs/Maths/math.constants";
  49580. export * from "babylonjs/Maths/math.frustum";
  49581. export * from "babylonjs/Maths/math.path";
  49582. export * from "babylonjs/Maths/math.plane";
  49583. export * from "babylonjs/Maths/math.size";
  49584. export * from "babylonjs/Maths/math.vector";
  49585. export * from "babylonjs/Maths/math.vertexFormat";
  49586. export * from "babylonjs/Maths/math.viewport";
  49587. }
  49588. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49589. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49590. /** @hidden */
  49591. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49592. private _genericAttributeLocation;
  49593. private _varyingLocationCount;
  49594. private _varyingLocationMap;
  49595. private _replacements;
  49596. private _textureCount;
  49597. private _uniforms;
  49598. lineProcessor(line: string): string;
  49599. attributeProcessor(attribute: string): string;
  49600. varyingProcessor(varying: string, isFragment: boolean): string;
  49601. uniformProcessor(uniform: string): string;
  49602. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49603. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49604. }
  49605. }
  49606. declare module "babylonjs/Engines/nativeEngine" {
  49607. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49608. import { Engine } from "babylonjs/Engines/engine";
  49609. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49610. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49612. import { Effect } from "babylonjs/Materials/effect";
  49613. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49614. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49615. import { IColor4Like } from "babylonjs/Maths/math.like";
  49616. import { Scene } from "babylonjs/scene";
  49617. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49618. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49619. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49620. /**
  49621. * Container for accessors for natively-stored mesh data buffers.
  49622. */
  49623. class NativeDataBuffer extends DataBuffer {
  49624. /**
  49625. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49626. */
  49627. nativeIndexBuffer?: any;
  49628. /**
  49629. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49630. */
  49631. nativeVertexBuffer?: any;
  49632. }
  49633. /** @hidden */
  49634. class NativeTexture extends InternalTexture {
  49635. getInternalTexture(): InternalTexture;
  49636. getViewCount(): number;
  49637. }
  49638. /** @hidden */
  49639. export class NativeEngine extends Engine {
  49640. private readonly _native;
  49641. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49642. private readonly INVALID_HANDLE;
  49643. getHardwareScalingLevel(): number;
  49644. constructor();
  49645. /**
  49646. * Can be used to override the current requestAnimationFrame requester.
  49647. * @hidden
  49648. */
  49649. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49650. /**
  49651. * Override default engine behavior.
  49652. * @param color
  49653. * @param backBuffer
  49654. * @param depth
  49655. * @param stencil
  49656. */
  49657. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49658. /**
  49659. * Gets host document
  49660. * @returns the host document object
  49661. */
  49662. getHostDocument(): Nullable<Document>;
  49663. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49664. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49665. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49666. recordVertexArrayObject(vertexBuffers: {
  49667. [key: string]: VertexBuffer;
  49668. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49669. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49670. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49671. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49672. /**
  49673. * Draw a list of indexed primitives
  49674. * @param fillMode defines the primitive to use
  49675. * @param indexStart defines the starting index
  49676. * @param indexCount defines the number of index to draw
  49677. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49678. */
  49679. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49680. /**
  49681. * Draw a list of unindexed primitives
  49682. * @param fillMode defines the primitive to use
  49683. * @param verticesStart defines the index of first vertex to draw
  49684. * @param verticesCount defines the count of vertices to draw
  49685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49686. */
  49687. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49688. createPipelineContext(): IPipelineContext;
  49689. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49690. /** @hidden */
  49691. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49692. /** @hidden */
  49693. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49694. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49695. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49696. protected _setProgram(program: WebGLProgram): void;
  49697. _releaseEffect(effect: Effect): void;
  49698. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49699. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49700. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49701. bindSamplers(effect: Effect): void;
  49702. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49703. getRenderWidth(useScreen?: boolean): number;
  49704. getRenderHeight(useScreen?: boolean): number;
  49705. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49706. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49707. /**
  49708. * Set the z offset to apply to current rendering
  49709. * @param value defines the offset to apply
  49710. */
  49711. setZOffset(value: number): void;
  49712. /**
  49713. * Gets the current value of the zOffset
  49714. * @returns the current zOffset state
  49715. */
  49716. getZOffset(): number;
  49717. /**
  49718. * Enable or disable depth buffering
  49719. * @param enable defines the state to set
  49720. */
  49721. setDepthBuffer(enable: boolean): void;
  49722. /**
  49723. * Gets a boolean indicating if depth writing is enabled
  49724. * @returns the current depth writing state
  49725. */
  49726. getDepthWrite(): boolean;
  49727. /**
  49728. * Enable or disable depth writing
  49729. * @param enable defines the state to set
  49730. */
  49731. setDepthWrite(enable: boolean): void;
  49732. /**
  49733. * Enable or disable color writing
  49734. * @param enable defines the state to set
  49735. */
  49736. setColorWrite(enable: boolean): void;
  49737. /**
  49738. * Gets a boolean indicating if color writing is enabled
  49739. * @returns the current color writing state
  49740. */
  49741. getColorWrite(): boolean;
  49742. /**
  49743. * Sets alpha constants used by some alpha blending modes
  49744. * @param r defines the red component
  49745. * @param g defines the green component
  49746. * @param b defines the blue component
  49747. * @param a defines the alpha component
  49748. */
  49749. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49750. /**
  49751. * Sets the current alpha mode
  49752. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49753. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49754. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49755. */
  49756. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49757. /**
  49758. * Gets the current alpha mode
  49759. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49760. * @returns the current alpha mode
  49761. */
  49762. getAlphaMode(): number;
  49763. setInt(uniform: WebGLUniformLocation, int: number): void;
  49764. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49765. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49766. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49767. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49768. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49769. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49770. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49771. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49772. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49773. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49774. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49775. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49776. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49777. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49778. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49779. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49780. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49781. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49782. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49783. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49784. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49785. wipeCaches(bruteForce?: boolean): void;
  49786. _createTexture(): WebGLTexture;
  49787. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49788. /**
  49789. * Usually called from Texture.ts.
  49790. * Passed information to create a WebGLTexture
  49791. * @param urlArg defines a value which contains one of the following:
  49792. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49793. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49794. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49795. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49796. * @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)
  49797. * @param scene needed for loading to the correct scene
  49798. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49799. * @param onLoad optional callback to be called upon successful completion
  49800. * @param onError optional callback to be called upon failure
  49801. * @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
  49802. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49803. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49804. * @param forcedExtension defines the extension to use to pick the right loader
  49805. * @param mimeType defines an optional mime type
  49806. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49807. */
  49808. 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;
  49809. /**
  49810. * Creates a cube texture
  49811. * @param rootUrl defines the url where the files to load is located
  49812. * @param scene defines the current scene
  49813. * @param files defines the list of files to load (1 per face)
  49814. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49815. * @param onLoad defines an optional callback raised when the texture is loaded
  49816. * @param onError defines an optional callback raised if there is an issue to load the texture
  49817. * @param format defines the format of the data
  49818. * @param forcedExtension defines the extension to use to pick the right loader
  49819. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49820. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49821. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49822. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49823. * @returns the cube texture as an InternalTexture
  49824. */
  49825. 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;
  49826. private _getSamplingFilter;
  49827. private static _GetNativeTextureFormat;
  49828. createRenderTargetTexture(size: number | {
  49829. width: number;
  49830. height: number;
  49831. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49832. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49833. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49834. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49835. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49836. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49837. /**
  49838. * Updates a dynamic vertex buffer.
  49839. * @param vertexBuffer the vertex buffer to update
  49840. * @param data the data used to update the vertex buffer
  49841. * @param byteOffset the byte offset of the data (optional)
  49842. * @param byteLength the byte length of the data (optional)
  49843. */
  49844. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49845. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49846. private _updateAnisotropicLevel;
  49847. private _getAddressMode;
  49848. /** @hidden */
  49849. _bindTexture(channel: number, texture: InternalTexture): void;
  49850. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49851. releaseEffects(): void;
  49852. /** @hidden */
  49853. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49854. /** @hidden */
  49855. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49856. /** @hidden */
  49857. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49858. /** @hidden */
  49859. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49860. }
  49861. }
  49862. declare module "babylonjs/Engines/index" {
  49863. export * from "babylonjs/Engines/constants";
  49864. export * from "babylonjs/Engines/engineCapabilities";
  49865. export * from "babylonjs/Engines/instancingAttributeInfo";
  49866. export * from "babylonjs/Engines/thinEngine";
  49867. export * from "babylonjs/Engines/engine";
  49868. export * from "babylonjs/Engines/engineStore";
  49869. export * from "babylonjs/Engines/nullEngine";
  49870. export * from "babylonjs/Engines/Extensions/index";
  49871. export * from "babylonjs/Engines/IPipelineContext";
  49872. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49873. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49874. export * from "babylonjs/Engines/nativeEngine";
  49875. }
  49876. declare module "babylonjs/Events/clipboardEvents" {
  49877. /**
  49878. * Gather the list of clipboard event types as constants.
  49879. */
  49880. export class ClipboardEventTypes {
  49881. /**
  49882. * The clipboard event is fired when a copy command is active (pressed).
  49883. */
  49884. static readonly COPY: number;
  49885. /**
  49886. * The clipboard event is fired when a cut command is active (pressed).
  49887. */
  49888. static readonly CUT: number;
  49889. /**
  49890. * The clipboard event is fired when a paste command is active (pressed).
  49891. */
  49892. static readonly PASTE: number;
  49893. }
  49894. /**
  49895. * This class is used to store clipboard related info for the onClipboardObservable event.
  49896. */
  49897. export class ClipboardInfo {
  49898. /**
  49899. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49900. */
  49901. type: number;
  49902. /**
  49903. * Defines the related dom event
  49904. */
  49905. event: ClipboardEvent;
  49906. /**
  49907. *Creates an instance of ClipboardInfo.
  49908. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49909. * @param event Defines the related dom event
  49910. */
  49911. constructor(
  49912. /**
  49913. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49914. */
  49915. type: number,
  49916. /**
  49917. * Defines the related dom event
  49918. */
  49919. event: ClipboardEvent);
  49920. /**
  49921. * Get the clipboard event's type from the keycode.
  49922. * @param keyCode Defines the keyCode for the current keyboard event.
  49923. * @return {number}
  49924. */
  49925. static GetTypeFromCharacter(keyCode: number): number;
  49926. }
  49927. }
  49928. declare module "babylonjs/Events/index" {
  49929. export * from "babylonjs/Events/keyboardEvents";
  49930. export * from "babylonjs/Events/pointerEvents";
  49931. export * from "babylonjs/Events/clipboardEvents";
  49932. }
  49933. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49934. import { Scene } from "babylonjs/scene";
  49935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49936. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49937. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49938. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49939. /**
  49940. * Google Daydream controller
  49941. */
  49942. export class DaydreamController extends WebVRController {
  49943. /**
  49944. * Base Url for the controller model.
  49945. */
  49946. static MODEL_BASE_URL: string;
  49947. /**
  49948. * File name for the controller model.
  49949. */
  49950. static MODEL_FILENAME: string;
  49951. /**
  49952. * Gamepad Id prefix used to identify Daydream Controller.
  49953. */
  49954. static readonly GAMEPAD_ID_PREFIX: string;
  49955. /**
  49956. * Creates a new DaydreamController from a gamepad
  49957. * @param vrGamepad the gamepad that the controller should be created from
  49958. */
  49959. constructor(vrGamepad: any);
  49960. /**
  49961. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49962. * @param scene scene in which to add meshes
  49963. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49964. */
  49965. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49966. /**
  49967. * Called once for each button that changed state since the last frame
  49968. * @param buttonIdx Which button index changed
  49969. * @param state New state of the button
  49970. * @param changes Which properties on the state changed since last frame
  49971. */
  49972. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49973. }
  49974. }
  49975. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49976. import { Scene } from "babylonjs/scene";
  49977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49978. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49979. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49980. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49981. /**
  49982. * Gear VR Controller
  49983. */
  49984. export class GearVRController extends WebVRController {
  49985. /**
  49986. * Base Url for the controller model.
  49987. */
  49988. static MODEL_BASE_URL: string;
  49989. /**
  49990. * File name for the controller model.
  49991. */
  49992. static MODEL_FILENAME: string;
  49993. /**
  49994. * Gamepad Id prefix used to identify this controller.
  49995. */
  49996. static readonly GAMEPAD_ID_PREFIX: string;
  49997. private readonly _buttonIndexToObservableNameMap;
  49998. /**
  49999. * Creates a new GearVRController from a gamepad
  50000. * @param vrGamepad the gamepad that the controller should be created from
  50001. */
  50002. constructor(vrGamepad: any);
  50003. /**
  50004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50005. * @param scene scene in which to add meshes
  50006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50007. */
  50008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50009. /**
  50010. * Called once for each button that changed state since the last frame
  50011. * @param buttonIdx Which button index changed
  50012. * @param state New state of the button
  50013. * @param changes Which properties on the state changed since last frame
  50014. */
  50015. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50016. }
  50017. }
  50018. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50019. import { Scene } from "babylonjs/scene";
  50020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50021. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50022. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50023. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50024. /**
  50025. * Generic Controller
  50026. */
  50027. export class GenericController extends WebVRController {
  50028. /**
  50029. * Base Url for the controller model.
  50030. */
  50031. static readonly MODEL_BASE_URL: string;
  50032. /**
  50033. * File name for the controller model.
  50034. */
  50035. static readonly MODEL_FILENAME: string;
  50036. /**
  50037. * Creates a new GenericController from a gamepad
  50038. * @param vrGamepad the gamepad that the controller should be created from
  50039. */
  50040. constructor(vrGamepad: any);
  50041. /**
  50042. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50043. * @param scene scene in which to add meshes
  50044. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50045. */
  50046. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50047. /**
  50048. * Called once for each button that changed state since the last frame
  50049. * @param buttonIdx Which button index changed
  50050. * @param state New state of the button
  50051. * @param changes Which properties on the state changed since last frame
  50052. */
  50053. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50054. }
  50055. }
  50056. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50057. import { Observable } from "babylonjs/Misc/observable";
  50058. import { Scene } from "babylonjs/scene";
  50059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50060. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50061. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50062. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50063. /**
  50064. * Oculus Touch Controller
  50065. */
  50066. export class OculusTouchController extends WebVRController {
  50067. /**
  50068. * Base Url for the controller model.
  50069. */
  50070. static MODEL_BASE_URL: string;
  50071. /**
  50072. * File name for the left controller model.
  50073. */
  50074. static MODEL_LEFT_FILENAME: string;
  50075. /**
  50076. * File name for the right controller model.
  50077. */
  50078. static MODEL_RIGHT_FILENAME: string;
  50079. /**
  50080. * Base Url for the Quest controller model.
  50081. */
  50082. static QUEST_MODEL_BASE_URL: string;
  50083. /**
  50084. * @hidden
  50085. * If the controllers are running on a device that needs the updated Quest controller models
  50086. */
  50087. static _IsQuest: boolean;
  50088. /**
  50089. * Fired when the secondary trigger on this controller is modified
  50090. */
  50091. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50092. /**
  50093. * Fired when the thumb rest on this controller is modified
  50094. */
  50095. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50096. /**
  50097. * Creates a new OculusTouchController from a gamepad
  50098. * @param vrGamepad the gamepad that the controller should be created from
  50099. */
  50100. constructor(vrGamepad: any);
  50101. /**
  50102. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50103. * @param scene scene in which to add meshes
  50104. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50105. */
  50106. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50107. /**
  50108. * Fired when the A button on this controller is modified
  50109. */
  50110. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50111. /**
  50112. * Fired when the B button on this controller is modified
  50113. */
  50114. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50115. /**
  50116. * Fired when the X button on this controller is modified
  50117. */
  50118. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50119. /**
  50120. * Fired when the Y button on this controller is modified
  50121. */
  50122. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50123. /**
  50124. * Called once for each button that changed state since the last frame
  50125. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50126. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50127. * 2) secondary trigger (same)
  50128. * 3) A (right) X (left), touch, pressed = value
  50129. * 4) B / Y
  50130. * 5) thumb rest
  50131. * @param buttonIdx Which button index changed
  50132. * @param state New state of the button
  50133. * @param changes Which properties on the state changed since last frame
  50134. */
  50135. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50136. }
  50137. }
  50138. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50139. import { Scene } from "babylonjs/scene";
  50140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50141. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50142. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50143. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50144. import { Observable } from "babylonjs/Misc/observable";
  50145. /**
  50146. * Vive Controller
  50147. */
  50148. export class ViveController extends WebVRController {
  50149. /**
  50150. * Base Url for the controller model.
  50151. */
  50152. static MODEL_BASE_URL: string;
  50153. /**
  50154. * File name for the controller model.
  50155. */
  50156. static MODEL_FILENAME: string;
  50157. /**
  50158. * Creates a new ViveController from a gamepad
  50159. * @param vrGamepad the gamepad that the controller should be created from
  50160. */
  50161. constructor(vrGamepad: any);
  50162. /**
  50163. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50164. * @param scene scene in which to add meshes
  50165. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50166. */
  50167. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50168. /**
  50169. * Fired when the left button on this controller is modified
  50170. */
  50171. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50172. /**
  50173. * Fired when the right button on this controller is modified
  50174. */
  50175. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50176. /**
  50177. * Fired when the menu button on this controller is modified
  50178. */
  50179. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50180. /**
  50181. * Called once for each button that changed state since the last frame
  50182. * Vive mapping:
  50183. * 0: touchpad
  50184. * 1: trigger
  50185. * 2: left AND right buttons
  50186. * 3: menu button
  50187. * @param buttonIdx Which button index changed
  50188. * @param state New state of the button
  50189. * @param changes Which properties on the state changed since last frame
  50190. */
  50191. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50192. }
  50193. }
  50194. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50195. import { Observable } from "babylonjs/Misc/observable";
  50196. import { Scene } from "babylonjs/scene";
  50197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50198. import { Ray } from "babylonjs/Culling/ray";
  50199. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50200. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50201. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50202. /**
  50203. * Defines the WindowsMotionController object that the state of the windows motion controller
  50204. */
  50205. export class WindowsMotionController extends WebVRController {
  50206. /**
  50207. * The base url used to load the left and right controller models
  50208. */
  50209. static MODEL_BASE_URL: string;
  50210. /**
  50211. * The name of the left controller model file
  50212. */
  50213. static MODEL_LEFT_FILENAME: string;
  50214. /**
  50215. * The name of the right controller model file
  50216. */
  50217. static MODEL_RIGHT_FILENAME: string;
  50218. /**
  50219. * The controller name prefix for this controller type
  50220. */
  50221. static readonly GAMEPAD_ID_PREFIX: string;
  50222. /**
  50223. * The controller id pattern for this controller type
  50224. */
  50225. private static readonly GAMEPAD_ID_PATTERN;
  50226. private _loadedMeshInfo;
  50227. protected readonly _mapping: {
  50228. buttons: string[];
  50229. buttonMeshNames: {
  50230. 'trigger': string;
  50231. 'menu': string;
  50232. 'grip': string;
  50233. 'thumbstick': string;
  50234. 'trackpad': string;
  50235. };
  50236. buttonObservableNames: {
  50237. 'trigger': string;
  50238. 'menu': string;
  50239. 'grip': string;
  50240. 'thumbstick': string;
  50241. 'trackpad': string;
  50242. };
  50243. axisMeshNames: string[];
  50244. pointingPoseMeshName: string;
  50245. };
  50246. /**
  50247. * Fired when the trackpad on this controller is clicked
  50248. */
  50249. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50250. /**
  50251. * Fired when the trackpad on this controller is modified
  50252. */
  50253. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50254. /**
  50255. * The current x and y values of this controller's trackpad
  50256. */
  50257. trackpad: StickValues;
  50258. /**
  50259. * Creates a new WindowsMotionController from a gamepad
  50260. * @param vrGamepad the gamepad that the controller should be created from
  50261. */
  50262. constructor(vrGamepad: any);
  50263. /**
  50264. * Fired when the trigger on this controller is modified
  50265. */
  50266. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50267. /**
  50268. * Fired when the menu button on this controller is modified
  50269. */
  50270. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50271. /**
  50272. * Fired when the grip button on this controller is modified
  50273. */
  50274. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50275. /**
  50276. * Fired when the thumbstick button on this controller is modified
  50277. */
  50278. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50279. /**
  50280. * Fired when the touchpad button on this controller is modified
  50281. */
  50282. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50283. /**
  50284. * Fired when the touchpad values on this controller are modified
  50285. */
  50286. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50287. protected _updateTrackpad(): void;
  50288. /**
  50289. * Called once per frame by the engine.
  50290. */
  50291. update(): void;
  50292. /**
  50293. * Called once for each button that changed state since the last frame
  50294. * @param buttonIdx Which button index changed
  50295. * @param state New state of the button
  50296. * @param changes Which properties on the state changed since last frame
  50297. */
  50298. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50299. /**
  50300. * Moves the buttons on the controller mesh based on their current state
  50301. * @param buttonName the name of the button to move
  50302. * @param buttonValue the value of the button which determines the buttons new position
  50303. */
  50304. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50305. /**
  50306. * Moves the axis on the controller mesh based on its current state
  50307. * @param axis the index of the axis
  50308. * @param axisValue the value of the axis which determines the meshes new position
  50309. * @hidden
  50310. */
  50311. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50312. /**
  50313. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50314. * @param scene scene in which to add meshes
  50315. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50316. */
  50317. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50318. /**
  50319. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50320. * can be transformed by button presses and axes values, based on this._mapping.
  50321. *
  50322. * @param scene scene in which the meshes exist
  50323. * @param meshes list of meshes that make up the controller model to process
  50324. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50325. */
  50326. private processModel;
  50327. private createMeshInfo;
  50328. /**
  50329. * Gets the ray of the controller in the direction the controller is pointing
  50330. * @param length the length the resulting ray should be
  50331. * @returns a ray in the direction the controller is pointing
  50332. */
  50333. getForwardRay(length?: number): Ray;
  50334. /**
  50335. * Disposes of the controller
  50336. */
  50337. dispose(): void;
  50338. }
  50339. /**
  50340. * This class represents a new windows motion controller in XR.
  50341. */
  50342. export class XRWindowsMotionController extends WindowsMotionController {
  50343. /**
  50344. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50345. */
  50346. protected readonly _mapping: {
  50347. buttons: string[];
  50348. buttonMeshNames: {
  50349. 'trigger': string;
  50350. 'menu': string;
  50351. 'grip': string;
  50352. 'thumbstick': string;
  50353. 'trackpad': string;
  50354. };
  50355. buttonObservableNames: {
  50356. 'trigger': string;
  50357. 'menu': string;
  50358. 'grip': string;
  50359. 'thumbstick': string;
  50360. 'trackpad': string;
  50361. };
  50362. axisMeshNames: string[];
  50363. pointingPoseMeshName: string;
  50364. };
  50365. /**
  50366. * Construct a new XR-Based windows motion controller
  50367. *
  50368. * @param gamepadInfo the gamepad object from the browser
  50369. */
  50370. constructor(gamepadInfo: any);
  50371. /**
  50372. * holds the thumbstick values (X,Y)
  50373. */
  50374. thumbstickValues: StickValues;
  50375. /**
  50376. * Fired when the thumbstick on this controller is clicked
  50377. */
  50378. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50379. /**
  50380. * Fired when the thumbstick on this controller is modified
  50381. */
  50382. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50383. /**
  50384. * Fired when the touchpad button on this controller is modified
  50385. */
  50386. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50387. /**
  50388. * Fired when the touchpad values on this controller are modified
  50389. */
  50390. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50391. /**
  50392. * Fired when the thumbstick button on this controller is modified
  50393. * here to prevent breaking changes
  50394. */
  50395. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50396. /**
  50397. * updating the thumbstick(!) and not the trackpad.
  50398. * This is named this way due to the difference between WebVR and XR and to avoid
  50399. * changing the parent class.
  50400. */
  50401. protected _updateTrackpad(): void;
  50402. /**
  50403. * Disposes the class with joy
  50404. */
  50405. dispose(): void;
  50406. }
  50407. }
  50408. declare module "babylonjs/Gamepads/Controllers/index" {
  50409. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50410. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50411. export * from "babylonjs/Gamepads/Controllers/genericController";
  50412. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50413. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50414. export * from "babylonjs/Gamepads/Controllers/viveController";
  50415. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50416. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50417. }
  50418. declare module "babylonjs/Gamepads/index" {
  50419. export * from "babylonjs/Gamepads/Controllers/index";
  50420. export * from "babylonjs/Gamepads/gamepad";
  50421. export * from "babylonjs/Gamepads/gamepadManager";
  50422. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50423. export * from "babylonjs/Gamepads/xboxGamepad";
  50424. export * from "babylonjs/Gamepads/dualShockGamepad";
  50425. }
  50426. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50427. import { Scene } from "babylonjs/scene";
  50428. import { Vector4 } from "babylonjs/Maths/math.vector";
  50429. import { Color4 } from "babylonjs/Maths/math.color";
  50430. import { Mesh } from "babylonjs/Meshes/mesh";
  50431. import { Nullable } from "babylonjs/types";
  50432. /**
  50433. * Class containing static functions to help procedurally build meshes
  50434. */
  50435. export class PolyhedronBuilder {
  50436. /**
  50437. * Creates a polyhedron mesh
  50438. * * 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
  50439. * * The parameter `size` (positive float, default 1) sets the polygon size
  50440. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50441. * * 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`
  50442. * * 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
  50443. * * 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)`)
  50444. * * 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
  50445. * * 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
  50446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50449. * @param name defines the name of the mesh
  50450. * @param options defines the options used to create the mesh
  50451. * @param scene defines the hosting scene
  50452. * @returns the polyhedron mesh
  50453. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50454. */
  50455. static CreatePolyhedron(name: string, options: {
  50456. type?: number;
  50457. size?: number;
  50458. sizeX?: number;
  50459. sizeY?: number;
  50460. sizeZ?: number;
  50461. custom?: any;
  50462. faceUV?: Vector4[];
  50463. faceColors?: Color4[];
  50464. flat?: boolean;
  50465. updatable?: boolean;
  50466. sideOrientation?: number;
  50467. frontUVs?: Vector4;
  50468. backUVs?: Vector4;
  50469. }, scene?: Nullable<Scene>): Mesh;
  50470. }
  50471. }
  50472. declare module "babylonjs/Gizmos/scaleGizmo" {
  50473. import { Observable } from "babylonjs/Misc/observable";
  50474. import { Nullable } from "babylonjs/types";
  50475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50476. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50477. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50478. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50479. /**
  50480. * Gizmo that enables scaling a mesh along 3 axis
  50481. */
  50482. export class ScaleGizmo extends Gizmo {
  50483. /**
  50484. * Internal gizmo used for interactions on the x axis
  50485. */
  50486. xGizmo: AxisScaleGizmo;
  50487. /**
  50488. * Internal gizmo used for interactions on the y axis
  50489. */
  50490. yGizmo: AxisScaleGizmo;
  50491. /**
  50492. * Internal gizmo used for interactions on the z axis
  50493. */
  50494. zGizmo: AxisScaleGizmo;
  50495. /**
  50496. * Internal gizmo used to scale all axis equally
  50497. */
  50498. uniformScaleGizmo: AxisScaleGizmo;
  50499. private _meshAttached;
  50500. private _updateGizmoRotationToMatchAttachedMesh;
  50501. private _snapDistance;
  50502. private _scaleRatio;
  50503. private _uniformScalingMesh;
  50504. private _octahedron;
  50505. private _sensitivity;
  50506. /** Fires an event when any of it's sub gizmos are dragged */
  50507. onDragStartObservable: Observable<unknown>;
  50508. /** Fires an event when any of it's sub gizmos are released from dragging */
  50509. onDragEndObservable: Observable<unknown>;
  50510. get attachedMesh(): Nullable<AbstractMesh>;
  50511. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50512. /**
  50513. * Creates a ScaleGizmo
  50514. * @param gizmoLayer The utility layer the gizmo will be added to
  50515. */
  50516. constructor(gizmoLayer?: UtilityLayerRenderer);
  50517. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50518. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50519. /**
  50520. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50521. */
  50522. set snapDistance(value: number);
  50523. get snapDistance(): number;
  50524. /**
  50525. * Ratio for the scale of the gizmo (Default: 1)
  50526. */
  50527. set scaleRatio(value: number);
  50528. get scaleRatio(): number;
  50529. /**
  50530. * Sensitivity factor for dragging (Default: 1)
  50531. */
  50532. set sensitivity(value: number);
  50533. get sensitivity(): number;
  50534. /**
  50535. * Disposes of the gizmo
  50536. */
  50537. dispose(): void;
  50538. }
  50539. }
  50540. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50541. import { Observable } from "babylonjs/Misc/observable";
  50542. import { Nullable } from "babylonjs/types";
  50543. import { Vector3 } from "babylonjs/Maths/math.vector";
  50544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50545. import { Mesh } from "babylonjs/Meshes/mesh";
  50546. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50547. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50549. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50550. import { Color3 } from "babylonjs/Maths/math.color";
  50551. /**
  50552. * Single axis scale gizmo
  50553. */
  50554. export class AxisScaleGizmo extends Gizmo {
  50555. /**
  50556. * Drag behavior responsible for the gizmos dragging interactions
  50557. */
  50558. dragBehavior: PointerDragBehavior;
  50559. private _pointerObserver;
  50560. /**
  50561. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50562. */
  50563. snapDistance: number;
  50564. /**
  50565. * Event that fires each time the gizmo snaps to a new location.
  50566. * * snapDistance is the the change in distance
  50567. */
  50568. onSnapObservable: Observable<{
  50569. snapDistance: number;
  50570. }>;
  50571. /**
  50572. * If the scaling operation should be done on all axis (default: false)
  50573. */
  50574. uniformScaling: boolean;
  50575. /**
  50576. * Custom sensitivity value for the drag strength
  50577. */
  50578. sensitivity: number;
  50579. private _isEnabled;
  50580. private _parent;
  50581. private _arrow;
  50582. private _coloredMaterial;
  50583. private _hoverMaterial;
  50584. /**
  50585. * Creates an AxisScaleGizmo
  50586. * @param gizmoLayer The utility layer the gizmo will be added to
  50587. * @param dragAxis The axis which the gizmo will be able to scale on
  50588. * @param color The color of the gizmo
  50589. */
  50590. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50591. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50592. /**
  50593. * If the gizmo is enabled
  50594. */
  50595. set isEnabled(value: boolean);
  50596. get isEnabled(): boolean;
  50597. /**
  50598. * Disposes of the gizmo
  50599. */
  50600. dispose(): void;
  50601. /**
  50602. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50603. * @param mesh The mesh to replace the default mesh of the gizmo
  50604. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50605. */
  50606. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50607. }
  50608. }
  50609. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50610. import { Observable } from "babylonjs/Misc/observable";
  50611. import { Nullable } from "babylonjs/types";
  50612. import { Vector3 } from "babylonjs/Maths/math.vector";
  50613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50614. import { Mesh } from "babylonjs/Meshes/mesh";
  50615. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50616. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50617. import { Color3 } from "babylonjs/Maths/math.color";
  50618. import "babylonjs/Meshes/Builders/boxBuilder";
  50619. /**
  50620. * Bounding box gizmo
  50621. */
  50622. export class BoundingBoxGizmo extends Gizmo {
  50623. private _lineBoundingBox;
  50624. private _rotateSpheresParent;
  50625. private _scaleBoxesParent;
  50626. private _boundingDimensions;
  50627. private _renderObserver;
  50628. private _pointerObserver;
  50629. private _scaleDragSpeed;
  50630. private _tmpQuaternion;
  50631. private _tmpVector;
  50632. private _tmpRotationMatrix;
  50633. /**
  50634. * 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)
  50635. */
  50636. ignoreChildren: boolean;
  50637. /**
  50638. * 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)
  50639. */
  50640. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50641. /**
  50642. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50643. */
  50644. rotationSphereSize: number;
  50645. /**
  50646. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50647. */
  50648. scaleBoxSize: number;
  50649. /**
  50650. * 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)
  50651. */
  50652. fixedDragMeshScreenSize: boolean;
  50653. /**
  50654. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50655. */
  50656. fixedDragMeshScreenSizeDistanceFactor: number;
  50657. /**
  50658. * Fired when a rotation sphere or scale box is dragged
  50659. */
  50660. onDragStartObservable: Observable<{}>;
  50661. /**
  50662. * Fired when a scale box is dragged
  50663. */
  50664. onScaleBoxDragObservable: Observable<{}>;
  50665. /**
  50666. * Fired when a scale box drag is ended
  50667. */
  50668. onScaleBoxDragEndObservable: Observable<{}>;
  50669. /**
  50670. * Fired when a rotation sphere is dragged
  50671. */
  50672. onRotationSphereDragObservable: Observable<{}>;
  50673. /**
  50674. * Fired when a rotation sphere drag is ended
  50675. */
  50676. onRotationSphereDragEndObservable: Observable<{}>;
  50677. /**
  50678. * 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)
  50679. */
  50680. scalePivot: Nullable<Vector3>;
  50681. /**
  50682. * Mesh used as a pivot to rotate the attached mesh
  50683. */
  50684. private _anchorMesh;
  50685. private _existingMeshScale;
  50686. private _dragMesh;
  50687. private pointerDragBehavior;
  50688. private coloredMaterial;
  50689. private hoverColoredMaterial;
  50690. /**
  50691. * Sets the color of the bounding box gizmo
  50692. * @param color the color to set
  50693. */
  50694. setColor(color: Color3): void;
  50695. /**
  50696. * Creates an BoundingBoxGizmo
  50697. * @param gizmoLayer The utility layer the gizmo will be added to
  50698. * @param color The color of the gizmo
  50699. */
  50700. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50701. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50702. private _selectNode;
  50703. /**
  50704. * Updates the bounding box information for the Gizmo
  50705. */
  50706. updateBoundingBox(): void;
  50707. private _updateRotationSpheres;
  50708. private _updateScaleBoxes;
  50709. /**
  50710. * Enables rotation on the specified axis and disables rotation on the others
  50711. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50712. */
  50713. setEnabledRotationAxis(axis: string): void;
  50714. /**
  50715. * Enables/disables scaling
  50716. * @param enable if scaling should be enabled
  50717. */
  50718. setEnabledScaling(enable: boolean): void;
  50719. private _updateDummy;
  50720. /**
  50721. * Enables a pointer drag behavior on the bounding box of the gizmo
  50722. */
  50723. enableDragBehavior(): void;
  50724. /**
  50725. * Disposes of the gizmo
  50726. */
  50727. dispose(): void;
  50728. /**
  50729. * 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)
  50730. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50731. * @returns the bounding box mesh with the passed in mesh as a child
  50732. */
  50733. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50734. /**
  50735. * CustomMeshes are not supported by this gizmo
  50736. * @param mesh The mesh to replace the default mesh of the gizmo
  50737. */
  50738. setCustomMesh(mesh: Mesh): void;
  50739. }
  50740. }
  50741. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50742. import { Observable } from "babylonjs/Misc/observable";
  50743. import { Nullable } from "babylonjs/types";
  50744. import { Vector3 } from "babylonjs/Maths/math.vector";
  50745. import { Color3 } from "babylonjs/Maths/math.color";
  50746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50747. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50748. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50749. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50750. import "babylonjs/Meshes/Builders/linesBuilder";
  50751. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50752. /**
  50753. * Single plane rotation gizmo
  50754. */
  50755. export class PlaneRotationGizmo extends Gizmo {
  50756. /**
  50757. * Drag behavior responsible for the gizmos dragging interactions
  50758. */
  50759. dragBehavior: PointerDragBehavior;
  50760. private _pointerObserver;
  50761. /**
  50762. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50763. */
  50764. snapDistance: number;
  50765. /**
  50766. * Event that fires each time the gizmo snaps to a new location.
  50767. * * snapDistance is the the change in distance
  50768. */
  50769. onSnapObservable: Observable<{
  50770. snapDistance: number;
  50771. }>;
  50772. private _isEnabled;
  50773. private _parent;
  50774. /**
  50775. * Creates a PlaneRotationGizmo
  50776. * @param gizmoLayer The utility layer the gizmo will be added to
  50777. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50778. * @param color The color of the gizmo
  50779. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50780. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50781. */
  50782. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50783. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50784. /**
  50785. * If the gizmo is enabled
  50786. */
  50787. set isEnabled(value: boolean);
  50788. get isEnabled(): boolean;
  50789. /**
  50790. * Disposes of the gizmo
  50791. */
  50792. dispose(): void;
  50793. }
  50794. }
  50795. declare module "babylonjs/Gizmos/rotationGizmo" {
  50796. import { Observable } from "babylonjs/Misc/observable";
  50797. import { Nullable } from "babylonjs/types";
  50798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50799. import { Mesh } from "babylonjs/Meshes/mesh";
  50800. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50801. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50802. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50803. /**
  50804. * Gizmo that enables rotating a mesh along 3 axis
  50805. */
  50806. export class RotationGizmo extends Gizmo {
  50807. /**
  50808. * Internal gizmo used for interactions on the x axis
  50809. */
  50810. xGizmo: PlaneRotationGizmo;
  50811. /**
  50812. * Internal gizmo used for interactions on the y axis
  50813. */
  50814. yGizmo: PlaneRotationGizmo;
  50815. /**
  50816. * Internal gizmo used for interactions on the z axis
  50817. */
  50818. zGizmo: PlaneRotationGizmo;
  50819. /** Fires an event when any of it's sub gizmos are dragged */
  50820. onDragStartObservable: Observable<unknown>;
  50821. /** Fires an event when any of it's sub gizmos are released from dragging */
  50822. onDragEndObservable: Observable<unknown>;
  50823. private _meshAttached;
  50824. get attachedMesh(): Nullable<AbstractMesh>;
  50825. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50826. /**
  50827. * Creates a RotationGizmo
  50828. * @param gizmoLayer The utility layer the gizmo will be added to
  50829. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50830. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50831. */
  50832. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50833. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50834. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50835. /**
  50836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50837. */
  50838. set snapDistance(value: number);
  50839. get snapDistance(): number;
  50840. /**
  50841. * Ratio for the scale of the gizmo (Default: 1)
  50842. */
  50843. set scaleRatio(value: number);
  50844. get scaleRatio(): number;
  50845. /**
  50846. * Disposes of the gizmo
  50847. */
  50848. dispose(): void;
  50849. /**
  50850. * CustomMeshes are not supported by this gizmo
  50851. * @param mesh The mesh to replace the default mesh of the gizmo
  50852. */
  50853. setCustomMesh(mesh: Mesh): void;
  50854. }
  50855. }
  50856. declare module "babylonjs/Gizmos/gizmoManager" {
  50857. import { Observable } from "babylonjs/Misc/observable";
  50858. import { Nullable } from "babylonjs/types";
  50859. import { Scene, IDisposable } from "babylonjs/scene";
  50860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50861. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50862. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50863. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50864. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50865. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50866. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50867. /**
  50868. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50869. */
  50870. export class GizmoManager implements IDisposable {
  50871. private scene;
  50872. /**
  50873. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50874. */
  50875. gizmos: {
  50876. positionGizmo: Nullable<PositionGizmo>;
  50877. rotationGizmo: Nullable<RotationGizmo>;
  50878. scaleGizmo: Nullable<ScaleGizmo>;
  50879. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50880. };
  50881. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50882. clearGizmoOnEmptyPointerEvent: boolean;
  50883. /** Fires an event when the manager is attached to a mesh */
  50884. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50885. private _gizmosEnabled;
  50886. private _pointerObserver;
  50887. private _attachedMesh;
  50888. private _boundingBoxColor;
  50889. private _defaultUtilityLayer;
  50890. private _defaultKeepDepthUtilityLayer;
  50891. /**
  50892. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50893. */
  50894. boundingBoxDragBehavior: SixDofDragBehavior;
  50895. /**
  50896. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50897. */
  50898. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50899. /**
  50900. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50901. */
  50902. usePointerToAttachGizmos: boolean;
  50903. /**
  50904. * Utility layer that the bounding box gizmo belongs to
  50905. */
  50906. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50907. /**
  50908. * Utility layer that all gizmos besides bounding box belong to
  50909. */
  50910. get utilityLayer(): UtilityLayerRenderer;
  50911. /**
  50912. * Instatiates a gizmo manager
  50913. * @param scene the scene to overlay the gizmos on top of
  50914. */
  50915. constructor(scene: Scene);
  50916. /**
  50917. * Attaches a set of gizmos to the specified mesh
  50918. * @param mesh The mesh the gizmo's should be attached to
  50919. */
  50920. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50921. /**
  50922. * If the position gizmo is enabled
  50923. */
  50924. set positionGizmoEnabled(value: boolean);
  50925. get positionGizmoEnabled(): boolean;
  50926. /**
  50927. * If the rotation gizmo is enabled
  50928. */
  50929. set rotationGizmoEnabled(value: boolean);
  50930. get rotationGizmoEnabled(): boolean;
  50931. /**
  50932. * If the scale gizmo is enabled
  50933. */
  50934. set scaleGizmoEnabled(value: boolean);
  50935. get scaleGizmoEnabled(): boolean;
  50936. /**
  50937. * If the boundingBox gizmo is enabled
  50938. */
  50939. set boundingBoxGizmoEnabled(value: boolean);
  50940. get boundingBoxGizmoEnabled(): boolean;
  50941. /**
  50942. * Disposes of the gizmo manager
  50943. */
  50944. dispose(): void;
  50945. }
  50946. }
  50947. declare module "babylonjs/Lights/directionalLight" {
  50948. import { Camera } from "babylonjs/Cameras/camera";
  50949. import { Scene } from "babylonjs/scene";
  50950. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50952. import { Light } from "babylonjs/Lights/light";
  50953. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50954. import { Effect } from "babylonjs/Materials/effect";
  50955. /**
  50956. * A directional light is defined by a direction (what a surprise!).
  50957. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50958. * 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.
  50959. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50960. */
  50961. export class DirectionalLight extends ShadowLight {
  50962. private _shadowFrustumSize;
  50963. /**
  50964. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50965. */
  50966. get shadowFrustumSize(): number;
  50967. /**
  50968. * Specifies a fix frustum size for the shadow generation.
  50969. */
  50970. set shadowFrustumSize(value: number);
  50971. private _shadowOrthoScale;
  50972. /**
  50973. * Gets the shadow projection scale against the optimal computed one.
  50974. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50975. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50976. */
  50977. get shadowOrthoScale(): number;
  50978. /**
  50979. * Sets the shadow projection scale against the optimal computed one.
  50980. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50981. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50982. */
  50983. set shadowOrthoScale(value: number);
  50984. /**
  50985. * Automatically compute the projection matrix to best fit (including all the casters)
  50986. * on each frame.
  50987. */
  50988. autoUpdateExtends: boolean;
  50989. /**
  50990. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50991. * on each frame. autoUpdateExtends must be set to true for this to work
  50992. */
  50993. autoCalcShadowZBounds: boolean;
  50994. private _orthoLeft;
  50995. private _orthoRight;
  50996. private _orthoTop;
  50997. private _orthoBottom;
  50998. /**
  50999. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51000. * The directional light is emitted from everywhere in the given direction.
  51001. * It can cast shadows.
  51002. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51003. * @param name The friendly name of the light
  51004. * @param direction The direction of the light
  51005. * @param scene The scene the light belongs to
  51006. */
  51007. constructor(name: string, direction: Vector3, scene: Scene);
  51008. /**
  51009. * Returns the string "DirectionalLight".
  51010. * @return The class name
  51011. */
  51012. getClassName(): string;
  51013. /**
  51014. * Returns the integer 1.
  51015. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51016. */
  51017. getTypeID(): number;
  51018. /**
  51019. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51020. * Returns the DirectionalLight Shadow projection matrix.
  51021. */
  51022. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51023. /**
  51024. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51025. * Returns the DirectionalLight Shadow projection matrix.
  51026. */
  51027. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51028. /**
  51029. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51030. * Returns the DirectionalLight Shadow projection matrix.
  51031. */
  51032. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51033. protected _buildUniformLayout(): void;
  51034. /**
  51035. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51036. * @param effect The effect to update
  51037. * @param lightIndex The index of the light in the effect to update
  51038. * @returns The directional light
  51039. */
  51040. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51041. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51042. /**
  51043. * Gets the minZ used for shadow according to both the scene and the light.
  51044. *
  51045. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51046. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51047. * @param activeCamera The camera we are returning the min for
  51048. * @returns the depth min z
  51049. */
  51050. getDepthMinZ(activeCamera: Camera): number;
  51051. /**
  51052. * Gets the maxZ used for shadow according to both the scene and the light.
  51053. *
  51054. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51055. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51056. * @param activeCamera The camera we are returning the max for
  51057. * @returns the depth max z
  51058. */
  51059. getDepthMaxZ(activeCamera: Camera): number;
  51060. /**
  51061. * Prepares the list of defines specific to the light type.
  51062. * @param defines the list of defines
  51063. * @param lightIndex defines the index of the light for the effect
  51064. */
  51065. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51066. }
  51067. }
  51068. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51069. import { Mesh } from "babylonjs/Meshes/mesh";
  51070. /**
  51071. * Class containing static functions to help procedurally build meshes
  51072. */
  51073. export class HemisphereBuilder {
  51074. /**
  51075. * Creates a hemisphere mesh
  51076. * @param name defines the name of the mesh
  51077. * @param options defines the options used to create the mesh
  51078. * @param scene defines the hosting scene
  51079. * @returns the hemisphere mesh
  51080. */
  51081. static CreateHemisphere(name: string, options: {
  51082. segments?: number;
  51083. diameter?: number;
  51084. sideOrientation?: number;
  51085. }, scene: any): Mesh;
  51086. }
  51087. }
  51088. declare module "babylonjs/Lights/spotLight" {
  51089. import { Nullable } from "babylonjs/types";
  51090. import { Scene } from "babylonjs/scene";
  51091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51093. import { Effect } from "babylonjs/Materials/effect";
  51094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51095. import { Light } from "babylonjs/Lights/light";
  51096. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51097. /**
  51098. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51099. * These values define a cone of light starting from the position, emitting toward the direction.
  51100. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51101. * and the exponent defines the speed of the decay of the light with distance (reach).
  51102. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51103. */
  51104. export class SpotLight extends ShadowLight {
  51105. private _angle;
  51106. private _innerAngle;
  51107. private _cosHalfAngle;
  51108. private _lightAngleScale;
  51109. private _lightAngleOffset;
  51110. /**
  51111. * Gets the cone angle of the spot light in Radians.
  51112. */
  51113. get angle(): number;
  51114. /**
  51115. * Sets the cone angle of the spot light in Radians.
  51116. */
  51117. set angle(value: number);
  51118. /**
  51119. * Only used in gltf falloff mode, this defines the angle where
  51120. * the directional falloff will start before cutting at angle which could be seen
  51121. * as outer angle.
  51122. */
  51123. get innerAngle(): number;
  51124. /**
  51125. * Only used in gltf falloff mode, this defines the angle where
  51126. * the directional falloff will start before cutting at angle which could be seen
  51127. * as outer angle.
  51128. */
  51129. set innerAngle(value: number);
  51130. private _shadowAngleScale;
  51131. /**
  51132. * Allows scaling the angle of the light for shadow generation only.
  51133. */
  51134. get shadowAngleScale(): number;
  51135. /**
  51136. * Allows scaling the angle of the light for shadow generation only.
  51137. */
  51138. set shadowAngleScale(value: number);
  51139. /**
  51140. * The light decay speed with the distance from the emission spot.
  51141. */
  51142. exponent: number;
  51143. private _projectionTextureMatrix;
  51144. /**
  51145. * Allows reading the projecton texture
  51146. */
  51147. get projectionTextureMatrix(): Matrix;
  51148. protected _projectionTextureLightNear: number;
  51149. /**
  51150. * Gets the near clip of the Spotlight for texture projection.
  51151. */
  51152. get projectionTextureLightNear(): number;
  51153. /**
  51154. * Sets the near clip of the Spotlight for texture projection.
  51155. */
  51156. set projectionTextureLightNear(value: number);
  51157. protected _projectionTextureLightFar: number;
  51158. /**
  51159. * Gets the far clip of the Spotlight for texture projection.
  51160. */
  51161. get projectionTextureLightFar(): number;
  51162. /**
  51163. * Sets the far clip of the Spotlight for texture projection.
  51164. */
  51165. set projectionTextureLightFar(value: number);
  51166. protected _projectionTextureUpDirection: Vector3;
  51167. /**
  51168. * Gets the Up vector of the Spotlight for texture projection.
  51169. */
  51170. get projectionTextureUpDirection(): Vector3;
  51171. /**
  51172. * Sets the Up vector of the Spotlight for texture projection.
  51173. */
  51174. set projectionTextureUpDirection(value: Vector3);
  51175. private _projectionTexture;
  51176. /**
  51177. * Gets the projection texture of the light.
  51178. */
  51179. get projectionTexture(): Nullable<BaseTexture>;
  51180. /**
  51181. * Sets the projection texture of the light.
  51182. */
  51183. set projectionTexture(value: Nullable<BaseTexture>);
  51184. private _projectionTextureViewLightDirty;
  51185. private _projectionTextureProjectionLightDirty;
  51186. private _projectionTextureDirty;
  51187. private _projectionTextureViewTargetVector;
  51188. private _projectionTextureViewLightMatrix;
  51189. private _projectionTextureProjectionLightMatrix;
  51190. private _projectionTextureScalingMatrix;
  51191. /**
  51192. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51193. * It can cast shadows.
  51194. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51195. * @param name The light friendly name
  51196. * @param position The position of the spot light in the scene
  51197. * @param direction The direction of the light in the scene
  51198. * @param angle The cone angle of the light in Radians
  51199. * @param exponent The light decay speed with the distance from the emission spot
  51200. * @param scene The scene the lights belongs to
  51201. */
  51202. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51203. /**
  51204. * Returns the string "SpotLight".
  51205. * @returns the class name
  51206. */
  51207. getClassName(): string;
  51208. /**
  51209. * Returns the integer 2.
  51210. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51211. */
  51212. getTypeID(): number;
  51213. /**
  51214. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51215. */
  51216. protected _setDirection(value: Vector3): void;
  51217. /**
  51218. * Overrides the position setter to recompute the projection texture view light Matrix.
  51219. */
  51220. protected _setPosition(value: Vector3): void;
  51221. /**
  51222. * 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.
  51223. * Returns the SpotLight.
  51224. */
  51225. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51226. protected _computeProjectionTextureViewLightMatrix(): void;
  51227. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51228. /**
  51229. * Main function for light texture projection matrix computing.
  51230. */
  51231. protected _computeProjectionTextureMatrix(): void;
  51232. protected _buildUniformLayout(): void;
  51233. private _computeAngleValues;
  51234. /**
  51235. * Sets the passed Effect "effect" with the Light textures.
  51236. * @param effect The effect to update
  51237. * @param lightIndex The index of the light in the effect to update
  51238. * @returns The light
  51239. */
  51240. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51241. /**
  51242. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51243. * @param effect The effect to update
  51244. * @param lightIndex The index of the light in the effect to update
  51245. * @returns The spot light
  51246. */
  51247. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51248. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51249. /**
  51250. * Disposes the light and the associated resources.
  51251. */
  51252. dispose(): void;
  51253. /**
  51254. * Prepares the list of defines specific to the light type.
  51255. * @param defines the list of defines
  51256. * @param lightIndex defines the index of the light for the effect
  51257. */
  51258. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51259. }
  51260. }
  51261. declare module "babylonjs/Gizmos/lightGizmo" {
  51262. import { Nullable } from "babylonjs/types";
  51263. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51264. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51265. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51266. import { Light } from "babylonjs/Lights/light";
  51267. /**
  51268. * Gizmo that enables viewing a light
  51269. */
  51270. export class LightGizmo extends Gizmo {
  51271. private _lightMesh;
  51272. private _material;
  51273. private _cachedPosition;
  51274. private _cachedForward;
  51275. private _attachedMeshParent;
  51276. /**
  51277. * Creates a LightGizmo
  51278. * @param gizmoLayer The utility layer the gizmo will be added to
  51279. */
  51280. constructor(gizmoLayer?: UtilityLayerRenderer);
  51281. private _light;
  51282. /**
  51283. * The light that the gizmo is attached to
  51284. */
  51285. set light(light: Nullable<Light>);
  51286. get light(): Nullable<Light>;
  51287. /**
  51288. * Gets the material used to render the light gizmo
  51289. */
  51290. get material(): StandardMaterial;
  51291. /**
  51292. * @hidden
  51293. * Updates the gizmo to match the attached mesh's position/rotation
  51294. */
  51295. protected _update(): void;
  51296. private static _Scale;
  51297. /**
  51298. * Creates the lines for a light mesh
  51299. */
  51300. private static _CreateLightLines;
  51301. /**
  51302. * Disposes of the light gizmo
  51303. */
  51304. dispose(): void;
  51305. private static _CreateHemisphericLightMesh;
  51306. private static _CreatePointLightMesh;
  51307. private static _CreateSpotLightMesh;
  51308. private static _CreateDirectionalLightMesh;
  51309. }
  51310. }
  51311. declare module "babylonjs/Gizmos/index" {
  51312. export * from "babylonjs/Gizmos/axisDragGizmo";
  51313. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51314. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51315. export * from "babylonjs/Gizmos/gizmo";
  51316. export * from "babylonjs/Gizmos/gizmoManager";
  51317. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51318. export * from "babylonjs/Gizmos/positionGizmo";
  51319. export * from "babylonjs/Gizmos/rotationGizmo";
  51320. export * from "babylonjs/Gizmos/scaleGizmo";
  51321. export * from "babylonjs/Gizmos/lightGizmo";
  51322. export * from "babylonjs/Gizmos/planeDragGizmo";
  51323. }
  51324. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51325. /** @hidden */
  51326. export var backgroundFragmentDeclaration: {
  51327. name: string;
  51328. shader: string;
  51329. };
  51330. }
  51331. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51332. /** @hidden */
  51333. export var backgroundUboDeclaration: {
  51334. name: string;
  51335. shader: string;
  51336. };
  51337. }
  51338. declare module "babylonjs/Shaders/background.fragment" {
  51339. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51340. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51341. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51342. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51343. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51344. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51345. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51346. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51347. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51348. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51349. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51350. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51351. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51352. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51353. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51354. /** @hidden */
  51355. export var backgroundPixelShader: {
  51356. name: string;
  51357. shader: string;
  51358. };
  51359. }
  51360. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51361. /** @hidden */
  51362. export var backgroundVertexDeclaration: {
  51363. name: string;
  51364. shader: string;
  51365. };
  51366. }
  51367. declare module "babylonjs/Shaders/background.vertex" {
  51368. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51369. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51371. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51372. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51373. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51374. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51375. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51376. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51377. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51378. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51379. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51380. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51381. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51382. /** @hidden */
  51383. export var backgroundVertexShader: {
  51384. name: string;
  51385. shader: string;
  51386. };
  51387. }
  51388. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51389. import { Nullable, int, float } from "babylonjs/types";
  51390. import { Scene } from "babylonjs/scene";
  51391. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51392. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51394. import { Mesh } from "babylonjs/Meshes/mesh";
  51395. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51396. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51397. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51399. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51400. import { Color3 } from "babylonjs/Maths/math.color";
  51401. import "babylonjs/Shaders/background.fragment";
  51402. import "babylonjs/Shaders/background.vertex";
  51403. /**
  51404. * Background material used to create an efficient environement around your scene.
  51405. */
  51406. export class BackgroundMaterial extends PushMaterial {
  51407. /**
  51408. * Standard reflectance value at parallel view angle.
  51409. */
  51410. static StandardReflectance0: number;
  51411. /**
  51412. * Standard reflectance value at grazing angle.
  51413. */
  51414. static StandardReflectance90: number;
  51415. protected _primaryColor: Color3;
  51416. /**
  51417. * Key light Color (multiply against the environement texture)
  51418. */
  51419. primaryColor: Color3;
  51420. protected __perceptualColor: Nullable<Color3>;
  51421. /**
  51422. * Experimental Internal Use Only.
  51423. *
  51424. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51425. * This acts as a helper to set the primary color to a more "human friendly" value.
  51426. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51427. * output color as close as possible from the chosen value.
  51428. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51429. * part of lighting setup.)
  51430. */
  51431. get _perceptualColor(): Nullable<Color3>;
  51432. set _perceptualColor(value: Nullable<Color3>);
  51433. protected _primaryColorShadowLevel: float;
  51434. /**
  51435. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51436. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51437. */
  51438. get primaryColorShadowLevel(): float;
  51439. set primaryColorShadowLevel(value: float);
  51440. protected _primaryColorHighlightLevel: float;
  51441. /**
  51442. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51443. * The primary color is used at the level chosen to define what the white area would look.
  51444. */
  51445. get primaryColorHighlightLevel(): float;
  51446. set primaryColorHighlightLevel(value: float);
  51447. protected _reflectionTexture: Nullable<BaseTexture>;
  51448. /**
  51449. * Reflection Texture used in the material.
  51450. * Should be author in a specific way for the best result (refer to the documentation).
  51451. */
  51452. reflectionTexture: Nullable<BaseTexture>;
  51453. protected _reflectionBlur: float;
  51454. /**
  51455. * Reflection Texture level of blur.
  51456. *
  51457. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51458. * texture twice.
  51459. */
  51460. reflectionBlur: float;
  51461. protected _diffuseTexture: Nullable<BaseTexture>;
  51462. /**
  51463. * Diffuse Texture used in the material.
  51464. * Should be author in a specific way for the best result (refer to the documentation).
  51465. */
  51466. diffuseTexture: Nullable<BaseTexture>;
  51467. protected _shadowLights: Nullable<IShadowLight[]>;
  51468. /**
  51469. * Specify the list of lights casting shadow on the material.
  51470. * All scene shadow lights will be included if null.
  51471. */
  51472. shadowLights: Nullable<IShadowLight[]>;
  51473. protected _shadowLevel: float;
  51474. /**
  51475. * Helps adjusting the shadow to a softer level if required.
  51476. * 0 means black shadows and 1 means no shadows.
  51477. */
  51478. shadowLevel: float;
  51479. protected _sceneCenter: Vector3;
  51480. /**
  51481. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51482. * It is usually zero but might be interesting to modify according to your setup.
  51483. */
  51484. sceneCenter: Vector3;
  51485. protected _opacityFresnel: boolean;
  51486. /**
  51487. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51488. * This helps ensuring a nice transition when the camera goes under the ground.
  51489. */
  51490. opacityFresnel: boolean;
  51491. protected _reflectionFresnel: boolean;
  51492. /**
  51493. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51494. * This helps adding a mirror texture on the ground.
  51495. */
  51496. reflectionFresnel: boolean;
  51497. protected _reflectionFalloffDistance: number;
  51498. /**
  51499. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51500. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51501. */
  51502. reflectionFalloffDistance: number;
  51503. protected _reflectionAmount: number;
  51504. /**
  51505. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51506. */
  51507. reflectionAmount: number;
  51508. protected _reflectionReflectance0: number;
  51509. /**
  51510. * This specifies the weight of the reflection at grazing angle.
  51511. */
  51512. reflectionReflectance0: number;
  51513. protected _reflectionReflectance90: number;
  51514. /**
  51515. * This specifies the weight of the reflection at a perpendicular point of view.
  51516. */
  51517. reflectionReflectance90: number;
  51518. /**
  51519. * Sets the reflection reflectance fresnel values according to the default standard
  51520. * empirically know to work well :-)
  51521. */
  51522. set reflectionStandardFresnelWeight(value: number);
  51523. protected _useRGBColor: boolean;
  51524. /**
  51525. * Helps to directly use the maps channels instead of their level.
  51526. */
  51527. useRGBColor: boolean;
  51528. protected _enableNoise: boolean;
  51529. /**
  51530. * This helps reducing the banding effect that could occur on the background.
  51531. */
  51532. enableNoise: boolean;
  51533. /**
  51534. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51535. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51536. * Recommended to be keep at 1.0 except for special cases.
  51537. */
  51538. get fovMultiplier(): number;
  51539. set fovMultiplier(value: number);
  51540. private _fovMultiplier;
  51541. /**
  51542. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51543. */
  51544. useEquirectangularFOV: boolean;
  51545. private _maxSimultaneousLights;
  51546. /**
  51547. * Number of Simultaneous lights allowed on the material.
  51548. */
  51549. maxSimultaneousLights: int;
  51550. /**
  51551. * Default configuration related to image processing available in the Background Material.
  51552. */
  51553. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51554. /**
  51555. * Keep track of the image processing observer to allow dispose and replace.
  51556. */
  51557. private _imageProcessingObserver;
  51558. /**
  51559. * Attaches a new image processing configuration to the PBR Material.
  51560. * @param configuration (if null the scene configuration will be use)
  51561. */
  51562. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51563. /**
  51564. * Gets the image processing configuration used either in this material.
  51565. */
  51566. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51567. /**
  51568. * Sets the Default image processing configuration used either in the this material.
  51569. *
  51570. * If sets to null, the scene one is in use.
  51571. */
  51572. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51573. /**
  51574. * Gets wether the color curves effect is enabled.
  51575. */
  51576. get cameraColorCurvesEnabled(): boolean;
  51577. /**
  51578. * Sets wether the color curves effect is enabled.
  51579. */
  51580. set cameraColorCurvesEnabled(value: boolean);
  51581. /**
  51582. * Gets wether the color grading effect is enabled.
  51583. */
  51584. get cameraColorGradingEnabled(): boolean;
  51585. /**
  51586. * Gets wether the color grading effect is enabled.
  51587. */
  51588. set cameraColorGradingEnabled(value: boolean);
  51589. /**
  51590. * Gets wether tonemapping is enabled or not.
  51591. */
  51592. get cameraToneMappingEnabled(): boolean;
  51593. /**
  51594. * Sets wether tonemapping is enabled or not
  51595. */
  51596. set cameraToneMappingEnabled(value: boolean);
  51597. /**
  51598. * The camera exposure used on this material.
  51599. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51600. * This corresponds to a photographic exposure.
  51601. */
  51602. get cameraExposure(): float;
  51603. /**
  51604. * The camera exposure used on this material.
  51605. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51606. * This corresponds to a photographic exposure.
  51607. */
  51608. set cameraExposure(value: float);
  51609. /**
  51610. * Gets The camera contrast used on this material.
  51611. */
  51612. get cameraContrast(): float;
  51613. /**
  51614. * Sets The camera contrast used on this material.
  51615. */
  51616. set cameraContrast(value: float);
  51617. /**
  51618. * Gets the Color Grading 2D Lookup Texture.
  51619. */
  51620. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51621. /**
  51622. * Sets the Color Grading 2D Lookup Texture.
  51623. */
  51624. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51625. /**
  51626. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51627. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51628. * 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;
  51629. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51630. */
  51631. get cameraColorCurves(): Nullable<ColorCurves>;
  51632. /**
  51633. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51634. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51635. * 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;
  51636. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51637. */
  51638. set cameraColorCurves(value: Nullable<ColorCurves>);
  51639. /**
  51640. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51641. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51642. */
  51643. switchToBGR: boolean;
  51644. private _renderTargets;
  51645. private _reflectionControls;
  51646. private _white;
  51647. private _primaryShadowColor;
  51648. private _primaryHighlightColor;
  51649. /**
  51650. * Instantiates a Background Material in the given scene
  51651. * @param name The friendly name of the material
  51652. * @param scene The scene to add the material to
  51653. */
  51654. constructor(name: string, scene: Scene);
  51655. /**
  51656. * Gets a boolean indicating that current material needs to register RTT
  51657. */
  51658. get hasRenderTargetTextures(): boolean;
  51659. /**
  51660. * The entire material has been created in order to prevent overdraw.
  51661. * @returns false
  51662. */
  51663. needAlphaTesting(): boolean;
  51664. /**
  51665. * The entire material has been created in order to prevent overdraw.
  51666. * @returns true if blending is enable
  51667. */
  51668. needAlphaBlending(): boolean;
  51669. /**
  51670. * Checks wether the material is ready to be rendered for a given mesh.
  51671. * @param mesh The mesh to render
  51672. * @param subMesh The submesh to check against
  51673. * @param useInstances Specify wether or not the material is used with instances
  51674. * @returns true if all the dependencies are ready (Textures, Effects...)
  51675. */
  51676. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51677. /**
  51678. * Compute the primary color according to the chosen perceptual color.
  51679. */
  51680. private _computePrimaryColorFromPerceptualColor;
  51681. /**
  51682. * Compute the highlights and shadow colors according to their chosen levels.
  51683. */
  51684. private _computePrimaryColors;
  51685. /**
  51686. * Build the uniform buffer used in the material.
  51687. */
  51688. buildUniformLayout(): void;
  51689. /**
  51690. * Unbind the material.
  51691. */
  51692. unbind(): void;
  51693. /**
  51694. * Bind only the world matrix to the material.
  51695. * @param world The world matrix to bind.
  51696. */
  51697. bindOnlyWorldMatrix(world: Matrix): void;
  51698. /**
  51699. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51700. * @param world The world matrix to bind.
  51701. * @param subMesh The submesh to bind for.
  51702. */
  51703. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51704. /**
  51705. * Checks to see if a texture is used in the material.
  51706. * @param texture - Base texture to use.
  51707. * @returns - Boolean specifying if a texture is used in the material.
  51708. */
  51709. hasTexture(texture: BaseTexture): boolean;
  51710. /**
  51711. * Dispose the material.
  51712. * @param forceDisposeEffect Force disposal of the associated effect.
  51713. * @param forceDisposeTextures Force disposal of the associated textures.
  51714. */
  51715. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51716. /**
  51717. * Clones the material.
  51718. * @param name The cloned name.
  51719. * @returns The cloned material.
  51720. */
  51721. clone(name: string): BackgroundMaterial;
  51722. /**
  51723. * Serializes the current material to its JSON representation.
  51724. * @returns The JSON representation.
  51725. */
  51726. serialize(): any;
  51727. /**
  51728. * Gets the class name of the material
  51729. * @returns "BackgroundMaterial"
  51730. */
  51731. getClassName(): string;
  51732. /**
  51733. * Parse a JSON input to create back a background material.
  51734. * @param source The JSON data to parse
  51735. * @param scene The scene to create the parsed material in
  51736. * @param rootUrl The root url of the assets the material depends upon
  51737. * @returns the instantiated BackgroundMaterial.
  51738. */
  51739. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51740. }
  51741. }
  51742. declare module "babylonjs/Helpers/environmentHelper" {
  51743. import { Observable } from "babylonjs/Misc/observable";
  51744. import { Nullable } from "babylonjs/types";
  51745. import { Scene } from "babylonjs/scene";
  51746. import { Vector3 } from "babylonjs/Maths/math.vector";
  51747. import { Color3 } from "babylonjs/Maths/math.color";
  51748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51749. import { Mesh } from "babylonjs/Meshes/mesh";
  51750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51751. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51752. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51753. import "babylonjs/Meshes/Builders/planeBuilder";
  51754. import "babylonjs/Meshes/Builders/boxBuilder";
  51755. /**
  51756. * Represents the different options available during the creation of
  51757. * a Environment helper.
  51758. *
  51759. * This can control the default ground, skybox and image processing setup of your scene.
  51760. */
  51761. export interface IEnvironmentHelperOptions {
  51762. /**
  51763. * Specifies whether or not to create a ground.
  51764. * True by default.
  51765. */
  51766. createGround: boolean;
  51767. /**
  51768. * Specifies the ground size.
  51769. * 15 by default.
  51770. */
  51771. groundSize: number;
  51772. /**
  51773. * The texture used on the ground for the main color.
  51774. * Comes from the BabylonJS CDN by default.
  51775. *
  51776. * Remarks: Can be either a texture or a url.
  51777. */
  51778. groundTexture: string | BaseTexture;
  51779. /**
  51780. * The color mixed in the ground texture by default.
  51781. * BabylonJS clearColor by default.
  51782. */
  51783. groundColor: Color3;
  51784. /**
  51785. * Specifies the ground opacity.
  51786. * 1 by default.
  51787. */
  51788. groundOpacity: number;
  51789. /**
  51790. * Enables the ground to receive shadows.
  51791. * True by default.
  51792. */
  51793. enableGroundShadow: boolean;
  51794. /**
  51795. * Helps preventing the shadow to be fully black on the ground.
  51796. * 0.5 by default.
  51797. */
  51798. groundShadowLevel: number;
  51799. /**
  51800. * Creates a mirror texture attach to the ground.
  51801. * false by default.
  51802. */
  51803. enableGroundMirror: boolean;
  51804. /**
  51805. * Specifies the ground mirror size ratio.
  51806. * 0.3 by default as the default kernel is 64.
  51807. */
  51808. groundMirrorSizeRatio: number;
  51809. /**
  51810. * Specifies the ground mirror blur kernel size.
  51811. * 64 by default.
  51812. */
  51813. groundMirrorBlurKernel: number;
  51814. /**
  51815. * Specifies the ground mirror visibility amount.
  51816. * 1 by default
  51817. */
  51818. groundMirrorAmount: number;
  51819. /**
  51820. * Specifies the ground mirror reflectance weight.
  51821. * This uses the standard weight of the background material to setup the fresnel effect
  51822. * of the mirror.
  51823. * 1 by default.
  51824. */
  51825. groundMirrorFresnelWeight: number;
  51826. /**
  51827. * Specifies the ground mirror Falloff distance.
  51828. * This can helps reducing the size of the reflection.
  51829. * 0 by Default.
  51830. */
  51831. groundMirrorFallOffDistance: number;
  51832. /**
  51833. * Specifies the ground mirror texture type.
  51834. * Unsigned Int by Default.
  51835. */
  51836. groundMirrorTextureType: number;
  51837. /**
  51838. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51839. * the shown objects.
  51840. */
  51841. groundYBias: number;
  51842. /**
  51843. * Specifies whether or not to create a skybox.
  51844. * True by default.
  51845. */
  51846. createSkybox: boolean;
  51847. /**
  51848. * Specifies the skybox size.
  51849. * 20 by default.
  51850. */
  51851. skyboxSize: number;
  51852. /**
  51853. * The texture used on the skybox for the main color.
  51854. * Comes from the BabylonJS CDN by default.
  51855. *
  51856. * Remarks: Can be either a texture or a url.
  51857. */
  51858. skyboxTexture: string | BaseTexture;
  51859. /**
  51860. * The color mixed in the skybox texture by default.
  51861. * BabylonJS clearColor by default.
  51862. */
  51863. skyboxColor: Color3;
  51864. /**
  51865. * The background rotation around the Y axis of the scene.
  51866. * This helps aligning the key lights of your scene with the background.
  51867. * 0 by default.
  51868. */
  51869. backgroundYRotation: number;
  51870. /**
  51871. * Compute automatically the size of the elements to best fit with the scene.
  51872. */
  51873. sizeAuto: boolean;
  51874. /**
  51875. * Default position of the rootMesh if autoSize is not true.
  51876. */
  51877. rootPosition: Vector3;
  51878. /**
  51879. * Sets up the image processing in the scene.
  51880. * true by default.
  51881. */
  51882. setupImageProcessing: boolean;
  51883. /**
  51884. * The texture used as your environment texture in the scene.
  51885. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51886. *
  51887. * Remarks: Can be either a texture or a url.
  51888. */
  51889. environmentTexture: string | BaseTexture;
  51890. /**
  51891. * The value of the exposure to apply to the scene.
  51892. * 0.6 by default if setupImageProcessing is true.
  51893. */
  51894. cameraExposure: number;
  51895. /**
  51896. * The value of the contrast to apply to the scene.
  51897. * 1.6 by default if setupImageProcessing is true.
  51898. */
  51899. cameraContrast: number;
  51900. /**
  51901. * Specifies whether or not tonemapping should be enabled in the scene.
  51902. * true by default if setupImageProcessing is true.
  51903. */
  51904. toneMappingEnabled: boolean;
  51905. }
  51906. /**
  51907. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51908. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51909. * It also helps with the default setup of your imageProcessing configuration.
  51910. */
  51911. export class EnvironmentHelper {
  51912. /**
  51913. * Default ground texture URL.
  51914. */
  51915. private static _groundTextureCDNUrl;
  51916. /**
  51917. * Default skybox texture URL.
  51918. */
  51919. private static _skyboxTextureCDNUrl;
  51920. /**
  51921. * Default environment texture URL.
  51922. */
  51923. private static _environmentTextureCDNUrl;
  51924. /**
  51925. * Creates the default options for the helper.
  51926. */
  51927. private static _getDefaultOptions;
  51928. private _rootMesh;
  51929. /**
  51930. * Gets the root mesh created by the helper.
  51931. */
  51932. get rootMesh(): Mesh;
  51933. private _skybox;
  51934. /**
  51935. * Gets the skybox created by the helper.
  51936. */
  51937. get skybox(): Nullable<Mesh>;
  51938. private _skyboxTexture;
  51939. /**
  51940. * Gets the skybox texture created by the helper.
  51941. */
  51942. get skyboxTexture(): Nullable<BaseTexture>;
  51943. private _skyboxMaterial;
  51944. /**
  51945. * Gets the skybox material created by the helper.
  51946. */
  51947. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51948. private _ground;
  51949. /**
  51950. * Gets the ground mesh created by the helper.
  51951. */
  51952. get ground(): Nullable<Mesh>;
  51953. private _groundTexture;
  51954. /**
  51955. * Gets the ground texture created by the helper.
  51956. */
  51957. get groundTexture(): Nullable<BaseTexture>;
  51958. private _groundMirror;
  51959. /**
  51960. * Gets the ground mirror created by the helper.
  51961. */
  51962. get groundMirror(): Nullable<MirrorTexture>;
  51963. /**
  51964. * Gets the ground mirror render list to helps pushing the meshes
  51965. * you wish in the ground reflection.
  51966. */
  51967. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51968. private _groundMaterial;
  51969. /**
  51970. * Gets the ground material created by the helper.
  51971. */
  51972. get groundMaterial(): Nullable<BackgroundMaterial>;
  51973. /**
  51974. * Stores the creation options.
  51975. */
  51976. private readonly _scene;
  51977. private _options;
  51978. /**
  51979. * This observable will be notified with any error during the creation of the environment,
  51980. * mainly texture creation errors.
  51981. */
  51982. onErrorObservable: Observable<{
  51983. message?: string;
  51984. exception?: any;
  51985. }>;
  51986. /**
  51987. * constructor
  51988. * @param options Defines the options we want to customize the helper
  51989. * @param scene The scene to add the material to
  51990. */
  51991. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51992. /**
  51993. * Updates the background according to the new options
  51994. * @param options
  51995. */
  51996. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51997. /**
  51998. * Sets the primary color of all the available elements.
  51999. * @param color the main color to affect to the ground and the background
  52000. */
  52001. setMainColor(color: Color3): void;
  52002. /**
  52003. * Setup the image processing according to the specified options.
  52004. */
  52005. private _setupImageProcessing;
  52006. /**
  52007. * Setup the environment texture according to the specified options.
  52008. */
  52009. private _setupEnvironmentTexture;
  52010. /**
  52011. * Setup the background according to the specified options.
  52012. */
  52013. private _setupBackground;
  52014. /**
  52015. * Get the scene sizes according to the setup.
  52016. */
  52017. private _getSceneSize;
  52018. /**
  52019. * Setup the ground according to the specified options.
  52020. */
  52021. private _setupGround;
  52022. /**
  52023. * Setup the ground material according to the specified options.
  52024. */
  52025. private _setupGroundMaterial;
  52026. /**
  52027. * Setup the ground diffuse texture according to the specified options.
  52028. */
  52029. private _setupGroundDiffuseTexture;
  52030. /**
  52031. * Setup the ground mirror texture according to the specified options.
  52032. */
  52033. private _setupGroundMirrorTexture;
  52034. /**
  52035. * Setup the ground to receive the mirror texture.
  52036. */
  52037. private _setupMirrorInGroundMaterial;
  52038. /**
  52039. * Setup the skybox according to the specified options.
  52040. */
  52041. private _setupSkybox;
  52042. /**
  52043. * Setup the skybox material according to the specified options.
  52044. */
  52045. private _setupSkyboxMaterial;
  52046. /**
  52047. * Setup the skybox reflection texture according to the specified options.
  52048. */
  52049. private _setupSkyboxReflectionTexture;
  52050. private _errorHandler;
  52051. /**
  52052. * Dispose all the elements created by the Helper.
  52053. */
  52054. dispose(): void;
  52055. }
  52056. }
  52057. declare module "babylonjs/Helpers/photoDome" {
  52058. import { Observable } from "babylonjs/Misc/observable";
  52059. import { Nullable } from "babylonjs/types";
  52060. import { Scene } from "babylonjs/scene";
  52061. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52062. import { Mesh } from "babylonjs/Meshes/mesh";
  52063. import { Texture } from "babylonjs/Materials/Textures/texture";
  52064. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52065. import "babylonjs/Meshes/Builders/sphereBuilder";
  52066. /**
  52067. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52068. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52069. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52070. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52071. */
  52072. export class PhotoDome extends TransformNode {
  52073. /**
  52074. * Define the image as a Monoscopic panoramic 360 image.
  52075. */
  52076. static readonly MODE_MONOSCOPIC: number;
  52077. /**
  52078. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52079. */
  52080. static readonly MODE_TOPBOTTOM: number;
  52081. /**
  52082. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52083. */
  52084. static readonly MODE_SIDEBYSIDE: number;
  52085. private _useDirectMapping;
  52086. /**
  52087. * The texture being displayed on the sphere
  52088. */
  52089. protected _photoTexture: Texture;
  52090. /**
  52091. * Gets or sets the texture being displayed on the sphere
  52092. */
  52093. get photoTexture(): Texture;
  52094. set photoTexture(value: Texture);
  52095. /**
  52096. * Observable raised when an error occured while loading the 360 image
  52097. */
  52098. onLoadErrorObservable: Observable<string>;
  52099. /**
  52100. * The skybox material
  52101. */
  52102. protected _material: BackgroundMaterial;
  52103. /**
  52104. * The surface used for the skybox
  52105. */
  52106. protected _mesh: Mesh;
  52107. /**
  52108. * Gets the mesh used for the skybox.
  52109. */
  52110. get mesh(): Mesh;
  52111. /**
  52112. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52113. * Also see the options.resolution property.
  52114. */
  52115. get fovMultiplier(): number;
  52116. set fovMultiplier(value: number);
  52117. private _imageMode;
  52118. /**
  52119. * Gets or set the current video mode for the video. It can be:
  52120. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52121. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52122. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52123. */
  52124. get imageMode(): number;
  52125. set imageMode(value: number);
  52126. /**
  52127. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52128. * @param name Element's name, child elements will append suffixes for their own names.
  52129. * @param urlsOfPhoto defines the url of the photo to display
  52130. * @param options defines an object containing optional or exposed sub element properties
  52131. * @param onError defines a callback called when an error occured while loading the texture
  52132. */
  52133. constructor(name: string, urlOfPhoto: string, options: {
  52134. resolution?: number;
  52135. size?: number;
  52136. useDirectMapping?: boolean;
  52137. faceForward?: boolean;
  52138. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52139. private _onBeforeCameraRenderObserver;
  52140. private _changeImageMode;
  52141. /**
  52142. * Releases resources associated with this node.
  52143. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52144. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52145. */
  52146. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52147. }
  52148. }
  52149. declare module "babylonjs/Misc/rgbdTextureTools" {
  52150. import "babylonjs/Shaders/rgbdDecode.fragment";
  52151. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52152. import { Texture } from "babylonjs/Materials/Textures/texture";
  52153. /**
  52154. * Class used to host RGBD texture specific utilities
  52155. */
  52156. export class RGBDTextureTools {
  52157. /**
  52158. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52159. * @param texture the texture to expand.
  52160. */
  52161. static ExpandRGBDTexture(texture: Texture): void;
  52162. }
  52163. }
  52164. declare module "babylonjs/Misc/brdfTextureTools" {
  52165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52166. import { Scene } from "babylonjs/scene";
  52167. /**
  52168. * Class used to host texture specific utilities
  52169. */
  52170. export class BRDFTextureTools {
  52171. /**
  52172. * Prevents texture cache collision
  52173. */
  52174. private static _instanceNumber;
  52175. /**
  52176. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52177. * @param scene defines the hosting scene
  52178. * @returns the environment BRDF texture
  52179. */
  52180. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52181. private static _environmentBRDFBase64Texture;
  52182. }
  52183. }
  52184. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52185. import { Nullable } from "babylonjs/types";
  52186. import { Color3 } from "babylonjs/Maths/math.color";
  52187. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52188. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52189. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52190. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52191. import { Engine } from "babylonjs/Engines/engine";
  52192. import { Scene } from "babylonjs/scene";
  52193. /**
  52194. * @hidden
  52195. */
  52196. export interface IMaterialClearCoatDefines {
  52197. CLEARCOAT: boolean;
  52198. CLEARCOAT_DEFAULTIOR: boolean;
  52199. CLEARCOAT_TEXTURE: boolean;
  52200. CLEARCOAT_TEXTUREDIRECTUV: number;
  52201. CLEARCOAT_BUMP: boolean;
  52202. CLEARCOAT_BUMPDIRECTUV: number;
  52203. CLEARCOAT_TINT: boolean;
  52204. CLEARCOAT_TINT_TEXTURE: boolean;
  52205. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52206. /** @hidden */
  52207. _areTexturesDirty: boolean;
  52208. }
  52209. /**
  52210. * Define the code related to the clear coat parameters of the pbr material.
  52211. */
  52212. export class PBRClearCoatConfiguration {
  52213. /**
  52214. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52215. * The default fits with a polyurethane material.
  52216. */
  52217. private static readonly _DefaultIndexOfRefraction;
  52218. private _isEnabled;
  52219. /**
  52220. * Defines if the clear coat is enabled in the material.
  52221. */
  52222. isEnabled: boolean;
  52223. /**
  52224. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52225. */
  52226. intensity: number;
  52227. /**
  52228. * Defines the clear coat layer roughness.
  52229. */
  52230. roughness: number;
  52231. private _indexOfRefraction;
  52232. /**
  52233. * Defines the index of refraction of the clear coat.
  52234. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52235. * The default fits with a polyurethane material.
  52236. * Changing the default value is more performance intensive.
  52237. */
  52238. indexOfRefraction: number;
  52239. private _texture;
  52240. /**
  52241. * Stores the clear coat values in a texture.
  52242. */
  52243. texture: Nullable<BaseTexture>;
  52244. private _bumpTexture;
  52245. /**
  52246. * Define the clear coat specific bump texture.
  52247. */
  52248. bumpTexture: Nullable<BaseTexture>;
  52249. private _isTintEnabled;
  52250. /**
  52251. * Defines if the clear coat tint is enabled in the material.
  52252. */
  52253. isTintEnabled: boolean;
  52254. /**
  52255. * Defines the clear coat tint of the material.
  52256. * This is only use if tint is enabled
  52257. */
  52258. tintColor: Color3;
  52259. /**
  52260. * Defines the distance at which the tint color should be found in the
  52261. * clear coat media.
  52262. * This is only use if tint is enabled
  52263. */
  52264. tintColorAtDistance: number;
  52265. /**
  52266. * Defines the clear coat layer thickness.
  52267. * This is only use if tint is enabled
  52268. */
  52269. tintThickness: number;
  52270. private _tintTexture;
  52271. /**
  52272. * Stores the clear tint values in a texture.
  52273. * rgb is tint
  52274. * a is a thickness factor
  52275. */
  52276. tintTexture: Nullable<BaseTexture>;
  52277. /** @hidden */
  52278. private _internalMarkAllSubMeshesAsTexturesDirty;
  52279. /** @hidden */
  52280. _markAllSubMeshesAsTexturesDirty(): void;
  52281. /**
  52282. * Instantiate a new istance of clear coat configuration.
  52283. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52284. */
  52285. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52286. /**
  52287. * Gets wehter the submesh is ready to be used or not.
  52288. * @param defines the list of "defines" to update.
  52289. * @param scene defines the scene the material belongs to.
  52290. * @param engine defines the engine the material belongs to.
  52291. * @param disableBumpMap defines wether the material disables bump or not.
  52292. * @returns - boolean indicating that the submesh is ready or not.
  52293. */
  52294. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52295. /**
  52296. * Checks to see if a texture is used in the material.
  52297. * @param defines the list of "defines" to update.
  52298. * @param scene defines the scene to the material belongs to.
  52299. */
  52300. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52301. /**
  52302. * Binds the material data.
  52303. * @param uniformBuffer defines the Uniform buffer to fill in.
  52304. * @param scene defines the scene the material belongs to.
  52305. * @param engine defines the engine the material belongs to.
  52306. * @param disableBumpMap defines wether the material disables bump or not.
  52307. * @param isFrozen defines wether the material is frozen or not.
  52308. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52309. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52310. */
  52311. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52312. /**
  52313. * Checks to see if a texture is used in the material.
  52314. * @param texture - Base texture to use.
  52315. * @returns - Boolean specifying if a texture is used in the material.
  52316. */
  52317. hasTexture(texture: BaseTexture): boolean;
  52318. /**
  52319. * Returns an array of the actively used textures.
  52320. * @param activeTextures Array of BaseTextures
  52321. */
  52322. getActiveTextures(activeTextures: BaseTexture[]): void;
  52323. /**
  52324. * Returns the animatable textures.
  52325. * @param animatables Array of animatable textures.
  52326. */
  52327. getAnimatables(animatables: IAnimatable[]): void;
  52328. /**
  52329. * Disposes the resources of the material.
  52330. * @param forceDisposeTextures - Forces the disposal of all textures.
  52331. */
  52332. dispose(forceDisposeTextures?: boolean): void;
  52333. /**
  52334. * Get the current class name of the texture useful for serialization or dynamic coding.
  52335. * @returns "PBRClearCoatConfiguration"
  52336. */
  52337. getClassName(): string;
  52338. /**
  52339. * Add fallbacks to the effect fallbacks list.
  52340. * @param defines defines the Base texture to use.
  52341. * @param fallbacks defines the current fallback list.
  52342. * @param currentRank defines the current fallback rank.
  52343. * @returns the new fallback rank.
  52344. */
  52345. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52346. /**
  52347. * Add the required uniforms to the current list.
  52348. * @param uniforms defines the current uniform list.
  52349. */
  52350. static AddUniforms(uniforms: string[]): void;
  52351. /**
  52352. * Add the required samplers to the current list.
  52353. * @param samplers defines the current sampler list.
  52354. */
  52355. static AddSamplers(samplers: string[]): void;
  52356. /**
  52357. * Add the required uniforms to the current buffer.
  52358. * @param uniformBuffer defines the current uniform buffer.
  52359. */
  52360. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52361. /**
  52362. * Makes a duplicate of the current configuration into another one.
  52363. * @param clearCoatConfiguration define the config where to copy the info
  52364. */
  52365. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52366. /**
  52367. * Serializes this clear coat configuration.
  52368. * @returns - An object with the serialized config.
  52369. */
  52370. serialize(): any;
  52371. /**
  52372. * Parses a anisotropy Configuration from a serialized object.
  52373. * @param source - Serialized object.
  52374. * @param scene Defines the scene we are parsing for
  52375. * @param rootUrl Defines the rootUrl to load from
  52376. */
  52377. parse(source: any, scene: Scene, rootUrl: string): void;
  52378. }
  52379. }
  52380. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52381. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52383. import { Vector2 } from "babylonjs/Maths/math.vector";
  52384. import { Scene } from "babylonjs/scene";
  52385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52386. import { Nullable } from "babylonjs/types";
  52387. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52388. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52389. /**
  52390. * @hidden
  52391. */
  52392. export interface IMaterialAnisotropicDefines {
  52393. ANISOTROPIC: boolean;
  52394. ANISOTROPIC_TEXTURE: boolean;
  52395. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52396. MAINUV1: boolean;
  52397. _areTexturesDirty: boolean;
  52398. _needUVs: boolean;
  52399. }
  52400. /**
  52401. * Define the code related to the anisotropic parameters of the pbr material.
  52402. */
  52403. export class PBRAnisotropicConfiguration {
  52404. private _isEnabled;
  52405. /**
  52406. * Defines if the anisotropy is enabled in the material.
  52407. */
  52408. isEnabled: boolean;
  52409. /**
  52410. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52411. */
  52412. intensity: number;
  52413. /**
  52414. * Defines if the effect is along the tangents, bitangents or in between.
  52415. * By default, the effect is "strectching" the highlights along the tangents.
  52416. */
  52417. direction: Vector2;
  52418. private _texture;
  52419. /**
  52420. * Stores the anisotropy values in a texture.
  52421. * rg is direction (like normal from -1 to 1)
  52422. * b is a intensity
  52423. */
  52424. texture: Nullable<BaseTexture>;
  52425. /** @hidden */
  52426. private _internalMarkAllSubMeshesAsTexturesDirty;
  52427. /** @hidden */
  52428. _markAllSubMeshesAsTexturesDirty(): void;
  52429. /**
  52430. * Instantiate a new istance of anisotropy configuration.
  52431. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52432. */
  52433. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52434. /**
  52435. * Specifies that the submesh is ready to be used.
  52436. * @param defines the list of "defines" to update.
  52437. * @param scene defines the scene the material belongs to.
  52438. * @returns - boolean indicating that the submesh is ready or not.
  52439. */
  52440. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52441. /**
  52442. * Checks to see if a texture is used in the material.
  52443. * @param defines the list of "defines" to update.
  52444. * @param mesh the mesh we are preparing the defines for.
  52445. * @param scene defines the scene the material belongs to.
  52446. */
  52447. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52448. /**
  52449. * Binds the material data.
  52450. * @param uniformBuffer defines the Uniform buffer to fill in.
  52451. * @param scene defines the scene the material belongs to.
  52452. * @param isFrozen defines wether the material is frozen or not.
  52453. */
  52454. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52455. /**
  52456. * Checks to see if a texture is used in the material.
  52457. * @param texture - Base texture to use.
  52458. * @returns - Boolean specifying if a texture is used in the material.
  52459. */
  52460. hasTexture(texture: BaseTexture): boolean;
  52461. /**
  52462. * Returns an array of the actively used textures.
  52463. * @param activeTextures Array of BaseTextures
  52464. */
  52465. getActiveTextures(activeTextures: BaseTexture[]): void;
  52466. /**
  52467. * Returns the animatable textures.
  52468. * @param animatables Array of animatable textures.
  52469. */
  52470. getAnimatables(animatables: IAnimatable[]): void;
  52471. /**
  52472. * Disposes the resources of the material.
  52473. * @param forceDisposeTextures - Forces the disposal of all textures.
  52474. */
  52475. dispose(forceDisposeTextures?: boolean): void;
  52476. /**
  52477. * Get the current class name of the texture useful for serialization or dynamic coding.
  52478. * @returns "PBRAnisotropicConfiguration"
  52479. */
  52480. getClassName(): string;
  52481. /**
  52482. * Add fallbacks to the effect fallbacks list.
  52483. * @param defines defines the Base texture to use.
  52484. * @param fallbacks defines the current fallback list.
  52485. * @param currentRank defines the current fallback rank.
  52486. * @returns the new fallback rank.
  52487. */
  52488. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52489. /**
  52490. * Add the required uniforms to the current list.
  52491. * @param uniforms defines the current uniform list.
  52492. */
  52493. static AddUniforms(uniforms: string[]): void;
  52494. /**
  52495. * Add the required uniforms to the current buffer.
  52496. * @param uniformBuffer defines the current uniform buffer.
  52497. */
  52498. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52499. /**
  52500. * Add the required samplers to the current list.
  52501. * @param samplers defines the current sampler list.
  52502. */
  52503. static AddSamplers(samplers: string[]): void;
  52504. /**
  52505. * Makes a duplicate of the current configuration into another one.
  52506. * @param anisotropicConfiguration define the config where to copy the info
  52507. */
  52508. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52509. /**
  52510. * Serializes this anisotropy configuration.
  52511. * @returns - An object with the serialized config.
  52512. */
  52513. serialize(): any;
  52514. /**
  52515. * Parses a anisotropy Configuration from a serialized object.
  52516. * @param source - Serialized object.
  52517. * @param scene Defines the scene we are parsing for
  52518. * @param rootUrl Defines the rootUrl to load from
  52519. */
  52520. parse(source: any, scene: Scene, rootUrl: string): void;
  52521. }
  52522. }
  52523. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52524. import { Scene } from "babylonjs/scene";
  52525. /**
  52526. * @hidden
  52527. */
  52528. export interface IMaterialBRDFDefines {
  52529. BRDF_V_HEIGHT_CORRELATED: boolean;
  52530. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52531. SPHERICAL_HARMONICS: boolean;
  52532. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52533. /** @hidden */
  52534. _areMiscDirty: boolean;
  52535. }
  52536. /**
  52537. * Define the code related to the BRDF parameters of the pbr material.
  52538. */
  52539. export class PBRBRDFConfiguration {
  52540. /**
  52541. * Default value used for the energy conservation.
  52542. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52543. */
  52544. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52545. /**
  52546. * Default value used for the Smith Visibility Height Correlated mode.
  52547. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52548. */
  52549. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52550. /**
  52551. * Default value used for the IBL diffuse part.
  52552. * This can help switching back to the polynomials mode globally which is a tiny bit
  52553. * less GPU intensive at the drawback of a lower quality.
  52554. */
  52555. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52556. /**
  52557. * Default value used for activating energy conservation for the specular workflow.
  52558. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52559. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52560. */
  52561. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52562. private _useEnergyConservation;
  52563. /**
  52564. * Defines if the material uses energy conservation.
  52565. */
  52566. useEnergyConservation: boolean;
  52567. private _useSmithVisibilityHeightCorrelated;
  52568. /**
  52569. * LEGACY Mode set to false
  52570. * Defines if the material uses height smith correlated visibility term.
  52571. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52572. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52573. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52574. * Not relying on height correlated will also disable energy conservation.
  52575. */
  52576. useSmithVisibilityHeightCorrelated: boolean;
  52577. private _useSphericalHarmonics;
  52578. /**
  52579. * LEGACY Mode set to false
  52580. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52581. * diffuse part of the IBL.
  52582. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52583. * to the ground truth.
  52584. */
  52585. useSphericalHarmonics: boolean;
  52586. private _useSpecularGlossinessInputEnergyConservation;
  52587. /**
  52588. * Defines if the material uses energy conservation, when the specular workflow is active.
  52589. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52590. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52591. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52592. */
  52593. useSpecularGlossinessInputEnergyConservation: boolean;
  52594. /** @hidden */
  52595. private _internalMarkAllSubMeshesAsMiscDirty;
  52596. /** @hidden */
  52597. _markAllSubMeshesAsMiscDirty(): void;
  52598. /**
  52599. * Instantiate a new istance of clear coat configuration.
  52600. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52601. */
  52602. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52603. /**
  52604. * Checks to see if a texture is used in the material.
  52605. * @param defines the list of "defines" to update.
  52606. */
  52607. prepareDefines(defines: IMaterialBRDFDefines): void;
  52608. /**
  52609. * Get the current class name of the texture useful for serialization or dynamic coding.
  52610. * @returns "PBRClearCoatConfiguration"
  52611. */
  52612. getClassName(): string;
  52613. /**
  52614. * Makes a duplicate of the current configuration into another one.
  52615. * @param brdfConfiguration define the config where to copy the info
  52616. */
  52617. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52618. /**
  52619. * Serializes this BRDF configuration.
  52620. * @returns - An object with the serialized config.
  52621. */
  52622. serialize(): any;
  52623. /**
  52624. * Parses a anisotropy Configuration from a serialized object.
  52625. * @param source - Serialized object.
  52626. * @param scene Defines the scene we are parsing for
  52627. * @param rootUrl Defines the rootUrl to load from
  52628. */
  52629. parse(source: any, scene: Scene, rootUrl: string): void;
  52630. }
  52631. }
  52632. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52633. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52634. import { Color3 } from "babylonjs/Maths/math.color";
  52635. import { Scene } from "babylonjs/scene";
  52636. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52637. import { Nullable } from "babylonjs/types";
  52638. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52639. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52640. /**
  52641. * @hidden
  52642. */
  52643. export interface IMaterialSheenDefines {
  52644. SHEEN: boolean;
  52645. SHEEN_TEXTURE: boolean;
  52646. SHEEN_TEXTUREDIRECTUV: number;
  52647. SHEEN_LINKWITHALBEDO: boolean;
  52648. SHEEN_ROUGHNESS: boolean;
  52649. SHEEN_ALBEDOSCALING: boolean;
  52650. /** @hidden */
  52651. _areTexturesDirty: boolean;
  52652. }
  52653. /**
  52654. * Define the code related to the Sheen parameters of the pbr material.
  52655. */
  52656. export class PBRSheenConfiguration {
  52657. private _isEnabled;
  52658. /**
  52659. * Defines if the material uses sheen.
  52660. */
  52661. isEnabled: boolean;
  52662. private _linkSheenWithAlbedo;
  52663. /**
  52664. * Defines if the sheen is linked to the sheen color.
  52665. */
  52666. linkSheenWithAlbedo: boolean;
  52667. /**
  52668. * Defines the sheen intensity.
  52669. */
  52670. intensity: number;
  52671. /**
  52672. * Defines the sheen color.
  52673. */
  52674. color: Color3;
  52675. private _texture;
  52676. /**
  52677. * Stores the sheen tint values in a texture.
  52678. * rgb is tint
  52679. * a is a intensity
  52680. */
  52681. texture: Nullable<BaseTexture>;
  52682. private _roughness;
  52683. /**
  52684. * Defines the sheen roughness.
  52685. * It is not taken into account if linkSheenWithAlbedo is true.
  52686. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52687. */
  52688. roughness: Nullable<number>;
  52689. private _albedoScaling;
  52690. /**
  52691. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52692. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52693. * making it easier to setup and tweak the effect
  52694. */
  52695. albedoScaling: boolean;
  52696. /** @hidden */
  52697. private _internalMarkAllSubMeshesAsTexturesDirty;
  52698. /** @hidden */
  52699. _markAllSubMeshesAsTexturesDirty(): void;
  52700. /**
  52701. * Instantiate a new istance of clear coat configuration.
  52702. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52703. */
  52704. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52705. /**
  52706. * Specifies that the submesh is ready to be used.
  52707. * @param defines the list of "defines" to update.
  52708. * @param scene defines the scene the material belongs to.
  52709. * @returns - boolean indicating that the submesh is ready or not.
  52710. */
  52711. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52712. /**
  52713. * Checks to see if a texture is used in the material.
  52714. * @param defines the list of "defines" to update.
  52715. * @param scene defines the scene the material belongs to.
  52716. */
  52717. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52718. /**
  52719. * Binds the material data.
  52720. * @param uniformBuffer defines the Uniform buffer to fill in.
  52721. * @param scene defines the scene the material belongs to.
  52722. * @param isFrozen defines wether the material is frozen or not.
  52723. */
  52724. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52725. /**
  52726. * Checks to see if a texture is used in the material.
  52727. * @param texture - Base texture to use.
  52728. * @returns - Boolean specifying if a texture is used in the material.
  52729. */
  52730. hasTexture(texture: BaseTexture): boolean;
  52731. /**
  52732. * Returns an array of the actively used textures.
  52733. * @param activeTextures Array of BaseTextures
  52734. */
  52735. getActiveTextures(activeTextures: BaseTexture[]): void;
  52736. /**
  52737. * Returns the animatable textures.
  52738. * @param animatables Array of animatable textures.
  52739. */
  52740. getAnimatables(animatables: IAnimatable[]): void;
  52741. /**
  52742. * Disposes the resources of the material.
  52743. * @param forceDisposeTextures - Forces the disposal of all textures.
  52744. */
  52745. dispose(forceDisposeTextures?: boolean): void;
  52746. /**
  52747. * Get the current class name of the texture useful for serialization or dynamic coding.
  52748. * @returns "PBRSheenConfiguration"
  52749. */
  52750. getClassName(): string;
  52751. /**
  52752. * Add fallbacks to the effect fallbacks list.
  52753. * @param defines defines the Base texture to use.
  52754. * @param fallbacks defines the current fallback list.
  52755. * @param currentRank defines the current fallback rank.
  52756. * @returns the new fallback rank.
  52757. */
  52758. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52759. /**
  52760. * Add the required uniforms to the current list.
  52761. * @param uniforms defines the current uniform list.
  52762. */
  52763. static AddUniforms(uniforms: string[]): void;
  52764. /**
  52765. * Add the required uniforms to the current buffer.
  52766. * @param uniformBuffer defines the current uniform buffer.
  52767. */
  52768. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52769. /**
  52770. * Add the required samplers to the current list.
  52771. * @param samplers defines the current sampler list.
  52772. */
  52773. static AddSamplers(samplers: string[]): void;
  52774. /**
  52775. * Makes a duplicate of the current configuration into another one.
  52776. * @param sheenConfiguration define the config where to copy the info
  52777. */
  52778. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52779. /**
  52780. * Serializes this BRDF configuration.
  52781. * @returns - An object with the serialized config.
  52782. */
  52783. serialize(): any;
  52784. /**
  52785. * Parses a anisotropy Configuration from a serialized object.
  52786. * @param source - Serialized object.
  52787. * @param scene Defines the scene we are parsing for
  52788. * @param rootUrl Defines the rootUrl to load from
  52789. */
  52790. parse(source: any, scene: Scene, rootUrl: string): void;
  52791. }
  52792. }
  52793. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52794. import { Nullable } from "babylonjs/types";
  52795. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52796. import { Color3 } from "babylonjs/Maths/math.color";
  52797. import { SmartArray } from "babylonjs/Misc/smartArray";
  52798. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52800. import { Effect } from "babylonjs/Materials/effect";
  52801. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52802. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52803. import { Engine } from "babylonjs/Engines/engine";
  52804. import { Scene } from "babylonjs/scene";
  52805. /**
  52806. * @hidden
  52807. */
  52808. export interface IMaterialSubSurfaceDefines {
  52809. SUBSURFACE: boolean;
  52810. SS_REFRACTION: boolean;
  52811. SS_TRANSLUCENCY: boolean;
  52812. SS_SCATERRING: boolean;
  52813. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52814. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52815. SS_REFRACTIONMAP_3D: boolean;
  52816. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52817. SS_LODINREFRACTIONALPHA: boolean;
  52818. SS_GAMMAREFRACTION: boolean;
  52819. SS_RGBDREFRACTION: boolean;
  52820. SS_LINEARSPECULARREFRACTION: boolean;
  52821. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52822. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52823. /** @hidden */
  52824. _areTexturesDirty: boolean;
  52825. }
  52826. /**
  52827. * Define the code related to the sub surface parameters of the pbr material.
  52828. */
  52829. export class PBRSubSurfaceConfiguration {
  52830. private _isRefractionEnabled;
  52831. /**
  52832. * Defines if the refraction is enabled in the material.
  52833. */
  52834. isRefractionEnabled: boolean;
  52835. private _isTranslucencyEnabled;
  52836. /**
  52837. * Defines if the translucency is enabled in the material.
  52838. */
  52839. isTranslucencyEnabled: boolean;
  52840. private _isScatteringEnabled;
  52841. /**
  52842. * Defines the refraction intensity of the material.
  52843. * The refraction when enabled replaces the Diffuse part of the material.
  52844. * The intensity helps transitionning between diffuse and refraction.
  52845. */
  52846. refractionIntensity: number;
  52847. /**
  52848. * Defines the translucency intensity of the material.
  52849. * When translucency has been enabled, this defines how much of the "translucency"
  52850. * is addded to the diffuse part of the material.
  52851. */
  52852. translucencyIntensity: number;
  52853. /**
  52854. * Defines the scattering intensity of the material.
  52855. * When scattering has been enabled, this defines how much of the "scattered light"
  52856. * is addded to the diffuse part of the material.
  52857. */
  52858. scatteringIntensity: number;
  52859. private _thicknessTexture;
  52860. /**
  52861. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52862. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52863. * 0 would mean minimumThickness
  52864. * 1 would mean maximumThickness
  52865. * The other channels might be use as a mask to vary the different effects intensity.
  52866. */
  52867. thicknessTexture: Nullable<BaseTexture>;
  52868. private _refractionTexture;
  52869. /**
  52870. * Defines the texture to use for refraction.
  52871. */
  52872. refractionTexture: Nullable<BaseTexture>;
  52873. private _indexOfRefraction;
  52874. /**
  52875. * Defines the index of refraction used in the material.
  52876. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52877. */
  52878. indexOfRefraction: number;
  52879. private _invertRefractionY;
  52880. /**
  52881. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52882. */
  52883. invertRefractionY: boolean;
  52884. private _linkRefractionWithTransparency;
  52885. /**
  52886. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52887. * Materials half opaque for instance using refraction could benefit from this control.
  52888. */
  52889. linkRefractionWithTransparency: boolean;
  52890. /**
  52891. * Defines the minimum thickness stored in the thickness map.
  52892. * If no thickness map is defined, this value will be used to simulate thickness.
  52893. */
  52894. minimumThickness: number;
  52895. /**
  52896. * Defines the maximum thickness stored in the thickness map.
  52897. */
  52898. maximumThickness: number;
  52899. /**
  52900. * Defines the volume tint of the material.
  52901. * This is used for both translucency and scattering.
  52902. */
  52903. tintColor: Color3;
  52904. /**
  52905. * Defines the distance at which the tint color should be found in the media.
  52906. * This is used for refraction only.
  52907. */
  52908. tintColorAtDistance: number;
  52909. /**
  52910. * Defines how far each channel transmit through the media.
  52911. * It is defined as a color to simplify it selection.
  52912. */
  52913. diffusionDistance: Color3;
  52914. private _useMaskFromThicknessTexture;
  52915. /**
  52916. * Stores the intensity of the different subsurface effects in the thickness texture.
  52917. * * the green channel is the translucency intensity.
  52918. * * the blue channel is the scattering intensity.
  52919. * * the alpha channel is the refraction intensity.
  52920. */
  52921. useMaskFromThicknessTexture: boolean;
  52922. /** @hidden */
  52923. private _internalMarkAllSubMeshesAsTexturesDirty;
  52924. /** @hidden */
  52925. _markAllSubMeshesAsTexturesDirty(): void;
  52926. /**
  52927. * Instantiate a new istance of sub surface configuration.
  52928. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52929. */
  52930. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52931. /**
  52932. * Gets wehter the submesh is ready to be used or not.
  52933. * @param defines the list of "defines" to update.
  52934. * @param scene defines the scene the material belongs to.
  52935. * @returns - boolean indicating that the submesh is ready or not.
  52936. */
  52937. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52938. /**
  52939. * Checks to see if a texture is used in the material.
  52940. * @param defines the list of "defines" to update.
  52941. * @param scene defines the scene to the material belongs to.
  52942. */
  52943. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52944. /**
  52945. * Binds the material data.
  52946. * @param uniformBuffer defines the Uniform buffer to fill in.
  52947. * @param scene defines the scene the material belongs to.
  52948. * @param engine defines the engine the material belongs to.
  52949. * @param isFrozen defines wether the material is frozen or not.
  52950. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52951. */
  52952. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52953. /**
  52954. * Unbinds the material from the mesh.
  52955. * @param activeEffect defines the effect that should be unbound from.
  52956. * @returns true if unbound, otherwise false
  52957. */
  52958. unbind(activeEffect: Effect): boolean;
  52959. /**
  52960. * Returns the texture used for refraction or null if none is used.
  52961. * @param scene defines the scene the material belongs to.
  52962. * @returns - Refraction texture if present. If no refraction texture and refraction
  52963. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52964. */
  52965. private _getRefractionTexture;
  52966. /**
  52967. * Returns true if alpha blending should be disabled.
  52968. */
  52969. get disableAlphaBlending(): boolean;
  52970. /**
  52971. * Fills the list of render target textures.
  52972. * @param renderTargets the list of render targets to update
  52973. */
  52974. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52975. /**
  52976. * Checks to see if a texture is used in the material.
  52977. * @param texture - Base texture to use.
  52978. * @returns - Boolean specifying if a texture is used in the material.
  52979. */
  52980. hasTexture(texture: BaseTexture): boolean;
  52981. /**
  52982. * Gets a boolean indicating that current material needs to register RTT
  52983. * @returns true if this uses a render target otherwise false.
  52984. */
  52985. hasRenderTargetTextures(): boolean;
  52986. /**
  52987. * Returns an array of the actively used textures.
  52988. * @param activeTextures Array of BaseTextures
  52989. */
  52990. getActiveTextures(activeTextures: BaseTexture[]): void;
  52991. /**
  52992. * Returns the animatable textures.
  52993. * @param animatables Array of animatable textures.
  52994. */
  52995. getAnimatables(animatables: IAnimatable[]): void;
  52996. /**
  52997. * Disposes the resources of the material.
  52998. * @param forceDisposeTextures - Forces the disposal of all textures.
  52999. */
  53000. dispose(forceDisposeTextures?: boolean): void;
  53001. /**
  53002. * Get the current class name of the texture useful for serialization or dynamic coding.
  53003. * @returns "PBRSubSurfaceConfiguration"
  53004. */
  53005. getClassName(): string;
  53006. /**
  53007. * Add fallbacks to the effect fallbacks list.
  53008. * @param defines defines the Base texture to use.
  53009. * @param fallbacks defines the current fallback list.
  53010. * @param currentRank defines the current fallback rank.
  53011. * @returns the new fallback rank.
  53012. */
  53013. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53014. /**
  53015. * Add the required uniforms to the current list.
  53016. * @param uniforms defines the current uniform list.
  53017. */
  53018. static AddUniforms(uniforms: string[]): void;
  53019. /**
  53020. * Add the required samplers to the current list.
  53021. * @param samplers defines the current sampler list.
  53022. */
  53023. static AddSamplers(samplers: string[]): void;
  53024. /**
  53025. * Add the required uniforms to the current buffer.
  53026. * @param uniformBuffer defines the current uniform buffer.
  53027. */
  53028. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53029. /**
  53030. * Makes a duplicate of the current configuration into another one.
  53031. * @param configuration define the config where to copy the info
  53032. */
  53033. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53034. /**
  53035. * Serializes this Sub Surface configuration.
  53036. * @returns - An object with the serialized config.
  53037. */
  53038. serialize(): any;
  53039. /**
  53040. * Parses a anisotropy Configuration from a serialized object.
  53041. * @param source - Serialized object.
  53042. * @param scene Defines the scene we are parsing for
  53043. * @param rootUrl Defines the rootUrl to load from
  53044. */
  53045. parse(source: any, scene: Scene, rootUrl: string): void;
  53046. }
  53047. }
  53048. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53049. /** @hidden */
  53050. export var pbrFragmentDeclaration: {
  53051. name: string;
  53052. shader: string;
  53053. };
  53054. }
  53055. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53056. /** @hidden */
  53057. export var pbrUboDeclaration: {
  53058. name: string;
  53059. shader: string;
  53060. };
  53061. }
  53062. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53063. /** @hidden */
  53064. export var pbrFragmentExtraDeclaration: {
  53065. name: string;
  53066. shader: string;
  53067. };
  53068. }
  53069. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53070. /** @hidden */
  53071. export var pbrFragmentSamplersDeclaration: {
  53072. name: string;
  53073. shader: string;
  53074. };
  53075. }
  53076. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53077. /** @hidden */
  53078. export var pbrHelperFunctions: {
  53079. name: string;
  53080. shader: string;
  53081. };
  53082. }
  53083. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53084. /** @hidden */
  53085. export var harmonicsFunctions: {
  53086. name: string;
  53087. shader: string;
  53088. };
  53089. }
  53090. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53091. /** @hidden */
  53092. export var pbrDirectLightingSetupFunctions: {
  53093. name: string;
  53094. shader: string;
  53095. };
  53096. }
  53097. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53098. /** @hidden */
  53099. export var pbrDirectLightingFalloffFunctions: {
  53100. name: string;
  53101. shader: string;
  53102. };
  53103. }
  53104. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53105. /** @hidden */
  53106. export var pbrBRDFFunctions: {
  53107. name: string;
  53108. shader: string;
  53109. };
  53110. }
  53111. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53112. /** @hidden */
  53113. export var pbrDirectLightingFunctions: {
  53114. name: string;
  53115. shader: string;
  53116. };
  53117. }
  53118. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53119. /** @hidden */
  53120. export var pbrIBLFunctions: {
  53121. name: string;
  53122. shader: string;
  53123. };
  53124. }
  53125. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53126. /** @hidden */
  53127. export var pbrDebug: {
  53128. name: string;
  53129. shader: string;
  53130. };
  53131. }
  53132. declare module "babylonjs/Shaders/pbr.fragment" {
  53133. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53134. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53135. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53136. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53137. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53138. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53139. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53140. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53141. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53142. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53143. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53144. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53145. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53146. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53147. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53148. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53149. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53150. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53151. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53152. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53153. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53154. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53155. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53156. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53157. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53158. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53159. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53160. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53161. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53162. /** @hidden */
  53163. export var pbrPixelShader: {
  53164. name: string;
  53165. shader: string;
  53166. };
  53167. }
  53168. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53169. /** @hidden */
  53170. export var pbrVertexDeclaration: {
  53171. name: string;
  53172. shader: string;
  53173. };
  53174. }
  53175. declare module "babylonjs/Shaders/pbr.vertex" {
  53176. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53177. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53178. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53179. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53180. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53181. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53182. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53183. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53184. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53185. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53186. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53189. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53190. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53191. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53192. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53193. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53194. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53195. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53196. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53197. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53198. /** @hidden */
  53199. export var pbrVertexShader: {
  53200. name: string;
  53201. shader: string;
  53202. };
  53203. }
  53204. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53205. import { Nullable } from "babylonjs/types";
  53206. import { Scene } from "babylonjs/scene";
  53207. import { Matrix } from "babylonjs/Maths/math.vector";
  53208. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53210. import { Mesh } from "babylonjs/Meshes/mesh";
  53211. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53212. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53213. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53214. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53215. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53216. import { Color3 } from "babylonjs/Maths/math.color";
  53217. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53218. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53219. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53220. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53222. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53223. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53224. import "babylonjs/Shaders/pbr.fragment";
  53225. import "babylonjs/Shaders/pbr.vertex";
  53226. /**
  53227. * Manages the defines for the PBR Material.
  53228. * @hidden
  53229. */
  53230. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53231. PBR: boolean;
  53232. MAINUV1: boolean;
  53233. MAINUV2: boolean;
  53234. UV1: boolean;
  53235. UV2: boolean;
  53236. ALBEDO: boolean;
  53237. GAMMAALBEDO: boolean;
  53238. ALBEDODIRECTUV: number;
  53239. VERTEXCOLOR: boolean;
  53240. AMBIENT: boolean;
  53241. AMBIENTDIRECTUV: number;
  53242. AMBIENTINGRAYSCALE: boolean;
  53243. OPACITY: boolean;
  53244. VERTEXALPHA: boolean;
  53245. OPACITYDIRECTUV: number;
  53246. OPACITYRGB: boolean;
  53247. ALPHATEST: boolean;
  53248. DEPTHPREPASS: boolean;
  53249. ALPHABLEND: boolean;
  53250. ALPHAFROMALBEDO: boolean;
  53251. ALPHATESTVALUE: string;
  53252. SPECULAROVERALPHA: boolean;
  53253. RADIANCEOVERALPHA: boolean;
  53254. ALPHAFRESNEL: boolean;
  53255. LINEARALPHAFRESNEL: boolean;
  53256. PREMULTIPLYALPHA: boolean;
  53257. EMISSIVE: boolean;
  53258. EMISSIVEDIRECTUV: number;
  53259. REFLECTIVITY: boolean;
  53260. REFLECTIVITYDIRECTUV: number;
  53261. SPECULARTERM: boolean;
  53262. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53263. MICROSURFACEAUTOMATIC: boolean;
  53264. LODBASEDMICROSFURACE: boolean;
  53265. MICROSURFACEMAP: boolean;
  53266. MICROSURFACEMAPDIRECTUV: number;
  53267. METALLICWORKFLOW: boolean;
  53268. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53269. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53270. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53271. AOSTOREINMETALMAPRED: boolean;
  53272. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53273. ENVIRONMENTBRDF: boolean;
  53274. ENVIRONMENTBRDF_RGBD: boolean;
  53275. NORMAL: boolean;
  53276. TANGENT: boolean;
  53277. BUMP: boolean;
  53278. BUMPDIRECTUV: number;
  53279. OBJECTSPACE_NORMALMAP: boolean;
  53280. PARALLAX: boolean;
  53281. PARALLAXOCCLUSION: boolean;
  53282. NORMALXYSCALE: boolean;
  53283. LIGHTMAP: boolean;
  53284. LIGHTMAPDIRECTUV: number;
  53285. USELIGHTMAPASSHADOWMAP: boolean;
  53286. GAMMALIGHTMAP: boolean;
  53287. RGBDLIGHTMAP: boolean;
  53288. REFLECTION: boolean;
  53289. REFLECTIONMAP_3D: boolean;
  53290. REFLECTIONMAP_SPHERICAL: boolean;
  53291. REFLECTIONMAP_PLANAR: boolean;
  53292. REFLECTIONMAP_CUBIC: boolean;
  53293. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53294. REFLECTIONMAP_PROJECTION: boolean;
  53295. REFLECTIONMAP_SKYBOX: boolean;
  53296. REFLECTIONMAP_EXPLICIT: boolean;
  53297. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53298. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53299. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53300. INVERTCUBICMAP: boolean;
  53301. USESPHERICALFROMREFLECTIONMAP: boolean;
  53302. USEIRRADIANCEMAP: boolean;
  53303. SPHERICAL_HARMONICS: boolean;
  53304. USESPHERICALINVERTEX: boolean;
  53305. REFLECTIONMAP_OPPOSITEZ: boolean;
  53306. LODINREFLECTIONALPHA: boolean;
  53307. GAMMAREFLECTION: boolean;
  53308. RGBDREFLECTION: boolean;
  53309. LINEARSPECULARREFLECTION: boolean;
  53310. RADIANCEOCCLUSION: boolean;
  53311. HORIZONOCCLUSION: boolean;
  53312. INSTANCES: boolean;
  53313. NUM_BONE_INFLUENCERS: number;
  53314. BonesPerMesh: number;
  53315. BONETEXTURE: boolean;
  53316. NONUNIFORMSCALING: boolean;
  53317. MORPHTARGETS: boolean;
  53318. MORPHTARGETS_NORMAL: boolean;
  53319. MORPHTARGETS_TANGENT: boolean;
  53320. MORPHTARGETS_UV: boolean;
  53321. NUM_MORPH_INFLUENCERS: number;
  53322. IMAGEPROCESSING: boolean;
  53323. VIGNETTE: boolean;
  53324. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53325. VIGNETTEBLENDMODEOPAQUE: boolean;
  53326. TONEMAPPING: boolean;
  53327. TONEMAPPING_ACES: boolean;
  53328. CONTRAST: boolean;
  53329. COLORCURVES: boolean;
  53330. COLORGRADING: boolean;
  53331. COLORGRADING3D: boolean;
  53332. SAMPLER3DGREENDEPTH: boolean;
  53333. SAMPLER3DBGRMAP: boolean;
  53334. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53335. EXPOSURE: boolean;
  53336. MULTIVIEW: boolean;
  53337. USEPHYSICALLIGHTFALLOFF: boolean;
  53338. USEGLTFLIGHTFALLOFF: boolean;
  53339. TWOSIDEDLIGHTING: boolean;
  53340. SHADOWFLOAT: boolean;
  53341. CLIPPLANE: boolean;
  53342. CLIPPLANE2: boolean;
  53343. CLIPPLANE3: boolean;
  53344. CLIPPLANE4: boolean;
  53345. CLIPPLANE5: boolean;
  53346. CLIPPLANE6: boolean;
  53347. POINTSIZE: boolean;
  53348. FOG: boolean;
  53349. LOGARITHMICDEPTH: boolean;
  53350. FORCENORMALFORWARD: boolean;
  53351. SPECULARAA: boolean;
  53352. CLEARCOAT: boolean;
  53353. CLEARCOAT_DEFAULTIOR: boolean;
  53354. CLEARCOAT_TEXTURE: boolean;
  53355. CLEARCOAT_TEXTUREDIRECTUV: number;
  53356. CLEARCOAT_BUMP: boolean;
  53357. CLEARCOAT_BUMPDIRECTUV: number;
  53358. CLEARCOAT_TINT: boolean;
  53359. CLEARCOAT_TINT_TEXTURE: boolean;
  53360. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53361. ANISOTROPIC: boolean;
  53362. ANISOTROPIC_TEXTURE: boolean;
  53363. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53364. BRDF_V_HEIGHT_CORRELATED: boolean;
  53365. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53366. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53367. SHEEN: boolean;
  53368. SHEEN_TEXTURE: boolean;
  53369. SHEEN_TEXTUREDIRECTUV: number;
  53370. SHEEN_LINKWITHALBEDO: boolean;
  53371. SHEEN_ROUGHNESS: boolean;
  53372. SHEEN_ALBEDOSCALING: boolean;
  53373. SUBSURFACE: boolean;
  53374. SS_REFRACTION: boolean;
  53375. SS_TRANSLUCENCY: boolean;
  53376. SS_SCATERRING: boolean;
  53377. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53378. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53379. SS_REFRACTIONMAP_3D: boolean;
  53380. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53381. SS_LODINREFRACTIONALPHA: boolean;
  53382. SS_GAMMAREFRACTION: boolean;
  53383. SS_RGBDREFRACTION: boolean;
  53384. SS_LINEARSPECULARREFRACTION: boolean;
  53385. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53386. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53387. UNLIT: boolean;
  53388. DEBUGMODE: number;
  53389. /**
  53390. * Initializes the PBR Material defines.
  53391. */
  53392. constructor();
  53393. /**
  53394. * Resets the PBR Material defines.
  53395. */
  53396. reset(): void;
  53397. }
  53398. /**
  53399. * The Physically based material base class of BJS.
  53400. *
  53401. * This offers the main features of a standard PBR material.
  53402. * For more information, please refer to the documentation :
  53403. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53404. */
  53405. export abstract class PBRBaseMaterial extends PushMaterial {
  53406. /**
  53407. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53408. */
  53409. static readonly PBRMATERIAL_OPAQUE: number;
  53410. /**
  53411. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53412. */
  53413. static readonly PBRMATERIAL_ALPHATEST: number;
  53414. /**
  53415. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53416. */
  53417. static readonly PBRMATERIAL_ALPHABLEND: number;
  53418. /**
  53419. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53420. * They are also discarded below the alpha cutoff threshold to improve performances.
  53421. */
  53422. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53423. /**
  53424. * Defines the default value of how much AO map is occluding the analytical lights
  53425. * (point spot...).
  53426. */
  53427. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53428. /**
  53429. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53430. */
  53431. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53432. /**
  53433. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53434. * to enhance interoperability with other engines.
  53435. */
  53436. static readonly LIGHTFALLOFF_GLTF: number;
  53437. /**
  53438. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53439. * to enhance interoperability with other materials.
  53440. */
  53441. static readonly LIGHTFALLOFF_STANDARD: number;
  53442. /**
  53443. * Intensity of the direct lights e.g. the four lights available in your scene.
  53444. * This impacts both the direct diffuse and specular highlights.
  53445. */
  53446. protected _directIntensity: number;
  53447. /**
  53448. * Intensity of the emissive part of the material.
  53449. * This helps controlling the emissive effect without modifying the emissive color.
  53450. */
  53451. protected _emissiveIntensity: number;
  53452. /**
  53453. * Intensity of the environment e.g. how much the environment will light the object
  53454. * either through harmonics for rough material or through the refelction for shiny ones.
  53455. */
  53456. protected _environmentIntensity: number;
  53457. /**
  53458. * This is a special control allowing the reduction of the specular highlights coming from the
  53459. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53460. */
  53461. protected _specularIntensity: number;
  53462. /**
  53463. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53464. */
  53465. private _lightingInfos;
  53466. /**
  53467. * Debug Control allowing disabling the bump map on this material.
  53468. */
  53469. protected _disableBumpMap: boolean;
  53470. /**
  53471. * AKA Diffuse Texture in standard nomenclature.
  53472. */
  53473. protected _albedoTexture: Nullable<BaseTexture>;
  53474. /**
  53475. * AKA Occlusion Texture in other nomenclature.
  53476. */
  53477. protected _ambientTexture: Nullable<BaseTexture>;
  53478. /**
  53479. * AKA Occlusion Texture Intensity in other nomenclature.
  53480. */
  53481. protected _ambientTextureStrength: number;
  53482. /**
  53483. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53484. * 1 means it completely occludes it
  53485. * 0 mean it has no impact
  53486. */
  53487. protected _ambientTextureImpactOnAnalyticalLights: number;
  53488. /**
  53489. * Stores the alpha values in a texture.
  53490. */
  53491. protected _opacityTexture: Nullable<BaseTexture>;
  53492. /**
  53493. * Stores the reflection values in a texture.
  53494. */
  53495. protected _reflectionTexture: Nullable<BaseTexture>;
  53496. /**
  53497. * Stores the emissive values in a texture.
  53498. */
  53499. protected _emissiveTexture: Nullable<BaseTexture>;
  53500. /**
  53501. * AKA Specular texture in other nomenclature.
  53502. */
  53503. protected _reflectivityTexture: Nullable<BaseTexture>;
  53504. /**
  53505. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53506. */
  53507. protected _metallicTexture: Nullable<BaseTexture>;
  53508. /**
  53509. * Specifies the metallic scalar of the metallic/roughness workflow.
  53510. * Can also be used to scale the metalness values of the metallic texture.
  53511. */
  53512. protected _metallic: Nullable<number>;
  53513. /**
  53514. * Specifies the roughness scalar of the metallic/roughness workflow.
  53515. * Can also be used to scale the roughness values of the metallic texture.
  53516. */
  53517. protected _roughness: Nullable<number>;
  53518. /**
  53519. * Specifies the an F0 factor to help configuring the material F0.
  53520. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53521. * to 0.5 the previously hard coded value stays the same.
  53522. * Can also be used to scale the F0 values of the metallic texture.
  53523. */
  53524. protected _metallicF0Factor: number;
  53525. /**
  53526. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53527. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53528. * your expectation as it multiplies with the texture data.
  53529. */
  53530. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53531. /**
  53532. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53533. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53534. */
  53535. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53536. /**
  53537. * Stores surface normal data used to displace a mesh in a texture.
  53538. */
  53539. protected _bumpTexture: Nullable<BaseTexture>;
  53540. /**
  53541. * Stores the pre-calculated light information of a mesh in a texture.
  53542. */
  53543. protected _lightmapTexture: Nullable<BaseTexture>;
  53544. /**
  53545. * The color of a material in ambient lighting.
  53546. */
  53547. protected _ambientColor: Color3;
  53548. /**
  53549. * AKA Diffuse Color in other nomenclature.
  53550. */
  53551. protected _albedoColor: Color3;
  53552. /**
  53553. * AKA Specular Color in other nomenclature.
  53554. */
  53555. protected _reflectivityColor: Color3;
  53556. /**
  53557. * The color applied when light is reflected from a material.
  53558. */
  53559. protected _reflectionColor: Color3;
  53560. /**
  53561. * The color applied when light is emitted from a material.
  53562. */
  53563. protected _emissiveColor: Color3;
  53564. /**
  53565. * AKA Glossiness in other nomenclature.
  53566. */
  53567. protected _microSurface: number;
  53568. /**
  53569. * Specifies that the material will use the light map as a show map.
  53570. */
  53571. protected _useLightmapAsShadowmap: boolean;
  53572. /**
  53573. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53574. * makes the reflect vector face the model (under horizon).
  53575. */
  53576. protected _useHorizonOcclusion: boolean;
  53577. /**
  53578. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53579. * too much the area relying on ambient texture to define their ambient occlusion.
  53580. */
  53581. protected _useRadianceOcclusion: boolean;
  53582. /**
  53583. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53584. */
  53585. protected _useAlphaFromAlbedoTexture: boolean;
  53586. /**
  53587. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53588. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53589. */
  53590. protected _useSpecularOverAlpha: boolean;
  53591. /**
  53592. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53593. */
  53594. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53595. /**
  53596. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53597. */
  53598. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53599. /**
  53600. * Specifies if the metallic texture contains the roughness information in its green channel.
  53601. */
  53602. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53603. /**
  53604. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53605. */
  53606. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53607. /**
  53608. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53609. */
  53610. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53611. /**
  53612. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53613. */
  53614. protected _useAmbientInGrayScale: boolean;
  53615. /**
  53616. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53617. * The material will try to infer what glossiness each pixel should be.
  53618. */
  53619. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53620. /**
  53621. * Defines the falloff type used in this material.
  53622. * It by default is Physical.
  53623. */
  53624. protected _lightFalloff: number;
  53625. /**
  53626. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53627. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53628. */
  53629. protected _useRadianceOverAlpha: boolean;
  53630. /**
  53631. * Allows using an object space normal map (instead of tangent space).
  53632. */
  53633. protected _useObjectSpaceNormalMap: boolean;
  53634. /**
  53635. * Allows using the bump map in parallax mode.
  53636. */
  53637. protected _useParallax: boolean;
  53638. /**
  53639. * Allows using the bump map in parallax occlusion mode.
  53640. */
  53641. protected _useParallaxOcclusion: boolean;
  53642. /**
  53643. * Controls the scale bias of the parallax mode.
  53644. */
  53645. protected _parallaxScaleBias: number;
  53646. /**
  53647. * If sets to true, disables all the lights affecting the material.
  53648. */
  53649. protected _disableLighting: boolean;
  53650. /**
  53651. * Number of Simultaneous lights allowed on the material.
  53652. */
  53653. protected _maxSimultaneousLights: number;
  53654. /**
  53655. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53656. */
  53657. protected _invertNormalMapX: boolean;
  53658. /**
  53659. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53660. */
  53661. protected _invertNormalMapY: boolean;
  53662. /**
  53663. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53664. */
  53665. protected _twoSidedLighting: boolean;
  53666. /**
  53667. * Defines the alpha limits in alpha test mode.
  53668. */
  53669. protected _alphaCutOff: number;
  53670. /**
  53671. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53672. */
  53673. protected _forceAlphaTest: boolean;
  53674. /**
  53675. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53676. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53677. */
  53678. protected _useAlphaFresnel: boolean;
  53679. /**
  53680. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53681. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53682. */
  53683. protected _useLinearAlphaFresnel: boolean;
  53684. /**
  53685. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53686. * from cos thetav and roughness:
  53687. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53688. */
  53689. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53690. /**
  53691. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53692. */
  53693. protected _forceIrradianceInFragment: boolean;
  53694. /**
  53695. * Force normal to face away from face.
  53696. */
  53697. protected _forceNormalForward: boolean;
  53698. /**
  53699. * Enables specular anti aliasing in the PBR shader.
  53700. * It will both interacts on the Geometry for analytical and IBL lighting.
  53701. * It also prefilter the roughness map based on the bump values.
  53702. */
  53703. protected _enableSpecularAntiAliasing: boolean;
  53704. /**
  53705. * Default configuration related to image processing available in the PBR Material.
  53706. */
  53707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53708. /**
  53709. * Keep track of the image processing observer to allow dispose and replace.
  53710. */
  53711. private _imageProcessingObserver;
  53712. /**
  53713. * Attaches a new image processing configuration to the PBR Material.
  53714. * @param configuration
  53715. */
  53716. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53717. /**
  53718. * Stores the available render targets.
  53719. */
  53720. private _renderTargets;
  53721. /**
  53722. * Sets the global ambient color for the material used in lighting calculations.
  53723. */
  53724. private _globalAmbientColor;
  53725. /**
  53726. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53727. */
  53728. private _useLogarithmicDepth;
  53729. /**
  53730. * If set to true, no lighting calculations will be applied.
  53731. */
  53732. private _unlit;
  53733. private _debugMode;
  53734. /**
  53735. * @hidden
  53736. * This is reserved for the inspector.
  53737. * Defines the material debug mode.
  53738. * It helps seeing only some components of the material while troubleshooting.
  53739. */
  53740. debugMode: number;
  53741. /**
  53742. * @hidden
  53743. * This is reserved for the inspector.
  53744. * Specify from where on screen the debug mode should start.
  53745. * The value goes from -1 (full screen) to 1 (not visible)
  53746. * It helps with side by side comparison against the final render
  53747. * This defaults to -1
  53748. */
  53749. private debugLimit;
  53750. /**
  53751. * @hidden
  53752. * This is reserved for the inspector.
  53753. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53754. * You can use the factor to better multiply the final value.
  53755. */
  53756. private debugFactor;
  53757. /**
  53758. * Defines the clear coat layer parameters for the material.
  53759. */
  53760. readonly clearCoat: PBRClearCoatConfiguration;
  53761. /**
  53762. * Defines the anisotropic parameters for the material.
  53763. */
  53764. readonly anisotropy: PBRAnisotropicConfiguration;
  53765. /**
  53766. * Defines the BRDF parameters for the material.
  53767. */
  53768. readonly brdf: PBRBRDFConfiguration;
  53769. /**
  53770. * Defines the Sheen parameters for the material.
  53771. */
  53772. readonly sheen: PBRSheenConfiguration;
  53773. /**
  53774. * Defines the SubSurface parameters for the material.
  53775. */
  53776. readonly subSurface: PBRSubSurfaceConfiguration;
  53777. /**
  53778. * Custom callback helping to override the default shader used in the material.
  53779. */
  53780. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53781. protected _rebuildInParallel: boolean;
  53782. /**
  53783. * Instantiates a new PBRMaterial instance.
  53784. *
  53785. * @param name The material name
  53786. * @param scene The scene the material will be use in.
  53787. */
  53788. constructor(name: string, scene: Scene);
  53789. /**
  53790. * Gets a boolean indicating that current material needs to register RTT
  53791. */
  53792. get hasRenderTargetTextures(): boolean;
  53793. /**
  53794. * Gets the name of the material class.
  53795. */
  53796. getClassName(): string;
  53797. /**
  53798. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53799. */
  53800. get useLogarithmicDepth(): boolean;
  53801. /**
  53802. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53803. */
  53804. set useLogarithmicDepth(value: boolean);
  53805. /**
  53806. * Returns true if alpha blending should be disabled.
  53807. */
  53808. protected get _disableAlphaBlending(): boolean;
  53809. /**
  53810. * Specifies whether or not this material should be rendered in alpha blend mode.
  53811. */
  53812. needAlphaBlending(): boolean;
  53813. /**
  53814. * Specifies whether or not this material should be rendered in alpha test mode.
  53815. */
  53816. needAlphaTesting(): boolean;
  53817. /**
  53818. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53819. */
  53820. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53821. /**
  53822. * Gets the texture used for the alpha test.
  53823. */
  53824. getAlphaTestTexture(): Nullable<BaseTexture>;
  53825. /**
  53826. * Specifies that the submesh is ready to be used.
  53827. * @param mesh - BJS mesh.
  53828. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53829. * @param useInstances - Specifies that instances should be used.
  53830. * @returns - boolean indicating that the submesh is ready or not.
  53831. */
  53832. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53833. /**
  53834. * Specifies if the material uses metallic roughness workflow.
  53835. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53836. */
  53837. isMetallicWorkflow(): boolean;
  53838. private _prepareEffect;
  53839. private _prepareDefines;
  53840. /**
  53841. * Force shader compilation
  53842. */
  53843. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53844. /**
  53845. * Initializes the uniform buffer layout for the shader.
  53846. */
  53847. buildUniformLayout(): void;
  53848. /**
  53849. * Unbinds the material from the mesh
  53850. */
  53851. unbind(): void;
  53852. /**
  53853. * Binds the submesh data.
  53854. * @param world - The world matrix.
  53855. * @param mesh - The BJS mesh.
  53856. * @param subMesh - A submesh of the BJS mesh.
  53857. */
  53858. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53859. /**
  53860. * Returns the animatable textures.
  53861. * @returns - Array of animatable textures.
  53862. */
  53863. getAnimatables(): IAnimatable[];
  53864. /**
  53865. * Returns the texture used for reflections.
  53866. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53867. */
  53868. private _getReflectionTexture;
  53869. /**
  53870. * Returns an array of the actively used textures.
  53871. * @returns - Array of BaseTextures
  53872. */
  53873. getActiveTextures(): BaseTexture[];
  53874. /**
  53875. * Checks to see if a texture is used in the material.
  53876. * @param texture - Base texture to use.
  53877. * @returns - Boolean specifying if a texture is used in the material.
  53878. */
  53879. hasTexture(texture: BaseTexture): boolean;
  53880. /**
  53881. * Disposes the resources of the material.
  53882. * @param forceDisposeEffect - Forces the disposal of effects.
  53883. * @param forceDisposeTextures - Forces the disposal of all textures.
  53884. */
  53885. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53886. }
  53887. }
  53888. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53889. import { Nullable } from "babylonjs/types";
  53890. import { Scene } from "babylonjs/scene";
  53891. import { Color3 } from "babylonjs/Maths/math.color";
  53892. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53893. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53895. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53896. /**
  53897. * The Physically based material of BJS.
  53898. *
  53899. * This offers the main features of a standard PBR material.
  53900. * For more information, please refer to the documentation :
  53901. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53902. */
  53903. export class PBRMaterial extends PBRBaseMaterial {
  53904. /**
  53905. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53906. */
  53907. static readonly PBRMATERIAL_OPAQUE: number;
  53908. /**
  53909. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53910. */
  53911. static readonly PBRMATERIAL_ALPHATEST: number;
  53912. /**
  53913. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53914. */
  53915. static readonly PBRMATERIAL_ALPHABLEND: number;
  53916. /**
  53917. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53918. * They are also discarded below the alpha cutoff threshold to improve performances.
  53919. */
  53920. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53921. /**
  53922. * Defines the default value of how much AO map is occluding the analytical lights
  53923. * (point spot...).
  53924. */
  53925. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53926. /**
  53927. * Intensity of the direct lights e.g. the four lights available in your scene.
  53928. * This impacts both the direct diffuse and specular highlights.
  53929. */
  53930. directIntensity: number;
  53931. /**
  53932. * Intensity of the emissive part of the material.
  53933. * This helps controlling the emissive effect without modifying the emissive color.
  53934. */
  53935. emissiveIntensity: number;
  53936. /**
  53937. * Intensity of the environment e.g. how much the environment will light the object
  53938. * either through harmonics for rough material or through the refelction for shiny ones.
  53939. */
  53940. environmentIntensity: number;
  53941. /**
  53942. * This is a special control allowing the reduction of the specular highlights coming from the
  53943. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53944. */
  53945. specularIntensity: number;
  53946. /**
  53947. * Debug Control allowing disabling the bump map on this material.
  53948. */
  53949. disableBumpMap: boolean;
  53950. /**
  53951. * AKA Diffuse Texture in standard nomenclature.
  53952. */
  53953. albedoTexture: BaseTexture;
  53954. /**
  53955. * AKA Occlusion Texture in other nomenclature.
  53956. */
  53957. ambientTexture: BaseTexture;
  53958. /**
  53959. * AKA Occlusion Texture Intensity in other nomenclature.
  53960. */
  53961. ambientTextureStrength: number;
  53962. /**
  53963. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53964. * 1 means it completely occludes it
  53965. * 0 mean it has no impact
  53966. */
  53967. ambientTextureImpactOnAnalyticalLights: number;
  53968. /**
  53969. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53970. */
  53971. opacityTexture: BaseTexture;
  53972. /**
  53973. * Stores the reflection values in a texture.
  53974. */
  53975. reflectionTexture: Nullable<BaseTexture>;
  53976. /**
  53977. * Stores the emissive values in a texture.
  53978. */
  53979. emissiveTexture: BaseTexture;
  53980. /**
  53981. * AKA Specular texture in other nomenclature.
  53982. */
  53983. reflectivityTexture: BaseTexture;
  53984. /**
  53985. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53986. */
  53987. metallicTexture: BaseTexture;
  53988. /**
  53989. * Specifies the metallic scalar of the metallic/roughness workflow.
  53990. * Can also be used to scale the metalness values of the metallic texture.
  53991. */
  53992. metallic: Nullable<number>;
  53993. /**
  53994. * Specifies the roughness scalar of the metallic/roughness workflow.
  53995. * Can also be used to scale the roughness values of the metallic texture.
  53996. */
  53997. roughness: Nullable<number>;
  53998. /**
  53999. * Specifies the an F0 factor to help configuring the material F0.
  54000. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54001. * to 0.5 the previously hard coded value stays the same.
  54002. * Can also be used to scale the F0 values of the metallic texture.
  54003. */
  54004. metallicF0Factor: number;
  54005. /**
  54006. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54007. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54008. * your expectation as it multiplies with the texture data.
  54009. */
  54010. useMetallicF0FactorFromMetallicTexture: boolean;
  54011. /**
  54012. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54013. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54014. */
  54015. microSurfaceTexture: BaseTexture;
  54016. /**
  54017. * Stores surface normal data used to displace a mesh in a texture.
  54018. */
  54019. bumpTexture: BaseTexture;
  54020. /**
  54021. * Stores the pre-calculated light information of a mesh in a texture.
  54022. */
  54023. lightmapTexture: BaseTexture;
  54024. /**
  54025. * Stores the refracted light information in a texture.
  54026. */
  54027. get refractionTexture(): Nullable<BaseTexture>;
  54028. set refractionTexture(value: Nullable<BaseTexture>);
  54029. /**
  54030. * The color of a material in ambient lighting.
  54031. */
  54032. ambientColor: Color3;
  54033. /**
  54034. * AKA Diffuse Color in other nomenclature.
  54035. */
  54036. albedoColor: Color3;
  54037. /**
  54038. * AKA Specular Color in other nomenclature.
  54039. */
  54040. reflectivityColor: Color3;
  54041. /**
  54042. * The color reflected from the material.
  54043. */
  54044. reflectionColor: Color3;
  54045. /**
  54046. * The color emitted from the material.
  54047. */
  54048. emissiveColor: Color3;
  54049. /**
  54050. * AKA Glossiness in other nomenclature.
  54051. */
  54052. microSurface: number;
  54053. /**
  54054. * source material index of refraction (IOR)' / 'destination material IOR.
  54055. */
  54056. get indexOfRefraction(): number;
  54057. set indexOfRefraction(value: number);
  54058. /**
  54059. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54060. */
  54061. get invertRefractionY(): boolean;
  54062. set invertRefractionY(value: boolean);
  54063. /**
  54064. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54065. * Materials half opaque for instance using refraction could benefit from this control.
  54066. */
  54067. get linkRefractionWithTransparency(): boolean;
  54068. set linkRefractionWithTransparency(value: boolean);
  54069. /**
  54070. * If true, the light map contains occlusion information instead of lighting info.
  54071. */
  54072. useLightmapAsShadowmap: boolean;
  54073. /**
  54074. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54075. */
  54076. useAlphaFromAlbedoTexture: boolean;
  54077. /**
  54078. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54079. */
  54080. forceAlphaTest: boolean;
  54081. /**
  54082. * Defines the alpha limits in alpha test mode.
  54083. */
  54084. alphaCutOff: number;
  54085. /**
  54086. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54087. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54088. */
  54089. useSpecularOverAlpha: boolean;
  54090. /**
  54091. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54092. */
  54093. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54094. /**
  54095. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54096. */
  54097. useRoughnessFromMetallicTextureAlpha: boolean;
  54098. /**
  54099. * Specifies if the metallic texture contains the roughness information in its green channel.
  54100. */
  54101. useRoughnessFromMetallicTextureGreen: boolean;
  54102. /**
  54103. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54104. */
  54105. useMetallnessFromMetallicTextureBlue: boolean;
  54106. /**
  54107. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54108. */
  54109. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54110. /**
  54111. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54112. */
  54113. useAmbientInGrayScale: boolean;
  54114. /**
  54115. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54116. * The material will try to infer what glossiness each pixel should be.
  54117. */
  54118. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54119. /**
  54120. * BJS is using an harcoded light falloff based on a manually sets up range.
  54121. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54122. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54123. */
  54124. get usePhysicalLightFalloff(): boolean;
  54125. /**
  54126. * BJS is using an harcoded light falloff based on a manually sets up range.
  54127. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54128. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54129. */
  54130. set usePhysicalLightFalloff(value: boolean);
  54131. /**
  54132. * In order to support the falloff compatibility with gltf, a special mode has been added
  54133. * to reproduce the gltf light falloff.
  54134. */
  54135. get useGLTFLightFalloff(): boolean;
  54136. /**
  54137. * In order to support the falloff compatibility with gltf, a special mode has been added
  54138. * to reproduce the gltf light falloff.
  54139. */
  54140. set useGLTFLightFalloff(value: boolean);
  54141. /**
  54142. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54143. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54144. */
  54145. useRadianceOverAlpha: boolean;
  54146. /**
  54147. * Allows using an object space normal map (instead of tangent space).
  54148. */
  54149. useObjectSpaceNormalMap: boolean;
  54150. /**
  54151. * Allows using the bump map in parallax mode.
  54152. */
  54153. useParallax: boolean;
  54154. /**
  54155. * Allows using the bump map in parallax occlusion mode.
  54156. */
  54157. useParallaxOcclusion: boolean;
  54158. /**
  54159. * Controls the scale bias of the parallax mode.
  54160. */
  54161. parallaxScaleBias: number;
  54162. /**
  54163. * If sets to true, disables all the lights affecting the material.
  54164. */
  54165. disableLighting: boolean;
  54166. /**
  54167. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54168. */
  54169. forceIrradianceInFragment: boolean;
  54170. /**
  54171. * Number of Simultaneous lights allowed on the material.
  54172. */
  54173. maxSimultaneousLights: number;
  54174. /**
  54175. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54176. */
  54177. invertNormalMapX: boolean;
  54178. /**
  54179. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54180. */
  54181. invertNormalMapY: boolean;
  54182. /**
  54183. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54184. */
  54185. twoSidedLighting: boolean;
  54186. /**
  54187. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54188. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54189. */
  54190. useAlphaFresnel: boolean;
  54191. /**
  54192. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54193. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54194. */
  54195. useLinearAlphaFresnel: boolean;
  54196. /**
  54197. * Let user defines the brdf lookup texture used for IBL.
  54198. * A default 8bit version is embedded but you could point at :
  54199. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54200. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54201. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54202. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54203. */
  54204. environmentBRDFTexture: Nullable<BaseTexture>;
  54205. /**
  54206. * Force normal to face away from face.
  54207. */
  54208. forceNormalForward: boolean;
  54209. /**
  54210. * Enables specular anti aliasing in the PBR shader.
  54211. * It will both interacts on the Geometry for analytical and IBL lighting.
  54212. * It also prefilter the roughness map based on the bump values.
  54213. */
  54214. enableSpecularAntiAliasing: boolean;
  54215. /**
  54216. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54217. * makes the reflect vector face the model (under horizon).
  54218. */
  54219. useHorizonOcclusion: boolean;
  54220. /**
  54221. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54222. * too much the area relying on ambient texture to define their ambient occlusion.
  54223. */
  54224. useRadianceOcclusion: boolean;
  54225. /**
  54226. * If set to true, no lighting calculations will be applied.
  54227. */
  54228. unlit: boolean;
  54229. /**
  54230. * Gets the image processing configuration used either in this material.
  54231. */
  54232. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54233. /**
  54234. * Sets the Default image processing configuration used either in the this material.
  54235. *
  54236. * If sets to null, the scene one is in use.
  54237. */
  54238. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54239. /**
  54240. * Gets wether the color curves effect is enabled.
  54241. */
  54242. get cameraColorCurvesEnabled(): boolean;
  54243. /**
  54244. * Sets wether the color curves effect is enabled.
  54245. */
  54246. set cameraColorCurvesEnabled(value: boolean);
  54247. /**
  54248. * Gets wether the color grading effect is enabled.
  54249. */
  54250. get cameraColorGradingEnabled(): boolean;
  54251. /**
  54252. * Gets wether the color grading effect is enabled.
  54253. */
  54254. set cameraColorGradingEnabled(value: boolean);
  54255. /**
  54256. * Gets wether tonemapping is enabled or not.
  54257. */
  54258. get cameraToneMappingEnabled(): boolean;
  54259. /**
  54260. * Sets wether tonemapping is enabled or not
  54261. */
  54262. set cameraToneMappingEnabled(value: boolean);
  54263. /**
  54264. * The camera exposure used on this material.
  54265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54266. * This corresponds to a photographic exposure.
  54267. */
  54268. get cameraExposure(): number;
  54269. /**
  54270. * The camera exposure used on this material.
  54271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54272. * This corresponds to a photographic exposure.
  54273. */
  54274. set cameraExposure(value: number);
  54275. /**
  54276. * Gets The camera contrast used on this material.
  54277. */
  54278. get cameraContrast(): number;
  54279. /**
  54280. * Sets The camera contrast used on this material.
  54281. */
  54282. set cameraContrast(value: number);
  54283. /**
  54284. * Gets the Color Grading 2D Lookup Texture.
  54285. */
  54286. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54287. /**
  54288. * Sets the Color Grading 2D Lookup Texture.
  54289. */
  54290. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54291. /**
  54292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54294. * 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;
  54295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54296. */
  54297. get cameraColorCurves(): Nullable<ColorCurves>;
  54298. /**
  54299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54301. * 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;
  54302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54303. */
  54304. set cameraColorCurves(value: Nullable<ColorCurves>);
  54305. /**
  54306. * Instantiates a new PBRMaterial instance.
  54307. *
  54308. * @param name The material name
  54309. * @param scene The scene the material will be use in.
  54310. */
  54311. constructor(name: string, scene: Scene);
  54312. /**
  54313. * Returns the name of this material class.
  54314. */
  54315. getClassName(): string;
  54316. /**
  54317. * Makes a duplicate of the current material.
  54318. * @param name - name to use for the new material.
  54319. */
  54320. clone(name: string): PBRMaterial;
  54321. /**
  54322. * Serializes this PBR Material.
  54323. * @returns - An object with the serialized material.
  54324. */
  54325. serialize(): any;
  54326. /**
  54327. * Parses a PBR Material from a serialized object.
  54328. * @param source - Serialized object.
  54329. * @param scene - BJS scene instance.
  54330. * @param rootUrl - url for the scene object
  54331. * @returns - PBRMaterial
  54332. */
  54333. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54334. }
  54335. }
  54336. declare module "babylonjs/Misc/dds" {
  54337. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54338. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54339. import { Nullable } from "babylonjs/types";
  54340. import { Scene } from "babylonjs/scene";
  54341. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54342. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54343. /**
  54344. * Direct draw surface info
  54345. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54346. */
  54347. export interface DDSInfo {
  54348. /**
  54349. * Width of the texture
  54350. */
  54351. width: number;
  54352. /**
  54353. * Width of the texture
  54354. */
  54355. height: number;
  54356. /**
  54357. * Number of Mipmaps for the texture
  54358. * @see https://en.wikipedia.org/wiki/Mipmap
  54359. */
  54360. mipmapCount: number;
  54361. /**
  54362. * If the textures format is a known fourCC format
  54363. * @see https://www.fourcc.org/
  54364. */
  54365. isFourCC: boolean;
  54366. /**
  54367. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54368. */
  54369. isRGB: boolean;
  54370. /**
  54371. * If the texture is a lumincance format
  54372. */
  54373. isLuminance: boolean;
  54374. /**
  54375. * If this is a cube texture
  54376. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54377. */
  54378. isCube: boolean;
  54379. /**
  54380. * If the texture is a compressed format eg. FOURCC_DXT1
  54381. */
  54382. isCompressed: boolean;
  54383. /**
  54384. * The dxgiFormat of the texture
  54385. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54386. */
  54387. dxgiFormat: number;
  54388. /**
  54389. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54390. */
  54391. textureType: number;
  54392. /**
  54393. * Sphericle polynomial created for the dds texture
  54394. */
  54395. sphericalPolynomial?: SphericalPolynomial;
  54396. }
  54397. /**
  54398. * Class used to provide DDS decompression tools
  54399. */
  54400. export class DDSTools {
  54401. /**
  54402. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54403. */
  54404. static StoreLODInAlphaChannel: boolean;
  54405. /**
  54406. * Gets DDS information from an array buffer
  54407. * @param data defines the array buffer view to read data from
  54408. * @returns the DDS information
  54409. */
  54410. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54411. private static _FloatView;
  54412. private static _Int32View;
  54413. private static _ToHalfFloat;
  54414. private static _FromHalfFloat;
  54415. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54416. private static _GetHalfFloatRGBAArrayBuffer;
  54417. private static _GetFloatRGBAArrayBuffer;
  54418. private static _GetFloatAsUIntRGBAArrayBuffer;
  54419. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54420. private static _GetRGBAArrayBuffer;
  54421. private static _ExtractLongWordOrder;
  54422. private static _GetRGBArrayBuffer;
  54423. private static _GetLuminanceArrayBuffer;
  54424. /**
  54425. * Uploads DDS Levels to a Babylon Texture
  54426. * @hidden
  54427. */
  54428. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54429. }
  54430. module "babylonjs/Engines/thinEngine" {
  54431. interface ThinEngine {
  54432. /**
  54433. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54434. * @param rootUrl defines the url where the file to load is located
  54435. * @param scene defines the current scene
  54436. * @param lodScale defines scale to apply to the mip map selection
  54437. * @param lodOffset defines offset to apply to the mip map selection
  54438. * @param onLoad defines an optional callback raised when the texture is loaded
  54439. * @param onError defines an optional callback raised if there is an issue to load the texture
  54440. * @param format defines the format of the data
  54441. * @param forcedExtension defines the extension to use to pick the right loader
  54442. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54443. * @returns the cube texture as an InternalTexture
  54444. */
  54445. 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;
  54446. }
  54447. }
  54448. }
  54449. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54450. import { Nullable } from "babylonjs/types";
  54451. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54452. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54453. /**
  54454. * Implementation of the DDS Texture Loader.
  54455. * @hidden
  54456. */
  54457. export class _DDSTextureLoader implements IInternalTextureLoader {
  54458. /**
  54459. * Defines wether the loader supports cascade loading the different faces.
  54460. */
  54461. readonly supportCascades: boolean;
  54462. /**
  54463. * This returns if the loader support the current file information.
  54464. * @param extension defines the file extension of the file being loaded
  54465. * @returns true if the loader can load the specified file
  54466. */
  54467. canLoad(extension: string): boolean;
  54468. /**
  54469. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54470. * @param data contains the texture data
  54471. * @param texture defines the BabylonJS internal texture
  54472. * @param createPolynomials will be true if polynomials have been requested
  54473. * @param onLoad defines the callback to trigger once the texture is ready
  54474. * @param onError defines the callback to trigger in case of error
  54475. */
  54476. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54477. /**
  54478. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54479. * @param data contains the texture data
  54480. * @param texture defines the BabylonJS internal texture
  54481. * @param callback defines the method to call once ready to upload
  54482. */
  54483. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54484. }
  54485. }
  54486. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54487. import { Nullable } from "babylonjs/types";
  54488. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54489. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54490. /**
  54491. * Implementation of the ENV Texture Loader.
  54492. * @hidden
  54493. */
  54494. export class _ENVTextureLoader implements IInternalTextureLoader {
  54495. /**
  54496. * Defines wether the loader supports cascade loading the different faces.
  54497. */
  54498. readonly supportCascades: boolean;
  54499. /**
  54500. * This returns if the loader support the current file information.
  54501. * @param extension defines the file extension of the file being loaded
  54502. * @returns true if the loader can load the specified file
  54503. */
  54504. canLoad(extension: string): boolean;
  54505. /**
  54506. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54507. * @param data contains the texture data
  54508. * @param texture defines the BabylonJS internal texture
  54509. * @param createPolynomials will be true if polynomials have been requested
  54510. * @param onLoad defines the callback to trigger once the texture is ready
  54511. * @param onError defines the callback to trigger in case of error
  54512. */
  54513. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54514. /**
  54515. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54516. * @param data contains the texture data
  54517. * @param texture defines the BabylonJS internal texture
  54518. * @param callback defines the method to call once ready to upload
  54519. */
  54520. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54521. }
  54522. }
  54523. declare module "babylonjs/Misc/khronosTextureContainer" {
  54524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54525. /**
  54526. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54527. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54528. */
  54529. export class KhronosTextureContainer {
  54530. /** contents of the KTX container file */
  54531. data: ArrayBufferView;
  54532. private static HEADER_LEN;
  54533. private static COMPRESSED_2D;
  54534. private static COMPRESSED_3D;
  54535. private static TEX_2D;
  54536. private static TEX_3D;
  54537. /**
  54538. * Gets the openGL type
  54539. */
  54540. glType: number;
  54541. /**
  54542. * Gets the openGL type size
  54543. */
  54544. glTypeSize: number;
  54545. /**
  54546. * Gets the openGL format
  54547. */
  54548. glFormat: number;
  54549. /**
  54550. * Gets the openGL internal format
  54551. */
  54552. glInternalFormat: number;
  54553. /**
  54554. * Gets the base internal format
  54555. */
  54556. glBaseInternalFormat: number;
  54557. /**
  54558. * Gets image width in pixel
  54559. */
  54560. pixelWidth: number;
  54561. /**
  54562. * Gets image height in pixel
  54563. */
  54564. pixelHeight: number;
  54565. /**
  54566. * Gets image depth in pixels
  54567. */
  54568. pixelDepth: number;
  54569. /**
  54570. * Gets the number of array elements
  54571. */
  54572. numberOfArrayElements: number;
  54573. /**
  54574. * Gets the number of faces
  54575. */
  54576. numberOfFaces: number;
  54577. /**
  54578. * Gets the number of mipmap levels
  54579. */
  54580. numberOfMipmapLevels: number;
  54581. /**
  54582. * Gets the bytes of key value data
  54583. */
  54584. bytesOfKeyValueData: number;
  54585. /**
  54586. * Gets the load type
  54587. */
  54588. loadType: number;
  54589. /**
  54590. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54591. */
  54592. isInvalid: boolean;
  54593. /**
  54594. * Creates a new KhronosTextureContainer
  54595. * @param data contents of the KTX container file
  54596. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54597. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54598. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54599. */
  54600. constructor(
  54601. /** contents of the KTX container file */
  54602. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54603. /**
  54604. * Uploads KTX content to a Babylon Texture.
  54605. * It is assumed that the texture has already been created & is currently bound
  54606. * @hidden
  54607. */
  54608. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54609. private _upload2DCompressedLevels;
  54610. /**
  54611. * Checks if the given data starts with a KTX file identifier.
  54612. * @param data the data to check
  54613. * @returns true if the data is a KTX file or false otherwise
  54614. */
  54615. static IsValid(data: ArrayBufferView): boolean;
  54616. }
  54617. }
  54618. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54619. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54620. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54621. /**
  54622. * Class for loading KTX2 files
  54623. * !!! Experimental Extension Subject to Changes !!!
  54624. * @hidden
  54625. */
  54626. export class KhronosTextureContainer2 {
  54627. private static _ModulePromise;
  54628. private static _TranscodeFormat;
  54629. constructor(engine: ThinEngine);
  54630. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54631. private _determineTranscodeFormat;
  54632. /**
  54633. * Checks if the given data starts with a KTX2 file identifier.
  54634. * @param data the data to check
  54635. * @returns true if the data is a KTX2 file or false otherwise
  54636. */
  54637. static IsValid(data: ArrayBufferView): boolean;
  54638. }
  54639. }
  54640. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54641. import { Nullable } from "babylonjs/types";
  54642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54643. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54644. /**
  54645. * Implementation of the KTX Texture Loader.
  54646. * @hidden
  54647. */
  54648. export class _KTXTextureLoader implements IInternalTextureLoader {
  54649. /**
  54650. * Defines wether the loader supports cascade loading the different faces.
  54651. */
  54652. readonly supportCascades: boolean;
  54653. /**
  54654. * This returns if the loader support the current file information.
  54655. * @param extension defines the file extension of the file being loaded
  54656. * @returns true if the loader can load the specified file
  54657. */
  54658. canLoad(extension: string): boolean;
  54659. /**
  54660. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54661. * @param data contains the texture data
  54662. * @param texture defines the BabylonJS internal texture
  54663. * @param createPolynomials will be true if polynomials have been requested
  54664. * @param onLoad defines the callback to trigger once the texture is ready
  54665. * @param onError defines the callback to trigger in case of error
  54666. */
  54667. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54668. /**
  54669. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54670. * @param data contains the texture data
  54671. * @param texture defines the BabylonJS internal texture
  54672. * @param callback defines the method to call once ready to upload
  54673. */
  54674. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54675. }
  54676. }
  54677. declare module "babylonjs/Helpers/sceneHelpers" {
  54678. import { Nullable } from "babylonjs/types";
  54679. import { Mesh } from "babylonjs/Meshes/mesh";
  54680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54681. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54682. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54683. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54684. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54685. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54686. import "babylonjs/Meshes/Builders/boxBuilder";
  54687. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54688. /** @hidden */
  54689. export var _forceSceneHelpersToBundle: boolean;
  54690. module "babylonjs/scene" {
  54691. interface Scene {
  54692. /**
  54693. * Creates a default light for the scene.
  54694. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54695. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54696. */
  54697. createDefaultLight(replace?: boolean): void;
  54698. /**
  54699. * Creates a default camera for the scene.
  54700. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54701. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54702. * @param replace has default false, when true replaces the active camera in the scene
  54703. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54704. */
  54705. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54706. /**
  54707. * Creates a default camera and a default light.
  54708. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54709. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54710. * @param replace has the default false, when true replaces the active camera/light in the scene
  54711. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54712. */
  54713. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54714. /**
  54715. * Creates a new sky box
  54716. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54717. * @param environmentTexture defines the texture to use as environment texture
  54718. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54719. * @param scale defines the overall scale of the skybox
  54720. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54721. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54722. * @returns a new mesh holding the sky box
  54723. */
  54724. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54725. /**
  54726. * Creates a new environment
  54727. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54728. * @param options defines the options you can use to configure the environment
  54729. * @returns the new EnvironmentHelper
  54730. */
  54731. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54732. /**
  54733. * Creates a new VREXperienceHelper
  54734. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54735. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54736. * @returns a new VREXperienceHelper
  54737. */
  54738. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54739. /**
  54740. * Creates a new WebXRDefaultExperience
  54741. * @see http://doc.babylonjs.com/how_to/webxr
  54742. * @param options experience options
  54743. * @returns a promise for a new WebXRDefaultExperience
  54744. */
  54745. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54746. }
  54747. }
  54748. }
  54749. declare module "babylonjs/Helpers/videoDome" {
  54750. import { Scene } from "babylonjs/scene";
  54751. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54752. import { Mesh } from "babylonjs/Meshes/mesh";
  54753. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54754. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54755. import "babylonjs/Meshes/Builders/sphereBuilder";
  54756. /**
  54757. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54758. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54759. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54760. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54761. */
  54762. export class VideoDome extends TransformNode {
  54763. /**
  54764. * Define the video source as a Monoscopic panoramic 360 video.
  54765. */
  54766. static readonly MODE_MONOSCOPIC: number;
  54767. /**
  54768. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54769. */
  54770. static readonly MODE_TOPBOTTOM: number;
  54771. /**
  54772. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54773. */
  54774. static readonly MODE_SIDEBYSIDE: number;
  54775. private _halfDome;
  54776. private _useDirectMapping;
  54777. /**
  54778. * The video texture being displayed on the sphere
  54779. */
  54780. protected _videoTexture: VideoTexture;
  54781. /**
  54782. * Gets the video texture being displayed on the sphere
  54783. */
  54784. get videoTexture(): VideoTexture;
  54785. /**
  54786. * The skybox material
  54787. */
  54788. protected _material: BackgroundMaterial;
  54789. /**
  54790. * The surface used for the skybox
  54791. */
  54792. protected _mesh: Mesh;
  54793. /**
  54794. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54795. */
  54796. private _halfDomeMask;
  54797. /**
  54798. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54799. * Also see the options.resolution property.
  54800. */
  54801. get fovMultiplier(): number;
  54802. set fovMultiplier(value: number);
  54803. private _videoMode;
  54804. /**
  54805. * Gets or set the current video mode for the video. It can be:
  54806. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54807. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54808. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54809. */
  54810. get videoMode(): number;
  54811. set videoMode(value: number);
  54812. /**
  54813. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54814. *
  54815. */
  54816. get halfDome(): boolean;
  54817. /**
  54818. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54819. */
  54820. set halfDome(enabled: boolean);
  54821. /**
  54822. * Oberserver used in Stereoscopic VR Mode.
  54823. */
  54824. private _onBeforeCameraRenderObserver;
  54825. /**
  54826. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54827. * @param name Element's name, child elements will append suffixes for their own names.
  54828. * @param urlsOrVideo defines the url(s) or the video element to use
  54829. * @param options An object containing optional or exposed sub element properties
  54830. */
  54831. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54832. resolution?: number;
  54833. clickToPlay?: boolean;
  54834. autoPlay?: boolean;
  54835. loop?: boolean;
  54836. size?: number;
  54837. poster?: string;
  54838. faceForward?: boolean;
  54839. useDirectMapping?: boolean;
  54840. halfDomeMode?: boolean;
  54841. }, scene: Scene);
  54842. private _changeVideoMode;
  54843. /**
  54844. * Releases resources associated with this node.
  54845. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54846. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54847. */
  54848. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54849. }
  54850. }
  54851. declare module "babylonjs/Helpers/index" {
  54852. export * from "babylonjs/Helpers/environmentHelper";
  54853. export * from "babylonjs/Helpers/photoDome";
  54854. export * from "babylonjs/Helpers/sceneHelpers";
  54855. export * from "babylonjs/Helpers/videoDome";
  54856. }
  54857. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54858. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54859. import { IDisposable } from "babylonjs/scene";
  54860. import { Engine } from "babylonjs/Engines/engine";
  54861. /**
  54862. * This class can be used to get instrumentation data from a Babylon engine
  54863. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54864. */
  54865. export class EngineInstrumentation implements IDisposable {
  54866. /**
  54867. * Define the instrumented engine.
  54868. */
  54869. engine: Engine;
  54870. private _captureGPUFrameTime;
  54871. private _gpuFrameTimeToken;
  54872. private _gpuFrameTime;
  54873. private _captureShaderCompilationTime;
  54874. private _shaderCompilationTime;
  54875. private _onBeginFrameObserver;
  54876. private _onEndFrameObserver;
  54877. private _onBeforeShaderCompilationObserver;
  54878. private _onAfterShaderCompilationObserver;
  54879. /**
  54880. * Gets the perf counter used for GPU frame time
  54881. */
  54882. get gpuFrameTimeCounter(): PerfCounter;
  54883. /**
  54884. * Gets the GPU frame time capture status
  54885. */
  54886. get captureGPUFrameTime(): boolean;
  54887. /**
  54888. * Enable or disable the GPU frame time capture
  54889. */
  54890. set captureGPUFrameTime(value: boolean);
  54891. /**
  54892. * Gets the perf counter used for shader compilation time
  54893. */
  54894. get shaderCompilationTimeCounter(): PerfCounter;
  54895. /**
  54896. * Gets the shader compilation time capture status
  54897. */
  54898. get captureShaderCompilationTime(): boolean;
  54899. /**
  54900. * Enable or disable the shader compilation time capture
  54901. */
  54902. set captureShaderCompilationTime(value: boolean);
  54903. /**
  54904. * Instantiates a new engine instrumentation.
  54905. * This class can be used to get instrumentation data from a Babylon engine
  54906. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54907. * @param engine Defines the engine to instrument
  54908. */
  54909. constructor(
  54910. /**
  54911. * Define the instrumented engine.
  54912. */
  54913. engine: Engine);
  54914. /**
  54915. * Dispose and release associated resources.
  54916. */
  54917. dispose(): void;
  54918. }
  54919. }
  54920. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54921. import { Scene, IDisposable } from "babylonjs/scene";
  54922. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54923. /**
  54924. * This class can be used to get instrumentation data from a Babylon engine
  54925. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54926. */
  54927. export class SceneInstrumentation implements IDisposable {
  54928. /**
  54929. * Defines the scene to instrument
  54930. */
  54931. scene: Scene;
  54932. private _captureActiveMeshesEvaluationTime;
  54933. private _activeMeshesEvaluationTime;
  54934. private _captureRenderTargetsRenderTime;
  54935. private _renderTargetsRenderTime;
  54936. private _captureFrameTime;
  54937. private _frameTime;
  54938. private _captureRenderTime;
  54939. private _renderTime;
  54940. private _captureInterFrameTime;
  54941. private _interFrameTime;
  54942. private _captureParticlesRenderTime;
  54943. private _particlesRenderTime;
  54944. private _captureSpritesRenderTime;
  54945. private _spritesRenderTime;
  54946. private _capturePhysicsTime;
  54947. private _physicsTime;
  54948. private _captureAnimationsTime;
  54949. private _animationsTime;
  54950. private _captureCameraRenderTime;
  54951. private _cameraRenderTime;
  54952. private _onBeforeActiveMeshesEvaluationObserver;
  54953. private _onAfterActiveMeshesEvaluationObserver;
  54954. private _onBeforeRenderTargetsRenderObserver;
  54955. private _onAfterRenderTargetsRenderObserver;
  54956. private _onAfterRenderObserver;
  54957. private _onBeforeDrawPhaseObserver;
  54958. private _onAfterDrawPhaseObserver;
  54959. private _onBeforeAnimationsObserver;
  54960. private _onBeforeParticlesRenderingObserver;
  54961. private _onAfterParticlesRenderingObserver;
  54962. private _onBeforeSpritesRenderingObserver;
  54963. private _onAfterSpritesRenderingObserver;
  54964. private _onBeforePhysicsObserver;
  54965. private _onAfterPhysicsObserver;
  54966. private _onAfterAnimationsObserver;
  54967. private _onBeforeCameraRenderObserver;
  54968. private _onAfterCameraRenderObserver;
  54969. /**
  54970. * Gets the perf counter used for active meshes evaluation time
  54971. */
  54972. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54973. /**
  54974. * Gets the active meshes evaluation time capture status
  54975. */
  54976. get captureActiveMeshesEvaluationTime(): boolean;
  54977. /**
  54978. * Enable or disable the active meshes evaluation time capture
  54979. */
  54980. set captureActiveMeshesEvaluationTime(value: boolean);
  54981. /**
  54982. * Gets the perf counter used for render targets render time
  54983. */
  54984. get renderTargetsRenderTimeCounter(): PerfCounter;
  54985. /**
  54986. * Gets the render targets render time capture status
  54987. */
  54988. get captureRenderTargetsRenderTime(): boolean;
  54989. /**
  54990. * Enable or disable the render targets render time capture
  54991. */
  54992. set captureRenderTargetsRenderTime(value: boolean);
  54993. /**
  54994. * Gets the perf counter used for particles render time
  54995. */
  54996. get particlesRenderTimeCounter(): PerfCounter;
  54997. /**
  54998. * Gets the particles render time capture status
  54999. */
  55000. get captureParticlesRenderTime(): boolean;
  55001. /**
  55002. * Enable or disable the particles render time capture
  55003. */
  55004. set captureParticlesRenderTime(value: boolean);
  55005. /**
  55006. * Gets the perf counter used for sprites render time
  55007. */
  55008. get spritesRenderTimeCounter(): PerfCounter;
  55009. /**
  55010. * Gets the sprites render time capture status
  55011. */
  55012. get captureSpritesRenderTime(): boolean;
  55013. /**
  55014. * Enable or disable the sprites render time capture
  55015. */
  55016. set captureSpritesRenderTime(value: boolean);
  55017. /**
  55018. * Gets the perf counter used for physics time
  55019. */
  55020. get physicsTimeCounter(): PerfCounter;
  55021. /**
  55022. * Gets the physics time capture status
  55023. */
  55024. get capturePhysicsTime(): boolean;
  55025. /**
  55026. * Enable or disable the physics time capture
  55027. */
  55028. set capturePhysicsTime(value: boolean);
  55029. /**
  55030. * Gets the perf counter used for animations time
  55031. */
  55032. get animationsTimeCounter(): PerfCounter;
  55033. /**
  55034. * Gets the animations time capture status
  55035. */
  55036. get captureAnimationsTime(): boolean;
  55037. /**
  55038. * Enable or disable the animations time capture
  55039. */
  55040. set captureAnimationsTime(value: boolean);
  55041. /**
  55042. * Gets the perf counter used for frame time capture
  55043. */
  55044. get frameTimeCounter(): PerfCounter;
  55045. /**
  55046. * Gets the frame time capture status
  55047. */
  55048. get captureFrameTime(): boolean;
  55049. /**
  55050. * Enable or disable the frame time capture
  55051. */
  55052. set captureFrameTime(value: boolean);
  55053. /**
  55054. * Gets the perf counter used for inter-frames time capture
  55055. */
  55056. get interFrameTimeCounter(): PerfCounter;
  55057. /**
  55058. * Gets the inter-frames time capture status
  55059. */
  55060. get captureInterFrameTime(): boolean;
  55061. /**
  55062. * Enable or disable the inter-frames time capture
  55063. */
  55064. set captureInterFrameTime(value: boolean);
  55065. /**
  55066. * Gets the perf counter used for render time capture
  55067. */
  55068. get renderTimeCounter(): PerfCounter;
  55069. /**
  55070. * Gets the render time capture status
  55071. */
  55072. get captureRenderTime(): boolean;
  55073. /**
  55074. * Enable or disable the render time capture
  55075. */
  55076. set captureRenderTime(value: boolean);
  55077. /**
  55078. * Gets the perf counter used for camera render time capture
  55079. */
  55080. get cameraRenderTimeCounter(): PerfCounter;
  55081. /**
  55082. * Gets the camera render time capture status
  55083. */
  55084. get captureCameraRenderTime(): boolean;
  55085. /**
  55086. * Enable or disable the camera render time capture
  55087. */
  55088. set captureCameraRenderTime(value: boolean);
  55089. /**
  55090. * Gets the perf counter used for draw calls
  55091. */
  55092. get drawCallsCounter(): PerfCounter;
  55093. /**
  55094. * Instantiates a new scene instrumentation.
  55095. * This class can be used to get instrumentation data from a Babylon engine
  55096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55097. * @param scene Defines the scene to instrument
  55098. */
  55099. constructor(
  55100. /**
  55101. * Defines the scene to instrument
  55102. */
  55103. scene: Scene);
  55104. /**
  55105. * Dispose and release associated resources.
  55106. */
  55107. dispose(): void;
  55108. }
  55109. }
  55110. declare module "babylonjs/Instrumentation/index" {
  55111. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55112. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55113. export * from "babylonjs/Instrumentation/timeToken";
  55114. }
  55115. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55116. /** @hidden */
  55117. export var glowMapGenerationPixelShader: {
  55118. name: string;
  55119. shader: string;
  55120. };
  55121. }
  55122. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55123. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55124. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55125. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55126. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55127. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55128. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55129. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55130. /** @hidden */
  55131. export var glowMapGenerationVertexShader: {
  55132. name: string;
  55133. shader: string;
  55134. };
  55135. }
  55136. declare module "babylonjs/Layers/effectLayer" {
  55137. import { Observable } from "babylonjs/Misc/observable";
  55138. import { Nullable } from "babylonjs/types";
  55139. import { Camera } from "babylonjs/Cameras/camera";
  55140. import { Scene } from "babylonjs/scene";
  55141. import { ISize } from "babylonjs/Maths/math.size";
  55142. import { Color4 } from "babylonjs/Maths/math.color";
  55143. import { Engine } from "babylonjs/Engines/engine";
  55144. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55146. import { Mesh } from "babylonjs/Meshes/mesh";
  55147. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55148. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55149. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55150. import { Effect } from "babylonjs/Materials/effect";
  55151. import { Material } from "babylonjs/Materials/material";
  55152. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55153. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55154. /**
  55155. * Effect layer options. This helps customizing the behaviour
  55156. * of the effect layer.
  55157. */
  55158. export interface IEffectLayerOptions {
  55159. /**
  55160. * Multiplication factor apply to the canvas size to compute the render target size
  55161. * used to generated the objects (the smaller the faster).
  55162. */
  55163. mainTextureRatio: number;
  55164. /**
  55165. * Enforces a fixed size texture to ensure effect stability across devices.
  55166. */
  55167. mainTextureFixedSize?: number;
  55168. /**
  55169. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55170. */
  55171. alphaBlendingMode: number;
  55172. /**
  55173. * The camera attached to the layer.
  55174. */
  55175. camera: Nullable<Camera>;
  55176. /**
  55177. * The rendering group to draw the layer in.
  55178. */
  55179. renderingGroupId: number;
  55180. }
  55181. /**
  55182. * The effect layer Helps adding post process effect blended with the main pass.
  55183. *
  55184. * This can be for instance use to generate glow or higlight effects on the scene.
  55185. *
  55186. * The effect layer class can not be used directly and is intented to inherited from to be
  55187. * customized per effects.
  55188. */
  55189. export abstract class EffectLayer {
  55190. private _vertexBuffers;
  55191. private _indexBuffer;
  55192. private _cachedDefines;
  55193. private _effectLayerMapGenerationEffect;
  55194. private _effectLayerOptions;
  55195. private _mergeEffect;
  55196. protected _scene: Scene;
  55197. protected _engine: Engine;
  55198. protected _maxSize: number;
  55199. protected _mainTextureDesiredSize: ISize;
  55200. protected _mainTexture: RenderTargetTexture;
  55201. protected _shouldRender: boolean;
  55202. protected _postProcesses: PostProcess[];
  55203. protected _textures: BaseTexture[];
  55204. protected _emissiveTextureAndColor: {
  55205. texture: Nullable<BaseTexture>;
  55206. color: Color4;
  55207. };
  55208. /**
  55209. * The name of the layer
  55210. */
  55211. name: string;
  55212. /**
  55213. * The clear color of the texture used to generate the glow map.
  55214. */
  55215. neutralColor: Color4;
  55216. /**
  55217. * Specifies whether the highlight layer is enabled or not.
  55218. */
  55219. isEnabled: boolean;
  55220. /**
  55221. * Gets the camera attached to the layer.
  55222. */
  55223. get camera(): Nullable<Camera>;
  55224. /**
  55225. * Gets the rendering group id the layer should render in.
  55226. */
  55227. get renderingGroupId(): number;
  55228. set renderingGroupId(renderingGroupId: number);
  55229. /**
  55230. * An event triggered when the effect layer has been disposed.
  55231. */
  55232. onDisposeObservable: Observable<EffectLayer>;
  55233. /**
  55234. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55235. */
  55236. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55237. /**
  55238. * An event triggered when the generated texture is being merged in the scene.
  55239. */
  55240. onBeforeComposeObservable: Observable<EffectLayer>;
  55241. /**
  55242. * An event triggered when the mesh is rendered into the effect render target.
  55243. */
  55244. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55245. /**
  55246. * An event triggered after the mesh has been rendered into the effect render target.
  55247. */
  55248. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55249. /**
  55250. * An event triggered when the generated texture has been merged in the scene.
  55251. */
  55252. onAfterComposeObservable: Observable<EffectLayer>;
  55253. /**
  55254. * An event triggered when the efffect layer changes its size.
  55255. */
  55256. onSizeChangedObservable: Observable<EffectLayer>;
  55257. /** @hidden */
  55258. static _SceneComponentInitialization: (scene: Scene) => void;
  55259. /**
  55260. * Instantiates a new effect Layer and references it in the scene.
  55261. * @param name The name of the layer
  55262. * @param scene The scene to use the layer in
  55263. */
  55264. constructor(
  55265. /** The Friendly of the effect in the scene */
  55266. name: string, scene: Scene);
  55267. /**
  55268. * Get the effect name of the layer.
  55269. * @return The effect name
  55270. */
  55271. abstract getEffectName(): string;
  55272. /**
  55273. * Checks for the readiness of the element composing the layer.
  55274. * @param subMesh the mesh to check for
  55275. * @param useInstances specify whether or not to use instances to render the mesh
  55276. * @return true if ready otherwise, false
  55277. */
  55278. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55279. /**
  55280. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55281. * @returns true if the effect requires stencil during the main canvas render pass.
  55282. */
  55283. abstract needStencil(): boolean;
  55284. /**
  55285. * Create the merge effect. This is the shader use to blit the information back
  55286. * to the main canvas at the end of the scene rendering.
  55287. * @returns The effect containing the shader used to merge the effect on the main canvas
  55288. */
  55289. protected abstract _createMergeEffect(): Effect;
  55290. /**
  55291. * Creates the render target textures and post processes used in the effect layer.
  55292. */
  55293. protected abstract _createTextureAndPostProcesses(): void;
  55294. /**
  55295. * Implementation specific of rendering the generating effect on the main canvas.
  55296. * @param effect The effect used to render through
  55297. */
  55298. protected abstract _internalRender(effect: Effect): void;
  55299. /**
  55300. * Sets the required values for both the emissive texture and and the main color.
  55301. */
  55302. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55303. /**
  55304. * Free any resources and references associated to a mesh.
  55305. * Internal use
  55306. * @param mesh The mesh to free.
  55307. */
  55308. abstract _disposeMesh(mesh: Mesh): void;
  55309. /**
  55310. * Serializes this layer (Glow or Highlight for example)
  55311. * @returns a serialized layer object
  55312. */
  55313. abstract serialize?(): any;
  55314. /**
  55315. * Initializes the effect layer with the required options.
  55316. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55317. */
  55318. protected _init(options: Partial<IEffectLayerOptions>): void;
  55319. /**
  55320. * Generates the index buffer of the full screen quad blending to the main canvas.
  55321. */
  55322. private _generateIndexBuffer;
  55323. /**
  55324. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55325. */
  55326. private _generateVertexBuffer;
  55327. /**
  55328. * Sets the main texture desired size which is the closest power of two
  55329. * of the engine canvas size.
  55330. */
  55331. private _setMainTextureSize;
  55332. /**
  55333. * Creates the main texture for the effect layer.
  55334. */
  55335. protected _createMainTexture(): void;
  55336. /**
  55337. * Adds specific effects defines.
  55338. * @param defines The defines to add specifics to.
  55339. */
  55340. protected _addCustomEffectDefines(defines: string[]): void;
  55341. /**
  55342. * Checks for the readiness of the element composing the layer.
  55343. * @param subMesh the mesh to check for
  55344. * @param useInstances specify whether or not to use instances to render the mesh
  55345. * @param emissiveTexture the associated emissive texture used to generate the glow
  55346. * @return true if ready otherwise, false
  55347. */
  55348. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55349. /**
  55350. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55351. */
  55352. render(): void;
  55353. /**
  55354. * Determine if a given mesh will be used in the current effect.
  55355. * @param mesh mesh to test
  55356. * @returns true if the mesh will be used
  55357. */
  55358. hasMesh(mesh: AbstractMesh): boolean;
  55359. /**
  55360. * Returns true if the layer contains information to display, otherwise false.
  55361. * @returns true if the glow layer should be rendered
  55362. */
  55363. shouldRender(): boolean;
  55364. /**
  55365. * Returns true if the mesh should render, otherwise false.
  55366. * @param mesh The mesh to render
  55367. * @returns true if it should render otherwise false
  55368. */
  55369. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55370. /**
  55371. * Returns true if the mesh can be rendered, otherwise false.
  55372. * @param mesh The mesh to render
  55373. * @param material The material used on the mesh
  55374. * @returns true if it can be rendered otherwise false
  55375. */
  55376. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55377. /**
  55378. * Returns true if the mesh should render, otherwise false.
  55379. * @param mesh The mesh to render
  55380. * @returns true if it should render otherwise false
  55381. */
  55382. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55383. /**
  55384. * Renders the submesh passed in parameter to the generation map.
  55385. */
  55386. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55387. /**
  55388. * Defines whether the current material of the mesh should be use to render the effect.
  55389. * @param mesh defines the current mesh to render
  55390. */
  55391. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55392. /**
  55393. * Rebuild the required buffers.
  55394. * @hidden Internal use only.
  55395. */
  55396. _rebuild(): void;
  55397. /**
  55398. * Dispose only the render target textures and post process.
  55399. */
  55400. private _disposeTextureAndPostProcesses;
  55401. /**
  55402. * Dispose the highlight layer and free resources.
  55403. */
  55404. dispose(): void;
  55405. /**
  55406. * Gets the class name of the effect layer
  55407. * @returns the string with the class name of the effect layer
  55408. */
  55409. getClassName(): string;
  55410. /**
  55411. * Creates an effect layer from parsed effect layer data
  55412. * @param parsedEffectLayer defines effect layer data
  55413. * @param scene defines the current scene
  55414. * @param rootUrl defines the root URL containing the effect layer information
  55415. * @returns a parsed effect Layer
  55416. */
  55417. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55418. }
  55419. }
  55420. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55421. import { Scene } from "babylonjs/scene";
  55422. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55423. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55424. import { AbstractScene } from "babylonjs/abstractScene";
  55425. module "babylonjs/abstractScene" {
  55426. interface AbstractScene {
  55427. /**
  55428. * The list of effect layers (highlights/glow) added to the scene
  55429. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55430. * @see http://doc.babylonjs.com/how_to/glow_layer
  55431. */
  55432. effectLayers: Array<EffectLayer>;
  55433. /**
  55434. * Removes the given effect layer from this scene.
  55435. * @param toRemove defines the effect layer to remove
  55436. * @returns the index of the removed effect layer
  55437. */
  55438. removeEffectLayer(toRemove: EffectLayer): number;
  55439. /**
  55440. * Adds the given effect layer to this scene
  55441. * @param newEffectLayer defines the effect layer to add
  55442. */
  55443. addEffectLayer(newEffectLayer: EffectLayer): void;
  55444. }
  55445. }
  55446. /**
  55447. * Defines the layer scene component responsible to manage any effect layers
  55448. * in a given scene.
  55449. */
  55450. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55451. /**
  55452. * The component name helpfull to identify the component in the list of scene components.
  55453. */
  55454. readonly name: string;
  55455. /**
  55456. * The scene the component belongs to.
  55457. */
  55458. scene: Scene;
  55459. private _engine;
  55460. private _renderEffects;
  55461. private _needStencil;
  55462. private _previousStencilState;
  55463. /**
  55464. * Creates a new instance of the component for the given scene
  55465. * @param scene Defines the scene to register the component in
  55466. */
  55467. constructor(scene: Scene);
  55468. /**
  55469. * Registers the component in a given scene
  55470. */
  55471. register(): void;
  55472. /**
  55473. * Rebuilds the elements related to this component in case of
  55474. * context lost for instance.
  55475. */
  55476. rebuild(): void;
  55477. /**
  55478. * Serializes the component data to the specified json object
  55479. * @param serializationObject The object to serialize to
  55480. */
  55481. serialize(serializationObject: any): void;
  55482. /**
  55483. * Adds all the elements from the container to the scene
  55484. * @param container the container holding the elements
  55485. */
  55486. addFromContainer(container: AbstractScene): void;
  55487. /**
  55488. * Removes all the elements in the container from the scene
  55489. * @param container contains the elements to remove
  55490. * @param dispose if the removed element should be disposed (default: false)
  55491. */
  55492. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55493. /**
  55494. * Disposes the component and the associated ressources.
  55495. */
  55496. dispose(): void;
  55497. private _isReadyForMesh;
  55498. private _renderMainTexture;
  55499. private _setStencil;
  55500. private _setStencilBack;
  55501. private _draw;
  55502. private _drawCamera;
  55503. private _drawRenderingGroup;
  55504. }
  55505. }
  55506. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55507. /** @hidden */
  55508. export var glowMapMergePixelShader: {
  55509. name: string;
  55510. shader: string;
  55511. };
  55512. }
  55513. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55514. /** @hidden */
  55515. export var glowMapMergeVertexShader: {
  55516. name: string;
  55517. shader: string;
  55518. };
  55519. }
  55520. declare module "babylonjs/Layers/glowLayer" {
  55521. import { Nullable } from "babylonjs/types";
  55522. import { Camera } from "babylonjs/Cameras/camera";
  55523. import { Scene } from "babylonjs/scene";
  55524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55526. import { Mesh } from "babylonjs/Meshes/mesh";
  55527. import { Texture } from "babylonjs/Materials/Textures/texture";
  55528. import { Effect } from "babylonjs/Materials/effect";
  55529. import { Material } from "babylonjs/Materials/material";
  55530. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55531. import { Color4 } from "babylonjs/Maths/math.color";
  55532. import "babylonjs/Shaders/glowMapMerge.fragment";
  55533. import "babylonjs/Shaders/glowMapMerge.vertex";
  55534. import "babylonjs/Layers/effectLayerSceneComponent";
  55535. module "babylonjs/abstractScene" {
  55536. interface AbstractScene {
  55537. /**
  55538. * Return a the first highlight layer of the scene with a given name.
  55539. * @param name The name of the highlight layer to look for.
  55540. * @return The highlight layer if found otherwise null.
  55541. */
  55542. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55543. }
  55544. }
  55545. /**
  55546. * Glow layer options. This helps customizing the behaviour
  55547. * of the glow layer.
  55548. */
  55549. export interface IGlowLayerOptions {
  55550. /**
  55551. * Multiplication factor apply to the canvas size to compute the render target size
  55552. * used to generated the glowing objects (the smaller the faster).
  55553. */
  55554. mainTextureRatio: number;
  55555. /**
  55556. * Enforces a fixed size texture to ensure resize independant blur.
  55557. */
  55558. mainTextureFixedSize?: number;
  55559. /**
  55560. * How big is the kernel of the blur texture.
  55561. */
  55562. blurKernelSize: number;
  55563. /**
  55564. * The camera attached to the layer.
  55565. */
  55566. camera: Nullable<Camera>;
  55567. /**
  55568. * Enable MSAA by chosing the number of samples.
  55569. */
  55570. mainTextureSamples?: number;
  55571. /**
  55572. * The rendering group to draw the layer in.
  55573. */
  55574. renderingGroupId: number;
  55575. }
  55576. /**
  55577. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55578. *
  55579. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55580. *
  55581. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55582. */
  55583. export class GlowLayer extends EffectLayer {
  55584. /**
  55585. * Effect Name of the layer.
  55586. */
  55587. static readonly EffectName: string;
  55588. /**
  55589. * The default blur kernel size used for the glow.
  55590. */
  55591. static DefaultBlurKernelSize: number;
  55592. /**
  55593. * The default texture size ratio used for the glow.
  55594. */
  55595. static DefaultTextureRatio: number;
  55596. /**
  55597. * Sets the kernel size of the blur.
  55598. */
  55599. set blurKernelSize(value: number);
  55600. /**
  55601. * Gets the kernel size of the blur.
  55602. */
  55603. get blurKernelSize(): number;
  55604. /**
  55605. * Sets the glow intensity.
  55606. */
  55607. set intensity(value: number);
  55608. /**
  55609. * Gets the glow intensity.
  55610. */
  55611. get intensity(): number;
  55612. private _options;
  55613. private _intensity;
  55614. private _horizontalBlurPostprocess1;
  55615. private _verticalBlurPostprocess1;
  55616. private _horizontalBlurPostprocess2;
  55617. private _verticalBlurPostprocess2;
  55618. private _blurTexture1;
  55619. private _blurTexture2;
  55620. private _postProcesses1;
  55621. private _postProcesses2;
  55622. private _includedOnlyMeshes;
  55623. private _excludedMeshes;
  55624. private _meshesUsingTheirOwnMaterials;
  55625. /**
  55626. * Callback used to let the user override the color selection on a per mesh basis
  55627. */
  55628. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55629. /**
  55630. * Callback used to let the user override the texture selection on a per mesh basis
  55631. */
  55632. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55633. /**
  55634. * Instantiates a new glow Layer and references it to the scene.
  55635. * @param name The name of the layer
  55636. * @param scene The scene to use the layer in
  55637. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55638. */
  55639. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55640. /**
  55641. * Get the effect name of the layer.
  55642. * @return The effect name
  55643. */
  55644. getEffectName(): string;
  55645. /**
  55646. * Create the merge effect. This is the shader use to blit the information back
  55647. * to the main canvas at the end of the scene rendering.
  55648. */
  55649. protected _createMergeEffect(): Effect;
  55650. /**
  55651. * Creates the render target textures and post processes used in the glow layer.
  55652. */
  55653. protected _createTextureAndPostProcesses(): void;
  55654. /**
  55655. * Checks for the readiness of the element composing the layer.
  55656. * @param subMesh the mesh to check for
  55657. * @param useInstances specify wether or not to use instances to render the mesh
  55658. * @param emissiveTexture the associated emissive texture used to generate the glow
  55659. * @return true if ready otherwise, false
  55660. */
  55661. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55662. /**
  55663. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55664. */
  55665. needStencil(): boolean;
  55666. /**
  55667. * Returns true if the mesh can be rendered, otherwise false.
  55668. * @param mesh The mesh to render
  55669. * @param material The material used on the mesh
  55670. * @returns true if it can be rendered otherwise false
  55671. */
  55672. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55673. /**
  55674. * Implementation specific of rendering the generating effect on the main canvas.
  55675. * @param effect The effect used to render through
  55676. */
  55677. protected _internalRender(effect: Effect): void;
  55678. /**
  55679. * Sets the required values for both the emissive texture and and the main color.
  55680. */
  55681. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55682. /**
  55683. * Returns true if the mesh should render, otherwise false.
  55684. * @param mesh The mesh to render
  55685. * @returns true if it should render otherwise false
  55686. */
  55687. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55688. /**
  55689. * Adds specific effects defines.
  55690. * @param defines The defines to add specifics to.
  55691. */
  55692. protected _addCustomEffectDefines(defines: string[]): void;
  55693. /**
  55694. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55695. * @param mesh The mesh to exclude from the glow layer
  55696. */
  55697. addExcludedMesh(mesh: Mesh): void;
  55698. /**
  55699. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55700. * @param mesh The mesh to remove
  55701. */
  55702. removeExcludedMesh(mesh: Mesh): void;
  55703. /**
  55704. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55705. * @param mesh The mesh to include in the glow layer
  55706. */
  55707. addIncludedOnlyMesh(mesh: Mesh): void;
  55708. /**
  55709. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55710. * @param mesh The mesh to remove
  55711. */
  55712. removeIncludedOnlyMesh(mesh: Mesh): void;
  55713. /**
  55714. * Determine if a given mesh will be used in the glow layer
  55715. * @param mesh The mesh to test
  55716. * @returns true if the mesh will be highlighted by the current glow layer
  55717. */
  55718. hasMesh(mesh: AbstractMesh): boolean;
  55719. /**
  55720. * Defines whether the current material of the mesh should be use to render the effect.
  55721. * @param mesh defines the current mesh to render
  55722. */
  55723. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55724. /**
  55725. * Add a mesh to be rendered through its own material and not with emissive only.
  55726. * @param mesh The mesh for which we need to use its material
  55727. */
  55728. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55729. /**
  55730. * Remove a mesh from being rendered through its own material and not with emissive only.
  55731. * @param mesh The mesh for which we need to not use its material
  55732. */
  55733. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55734. /**
  55735. * Free any resources and references associated to a mesh.
  55736. * Internal use
  55737. * @param mesh The mesh to free.
  55738. * @hidden
  55739. */
  55740. _disposeMesh(mesh: Mesh): void;
  55741. /**
  55742. * Gets the class name of the effect layer
  55743. * @returns the string with the class name of the effect layer
  55744. */
  55745. getClassName(): string;
  55746. /**
  55747. * Serializes this glow layer
  55748. * @returns a serialized glow layer object
  55749. */
  55750. serialize(): any;
  55751. /**
  55752. * Creates a Glow Layer from parsed glow layer data
  55753. * @param parsedGlowLayer defines glow layer data
  55754. * @param scene defines the current scene
  55755. * @param rootUrl defines the root URL containing the glow layer information
  55756. * @returns a parsed Glow Layer
  55757. */
  55758. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55759. }
  55760. }
  55761. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55762. /** @hidden */
  55763. export var glowBlurPostProcessPixelShader: {
  55764. name: string;
  55765. shader: string;
  55766. };
  55767. }
  55768. declare module "babylonjs/Layers/highlightLayer" {
  55769. import { Observable } from "babylonjs/Misc/observable";
  55770. import { Nullable } from "babylonjs/types";
  55771. import { Camera } from "babylonjs/Cameras/camera";
  55772. import { Scene } from "babylonjs/scene";
  55773. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55775. import { Mesh } from "babylonjs/Meshes/mesh";
  55776. import { Effect } from "babylonjs/Materials/effect";
  55777. import { Material } from "babylonjs/Materials/material";
  55778. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55779. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55780. import "babylonjs/Shaders/glowMapMerge.fragment";
  55781. import "babylonjs/Shaders/glowMapMerge.vertex";
  55782. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55783. module "babylonjs/abstractScene" {
  55784. interface AbstractScene {
  55785. /**
  55786. * Return a the first highlight layer of the scene with a given name.
  55787. * @param name The name of the highlight layer to look for.
  55788. * @return The highlight layer if found otherwise null.
  55789. */
  55790. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55791. }
  55792. }
  55793. /**
  55794. * Highlight layer options. This helps customizing the behaviour
  55795. * of the highlight layer.
  55796. */
  55797. export interface IHighlightLayerOptions {
  55798. /**
  55799. * Multiplication factor apply to the canvas size to compute the render target size
  55800. * used to generated the glowing objects (the smaller the faster).
  55801. */
  55802. mainTextureRatio: number;
  55803. /**
  55804. * Enforces a fixed size texture to ensure resize independant blur.
  55805. */
  55806. mainTextureFixedSize?: number;
  55807. /**
  55808. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55809. * of the picture to blur (the smaller the faster).
  55810. */
  55811. blurTextureSizeRatio: number;
  55812. /**
  55813. * How big in texel of the blur texture is the vertical blur.
  55814. */
  55815. blurVerticalSize: number;
  55816. /**
  55817. * How big in texel of the blur texture is the horizontal blur.
  55818. */
  55819. blurHorizontalSize: number;
  55820. /**
  55821. * Alpha blending mode used to apply the blur. Default is combine.
  55822. */
  55823. alphaBlendingMode: number;
  55824. /**
  55825. * The camera attached to the layer.
  55826. */
  55827. camera: Nullable<Camera>;
  55828. /**
  55829. * Should we display highlight as a solid stroke?
  55830. */
  55831. isStroke?: boolean;
  55832. /**
  55833. * The rendering group to draw the layer in.
  55834. */
  55835. renderingGroupId: number;
  55836. }
  55837. /**
  55838. * The highlight layer Helps adding a glow effect around a mesh.
  55839. *
  55840. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55841. * glowy meshes to your scene.
  55842. *
  55843. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55844. */
  55845. export class HighlightLayer extends EffectLayer {
  55846. name: string;
  55847. /**
  55848. * Effect Name of the highlight layer.
  55849. */
  55850. static readonly EffectName: string;
  55851. /**
  55852. * The neutral color used during the preparation of the glow effect.
  55853. * This is black by default as the blend operation is a blend operation.
  55854. */
  55855. static NeutralColor: Color4;
  55856. /**
  55857. * Stencil value used for glowing meshes.
  55858. */
  55859. static GlowingMeshStencilReference: number;
  55860. /**
  55861. * Stencil value used for the other meshes in the scene.
  55862. */
  55863. static NormalMeshStencilReference: number;
  55864. /**
  55865. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55866. */
  55867. innerGlow: boolean;
  55868. /**
  55869. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55870. */
  55871. outerGlow: boolean;
  55872. /**
  55873. * Specifies the horizontal size of the blur.
  55874. */
  55875. set blurHorizontalSize(value: number);
  55876. /**
  55877. * Specifies the vertical size of the blur.
  55878. */
  55879. set blurVerticalSize(value: number);
  55880. /**
  55881. * Gets the horizontal size of the blur.
  55882. */
  55883. get blurHorizontalSize(): number;
  55884. /**
  55885. * Gets the vertical size of the blur.
  55886. */
  55887. get blurVerticalSize(): number;
  55888. /**
  55889. * An event triggered when the highlight layer is being blurred.
  55890. */
  55891. onBeforeBlurObservable: Observable<HighlightLayer>;
  55892. /**
  55893. * An event triggered when the highlight layer has been blurred.
  55894. */
  55895. onAfterBlurObservable: Observable<HighlightLayer>;
  55896. private _instanceGlowingMeshStencilReference;
  55897. private _options;
  55898. private _downSamplePostprocess;
  55899. private _horizontalBlurPostprocess;
  55900. private _verticalBlurPostprocess;
  55901. private _blurTexture;
  55902. private _meshes;
  55903. private _excludedMeshes;
  55904. /**
  55905. * Instantiates a new highlight Layer and references it to the scene..
  55906. * @param name The name of the layer
  55907. * @param scene The scene to use the layer in
  55908. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55909. */
  55910. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55911. /**
  55912. * Get the effect name of the layer.
  55913. * @return The effect name
  55914. */
  55915. getEffectName(): string;
  55916. /**
  55917. * Create the merge effect. This is the shader use to blit the information back
  55918. * to the main canvas at the end of the scene rendering.
  55919. */
  55920. protected _createMergeEffect(): Effect;
  55921. /**
  55922. * Creates the render target textures and post processes used in the highlight layer.
  55923. */
  55924. protected _createTextureAndPostProcesses(): void;
  55925. /**
  55926. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55927. */
  55928. needStencil(): boolean;
  55929. /**
  55930. * Checks for the readiness of the element composing the layer.
  55931. * @param subMesh the mesh to check for
  55932. * @param useInstances specify wether or not to use instances to render the mesh
  55933. * @param emissiveTexture the associated emissive texture used to generate the glow
  55934. * @return true if ready otherwise, false
  55935. */
  55936. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55937. /**
  55938. * Implementation specific of rendering the generating effect on the main canvas.
  55939. * @param effect The effect used to render through
  55940. */
  55941. protected _internalRender(effect: Effect): void;
  55942. /**
  55943. * Returns true if the layer contains information to display, otherwise false.
  55944. */
  55945. shouldRender(): boolean;
  55946. /**
  55947. * Returns true if the mesh should render, otherwise false.
  55948. * @param mesh The mesh to render
  55949. * @returns true if it should render otherwise false
  55950. */
  55951. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55952. /**
  55953. * Sets the required values for both the emissive texture and and the main color.
  55954. */
  55955. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55956. /**
  55957. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55958. * @param mesh The mesh to exclude from the highlight layer
  55959. */
  55960. addExcludedMesh(mesh: Mesh): void;
  55961. /**
  55962. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55963. * @param mesh The mesh to highlight
  55964. */
  55965. removeExcludedMesh(mesh: Mesh): void;
  55966. /**
  55967. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55968. * @param mesh mesh to test
  55969. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55970. */
  55971. hasMesh(mesh: AbstractMesh): boolean;
  55972. /**
  55973. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55974. * @param mesh The mesh to highlight
  55975. * @param color The color of the highlight
  55976. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55977. */
  55978. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55979. /**
  55980. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55981. * @param mesh The mesh to highlight
  55982. */
  55983. removeMesh(mesh: Mesh): void;
  55984. /**
  55985. * Remove all the meshes currently referenced in the highlight layer
  55986. */
  55987. removeAllMeshes(): void;
  55988. /**
  55989. * Force the stencil to the normal expected value for none glowing parts
  55990. */
  55991. private _defaultStencilReference;
  55992. /**
  55993. * Free any resources and references associated to a mesh.
  55994. * Internal use
  55995. * @param mesh The mesh to free.
  55996. * @hidden
  55997. */
  55998. _disposeMesh(mesh: Mesh): void;
  55999. /**
  56000. * Dispose the highlight layer and free resources.
  56001. */
  56002. dispose(): void;
  56003. /**
  56004. * Gets the class name of the effect layer
  56005. * @returns the string with the class name of the effect layer
  56006. */
  56007. getClassName(): string;
  56008. /**
  56009. * Serializes this Highlight layer
  56010. * @returns a serialized Highlight layer object
  56011. */
  56012. serialize(): any;
  56013. /**
  56014. * Creates a Highlight layer from parsed Highlight layer data
  56015. * @param parsedHightlightLayer defines the Highlight layer data
  56016. * @param scene defines the current scene
  56017. * @param rootUrl defines the root URL containing the Highlight layer information
  56018. * @returns a parsed Highlight layer
  56019. */
  56020. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56021. }
  56022. }
  56023. declare module "babylonjs/Layers/layerSceneComponent" {
  56024. import { Scene } from "babylonjs/scene";
  56025. import { ISceneComponent } from "babylonjs/sceneComponent";
  56026. import { Layer } from "babylonjs/Layers/layer";
  56027. import { AbstractScene } from "babylonjs/abstractScene";
  56028. module "babylonjs/abstractScene" {
  56029. interface AbstractScene {
  56030. /**
  56031. * The list of layers (background and foreground) of the scene
  56032. */
  56033. layers: Array<Layer>;
  56034. }
  56035. }
  56036. /**
  56037. * Defines the layer scene component responsible to manage any layers
  56038. * in a given scene.
  56039. */
  56040. export class LayerSceneComponent implements ISceneComponent {
  56041. /**
  56042. * The component name helpfull to identify the component in the list of scene components.
  56043. */
  56044. readonly name: string;
  56045. /**
  56046. * The scene the component belongs to.
  56047. */
  56048. scene: Scene;
  56049. private _engine;
  56050. /**
  56051. * Creates a new instance of the component for the given scene
  56052. * @param scene Defines the scene to register the component in
  56053. */
  56054. constructor(scene: Scene);
  56055. /**
  56056. * Registers the component in a given scene
  56057. */
  56058. register(): void;
  56059. /**
  56060. * Rebuilds the elements related to this component in case of
  56061. * context lost for instance.
  56062. */
  56063. rebuild(): void;
  56064. /**
  56065. * Disposes the component and the associated ressources.
  56066. */
  56067. dispose(): void;
  56068. private _draw;
  56069. private _drawCameraPredicate;
  56070. private _drawCameraBackground;
  56071. private _drawCameraForeground;
  56072. private _drawRenderTargetPredicate;
  56073. private _drawRenderTargetBackground;
  56074. private _drawRenderTargetForeground;
  56075. /**
  56076. * Adds all the elements from the container to the scene
  56077. * @param container the container holding the elements
  56078. */
  56079. addFromContainer(container: AbstractScene): void;
  56080. /**
  56081. * Removes all the elements in the container from the scene
  56082. * @param container contains the elements to remove
  56083. * @param dispose if the removed element should be disposed (default: false)
  56084. */
  56085. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56086. }
  56087. }
  56088. declare module "babylonjs/Shaders/layer.fragment" {
  56089. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56090. /** @hidden */
  56091. export var layerPixelShader: {
  56092. name: string;
  56093. shader: string;
  56094. };
  56095. }
  56096. declare module "babylonjs/Shaders/layer.vertex" {
  56097. /** @hidden */
  56098. export var layerVertexShader: {
  56099. name: string;
  56100. shader: string;
  56101. };
  56102. }
  56103. declare module "babylonjs/Layers/layer" {
  56104. import { Observable } from "babylonjs/Misc/observable";
  56105. import { Nullable } from "babylonjs/types";
  56106. import { Scene } from "babylonjs/scene";
  56107. import { Vector2 } from "babylonjs/Maths/math.vector";
  56108. import { Color4 } from "babylonjs/Maths/math.color";
  56109. import { Texture } from "babylonjs/Materials/Textures/texture";
  56110. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56111. import "babylonjs/Shaders/layer.fragment";
  56112. import "babylonjs/Shaders/layer.vertex";
  56113. /**
  56114. * This represents a full screen 2d layer.
  56115. * This can be useful to display a picture in the background of your scene for instance.
  56116. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56117. */
  56118. export class Layer {
  56119. /**
  56120. * Define the name of the layer.
  56121. */
  56122. name: string;
  56123. /**
  56124. * Define the texture the layer should display.
  56125. */
  56126. texture: Nullable<Texture>;
  56127. /**
  56128. * Is the layer in background or foreground.
  56129. */
  56130. isBackground: boolean;
  56131. /**
  56132. * Define the color of the layer (instead of texture).
  56133. */
  56134. color: Color4;
  56135. /**
  56136. * Define the scale of the layer in order to zoom in out of the texture.
  56137. */
  56138. scale: Vector2;
  56139. /**
  56140. * Define an offset for the layer in order to shift the texture.
  56141. */
  56142. offset: Vector2;
  56143. /**
  56144. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56145. */
  56146. alphaBlendingMode: number;
  56147. /**
  56148. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56149. * Alpha test will not mix with the background color in case of transparency.
  56150. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56151. */
  56152. alphaTest: boolean;
  56153. /**
  56154. * Define a mask to restrict the layer to only some of the scene cameras.
  56155. */
  56156. layerMask: number;
  56157. /**
  56158. * Define the list of render target the layer is visible into.
  56159. */
  56160. renderTargetTextures: RenderTargetTexture[];
  56161. /**
  56162. * Define if the layer is only used in renderTarget or if it also
  56163. * renders in the main frame buffer of the canvas.
  56164. */
  56165. renderOnlyInRenderTargetTextures: boolean;
  56166. private _scene;
  56167. private _vertexBuffers;
  56168. private _indexBuffer;
  56169. private _effect;
  56170. private _previousDefines;
  56171. /**
  56172. * An event triggered when the layer is disposed.
  56173. */
  56174. onDisposeObservable: Observable<Layer>;
  56175. private _onDisposeObserver;
  56176. /**
  56177. * Back compatibility with callback before the onDisposeObservable existed.
  56178. * The set callback will be triggered when the layer has been disposed.
  56179. */
  56180. set onDispose(callback: () => void);
  56181. /**
  56182. * An event triggered before rendering the scene
  56183. */
  56184. onBeforeRenderObservable: Observable<Layer>;
  56185. private _onBeforeRenderObserver;
  56186. /**
  56187. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56188. * The set callback will be triggered just before rendering the layer.
  56189. */
  56190. set onBeforeRender(callback: () => void);
  56191. /**
  56192. * An event triggered after rendering the scene
  56193. */
  56194. onAfterRenderObservable: Observable<Layer>;
  56195. private _onAfterRenderObserver;
  56196. /**
  56197. * Back compatibility with callback before the onAfterRenderObservable existed.
  56198. * The set callback will be triggered just after rendering the layer.
  56199. */
  56200. set onAfterRender(callback: () => void);
  56201. /**
  56202. * Instantiates a new layer.
  56203. * This represents a full screen 2d layer.
  56204. * This can be useful to display a picture in the background of your scene for instance.
  56205. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56206. * @param name Define the name of the layer in the scene
  56207. * @param imgUrl Define the url of the texture to display in the layer
  56208. * @param scene Define the scene the layer belongs to
  56209. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56210. * @param color Defines a color for the layer
  56211. */
  56212. constructor(
  56213. /**
  56214. * Define the name of the layer.
  56215. */
  56216. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56217. private _createIndexBuffer;
  56218. /** @hidden */
  56219. _rebuild(): void;
  56220. /**
  56221. * Renders the layer in the scene.
  56222. */
  56223. render(): void;
  56224. /**
  56225. * Disposes and releases the associated ressources.
  56226. */
  56227. dispose(): void;
  56228. }
  56229. }
  56230. declare module "babylonjs/Layers/index" {
  56231. export * from "babylonjs/Layers/effectLayer";
  56232. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56233. export * from "babylonjs/Layers/glowLayer";
  56234. export * from "babylonjs/Layers/highlightLayer";
  56235. export * from "babylonjs/Layers/layer";
  56236. export * from "babylonjs/Layers/layerSceneComponent";
  56237. }
  56238. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56239. /** @hidden */
  56240. export var lensFlarePixelShader: {
  56241. name: string;
  56242. shader: string;
  56243. };
  56244. }
  56245. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56246. /** @hidden */
  56247. export var lensFlareVertexShader: {
  56248. name: string;
  56249. shader: string;
  56250. };
  56251. }
  56252. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56253. import { Scene } from "babylonjs/scene";
  56254. import { Vector3 } from "babylonjs/Maths/math.vector";
  56255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56256. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56257. import "babylonjs/Shaders/lensFlare.fragment";
  56258. import "babylonjs/Shaders/lensFlare.vertex";
  56259. import { Viewport } from "babylonjs/Maths/math.viewport";
  56260. /**
  56261. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56262. * It is usually composed of several `lensFlare`.
  56263. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56264. */
  56265. export class LensFlareSystem {
  56266. /**
  56267. * Define the name of the lens flare system
  56268. */
  56269. name: string;
  56270. /**
  56271. * List of lens flares used in this system.
  56272. */
  56273. lensFlares: LensFlare[];
  56274. /**
  56275. * Define a limit from the border the lens flare can be visible.
  56276. */
  56277. borderLimit: number;
  56278. /**
  56279. * Define a viewport border we do not want to see the lens flare in.
  56280. */
  56281. viewportBorder: number;
  56282. /**
  56283. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56284. */
  56285. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56286. /**
  56287. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56288. */
  56289. layerMask: number;
  56290. /**
  56291. * Define the id of the lens flare system in the scene.
  56292. * (equal to name by default)
  56293. */
  56294. id: string;
  56295. private _scene;
  56296. private _emitter;
  56297. private _vertexBuffers;
  56298. private _indexBuffer;
  56299. private _effect;
  56300. private _positionX;
  56301. private _positionY;
  56302. private _isEnabled;
  56303. /** @hidden */
  56304. static _SceneComponentInitialization: (scene: Scene) => void;
  56305. /**
  56306. * Instantiates a lens flare system.
  56307. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56308. * It is usually composed of several `lensFlare`.
  56309. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56310. * @param name Define the name of the lens flare system in the scene
  56311. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56312. * @param scene Define the scene the lens flare system belongs to
  56313. */
  56314. constructor(
  56315. /**
  56316. * Define the name of the lens flare system
  56317. */
  56318. name: string, emitter: any, scene: Scene);
  56319. /**
  56320. * Define if the lens flare system is enabled.
  56321. */
  56322. get isEnabled(): boolean;
  56323. set isEnabled(value: boolean);
  56324. /**
  56325. * Get the scene the effects belongs to.
  56326. * @returns the scene holding the lens flare system
  56327. */
  56328. getScene(): Scene;
  56329. /**
  56330. * Get the emitter of the lens flare system.
  56331. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56332. * @returns the emitter of the lens flare system
  56333. */
  56334. getEmitter(): any;
  56335. /**
  56336. * Set the emitter of the lens flare system.
  56337. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56338. * @param newEmitter Define the new emitter of the system
  56339. */
  56340. setEmitter(newEmitter: any): void;
  56341. /**
  56342. * Get the lens flare system emitter position.
  56343. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56344. * @returns the position
  56345. */
  56346. getEmitterPosition(): Vector3;
  56347. /**
  56348. * @hidden
  56349. */
  56350. computeEffectivePosition(globalViewport: Viewport): boolean;
  56351. /** @hidden */
  56352. _isVisible(): boolean;
  56353. /**
  56354. * @hidden
  56355. */
  56356. render(): boolean;
  56357. /**
  56358. * Dispose and release the lens flare with its associated resources.
  56359. */
  56360. dispose(): void;
  56361. /**
  56362. * Parse a lens flare system from a JSON repressentation
  56363. * @param parsedLensFlareSystem Define the JSON to parse
  56364. * @param scene Define the scene the parsed system should be instantiated in
  56365. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56366. * @returns the parsed system
  56367. */
  56368. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56369. /**
  56370. * Serialize the current Lens Flare System into a JSON representation.
  56371. * @returns the serialized JSON
  56372. */
  56373. serialize(): any;
  56374. }
  56375. }
  56376. declare module "babylonjs/LensFlares/lensFlare" {
  56377. import { Nullable } from "babylonjs/types";
  56378. import { Color3 } from "babylonjs/Maths/math.color";
  56379. import { Texture } from "babylonjs/Materials/Textures/texture";
  56380. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56381. /**
  56382. * This represents one of the lens effect in a `lensFlareSystem`.
  56383. * It controls one of the indiviual texture used in the effect.
  56384. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56385. */
  56386. export class LensFlare {
  56387. /**
  56388. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56389. */
  56390. size: number;
  56391. /**
  56392. * 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.
  56393. */
  56394. position: number;
  56395. /**
  56396. * Define the lens color.
  56397. */
  56398. color: Color3;
  56399. /**
  56400. * Define the lens texture.
  56401. */
  56402. texture: Nullable<Texture>;
  56403. /**
  56404. * Define the alpha mode to render this particular lens.
  56405. */
  56406. alphaMode: number;
  56407. private _system;
  56408. /**
  56409. * Creates a new Lens Flare.
  56410. * This represents one of the lens effect in a `lensFlareSystem`.
  56411. * It controls one of the indiviual texture used in the effect.
  56412. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56413. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56414. * @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.
  56415. * @param color Define the lens color
  56416. * @param imgUrl Define the lens texture url
  56417. * @param system Define the `lensFlareSystem` this flare is part of
  56418. * @returns The newly created Lens Flare
  56419. */
  56420. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56421. /**
  56422. * Instantiates a new Lens Flare.
  56423. * This represents one of the lens effect in a `lensFlareSystem`.
  56424. * It controls one of the indiviual texture used in the effect.
  56425. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56426. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56427. * @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.
  56428. * @param color Define the lens color
  56429. * @param imgUrl Define the lens texture url
  56430. * @param system Define the `lensFlareSystem` this flare is part of
  56431. */
  56432. constructor(
  56433. /**
  56434. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56435. */
  56436. size: number,
  56437. /**
  56438. * 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.
  56439. */
  56440. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56441. /**
  56442. * Dispose and release the lens flare with its associated resources.
  56443. */
  56444. dispose(): void;
  56445. }
  56446. }
  56447. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56448. import { Nullable } from "babylonjs/types";
  56449. import { Scene } from "babylonjs/scene";
  56450. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56451. import { AbstractScene } from "babylonjs/abstractScene";
  56452. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56453. module "babylonjs/abstractScene" {
  56454. interface AbstractScene {
  56455. /**
  56456. * The list of lens flare system added to the scene
  56457. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56458. */
  56459. lensFlareSystems: Array<LensFlareSystem>;
  56460. /**
  56461. * Removes the given lens flare system from this scene.
  56462. * @param toRemove The lens flare system to remove
  56463. * @returns The index of the removed lens flare system
  56464. */
  56465. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56466. /**
  56467. * Adds the given lens flare system to this scene
  56468. * @param newLensFlareSystem The lens flare system to add
  56469. */
  56470. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56471. /**
  56472. * Gets a lens flare system using its name
  56473. * @param name defines the name to look for
  56474. * @returns the lens flare system or null if not found
  56475. */
  56476. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56477. /**
  56478. * Gets a lens flare system using its id
  56479. * @param id defines the id to look for
  56480. * @returns the lens flare system or null if not found
  56481. */
  56482. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56483. }
  56484. }
  56485. /**
  56486. * Defines the lens flare scene component responsible to manage any lens flares
  56487. * in a given scene.
  56488. */
  56489. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56490. /**
  56491. * The component name helpfull to identify the component in the list of scene components.
  56492. */
  56493. readonly name: string;
  56494. /**
  56495. * The scene the component belongs to.
  56496. */
  56497. scene: Scene;
  56498. /**
  56499. * Creates a new instance of the component for the given scene
  56500. * @param scene Defines the scene to register the component in
  56501. */
  56502. constructor(scene: Scene);
  56503. /**
  56504. * Registers the component in a given scene
  56505. */
  56506. register(): void;
  56507. /**
  56508. * Rebuilds the elements related to this component in case of
  56509. * context lost for instance.
  56510. */
  56511. rebuild(): void;
  56512. /**
  56513. * Adds all the elements from the container to the scene
  56514. * @param container the container holding the elements
  56515. */
  56516. addFromContainer(container: AbstractScene): void;
  56517. /**
  56518. * Removes all the elements in the container from the scene
  56519. * @param container contains the elements to remove
  56520. * @param dispose if the removed element should be disposed (default: false)
  56521. */
  56522. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56523. /**
  56524. * Serializes the component data to the specified json object
  56525. * @param serializationObject The object to serialize to
  56526. */
  56527. serialize(serializationObject: any): void;
  56528. /**
  56529. * Disposes the component and the associated ressources.
  56530. */
  56531. dispose(): void;
  56532. private _draw;
  56533. }
  56534. }
  56535. declare module "babylonjs/LensFlares/index" {
  56536. export * from "babylonjs/LensFlares/lensFlare";
  56537. export * from "babylonjs/LensFlares/lensFlareSystem";
  56538. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56539. }
  56540. declare module "babylonjs/Shaders/depth.fragment" {
  56541. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56542. /** @hidden */
  56543. export var depthPixelShader: {
  56544. name: string;
  56545. shader: string;
  56546. };
  56547. }
  56548. declare module "babylonjs/Shaders/depth.vertex" {
  56549. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56552. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56553. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56554. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56555. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56556. /** @hidden */
  56557. export var depthVertexShader: {
  56558. name: string;
  56559. shader: string;
  56560. };
  56561. }
  56562. declare module "babylonjs/Rendering/depthRenderer" {
  56563. import { Nullable } from "babylonjs/types";
  56564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56565. import { Scene } from "babylonjs/scene";
  56566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56567. import { Camera } from "babylonjs/Cameras/camera";
  56568. import "babylonjs/Shaders/depth.fragment";
  56569. import "babylonjs/Shaders/depth.vertex";
  56570. /**
  56571. * This represents a depth renderer in Babylon.
  56572. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56573. */
  56574. export class DepthRenderer {
  56575. private _scene;
  56576. private _depthMap;
  56577. private _effect;
  56578. private readonly _storeNonLinearDepth;
  56579. private readonly _clearColor;
  56580. /** Get if the depth renderer is using packed depth or not */
  56581. readonly isPacked: boolean;
  56582. private _cachedDefines;
  56583. private _camera;
  56584. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56585. enabled: boolean;
  56586. /**
  56587. * Specifiess that the depth renderer will only be used within
  56588. * the camera it is created for.
  56589. * This can help forcing its rendering during the camera processing.
  56590. */
  56591. useOnlyInActiveCamera: boolean;
  56592. /** @hidden */
  56593. static _SceneComponentInitialization: (scene: Scene) => void;
  56594. /**
  56595. * Instantiates a depth renderer
  56596. * @param scene The scene the renderer belongs to
  56597. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56598. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56599. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56600. */
  56601. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56602. /**
  56603. * Creates the depth rendering effect and checks if the effect is ready.
  56604. * @param subMesh The submesh to be used to render the depth map of
  56605. * @param useInstances If multiple world instances should be used
  56606. * @returns if the depth renderer is ready to render the depth map
  56607. */
  56608. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56609. /**
  56610. * Gets the texture which the depth map will be written to.
  56611. * @returns The depth map texture
  56612. */
  56613. getDepthMap(): RenderTargetTexture;
  56614. /**
  56615. * Disposes of the depth renderer.
  56616. */
  56617. dispose(): void;
  56618. }
  56619. }
  56620. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56621. /** @hidden */
  56622. export var minmaxReduxPixelShader: {
  56623. name: string;
  56624. shader: string;
  56625. };
  56626. }
  56627. declare module "babylonjs/Misc/minMaxReducer" {
  56628. import { Nullable } from "babylonjs/types";
  56629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56630. import { Camera } from "babylonjs/Cameras/camera";
  56631. import { Observer } from "babylonjs/Misc/observable";
  56632. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56633. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56634. import { Observable } from "babylonjs/Misc/observable";
  56635. import "babylonjs/Shaders/minmaxRedux.fragment";
  56636. /**
  56637. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56638. * and maximum values from all values of the texture.
  56639. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56640. * The source values are read from the red channel of the texture.
  56641. */
  56642. export class MinMaxReducer {
  56643. /**
  56644. * Observable triggered when the computation has been performed
  56645. */
  56646. onAfterReductionPerformed: Observable<{
  56647. min: number;
  56648. max: number;
  56649. }>;
  56650. protected _camera: Camera;
  56651. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56652. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56653. protected _postProcessManager: PostProcessManager;
  56654. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56655. protected _forceFullscreenViewport: boolean;
  56656. /**
  56657. * Creates a min/max reducer
  56658. * @param camera The camera to use for the post processes
  56659. */
  56660. constructor(camera: Camera);
  56661. /**
  56662. * Gets the texture used to read the values from.
  56663. */
  56664. get sourceTexture(): Nullable<RenderTargetTexture>;
  56665. /**
  56666. * Sets the source texture to read the values from.
  56667. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56668. * because in such textures '1' value must not be taken into account to compute the maximum
  56669. * as this value is used to clear the texture.
  56670. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56671. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56672. * @param depthRedux Indicates if the texture is a depth texture or not
  56673. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56674. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56675. */
  56676. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56677. /**
  56678. * Defines the refresh rate of the computation.
  56679. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56680. */
  56681. get refreshRate(): number;
  56682. set refreshRate(value: number);
  56683. protected _activated: boolean;
  56684. /**
  56685. * Gets the activation status of the reducer
  56686. */
  56687. get activated(): boolean;
  56688. /**
  56689. * Activates the reduction computation.
  56690. * When activated, the observers registered in onAfterReductionPerformed are
  56691. * called after the compuation is performed
  56692. */
  56693. activate(): void;
  56694. /**
  56695. * Deactivates the reduction computation.
  56696. */
  56697. deactivate(): void;
  56698. /**
  56699. * Disposes the min/max reducer
  56700. * @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.
  56701. */
  56702. dispose(disposeAll?: boolean): void;
  56703. }
  56704. }
  56705. declare module "babylonjs/Misc/depthReducer" {
  56706. import { Nullable } from "babylonjs/types";
  56707. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56708. import { Camera } from "babylonjs/Cameras/camera";
  56709. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56710. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56711. /**
  56712. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56713. */
  56714. export class DepthReducer extends MinMaxReducer {
  56715. private _depthRenderer;
  56716. private _depthRendererId;
  56717. /**
  56718. * Gets the depth renderer used for the computation.
  56719. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56720. */
  56721. get depthRenderer(): Nullable<DepthRenderer>;
  56722. /**
  56723. * Creates a depth reducer
  56724. * @param camera The camera used to render the depth texture
  56725. */
  56726. constructor(camera: Camera);
  56727. /**
  56728. * Sets the depth renderer to use to generate the depth map
  56729. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56730. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56731. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56732. */
  56733. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56734. /** @hidden */
  56735. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56736. /**
  56737. * Activates the reduction computation.
  56738. * When activated, the observers registered in onAfterReductionPerformed are
  56739. * called after the compuation is performed
  56740. */
  56741. activate(): void;
  56742. /**
  56743. * Deactivates the reduction computation.
  56744. */
  56745. deactivate(): void;
  56746. /**
  56747. * Disposes the depth reducer
  56748. * @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.
  56749. */
  56750. dispose(disposeAll?: boolean): void;
  56751. }
  56752. }
  56753. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56754. import { Nullable } from "babylonjs/types";
  56755. import { Scene } from "babylonjs/scene";
  56756. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56758. import { Effect } from "babylonjs/Materials/effect";
  56759. import "babylonjs/Shaders/shadowMap.fragment";
  56760. import "babylonjs/Shaders/shadowMap.vertex";
  56761. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56762. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56763. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56764. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56765. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56766. /**
  56767. * A CSM implementation allowing casting shadows on large scenes.
  56768. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56769. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56770. */
  56771. export class CascadedShadowGenerator extends ShadowGenerator {
  56772. private static readonly frustumCornersNDCSpace;
  56773. /**
  56774. * Name of the CSM class
  56775. */
  56776. static CLASSNAME: string;
  56777. /**
  56778. * Defines the default number of cascades used by the CSM.
  56779. */
  56780. static readonly DEFAULT_CASCADES_COUNT: number;
  56781. /**
  56782. * Defines the minimum number of cascades used by the CSM.
  56783. */
  56784. static readonly MIN_CASCADES_COUNT: number;
  56785. /**
  56786. * Defines the maximum number of cascades used by the CSM.
  56787. */
  56788. static readonly MAX_CASCADES_COUNT: number;
  56789. protected _validateFilter(filter: number): number;
  56790. /**
  56791. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56792. */
  56793. penumbraDarkness: number;
  56794. private _numCascades;
  56795. /**
  56796. * Gets or set the number of cascades used by the CSM.
  56797. */
  56798. get numCascades(): number;
  56799. set numCascades(value: number);
  56800. /**
  56801. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56802. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56803. */
  56804. stabilizeCascades: boolean;
  56805. private _freezeShadowCastersBoundingInfo;
  56806. private _freezeShadowCastersBoundingInfoObservable;
  56807. /**
  56808. * Enables or disables the shadow casters bounding info computation.
  56809. * If your shadow casters don't move, you can disable this feature.
  56810. * If it is enabled, the bounding box computation is done every frame.
  56811. */
  56812. get freezeShadowCastersBoundingInfo(): boolean;
  56813. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56814. private _scbiMin;
  56815. private _scbiMax;
  56816. protected _computeShadowCastersBoundingInfo(): void;
  56817. protected _shadowCastersBoundingInfo: BoundingInfo;
  56818. /**
  56819. * Gets or sets the shadow casters bounding info.
  56820. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56821. * so that the system won't overwrite the bounds you provide
  56822. */
  56823. get shadowCastersBoundingInfo(): BoundingInfo;
  56824. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56825. protected _breaksAreDirty: boolean;
  56826. protected _minDistance: number;
  56827. protected _maxDistance: number;
  56828. /**
  56829. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56830. *
  56831. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56832. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56833. * @param min minimal distance for the breaks (default to 0.)
  56834. * @param max maximal distance for the breaks (default to 1.)
  56835. */
  56836. setMinMaxDistance(min: number, max: number): void;
  56837. /** Gets the minimal distance used in the cascade break computation */
  56838. get minDistance(): number;
  56839. /** Gets the maximal distance used in the cascade break computation */
  56840. get maxDistance(): number;
  56841. /**
  56842. * Gets the class name of that object
  56843. * @returns "CascadedShadowGenerator"
  56844. */
  56845. getClassName(): string;
  56846. private _cascadeMinExtents;
  56847. private _cascadeMaxExtents;
  56848. /**
  56849. * Gets a cascade minimum extents
  56850. * @param cascadeIndex index of the cascade
  56851. * @returns the minimum cascade extents
  56852. */
  56853. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56854. /**
  56855. * Gets a cascade maximum extents
  56856. * @param cascadeIndex index of the cascade
  56857. * @returns the maximum cascade extents
  56858. */
  56859. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56860. private _cascades;
  56861. private _currentLayer;
  56862. private _viewSpaceFrustumsZ;
  56863. private _viewMatrices;
  56864. private _projectionMatrices;
  56865. private _transformMatrices;
  56866. private _transformMatricesAsArray;
  56867. private _frustumLengths;
  56868. private _lightSizeUVCorrection;
  56869. private _depthCorrection;
  56870. private _frustumCornersWorldSpace;
  56871. private _frustumCenter;
  56872. private _shadowCameraPos;
  56873. private _shadowMaxZ;
  56874. /**
  56875. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56876. * It defaults to camera.maxZ
  56877. */
  56878. get shadowMaxZ(): number;
  56879. /**
  56880. * Sets the shadow max z distance.
  56881. */
  56882. set shadowMaxZ(value: number);
  56883. protected _debug: boolean;
  56884. /**
  56885. * Gets or sets the debug flag.
  56886. * When enabled, the cascades are materialized by different colors on the screen.
  56887. */
  56888. get debug(): boolean;
  56889. set debug(dbg: boolean);
  56890. private _depthClamp;
  56891. /**
  56892. * Gets or sets the depth clamping value.
  56893. *
  56894. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56895. * to account for the shadow casters far away.
  56896. *
  56897. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56898. */
  56899. get depthClamp(): boolean;
  56900. set depthClamp(value: boolean);
  56901. private _cascadeBlendPercentage;
  56902. /**
  56903. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56904. * It defaults to 0.1 (10% blending).
  56905. */
  56906. get cascadeBlendPercentage(): number;
  56907. set cascadeBlendPercentage(value: number);
  56908. private _lambda;
  56909. /**
  56910. * Gets or set the lambda parameter.
  56911. * This parameter is used to split the camera frustum and create the cascades.
  56912. * 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.
  56913. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56914. */
  56915. get lambda(): number;
  56916. set lambda(value: number);
  56917. /**
  56918. * Gets the view matrix corresponding to a given cascade
  56919. * @param cascadeNum cascade to retrieve the view matrix from
  56920. * @returns the cascade view matrix
  56921. */
  56922. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56923. /**
  56924. * Gets the projection matrix corresponding to a given cascade
  56925. * @param cascadeNum cascade to retrieve the projection matrix from
  56926. * @returns the cascade projection matrix
  56927. */
  56928. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56929. /**
  56930. * Gets the transformation matrix corresponding to a given cascade
  56931. * @param cascadeNum cascade to retrieve the transformation matrix from
  56932. * @returns the cascade transformation matrix
  56933. */
  56934. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56935. private _depthRenderer;
  56936. /**
  56937. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56938. *
  56939. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56940. *
  56941. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56942. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56943. * @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
  56944. */
  56945. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56946. private _depthReducer;
  56947. private _autoCalcDepthBounds;
  56948. /**
  56949. * Gets or sets the autoCalcDepthBounds property.
  56950. *
  56951. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56952. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56953. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56954. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56955. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56956. */
  56957. get autoCalcDepthBounds(): boolean;
  56958. set autoCalcDepthBounds(value: boolean);
  56959. /**
  56960. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56961. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56962. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56963. * for setting the refresh rate on the renderer yourself!
  56964. */
  56965. get autoCalcDepthBoundsRefreshRate(): number;
  56966. set autoCalcDepthBoundsRefreshRate(value: number);
  56967. /**
  56968. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56969. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56970. * you change the camera near/far planes!
  56971. */
  56972. splitFrustum(): void;
  56973. private _splitFrustum;
  56974. private _computeMatrices;
  56975. private _computeFrustumInWorldSpace;
  56976. private _computeCascadeFrustum;
  56977. /** @hidden */
  56978. static _SceneComponentInitialization: (scene: Scene) => void;
  56979. /**
  56980. * Creates a Cascaded Shadow Generator object.
  56981. * A ShadowGenerator is the required tool to use the shadows.
  56982. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56983. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56984. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56985. * @param light The directional light object generating the shadows.
  56986. * @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.
  56987. */
  56988. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56989. protected _initializeGenerator(): void;
  56990. protected _createTargetRenderTexture(): void;
  56991. protected _initializeShadowMap(): void;
  56992. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56993. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56994. /**
  56995. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56996. * @param defines Defines of the material we want to update
  56997. * @param lightIndex Index of the light in the enabled light list of the material
  56998. */
  56999. prepareDefines(defines: any, lightIndex: number): void;
  57000. /**
  57001. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57002. * defined in the generator but impacting the effect).
  57003. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57004. * @param effect The effect we are binfing the information for
  57005. */
  57006. bindShadowLight(lightIndex: string, effect: Effect): void;
  57007. /**
  57008. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57009. * (eq to view projection * shadow projection matrices)
  57010. * @returns The transform matrix used to create the shadow map
  57011. */
  57012. getTransformMatrix(): Matrix;
  57013. /**
  57014. * Disposes the ShadowGenerator.
  57015. * Returns nothing.
  57016. */
  57017. dispose(): void;
  57018. /**
  57019. * Serializes the shadow generator setup to a json object.
  57020. * @returns The serialized JSON object
  57021. */
  57022. serialize(): any;
  57023. /**
  57024. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57025. * @param parsedShadowGenerator The JSON object to parse
  57026. * @param scene The scene to create the shadow map for
  57027. * @returns The parsed shadow generator
  57028. */
  57029. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57030. }
  57031. }
  57032. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57033. import { Scene } from "babylonjs/scene";
  57034. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57035. import { AbstractScene } from "babylonjs/abstractScene";
  57036. /**
  57037. * Defines the shadow generator component responsible to manage any shadow generators
  57038. * in a given scene.
  57039. */
  57040. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57041. /**
  57042. * The component name helpfull to identify the component in the list of scene components.
  57043. */
  57044. readonly name: string;
  57045. /**
  57046. * The scene the component belongs to.
  57047. */
  57048. scene: Scene;
  57049. /**
  57050. * Creates a new instance of the component for the given scene
  57051. * @param scene Defines the scene to register the component in
  57052. */
  57053. constructor(scene: Scene);
  57054. /**
  57055. * Registers the component in a given scene
  57056. */
  57057. register(): void;
  57058. /**
  57059. * Rebuilds the elements related to this component in case of
  57060. * context lost for instance.
  57061. */
  57062. rebuild(): void;
  57063. /**
  57064. * Serializes the component data to the specified json object
  57065. * @param serializationObject The object to serialize to
  57066. */
  57067. serialize(serializationObject: any): void;
  57068. /**
  57069. * Adds all the elements from the container to the scene
  57070. * @param container the container holding the elements
  57071. */
  57072. addFromContainer(container: AbstractScene): void;
  57073. /**
  57074. * Removes all the elements in the container from the scene
  57075. * @param container contains the elements to remove
  57076. * @param dispose if the removed element should be disposed (default: false)
  57077. */
  57078. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57079. /**
  57080. * Rebuilds the elements related to this component in case of
  57081. * context lost for instance.
  57082. */
  57083. dispose(): void;
  57084. private _gatherRenderTargets;
  57085. }
  57086. }
  57087. declare module "babylonjs/Lights/Shadows/index" {
  57088. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57089. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57090. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57091. }
  57092. declare module "babylonjs/Lights/pointLight" {
  57093. import { Scene } from "babylonjs/scene";
  57094. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57096. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57097. import { Effect } from "babylonjs/Materials/effect";
  57098. /**
  57099. * A point light is a light defined by an unique point in world space.
  57100. * The light is emitted in every direction from this point.
  57101. * A good example of a point light is a standard light bulb.
  57102. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57103. */
  57104. export class PointLight extends ShadowLight {
  57105. private _shadowAngle;
  57106. /**
  57107. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57108. * This specifies what angle the shadow will use to be created.
  57109. *
  57110. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57111. */
  57112. get shadowAngle(): number;
  57113. /**
  57114. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57115. * This specifies what angle the shadow will use to be created.
  57116. *
  57117. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57118. */
  57119. set shadowAngle(value: number);
  57120. /**
  57121. * Gets the direction if it has been set.
  57122. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57123. */
  57124. get direction(): Vector3;
  57125. /**
  57126. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57127. */
  57128. set direction(value: Vector3);
  57129. /**
  57130. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57131. * A PointLight emits the light in every direction.
  57132. * It can cast shadows.
  57133. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57134. * ```javascript
  57135. * var pointLight = new PointLight("pl", camera.position, scene);
  57136. * ```
  57137. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57138. * @param name The light friendly name
  57139. * @param position The position of the point light in the scene
  57140. * @param scene The scene the lights belongs to
  57141. */
  57142. constructor(name: string, position: Vector3, scene: Scene);
  57143. /**
  57144. * Returns the string "PointLight"
  57145. * @returns the class name
  57146. */
  57147. getClassName(): string;
  57148. /**
  57149. * Returns the integer 0.
  57150. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57151. */
  57152. getTypeID(): number;
  57153. /**
  57154. * Specifies wether or not the shadowmap should be a cube texture.
  57155. * @returns true if the shadowmap needs to be a cube texture.
  57156. */
  57157. needCube(): boolean;
  57158. /**
  57159. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57160. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57161. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57162. */
  57163. getShadowDirection(faceIndex?: number): Vector3;
  57164. /**
  57165. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57166. * - fov = PI / 2
  57167. * - aspect ratio : 1.0
  57168. * - z-near and far equal to the active camera minZ and maxZ.
  57169. * Returns the PointLight.
  57170. */
  57171. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57172. protected _buildUniformLayout(): void;
  57173. /**
  57174. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57175. * @param effect The effect to update
  57176. * @param lightIndex The index of the light in the effect to update
  57177. * @returns The point light
  57178. */
  57179. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57180. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57181. /**
  57182. * Prepares the list of defines specific to the light type.
  57183. * @param defines the list of defines
  57184. * @param lightIndex defines the index of the light for the effect
  57185. */
  57186. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57187. }
  57188. }
  57189. declare module "babylonjs/Lights/index" {
  57190. export * from "babylonjs/Lights/light";
  57191. export * from "babylonjs/Lights/shadowLight";
  57192. export * from "babylonjs/Lights/Shadows/index";
  57193. export * from "babylonjs/Lights/directionalLight";
  57194. export * from "babylonjs/Lights/hemisphericLight";
  57195. export * from "babylonjs/Lights/pointLight";
  57196. export * from "babylonjs/Lights/spotLight";
  57197. }
  57198. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57199. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57200. /**
  57201. * Header information of HDR texture files.
  57202. */
  57203. export interface HDRInfo {
  57204. /**
  57205. * The height of the texture in pixels.
  57206. */
  57207. height: number;
  57208. /**
  57209. * The width of the texture in pixels.
  57210. */
  57211. width: number;
  57212. /**
  57213. * The index of the beginning of the data in the binary file.
  57214. */
  57215. dataPosition: number;
  57216. }
  57217. /**
  57218. * This groups tools to convert HDR texture to native colors array.
  57219. */
  57220. export class HDRTools {
  57221. private static Ldexp;
  57222. private static Rgbe2float;
  57223. private static readStringLine;
  57224. /**
  57225. * Reads header information from an RGBE texture stored in a native array.
  57226. * More information on this format are available here:
  57227. * https://en.wikipedia.org/wiki/RGBE_image_format
  57228. *
  57229. * @param uint8array The binary file stored in native array.
  57230. * @return The header information.
  57231. */
  57232. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57233. /**
  57234. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57235. * This RGBE texture needs to store the information as a panorama.
  57236. *
  57237. * More information on this format are available here:
  57238. * https://en.wikipedia.org/wiki/RGBE_image_format
  57239. *
  57240. * @param buffer The binary file stored in an array buffer.
  57241. * @param size The expected size of the extracted cubemap.
  57242. * @return The Cube Map information.
  57243. */
  57244. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57245. /**
  57246. * Returns the pixels data extracted from an RGBE texture.
  57247. * This pixels will be stored left to right up to down in the R G B order in one array.
  57248. *
  57249. * More information on this format are available here:
  57250. * https://en.wikipedia.org/wiki/RGBE_image_format
  57251. *
  57252. * @param uint8array The binary file stored in an array buffer.
  57253. * @param hdrInfo The header information of the file.
  57254. * @return The pixels data in RGB right to left up to down order.
  57255. */
  57256. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57257. private static RGBE_ReadPixels_RLE;
  57258. }
  57259. }
  57260. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57261. import { Nullable } from "babylonjs/types";
  57262. import { Scene } from "babylonjs/scene";
  57263. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57265. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57266. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57267. /**
  57268. * This represents a texture coming from an HDR input.
  57269. *
  57270. * The only supported format is currently panorama picture stored in RGBE format.
  57271. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57272. */
  57273. export class HDRCubeTexture extends BaseTexture {
  57274. private static _facesMapping;
  57275. private _generateHarmonics;
  57276. private _noMipmap;
  57277. private _textureMatrix;
  57278. private _size;
  57279. private _onLoad;
  57280. private _onError;
  57281. /**
  57282. * The texture URL.
  57283. */
  57284. url: string;
  57285. /**
  57286. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57287. */
  57288. coordinatesMode: number;
  57289. protected _isBlocking: boolean;
  57290. /**
  57291. * Sets wether or not the texture is blocking during loading.
  57292. */
  57293. set isBlocking(value: boolean);
  57294. /**
  57295. * Gets wether or not the texture is blocking during loading.
  57296. */
  57297. get isBlocking(): boolean;
  57298. protected _rotationY: number;
  57299. /**
  57300. * Sets texture matrix rotation angle around Y axis in radians.
  57301. */
  57302. set rotationY(value: number);
  57303. /**
  57304. * Gets texture matrix rotation angle around Y axis radians.
  57305. */
  57306. get rotationY(): number;
  57307. /**
  57308. * Gets or sets the center of the bounding box associated with the cube texture
  57309. * It must define where the camera used to render the texture was set
  57310. */
  57311. boundingBoxPosition: Vector3;
  57312. private _boundingBoxSize;
  57313. /**
  57314. * Gets or sets the size of the bounding box associated with the cube texture
  57315. * When defined, the cubemap will switch to local mode
  57316. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57317. * @example https://www.babylonjs-playground.com/#RNASML
  57318. */
  57319. set boundingBoxSize(value: Vector3);
  57320. get boundingBoxSize(): Vector3;
  57321. /**
  57322. * Instantiates an HDRTexture from the following parameters.
  57323. *
  57324. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57325. * @param scene The scene the texture will be used in
  57326. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57327. * @param noMipmap Forces to not generate the mipmap if true
  57328. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57329. * @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)
  57330. * @param reserved Reserved flag for internal use.
  57331. */
  57332. 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>);
  57333. /**
  57334. * Get the current class name of the texture useful for serialization or dynamic coding.
  57335. * @returns "HDRCubeTexture"
  57336. */
  57337. getClassName(): string;
  57338. /**
  57339. * Occurs when the file is raw .hdr file.
  57340. */
  57341. private loadTexture;
  57342. clone(): HDRCubeTexture;
  57343. delayLoad(): void;
  57344. /**
  57345. * Get the texture reflection matrix used to rotate/transform the reflection.
  57346. * @returns the reflection matrix
  57347. */
  57348. getReflectionTextureMatrix(): Matrix;
  57349. /**
  57350. * Set the texture reflection matrix used to rotate/transform the reflection.
  57351. * @param value Define the reflection matrix to set
  57352. */
  57353. setReflectionTextureMatrix(value: Matrix): void;
  57354. /**
  57355. * Parses a JSON representation of an HDR Texture in order to create the texture
  57356. * @param parsedTexture Define the JSON representation
  57357. * @param scene Define the scene the texture should be created in
  57358. * @param rootUrl Define the root url in case we need to load relative dependencies
  57359. * @returns the newly created texture after parsing
  57360. */
  57361. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57362. serialize(): any;
  57363. }
  57364. }
  57365. declare module "babylonjs/Physics/physicsEngine" {
  57366. import { Nullable } from "babylonjs/types";
  57367. import { Vector3 } from "babylonjs/Maths/math.vector";
  57368. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57369. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57370. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57371. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57372. /**
  57373. * Class used to control physics engine
  57374. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57375. */
  57376. export class PhysicsEngine implements IPhysicsEngine {
  57377. private _physicsPlugin;
  57378. /**
  57379. * Global value used to control the smallest number supported by the simulation
  57380. */
  57381. static Epsilon: number;
  57382. private _impostors;
  57383. private _joints;
  57384. private _subTimeStep;
  57385. /**
  57386. * Gets the gravity vector used by the simulation
  57387. */
  57388. gravity: Vector3;
  57389. /**
  57390. * Factory used to create the default physics plugin.
  57391. * @returns The default physics plugin
  57392. */
  57393. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57394. /**
  57395. * Creates a new Physics Engine
  57396. * @param gravity defines the gravity vector used by the simulation
  57397. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57398. */
  57399. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57400. /**
  57401. * Sets the gravity vector used by the simulation
  57402. * @param gravity defines the gravity vector to use
  57403. */
  57404. setGravity(gravity: Vector3): void;
  57405. /**
  57406. * Set the time step of the physics engine.
  57407. * Default is 1/60.
  57408. * To slow it down, enter 1/600 for example.
  57409. * To speed it up, 1/30
  57410. * @param newTimeStep defines the new timestep to apply to this world.
  57411. */
  57412. setTimeStep(newTimeStep?: number): void;
  57413. /**
  57414. * Get the time step of the physics engine.
  57415. * @returns the current time step
  57416. */
  57417. getTimeStep(): number;
  57418. /**
  57419. * Set the sub time step of the physics engine.
  57420. * Default is 0 meaning there is no sub steps
  57421. * To increase physics resolution precision, set a small value (like 1 ms)
  57422. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57423. */
  57424. setSubTimeStep(subTimeStep?: number): void;
  57425. /**
  57426. * Get the sub time step of the physics engine.
  57427. * @returns the current sub time step
  57428. */
  57429. getSubTimeStep(): number;
  57430. /**
  57431. * Release all resources
  57432. */
  57433. dispose(): void;
  57434. /**
  57435. * Gets the name of the current physics plugin
  57436. * @returns the name of the plugin
  57437. */
  57438. getPhysicsPluginName(): string;
  57439. /**
  57440. * Adding a new impostor for the impostor tracking.
  57441. * This will be done by the impostor itself.
  57442. * @param impostor the impostor to add
  57443. */
  57444. addImpostor(impostor: PhysicsImpostor): void;
  57445. /**
  57446. * Remove an impostor from the engine.
  57447. * This impostor and its mesh will not longer be updated by the physics engine.
  57448. * @param impostor the impostor to remove
  57449. */
  57450. removeImpostor(impostor: PhysicsImpostor): void;
  57451. /**
  57452. * Add a joint to the physics engine
  57453. * @param mainImpostor defines the main impostor to which the joint is added.
  57454. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57455. * @param joint defines the joint that will connect both impostors.
  57456. */
  57457. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57458. /**
  57459. * Removes a joint from the simulation
  57460. * @param mainImpostor defines the impostor used with the joint
  57461. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57462. * @param joint defines the joint to remove
  57463. */
  57464. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57465. /**
  57466. * Called by the scene. No need to call it.
  57467. * @param delta defines the timespam between frames
  57468. */
  57469. _step(delta: number): void;
  57470. /**
  57471. * Gets the current plugin used to run the simulation
  57472. * @returns current plugin
  57473. */
  57474. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57475. /**
  57476. * Gets the list of physic impostors
  57477. * @returns an array of PhysicsImpostor
  57478. */
  57479. getImpostors(): Array<PhysicsImpostor>;
  57480. /**
  57481. * Gets the impostor for a physics enabled object
  57482. * @param object defines the object impersonated by the impostor
  57483. * @returns the PhysicsImpostor or null if not found
  57484. */
  57485. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57486. /**
  57487. * Gets the impostor for a physics body object
  57488. * @param body defines physics body used by the impostor
  57489. * @returns the PhysicsImpostor or null if not found
  57490. */
  57491. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57492. /**
  57493. * Does a raycast in the physics world
  57494. * @param from when should the ray start?
  57495. * @param to when should the ray end?
  57496. * @returns PhysicsRaycastResult
  57497. */
  57498. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57499. }
  57500. }
  57501. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57502. import { Nullable } from "babylonjs/types";
  57503. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57505. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57506. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57507. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57508. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57509. /** @hidden */
  57510. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57511. private _useDeltaForWorldStep;
  57512. world: any;
  57513. name: string;
  57514. private _physicsMaterials;
  57515. private _fixedTimeStep;
  57516. private _cannonRaycastResult;
  57517. private _raycastResult;
  57518. private _physicsBodysToRemoveAfterStep;
  57519. BJSCANNON: any;
  57520. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57521. setGravity(gravity: Vector3): void;
  57522. setTimeStep(timeStep: number): void;
  57523. getTimeStep(): number;
  57524. executeStep(delta: number): void;
  57525. private _removeMarkedPhysicsBodiesFromWorld;
  57526. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57527. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57528. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57529. private _processChildMeshes;
  57530. removePhysicsBody(impostor: PhysicsImpostor): void;
  57531. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57532. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57533. private _addMaterial;
  57534. private _checkWithEpsilon;
  57535. private _createShape;
  57536. private _createHeightmap;
  57537. private _minus90X;
  57538. private _plus90X;
  57539. private _tmpPosition;
  57540. private _tmpDeltaPosition;
  57541. private _tmpUnityRotation;
  57542. private _updatePhysicsBodyTransformation;
  57543. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57544. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57545. isSupported(): boolean;
  57546. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57547. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57548. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57549. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57550. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57551. getBodyMass(impostor: PhysicsImpostor): number;
  57552. getBodyFriction(impostor: PhysicsImpostor): number;
  57553. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57554. getBodyRestitution(impostor: PhysicsImpostor): number;
  57555. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57556. sleepBody(impostor: PhysicsImpostor): void;
  57557. wakeUpBody(impostor: PhysicsImpostor): void;
  57558. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57559. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57560. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57561. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57562. getRadius(impostor: PhysicsImpostor): number;
  57563. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57564. dispose(): void;
  57565. private _extendNamespace;
  57566. /**
  57567. * Does a raycast in the physics world
  57568. * @param from when should the ray start?
  57569. * @param to when should the ray end?
  57570. * @returns PhysicsRaycastResult
  57571. */
  57572. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57573. }
  57574. }
  57575. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57576. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57577. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57578. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57580. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57581. import { Nullable } from "babylonjs/types";
  57582. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57583. /** @hidden */
  57584. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57585. world: any;
  57586. name: string;
  57587. BJSOIMO: any;
  57588. private _raycastResult;
  57589. constructor(iterations?: number, oimoInjection?: any);
  57590. setGravity(gravity: Vector3): void;
  57591. setTimeStep(timeStep: number): void;
  57592. getTimeStep(): number;
  57593. private _tmpImpostorsArray;
  57594. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57595. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57596. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57597. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57598. private _tmpPositionVector;
  57599. removePhysicsBody(impostor: PhysicsImpostor): void;
  57600. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57601. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57602. isSupported(): boolean;
  57603. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57604. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57605. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57606. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57607. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57608. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57609. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57610. getBodyMass(impostor: PhysicsImpostor): number;
  57611. getBodyFriction(impostor: PhysicsImpostor): number;
  57612. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57613. getBodyRestitution(impostor: PhysicsImpostor): number;
  57614. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57615. sleepBody(impostor: PhysicsImpostor): void;
  57616. wakeUpBody(impostor: PhysicsImpostor): void;
  57617. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57618. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57619. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57620. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57621. getRadius(impostor: PhysicsImpostor): number;
  57622. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57623. dispose(): void;
  57624. /**
  57625. * Does a raycast in the physics world
  57626. * @param from when should the ray start?
  57627. * @param to when should the ray end?
  57628. * @returns PhysicsRaycastResult
  57629. */
  57630. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57631. }
  57632. }
  57633. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57634. import { Nullable } from "babylonjs/types";
  57635. import { Scene } from "babylonjs/scene";
  57636. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57637. import { Color4 } from "babylonjs/Maths/math.color";
  57638. import { Mesh } from "babylonjs/Meshes/mesh";
  57639. /**
  57640. * Class containing static functions to help procedurally build meshes
  57641. */
  57642. export class RibbonBuilder {
  57643. /**
  57644. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57645. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57646. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57647. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57648. * * 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
  57649. * * 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
  57650. * * 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
  57651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57654. * * 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
  57655. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57656. * * 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
  57657. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57659. * @param name defines the name of the mesh
  57660. * @param options defines the options used to create the mesh
  57661. * @param scene defines the hosting scene
  57662. * @returns the ribbon mesh
  57663. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57665. */
  57666. static CreateRibbon(name: string, options: {
  57667. pathArray: Vector3[][];
  57668. closeArray?: boolean;
  57669. closePath?: boolean;
  57670. offset?: number;
  57671. updatable?: boolean;
  57672. sideOrientation?: number;
  57673. frontUVs?: Vector4;
  57674. backUVs?: Vector4;
  57675. instance?: Mesh;
  57676. invertUV?: boolean;
  57677. uvs?: Vector2[];
  57678. colors?: Color4[];
  57679. }, scene?: Nullable<Scene>): Mesh;
  57680. }
  57681. }
  57682. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57683. import { Nullable } from "babylonjs/types";
  57684. import { Scene } from "babylonjs/scene";
  57685. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57686. import { Mesh } from "babylonjs/Meshes/mesh";
  57687. /**
  57688. * Class containing static functions to help procedurally build meshes
  57689. */
  57690. export class ShapeBuilder {
  57691. /**
  57692. * 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.
  57693. * * 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.
  57694. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57695. * * 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.
  57696. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57697. * * 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
  57698. * * 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
  57699. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57702. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57704. * @param name defines the name of the mesh
  57705. * @param options defines the options used to create the mesh
  57706. * @param scene defines the hosting scene
  57707. * @returns the extruded shape mesh
  57708. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57710. */
  57711. static ExtrudeShape(name: string, options: {
  57712. shape: Vector3[];
  57713. path: Vector3[];
  57714. scale?: number;
  57715. rotation?: number;
  57716. cap?: number;
  57717. updatable?: boolean;
  57718. sideOrientation?: number;
  57719. frontUVs?: Vector4;
  57720. backUVs?: Vector4;
  57721. instance?: Mesh;
  57722. invertUV?: boolean;
  57723. }, scene?: Nullable<Scene>): Mesh;
  57724. /**
  57725. * Creates an custom extruded shape mesh.
  57726. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57727. * * 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.
  57728. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57729. * * 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
  57730. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57731. * * 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
  57732. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57733. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57734. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57735. * * 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
  57736. * * 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
  57737. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57740. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57742. * @param name defines the name of the mesh
  57743. * @param options defines the options used to create the mesh
  57744. * @param scene defines the hosting scene
  57745. * @returns the custom extruded shape mesh
  57746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57747. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57749. */
  57750. static ExtrudeShapeCustom(name: string, options: {
  57751. shape: Vector3[];
  57752. path: Vector3[];
  57753. scaleFunction?: any;
  57754. rotationFunction?: any;
  57755. ribbonCloseArray?: boolean;
  57756. ribbonClosePath?: boolean;
  57757. cap?: number;
  57758. updatable?: boolean;
  57759. sideOrientation?: number;
  57760. frontUVs?: Vector4;
  57761. backUVs?: Vector4;
  57762. instance?: Mesh;
  57763. invertUV?: boolean;
  57764. }, scene?: Nullable<Scene>): Mesh;
  57765. private static _ExtrudeShapeGeneric;
  57766. }
  57767. }
  57768. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57769. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57770. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57771. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57772. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57773. import { Nullable } from "babylonjs/types";
  57774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57775. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57776. /**
  57777. * AmmoJS Physics plugin
  57778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57779. * @see https://github.com/kripken/ammo.js/
  57780. */
  57781. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57782. private _useDeltaForWorldStep;
  57783. /**
  57784. * Reference to the Ammo library
  57785. */
  57786. bjsAMMO: any;
  57787. /**
  57788. * Created ammoJS world which physics bodies are added to
  57789. */
  57790. world: any;
  57791. /**
  57792. * Name of the plugin
  57793. */
  57794. name: string;
  57795. private _timeStep;
  57796. private _fixedTimeStep;
  57797. private _maxSteps;
  57798. private _tmpQuaternion;
  57799. private _tmpAmmoTransform;
  57800. private _tmpAmmoQuaternion;
  57801. private _tmpAmmoConcreteContactResultCallback;
  57802. private _collisionConfiguration;
  57803. private _dispatcher;
  57804. private _overlappingPairCache;
  57805. private _solver;
  57806. private _softBodySolver;
  57807. private _tmpAmmoVectorA;
  57808. private _tmpAmmoVectorB;
  57809. private _tmpAmmoVectorC;
  57810. private _tmpAmmoVectorD;
  57811. private _tmpContactCallbackResult;
  57812. private _tmpAmmoVectorRCA;
  57813. private _tmpAmmoVectorRCB;
  57814. private _raycastResult;
  57815. private static readonly DISABLE_COLLISION_FLAG;
  57816. private static readonly KINEMATIC_FLAG;
  57817. private static readonly DISABLE_DEACTIVATION_FLAG;
  57818. /**
  57819. * Initializes the ammoJS plugin
  57820. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57821. * @param ammoInjection can be used to inject your own ammo reference
  57822. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57823. */
  57824. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57825. /**
  57826. * Sets the gravity of the physics world (m/(s^2))
  57827. * @param gravity Gravity to set
  57828. */
  57829. setGravity(gravity: Vector3): void;
  57830. /**
  57831. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57832. * @param timeStep timestep to use in seconds
  57833. */
  57834. setTimeStep(timeStep: number): void;
  57835. /**
  57836. * 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)
  57837. * @param fixedTimeStep fixedTimeStep to use in seconds
  57838. */
  57839. setFixedTimeStep(fixedTimeStep: number): void;
  57840. /**
  57841. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57842. * @param maxSteps the maximum number of steps by the physics engine per frame
  57843. */
  57844. setMaxSteps(maxSteps: number): void;
  57845. /**
  57846. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57847. * @returns the current timestep in seconds
  57848. */
  57849. getTimeStep(): number;
  57850. /**
  57851. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57852. */
  57853. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57854. private _isImpostorInContact;
  57855. private _isImpostorPairInContact;
  57856. private _stepSimulation;
  57857. /**
  57858. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57859. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57860. * After the step the babylon meshes are set to the position of the physics imposters
  57861. * @param delta amount of time to step forward
  57862. * @param impostors array of imposters to update before/after the step
  57863. */
  57864. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57865. /**
  57866. * Update babylon mesh to match physics world object
  57867. * @param impostor imposter to match
  57868. */
  57869. private _afterSoftStep;
  57870. /**
  57871. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57872. * @param impostor imposter to match
  57873. */
  57874. private _ropeStep;
  57875. /**
  57876. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57877. * @param impostor imposter to match
  57878. */
  57879. private _softbodyOrClothStep;
  57880. private _tmpVector;
  57881. private _tmpMatrix;
  57882. /**
  57883. * Applies an impulse on the imposter
  57884. * @param impostor imposter to apply impulse to
  57885. * @param force amount of force to be applied to the imposter
  57886. * @param contactPoint the location to apply the impulse on the imposter
  57887. */
  57888. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57889. /**
  57890. * Applies a force on the imposter
  57891. * @param impostor imposter to apply force
  57892. * @param force amount of force to be applied to the imposter
  57893. * @param contactPoint the location to apply the force on the imposter
  57894. */
  57895. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57896. /**
  57897. * Creates a physics body using the plugin
  57898. * @param impostor the imposter to create the physics body on
  57899. */
  57900. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57901. /**
  57902. * Removes the physics body from the imposter and disposes of the body's memory
  57903. * @param impostor imposter to remove the physics body from
  57904. */
  57905. removePhysicsBody(impostor: PhysicsImpostor): void;
  57906. /**
  57907. * Generates a joint
  57908. * @param impostorJoint the imposter joint to create the joint with
  57909. */
  57910. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57911. /**
  57912. * Removes a joint
  57913. * @param impostorJoint the imposter joint to remove the joint from
  57914. */
  57915. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57916. private _addMeshVerts;
  57917. /**
  57918. * Initialise the soft body vertices to match its object's (mesh) vertices
  57919. * Softbody vertices (nodes) are in world space and to match this
  57920. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57921. * @param impostor to create the softbody for
  57922. */
  57923. private _softVertexData;
  57924. /**
  57925. * Create an impostor's soft body
  57926. * @param impostor to create the softbody for
  57927. */
  57928. private _createSoftbody;
  57929. /**
  57930. * Create cloth for an impostor
  57931. * @param impostor to create the softbody for
  57932. */
  57933. private _createCloth;
  57934. /**
  57935. * Create rope for an impostor
  57936. * @param impostor to create the softbody for
  57937. */
  57938. private _createRope;
  57939. /**
  57940. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57941. * @param impostor to create the custom physics shape for
  57942. */
  57943. private _createCustom;
  57944. private _addHullVerts;
  57945. private _createShape;
  57946. /**
  57947. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57948. * @param impostor imposter containing the physics body and babylon object
  57949. */
  57950. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57951. /**
  57952. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57953. * @param impostor imposter containing the physics body and babylon object
  57954. * @param newPosition new position
  57955. * @param newRotation new rotation
  57956. */
  57957. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57958. /**
  57959. * If this plugin is supported
  57960. * @returns true if its supported
  57961. */
  57962. isSupported(): boolean;
  57963. /**
  57964. * Sets the linear velocity of the physics body
  57965. * @param impostor imposter to set the velocity on
  57966. * @param velocity velocity to set
  57967. */
  57968. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57969. /**
  57970. * Sets the angular velocity of the physics body
  57971. * @param impostor imposter to set the velocity on
  57972. * @param velocity velocity to set
  57973. */
  57974. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57975. /**
  57976. * gets the linear velocity
  57977. * @param impostor imposter to get linear velocity from
  57978. * @returns linear velocity
  57979. */
  57980. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57981. /**
  57982. * gets the angular velocity
  57983. * @param impostor imposter to get angular velocity from
  57984. * @returns angular velocity
  57985. */
  57986. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57987. /**
  57988. * Sets the mass of physics body
  57989. * @param impostor imposter to set the mass on
  57990. * @param mass mass to set
  57991. */
  57992. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57993. /**
  57994. * Gets the mass of the physics body
  57995. * @param impostor imposter to get the mass from
  57996. * @returns mass
  57997. */
  57998. getBodyMass(impostor: PhysicsImpostor): number;
  57999. /**
  58000. * Gets friction of the impostor
  58001. * @param impostor impostor to get friction from
  58002. * @returns friction value
  58003. */
  58004. getBodyFriction(impostor: PhysicsImpostor): number;
  58005. /**
  58006. * Sets friction of the impostor
  58007. * @param impostor impostor to set friction on
  58008. * @param friction friction value
  58009. */
  58010. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58011. /**
  58012. * Gets restitution of the impostor
  58013. * @param impostor impostor to get restitution from
  58014. * @returns restitution value
  58015. */
  58016. getBodyRestitution(impostor: PhysicsImpostor): number;
  58017. /**
  58018. * Sets resitution of the impostor
  58019. * @param impostor impostor to set resitution on
  58020. * @param restitution resitution value
  58021. */
  58022. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58023. /**
  58024. * Gets pressure inside the impostor
  58025. * @param impostor impostor to get pressure from
  58026. * @returns pressure value
  58027. */
  58028. getBodyPressure(impostor: PhysicsImpostor): number;
  58029. /**
  58030. * Sets pressure inside a soft body impostor
  58031. * Cloth and rope must remain 0 pressure
  58032. * @param impostor impostor to set pressure on
  58033. * @param pressure pressure value
  58034. */
  58035. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58036. /**
  58037. * Gets stiffness of the impostor
  58038. * @param impostor impostor to get stiffness from
  58039. * @returns pressure value
  58040. */
  58041. getBodyStiffness(impostor: PhysicsImpostor): number;
  58042. /**
  58043. * Sets stiffness of the impostor
  58044. * @param impostor impostor to set stiffness on
  58045. * @param stiffness stiffness value from 0 to 1
  58046. */
  58047. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58048. /**
  58049. * Gets velocityIterations of the impostor
  58050. * @param impostor impostor to get velocity iterations from
  58051. * @returns velocityIterations value
  58052. */
  58053. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58054. /**
  58055. * Sets velocityIterations of the impostor
  58056. * @param impostor impostor to set velocity iterations on
  58057. * @param velocityIterations velocityIterations value
  58058. */
  58059. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58060. /**
  58061. * Gets positionIterations of the impostor
  58062. * @param impostor impostor to get position iterations from
  58063. * @returns positionIterations value
  58064. */
  58065. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58066. /**
  58067. * Sets positionIterations of the impostor
  58068. * @param impostor impostor to set position on
  58069. * @param positionIterations positionIterations value
  58070. */
  58071. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58072. /**
  58073. * Append an anchor to a cloth object
  58074. * @param impostor is the cloth impostor to add anchor to
  58075. * @param otherImpostor is the rigid impostor to anchor to
  58076. * @param width ratio across width from 0 to 1
  58077. * @param height ratio up height from 0 to 1
  58078. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58079. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58080. */
  58081. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58082. /**
  58083. * Append an hook to a rope object
  58084. * @param impostor is the rope impostor to add hook to
  58085. * @param otherImpostor is the rigid impostor to hook to
  58086. * @param length ratio along the rope from 0 to 1
  58087. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58088. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58089. */
  58090. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58091. /**
  58092. * Sleeps the physics body and stops it from being active
  58093. * @param impostor impostor to sleep
  58094. */
  58095. sleepBody(impostor: PhysicsImpostor): void;
  58096. /**
  58097. * Activates the physics body
  58098. * @param impostor impostor to activate
  58099. */
  58100. wakeUpBody(impostor: PhysicsImpostor): void;
  58101. /**
  58102. * Updates the distance parameters of the joint
  58103. * @param joint joint to update
  58104. * @param maxDistance maximum distance of the joint
  58105. * @param minDistance minimum distance of the joint
  58106. */
  58107. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58108. /**
  58109. * Sets a motor on the joint
  58110. * @param joint joint to set motor on
  58111. * @param speed speed of the motor
  58112. * @param maxForce maximum force of the motor
  58113. * @param motorIndex index of the motor
  58114. */
  58115. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58116. /**
  58117. * Sets the motors limit
  58118. * @param joint joint to set limit on
  58119. * @param upperLimit upper limit
  58120. * @param lowerLimit lower limit
  58121. */
  58122. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58123. /**
  58124. * Syncs the position and rotation of a mesh with the impostor
  58125. * @param mesh mesh to sync
  58126. * @param impostor impostor to update the mesh with
  58127. */
  58128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58129. /**
  58130. * Gets the radius of the impostor
  58131. * @param impostor impostor to get radius from
  58132. * @returns the radius
  58133. */
  58134. getRadius(impostor: PhysicsImpostor): number;
  58135. /**
  58136. * Gets the box size of the impostor
  58137. * @param impostor impostor to get box size from
  58138. * @param result the resulting box size
  58139. */
  58140. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58141. /**
  58142. * Disposes of the impostor
  58143. */
  58144. dispose(): void;
  58145. /**
  58146. * Does a raycast in the physics world
  58147. * @param from when should the ray start?
  58148. * @param to when should the ray end?
  58149. * @returns PhysicsRaycastResult
  58150. */
  58151. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58152. }
  58153. }
  58154. declare module "babylonjs/Probes/reflectionProbe" {
  58155. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58156. import { Vector3 } from "babylonjs/Maths/math.vector";
  58157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58158. import { Nullable } from "babylonjs/types";
  58159. import { Scene } from "babylonjs/scene";
  58160. module "babylonjs/abstractScene" {
  58161. interface AbstractScene {
  58162. /**
  58163. * The list of reflection probes added to the scene
  58164. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58165. */
  58166. reflectionProbes: Array<ReflectionProbe>;
  58167. /**
  58168. * Removes the given reflection probe from this scene.
  58169. * @param toRemove The reflection probe to remove
  58170. * @returns The index of the removed reflection probe
  58171. */
  58172. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58173. /**
  58174. * Adds the given reflection probe to this scene.
  58175. * @param newReflectionProbe The reflection probe to add
  58176. */
  58177. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58178. }
  58179. }
  58180. /**
  58181. * Class used to generate realtime reflection / refraction cube textures
  58182. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58183. */
  58184. export class ReflectionProbe {
  58185. /** defines the name of the probe */
  58186. name: string;
  58187. private _scene;
  58188. private _renderTargetTexture;
  58189. private _projectionMatrix;
  58190. private _viewMatrix;
  58191. private _target;
  58192. private _add;
  58193. private _attachedMesh;
  58194. private _invertYAxis;
  58195. /** Gets or sets probe position (center of the cube map) */
  58196. position: Vector3;
  58197. /**
  58198. * Creates a new reflection probe
  58199. * @param name defines the name of the probe
  58200. * @param size defines the texture resolution (for each face)
  58201. * @param scene defines the hosting scene
  58202. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58203. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58204. */
  58205. constructor(
  58206. /** defines the name of the probe */
  58207. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58208. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58209. get samples(): number;
  58210. set samples(value: number);
  58211. /** Gets or sets the refresh rate to use (on every frame by default) */
  58212. get refreshRate(): number;
  58213. set refreshRate(value: number);
  58214. /**
  58215. * Gets the hosting scene
  58216. * @returns a Scene
  58217. */
  58218. getScene(): Scene;
  58219. /** Gets the internal CubeTexture used to render to */
  58220. get cubeTexture(): RenderTargetTexture;
  58221. /** Gets the list of meshes to render */
  58222. get renderList(): Nullable<AbstractMesh[]>;
  58223. /**
  58224. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58225. * @param mesh defines the mesh to attach to
  58226. */
  58227. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58228. /**
  58229. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58230. * @param renderingGroupId The rendering group id corresponding to its index
  58231. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58232. */
  58233. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58234. /**
  58235. * Clean all associated resources
  58236. */
  58237. dispose(): void;
  58238. /**
  58239. * Converts the reflection probe information to a readable string for debug purpose.
  58240. * @param fullDetails Supports for multiple levels of logging within scene loading
  58241. * @returns the human readable reflection probe info
  58242. */
  58243. toString(fullDetails?: boolean): string;
  58244. /**
  58245. * Get the class name of the relfection probe.
  58246. * @returns "ReflectionProbe"
  58247. */
  58248. getClassName(): string;
  58249. /**
  58250. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58251. * @returns The JSON representation of the texture
  58252. */
  58253. serialize(): any;
  58254. /**
  58255. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58256. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58257. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58258. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58259. * @returns The parsed reflection probe if successful
  58260. */
  58261. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58262. }
  58263. }
  58264. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58265. /** @hidden */
  58266. export var _BabylonLoaderRegistered: boolean;
  58267. /**
  58268. * Helps setting up some configuration for the babylon file loader.
  58269. */
  58270. export class BabylonFileLoaderConfiguration {
  58271. /**
  58272. * The loader does not allow injecting custom physix engine into the plugins.
  58273. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58274. * So you could set this variable to your engine import to make it work.
  58275. */
  58276. static LoaderInjectedPhysicsEngine: any;
  58277. }
  58278. }
  58279. declare module "babylonjs/Loading/Plugins/index" {
  58280. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58281. }
  58282. declare module "babylonjs/Loading/index" {
  58283. export * from "babylonjs/Loading/loadingScreen";
  58284. export * from "babylonjs/Loading/Plugins/index";
  58285. export * from "babylonjs/Loading/sceneLoader";
  58286. export * from "babylonjs/Loading/sceneLoaderFlags";
  58287. }
  58288. declare module "babylonjs/Materials/Background/index" {
  58289. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58290. }
  58291. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58292. import { Scene } from "babylonjs/scene";
  58293. import { Color3 } from "babylonjs/Maths/math.color";
  58294. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58296. /**
  58297. * The Physically based simple base material of BJS.
  58298. *
  58299. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58300. * It is used as the base class for both the specGloss and metalRough conventions.
  58301. */
  58302. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58303. /**
  58304. * Number of Simultaneous lights allowed on the material.
  58305. */
  58306. maxSimultaneousLights: number;
  58307. /**
  58308. * If sets to true, disables all the lights affecting the material.
  58309. */
  58310. disableLighting: boolean;
  58311. /**
  58312. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58313. */
  58314. environmentTexture: BaseTexture;
  58315. /**
  58316. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58317. */
  58318. invertNormalMapX: boolean;
  58319. /**
  58320. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58321. */
  58322. invertNormalMapY: boolean;
  58323. /**
  58324. * Normal map used in the model.
  58325. */
  58326. normalTexture: BaseTexture;
  58327. /**
  58328. * Emissivie color used to self-illuminate the model.
  58329. */
  58330. emissiveColor: Color3;
  58331. /**
  58332. * Emissivie texture used to self-illuminate the model.
  58333. */
  58334. emissiveTexture: BaseTexture;
  58335. /**
  58336. * Occlusion Channel Strenght.
  58337. */
  58338. occlusionStrength: number;
  58339. /**
  58340. * Occlusion Texture of the material (adding extra occlusion effects).
  58341. */
  58342. occlusionTexture: BaseTexture;
  58343. /**
  58344. * Defines the alpha limits in alpha test mode.
  58345. */
  58346. alphaCutOff: number;
  58347. /**
  58348. * Gets the current double sided mode.
  58349. */
  58350. get doubleSided(): boolean;
  58351. /**
  58352. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58353. */
  58354. set doubleSided(value: boolean);
  58355. /**
  58356. * Stores the pre-calculated light information of a mesh in a texture.
  58357. */
  58358. lightmapTexture: BaseTexture;
  58359. /**
  58360. * If true, the light map contains occlusion information instead of lighting info.
  58361. */
  58362. useLightmapAsShadowmap: boolean;
  58363. /**
  58364. * Instantiates a new PBRMaterial instance.
  58365. *
  58366. * @param name The material name
  58367. * @param scene The scene the material will be use in.
  58368. */
  58369. constructor(name: string, scene: Scene);
  58370. getClassName(): string;
  58371. }
  58372. }
  58373. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58374. import { Scene } from "babylonjs/scene";
  58375. import { Color3 } from "babylonjs/Maths/math.color";
  58376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58377. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58378. /**
  58379. * The PBR material of BJS following the metal roughness convention.
  58380. *
  58381. * This fits to the PBR convention in the GLTF definition:
  58382. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58383. */
  58384. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58385. /**
  58386. * The base color has two different interpretations depending on the value of metalness.
  58387. * When the material is a metal, the base color is the specific measured reflectance value
  58388. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58389. * of the material.
  58390. */
  58391. baseColor: Color3;
  58392. /**
  58393. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58394. * well as opacity information in the alpha channel.
  58395. */
  58396. baseTexture: BaseTexture;
  58397. /**
  58398. * Specifies the metallic scalar value of the material.
  58399. * Can also be used to scale the metalness values of the metallic texture.
  58400. */
  58401. metallic: number;
  58402. /**
  58403. * Specifies the roughness scalar value of the material.
  58404. * Can also be used to scale the roughness values of the metallic texture.
  58405. */
  58406. roughness: number;
  58407. /**
  58408. * Texture containing both the metallic value in the B channel and the
  58409. * roughness value in the G channel to keep better precision.
  58410. */
  58411. metallicRoughnessTexture: BaseTexture;
  58412. /**
  58413. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58414. *
  58415. * @param name The material name
  58416. * @param scene The scene the material will be use in.
  58417. */
  58418. constructor(name: string, scene: Scene);
  58419. /**
  58420. * Return the currrent class name of the material.
  58421. */
  58422. getClassName(): string;
  58423. /**
  58424. * Makes a duplicate of the current material.
  58425. * @param name - name to use for the new material.
  58426. */
  58427. clone(name: string): PBRMetallicRoughnessMaterial;
  58428. /**
  58429. * Serialize the material to a parsable JSON object.
  58430. */
  58431. serialize(): any;
  58432. /**
  58433. * Parses a JSON object correponding to the serialize function.
  58434. */
  58435. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58436. }
  58437. }
  58438. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58439. import { Scene } from "babylonjs/scene";
  58440. import { Color3 } from "babylonjs/Maths/math.color";
  58441. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58442. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58443. /**
  58444. * The PBR material of BJS following the specular glossiness convention.
  58445. *
  58446. * This fits to the PBR convention in the GLTF definition:
  58447. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58448. */
  58449. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58450. /**
  58451. * Specifies the diffuse color of the material.
  58452. */
  58453. diffuseColor: Color3;
  58454. /**
  58455. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58456. * channel.
  58457. */
  58458. diffuseTexture: BaseTexture;
  58459. /**
  58460. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58461. */
  58462. specularColor: Color3;
  58463. /**
  58464. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58465. */
  58466. glossiness: number;
  58467. /**
  58468. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58469. */
  58470. specularGlossinessTexture: BaseTexture;
  58471. /**
  58472. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58473. *
  58474. * @param name The material name
  58475. * @param scene The scene the material will be use in.
  58476. */
  58477. constructor(name: string, scene: Scene);
  58478. /**
  58479. * Return the currrent class name of the material.
  58480. */
  58481. getClassName(): string;
  58482. /**
  58483. * Makes a duplicate of the current material.
  58484. * @param name - name to use for the new material.
  58485. */
  58486. clone(name: string): PBRSpecularGlossinessMaterial;
  58487. /**
  58488. * Serialize the material to a parsable JSON object.
  58489. */
  58490. serialize(): any;
  58491. /**
  58492. * Parses a JSON object correponding to the serialize function.
  58493. */
  58494. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58495. }
  58496. }
  58497. declare module "babylonjs/Materials/PBR/index" {
  58498. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58499. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58500. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58501. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58502. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58503. }
  58504. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58505. import { Nullable } from "babylonjs/types";
  58506. import { Scene } from "babylonjs/scene";
  58507. import { Matrix } from "babylonjs/Maths/math.vector";
  58508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58509. /**
  58510. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58511. * It can help converting any input color in a desired output one. This can then be used to create effects
  58512. * from sepia, black and white to sixties or futuristic rendering...
  58513. *
  58514. * The only supported format is currently 3dl.
  58515. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58516. */
  58517. export class ColorGradingTexture extends BaseTexture {
  58518. /**
  58519. * The current texture matrix. (will always be identity in color grading texture)
  58520. */
  58521. private _textureMatrix;
  58522. /**
  58523. * The texture URL.
  58524. */
  58525. url: string;
  58526. /**
  58527. * Empty line regex stored for GC.
  58528. */
  58529. private static _noneEmptyLineRegex;
  58530. private _engine;
  58531. /**
  58532. * Instantiates a ColorGradingTexture from the following parameters.
  58533. *
  58534. * @param url The location of the color gradind data (currently only supporting 3dl)
  58535. * @param scene The scene the texture will be used in
  58536. */
  58537. constructor(url: string, scene: Scene);
  58538. /**
  58539. * Returns the texture matrix used in most of the material.
  58540. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58541. */
  58542. getTextureMatrix(): Matrix;
  58543. /**
  58544. * Occurs when the file being loaded is a .3dl LUT file.
  58545. */
  58546. private load3dlTexture;
  58547. /**
  58548. * Starts the loading process of the texture.
  58549. */
  58550. private loadTexture;
  58551. /**
  58552. * Clones the color gradind texture.
  58553. */
  58554. clone(): ColorGradingTexture;
  58555. /**
  58556. * Called during delayed load for textures.
  58557. */
  58558. delayLoad(): void;
  58559. /**
  58560. * Parses a color grading texture serialized by Babylon.
  58561. * @param parsedTexture The texture information being parsedTexture
  58562. * @param scene The scene to load the texture in
  58563. * @param rootUrl The root url of the data assets to load
  58564. * @return A color gradind texture
  58565. */
  58566. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58567. /**
  58568. * Serializes the LUT texture to json format.
  58569. */
  58570. serialize(): any;
  58571. }
  58572. }
  58573. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58575. import { Scene } from "babylonjs/scene";
  58576. import { Nullable } from "babylonjs/types";
  58577. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58578. /**
  58579. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58580. */
  58581. export class EquiRectangularCubeTexture extends BaseTexture {
  58582. /** The six faces of the cube. */
  58583. private static _FacesMapping;
  58584. private _noMipmap;
  58585. private _onLoad;
  58586. private _onError;
  58587. /** The size of the cubemap. */
  58588. private _size;
  58589. /** The buffer of the image. */
  58590. private _buffer;
  58591. /** The width of the input image. */
  58592. private _width;
  58593. /** The height of the input image. */
  58594. private _height;
  58595. /** The URL to the image. */
  58596. url: string;
  58597. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58598. coordinatesMode: number;
  58599. /**
  58600. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58601. * @param url The location of the image
  58602. * @param scene The scene the texture will be used in
  58603. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58604. * @param noMipmap Forces to not generate the mipmap if true
  58605. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58606. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58607. * @param onLoad — defines a callback called when texture is loaded
  58608. * @param onError — defines a callback called if there is an error
  58609. */
  58610. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58611. /**
  58612. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58613. */
  58614. private loadImage;
  58615. /**
  58616. * Convert the image buffer into a cubemap and create a CubeTexture.
  58617. */
  58618. private loadTexture;
  58619. /**
  58620. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58621. * @param buffer The ArrayBuffer that should be converted.
  58622. * @returns The buffer as Float32Array.
  58623. */
  58624. private getFloat32ArrayFromArrayBuffer;
  58625. /**
  58626. * Get the current class name of the texture useful for serialization or dynamic coding.
  58627. * @returns "EquiRectangularCubeTexture"
  58628. */
  58629. getClassName(): string;
  58630. /**
  58631. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58632. * @returns A clone of the current EquiRectangularCubeTexture.
  58633. */
  58634. clone(): EquiRectangularCubeTexture;
  58635. }
  58636. }
  58637. declare module "babylonjs/Misc/tga" {
  58638. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58639. /**
  58640. * Based on jsTGALoader - Javascript loader for TGA file
  58641. * By Vincent Thibault
  58642. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58643. */
  58644. export class TGATools {
  58645. private static _TYPE_INDEXED;
  58646. private static _TYPE_RGB;
  58647. private static _TYPE_GREY;
  58648. private static _TYPE_RLE_INDEXED;
  58649. private static _TYPE_RLE_RGB;
  58650. private static _TYPE_RLE_GREY;
  58651. private static _ORIGIN_MASK;
  58652. private static _ORIGIN_SHIFT;
  58653. private static _ORIGIN_BL;
  58654. private static _ORIGIN_BR;
  58655. private static _ORIGIN_UL;
  58656. private static _ORIGIN_UR;
  58657. /**
  58658. * Gets the header of a TGA file
  58659. * @param data defines the TGA data
  58660. * @returns the header
  58661. */
  58662. static GetTGAHeader(data: Uint8Array): any;
  58663. /**
  58664. * Uploads TGA content to a Babylon Texture
  58665. * @hidden
  58666. */
  58667. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58668. /** @hidden */
  58669. 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;
  58670. /** @hidden */
  58671. 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;
  58672. /** @hidden */
  58673. 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;
  58674. /** @hidden */
  58675. 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;
  58676. /** @hidden */
  58677. 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;
  58678. /** @hidden */
  58679. 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;
  58680. }
  58681. }
  58682. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58683. import { Nullable } from "babylonjs/types";
  58684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58685. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58686. /**
  58687. * Implementation of the TGA Texture Loader.
  58688. * @hidden
  58689. */
  58690. export class _TGATextureLoader implements IInternalTextureLoader {
  58691. /**
  58692. * Defines wether the loader supports cascade loading the different faces.
  58693. */
  58694. readonly supportCascades: boolean;
  58695. /**
  58696. * This returns if the loader support the current file information.
  58697. * @param extension defines the file extension of the file being loaded
  58698. * @returns true if the loader can load the specified file
  58699. */
  58700. canLoad(extension: string): boolean;
  58701. /**
  58702. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58703. * @param data contains the texture data
  58704. * @param texture defines the BabylonJS internal texture
  58705. * @param createPolynomials will be true if polynomials have been requested
  58706. * @param onLoad defines the callback to trigger once the texture is ready
  58707. * @param onError defines the callback to trigger in case of error
  58708. */
  58709. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58710. /**
  58711. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58712. * @param data contains the texture data
  58713. * @param texture defines the BabylonJS internal texture
  58714. * @param callback defines the method to call once ready to upload
  58715. */
  58716. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58717. }
  58718. }
  58719. declare module "babylonjs/Misc/basis" {
  58720. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58721. /**
  58722. * Info about the .basis files
  58723. */
  58724. class BasisFileInfo {
  58725. /**
  58726. * If the file has alpha
  58727. */
  58728. hasAlpha: boolean;
  58729. /**
  58730. * Info about each image of the basis file
  58731. */
  58732. images: Array<{
  58733. levels: Array<{
  58734. width: number;
  58735. height: number;
  58736. transcodedPixels: ArrayBufferView;
  58737. }>;
  58738. }>;
  58739. }
  58740. /**
  58741. * Result of transcoding a basis file
  58742. */
  58743. class TranscodeResult {
  58744. /**
  58745. * Info about the .basis file
  58746. */
  58747. fileInfo: BasisFileInfo;
  58748. /**
  58749. * Format to use when loading the file
  58750. */
  58751. format: number;
  58752. }
  58753. /**
  58754. * Configuration options for the Basis transcoder
  58755. */
  58756. export class BasisTranscodeConfiguration {
  58757. /**
  58758. * Supported compression formats used to determine the supported output format of the transcoder
  58759. */
  58760. supportedCompressionFormats?: {
  58761. /**
  58762. * etc1 compression format
  58763. */
  58764. etc1?: boolean;
  58765. /**
  58766. * s3tc compression format
  58767. */
  58768. s3tc?: boolean;
  58769. /**
  58770. * pvrtc compression format
  58771. */
  58772. pvrtc?: boolean;
  58773. /**
  58774. * etc2 compression format
  58775. */
  58776. etc2?: boolean;
  58777. };
  58778. /**
  58779. * If mipmap levels should be loaded for transcoded images (Default: true)
  58780. */
  58781. loadMipmapLevels?: boolean;
  58782. /**
  58783. * Index of a single image to load (Default: all images)
  58784. */
  58785. loadSingleImage?: number;
  58786. }
  58787. /**
  58788. * Used to load .Basis files
  58789. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58790. */
  58791. export class BasisTools {
  58792. private static _IgnoreSupportedFormats;
  58793. /**
  58794. * URL to use when loading the basis transcoder
  58795. */
  58796. static JSModuleURL: string;
  58797. /**
  58798. * URL to use when loading the wasm module for the transcoder
  58799. */
  58800. static WasmModuleURL: string;
  58801. /**
  58802. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58803. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58804. * @returns internal format corresponding to the Basis format
  58805. */
  58806. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58807. private static _WorkerPromise;
  58808. private static _Worker;
  58809. private static _actionId;
  58810. private static _CreateWorkerAsync;
  58811. /**
  58812. * Transcodes a loaded image file to compressed pixel data
  58813. * @param data image data to transcode
  58814. * @param config configuration options for the transcoding
  58815. * @returns a promise resulting in the transcoded image
  58816. */
  58817. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58818. /**
  58819. * Loads a texture from the transcode result
  58820. * @param texture texture load to
  58821. * @param transcodeResult the result of transcoding the basis file to load from
  58822. */
  58823. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58824. }
  58825. }
  58826. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58827. import { Nullable } from "babylonjs/types";
  58828. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58829. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58830. /**
  58831. * Loader for .basis file format
  58832. */
  58833. export class _BasisTextureLoader implements IInternalTextureLoader {
  58834. /**
  58835. * Defines whether the loader supports cascade loading the different faces.
  58836. */
  58837. readonly supportCascades: boolean;
  58838. /**
  58839. * This returns if the loader support the current file information.
  58840. * @param extension defines the file extension of the file being loaded
  58841. * @returns true if the loader can load the specified file
  58842. */
  58843. canLoad(extension: string): boolean;
  58844. /**
  58845. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58846. * @param data contains the texture data
  58847. * @param texture defines the BabylonJS internal texture
  58848. * @param createPolynomials will be true if polynomials have been requested
  58849. * @param onLoad defines the callback to trigger once the texture is ready
  58850. * @param onError defines the callback to trigger in case of error
  58851. */
  58852. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58853. /**
  58854. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58855. * @param data contains the texture data
  58856. * @param texture defines the BabylonJS internal texture
  58857. * @param callback defines the method to call once ready to upload
  58858. */
  58859. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58860. }
  58861. }
  58862. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58863. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58864. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58865. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58866. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58867. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58868. }
  58869. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58870. import { Scene } from "babylonjs/scene";
  58871. import { Texture } from "babylonjs/Materials/Textures/texture";
  58872. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58873. /**
  58874. * 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.
  58875. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58876. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58877. */
  58878. export class CustomProceduralTexture extends ProceduralTexture {
  58879. private _animate;
  58880. private _time;
  58881. private _config;
  58882. private _texturePath;
  58883. /**
  58884. * Instantiates a new Custom Procedural Texture.
  58885. * 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.
  58886. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58887. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58888. * @param name Define the name of the texture
  58889. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58890. * @param size Define the size of the texture to create
  58891. * @param scene Define the scene the texture belongs to
  58892. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58893. * @param generateMipMaps Define if the texture should creates mip maps or not
  58894. */
  58895. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58896. private _loadJson;
  58897. /**
  58898. * Is the texture ready to be used ? (rendered at least once)
  58899. * @returns true if ready, otherwise, false.
  58900. */
  58901. isReady(): boolean;
  58902. /**
  58903. * Render the texture to its associated render target.
  58904. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58905. */
  58906. render(useCameraPostProcess?: boolean): void;
  58907. /**
  58908. * Update the list of dependant textures samplers in the shader.
  58909. */
  58910. updateTextures(): void;
  58911. /**
  58912. * Update the uniform values of the procedural texture in the shader.
  58913. */
  58914. updateShaderUniforms(): void;
  58915. /**
  58916. * Define if the texture animates or not.
  58917. */
  58918. get animate(): boolean;
  58919. set animate(value: boolean);
  58920. }
  58921. }
  58922. declare module "babylonjs/Shaders/noise.fragment" {
  58923. /** @hidden */
  58924. export var noisePixelShader: {
  58925. name: string;
  58926. shader: string;
  58927. };
  58928. }
  58929. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58930. import { Nullable } from "babylonjs/types";
  58931. import { Scene } from "babylonjs/scene";
  58932. import { Texture } from "babylonjs/Materials/Textures/texture";
  58933. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58934. import "babylonjs/Shaders/noise.fragment";
  58935. /**
  58936. * Class used to generate noise procedural textures
  58937. */
  58938. export class NoiseProceduralTexture extends ProceduralTexture {
  58939. private _time;
  58940. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58941. brightness: number;
  58942. /** Defines the number of octaves to process */
  58943. octaves: number;
  58944. /** Defines the level of persistence (0.8 by default) */
  58945. persistence: number;
  58946. /** Gets or sets animation speed factor (default is 1) */
  58947. animationSpeedFactor: number;
  58948. /**
  58949. * Creates a new NoiseProceduralTexture
  58950. * @param name defines the name fo the texture
  58951. * @param size defines the size of the texture (default is 256)
  58952. * @param scene defines the hosting scene
  58953. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58954. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58955. */
  58956. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58957. private _updateShaderUniforms;
  58958. protected _getDefines(): string;
  58959. /** Generate the current state of the procedural texture */
  58960. render(useCameraPostProcess?: boolean): void;
  58961. /**
  58962. * Serializes this noise procedural texture
  58963. * @returns a serialized noise procedural texture object
  58964. */
  58965. serialize(): any;
  58966. /**
  58967. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58968. * @param parsedTexture defines parsed texture data
  58969. * @param scene defines the current scene
  58970. * @param rootUrl defines the root URL containing noise procedural texture information
  58971. * @returns a parsed NoiseProceduralTexture
  58972. */
  58973. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58974. }
  58975. }
  58976. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58977. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58978. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58979. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58980. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58981. }
  58982. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58983. import { Nullable } from "babylonjs/types";
  58984. import { Scene } from "babylonjs/scene";
  58985. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58986. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58987. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58988. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58989. /**
  58990. * Raw cube texture where the raw buffers are passed in
  58991. */
  58992. export class RawCubeTexture extends CubeTexture {
  58993. /**
  58994. * Creates a cube texture where the raw buffers are passed in.
  58995. * @param scene defines the scene the texture is attached to
  58996. * @param data defines the array of data to use to create each face
  58997. * @param size defines the size of the textures
  58998. * @param format defines the format of the data
  58999. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59000. * @param generateMipMaps defines if the engine should generate the mip levels
  59001. * @param invertY defines if data must be stored with Y axis inverted
  59002. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59003. * @param compression defines the compression used (null by default)
  59004. */
  59005. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59006. /**
  59007. * Updates the raw cube texture.
  59008. * @param data defines the data to store
  59009. * @param format defines the data format
  59010. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59011. * @param invertY defines if data must be stored with Y axis inverted
  59012. * @param compression defines the compression used (null by default)
  59013. * @param level defines which level of the texture to update
  59014. */
  59015. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59016. /**
  59017. * Updates a raw cube texture with RGBD encoded data.
  59018. * @param data defines the array of data [mipmap][face] to use to create each face
  59019. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59020. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59021. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59022. * @returns a promsie that resolves when the operation is complete
  59023. */
  59024. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59025. /**
  59026. * Clones the raw cube texture.
  59027. * @return a new cube texture
  59028. */
  59029. clone(): CubeTexture;
  59030. /** @hidden */
  59031. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59032. }
  59033. }
  59034. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59035. import { Scene } from "babylonjs/scene";
  59036. import { Texture } from "babylonjs/Materials/Textures/texture";
  59037. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59038. /**
  59039. * Class used to store 3D textures containing user data
  59040. */
  59041. export class RawTexture3D extends Texture {
  59042. /** Gets or sets the texture format to use */
  59043. format: number;
  59044. private _engine;
  59045. /**
  59046. * Create a new RawTexture3D
  59047. * @param data defines the data of the texture
  59048. * @param width defines the width of the texture
  59049. * @param height defines the height of the texture
  59050. * @param depth defines the depth of the texture
  59051. * @param format defines the texture format to use
  59052. * @param scene defines the hosting scene
  59053. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59054. * @param invertY defines if texture must be stored with Y axis inverted
  59055. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59056. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59057. */
  59058. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59059. /** Gets or sets the texture format to use */
  59060. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59061. /**
  59062. * Update the texture with new data
  59063. * @param data defines the data to store in the texture
  59064. */
  59065. update(data: ArrayBufferView): void;
  59066. }
  59067. }
  59068. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59069. import { Scene } from "babylonjs/scene";
  59070. import { Texture } from "babylonjs/Materials/Textures/texture";
  59071. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59072. /**
  59073. * Class used to store 2D array textures containing user data
  59074. */
  59075. export class RawTexture2DArray extends Texture {
  59076. /** Gets or sets the texture format to use */
  59077. format: number;
  59078. private _engine;
  59079. /**
  59080. * Create a new RawTexture2DArray
  59081. * @param data defines the data of the texture
  59082. * @param width defines the width of the texture
  59083. * @param height defines the height of the texture
  59084. * @param depth defines the number of layers of the texture
  59085. * @param format defines the texture format to use
  59086. * @param scene defines the hosting scene
  59087. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59088. * @param invertY defines if texture must be stored with Y axis inverted
  59089. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59090. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59091. */
  59092. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59093. /** Gets or sets the texture format to use */
  59094. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59095. /**
  59096. * Update the texture with new data
  59097. * @param data defines the data to store in the texture
  59098. */
  59099. update(data: ArrayBufferView): void;
  59100. }
  59101. }
  59102. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59103. import { Scene } from "babylonjs/scene";
  59104. import { Plane } from "babylonjs/Maths/math.plane";
  59105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59106. /**
  59107. * Creates a refraction texture used by refraction channel of the standard material.
  59108. * It is like a mirror but to see through a material.
  59109. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59110. */
  59111. export class RefractionTexture extends RenderTargetTexture {
  59112. /**
  59113. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59114. * 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.
  59115. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59116. */
  59117. refractionPlane: Plane;
  59118. /**
  59119. * Define how deep under the surface we should see.
  59120. */
  59121. depth: number;
  59122. /**
  59123. * Creates a refraction texture used by refraction channel of the standard material.
  59124. * It is like a mirror but to see through a material.
  59125. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59126. * @param name Define the texture name
  59127. * @param size Define the size of the underlying texture
  59128. * @param scene Define the scene the refraction belongs to
  59129. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59130. */
  59131. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59132. /**
  59133. * Clone the refraction texture.
  59134. * @returns the cloned texture
  59135. */
  59136. clone(): RefractionTexture;
  59137. /**
  59138. * Serialize the texture to a JSON representation you could use in Parse later on
  59139. * @returns the serialized JSON representation
  59140. */
  59141. serialize(): any;
  59142. }
  59143. }
  59144. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59145. import { Nullable } from "babylonjs/types";
  59146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59147. import { Matrix } from "babylonjs/Maths/math.vector";
  59148. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59149. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59150. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59151. import { Scene } from "babylonjs/scene";
  59152. /**
  59153. * Defines the options related to the creation of an HtmlElementTexture
  59154. */
  59155. export interface IHtmlElementTextureOptions {
  59156. /**
  59157. * Defines wether mip maps should be created or not.
  59158. */
  59159. generateMipMaps?: boolean;
  59160. /**
  59161. * Defines the sampling mode of the texture.
  59162. */
  59163. samplingMode?: number;
  59164. /**
  59165. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59166. */
  59167. engine: Nullable<ThinEngine>;
  59168. /**
  59169. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59170. */
  59171. scene: Nullable<Scene>;
  59172. }
  59173. /**
  59174. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59175. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59176. * is automatically managed.
  59177. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59178. * in your application.
  59179. *
  59180. * As the update is not automatic, you need to call them manually.
  59181. */
  59182. export class HtmlElementTexture extends BaseTexture {
  59183. /**
  59184. * The texture URL.
  59185. */
  59186. element: HTMLVideoElement | HTMLCanvasElement;
  59187. private static readonly DefaultOptions;
  59188. private _textureMatrix;
  59189. private _engine;
  59190. private _isVideo;
  59191. private _generateMipMaps;
  59192. private _samplingMode;
  59193. /**
  59194. * Instantiates a HtmlElementTexture from the following parameters.
  59195. *
  59196. * @param name Defines the name of the texture
  59197. * @param element Defines the video or canvas the texture is filled with
  59198. * @param options Defines the other none mandatory texture creation options
  59199. */
  59200. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59201. private _createInternalTexture;
  59202. /**
  59203. * Returns the texture matrix used in most of the material.
  59204. */
  59205. getTextureMatrix(): Matrix;
  59206. /**
  59207. * Updates the content of the texture.
  59208. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59209. */
  59210. update(invertY?: Nullable<boolean>): void;
  59211. }
  59212. }
  59213. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59214. import { Vector2 } from "babylonjs/Maths/math.vector";
  59215. /**
  59216. * Defines the basic options interface of a TexturePacker Frame
  59217. */
  59218. export interface ITexturePackerFrame {
  59219. /**
  59220. * The frame ID
  59221. */
  59222. id: number;
  59223. /**
  59224. * The frames Scale
  59225. */
  59226. scale: Vector2;
  59227. /**
  59228. * The Frames offset
  59229. */
  59230. offset: Vector2;
  59231. }
  59232. /**
  59233. * This is a support class for frame Data on texture packer sets.
  59234. */
  59235. export class TexturePackerFrame implements ITexturePackerFrame {
  59236. /**
  59237. * The frame ID
  59238. */
  59239. id: number;
  59240. /**
  59241. * The frames Scale
  59242. */
  59243. scale: Vector2;
  59244. /**
  59245. * The Frames offset
  59246. */
  59247. offset: Vector2;
  59248. /**
  59249. * Initializes a texture package frame.
  59250. * @param id The numerical frame identifier
  59251. * @param scale Scalar Vector2 for UV frame
  59252. * @param offset Vector2 for the frame position in UV units.
  59253. * @returns TexturePackerFrame
  59254. */
  59255. constructor(id: number, scale: Vector2, offset: Vector2);
  59256. }
  59257. }
  59258. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59260. import { Scene } from "babylonjs/scene";
  59261. import { Nullable } from "babylonjs/types";
  59262. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59263. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59264. /**
  59265. * Defines the basic options interface of a TexturePacker
  59266. */
  59267. export interface ITexturePackerOptions {
  59268. /**
  59269. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59270. */
  59271. map?: string[];
  59272. /**
  59273. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59274. */
  59275. uvsIn?: string;
  59276. /**
  59277. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59278. */
  59279. uvsOut?: string;
  59280. /**
  59281. * number representing the layout style. Defaults to LAYOUT_STRIP
  59282. */
  59283. layout?: number;
  59284. /**
  59285. * number of columns if using custom column count layout(2). This defaults to 4.
  59286. */
  59287. colnum?: number;
  59288. /**
  59289. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59290. */
  59291. updateInputMeshes?: boolean;
  59292. /**
  59293. * boolean flag to dispose all the source textures. Defaults to true.
  59294. */
  59295. disposeSources?: boolean;
  59296. /**
  59297. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59298. */
  59299. fillBlanks?: boolean;
  59300. /**
  59301. * string value representing the context fill style color. Defaults to 'black'.
  59302. */
  59303. customFillColor?: string;
  59304. /**
  59305. * Width and Height Value of each Frame in the TexturePacker Sets
  59306. */
  59307. frameSize?: number;
  59308. /**
  59309. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59310. */
  59311. paddingRatio?: number;
  59312. /**
  59313. * Number that declares the fill method for the padding gutter.
  59314. */
  59315. paddingMode?: number;
  59316. /**
  59317. * If in SUBUV_COLOR padding mode what color to use.
  59318. */
  59319. paddingColor?: Color3 | Color4;
  59320. }
  59321. /**
  59322. * Defines the basic interface of a TexturePacker JSON File
  59323. */
  59324. export interface ITexturePackerJSON {
  59325. /**
  59326. * The frame ID
  59327. */
  59328. name: string;
  59329. /**
  59330. * The base64 channel data
  59331. */
  59332. sets: any;
  59333. /**
  59334. * The options of the Packer
  59335. */
  59336. options: ITexturePackerOptions;
  59337. /**
  59338. * The frame data of the Packer
  59339. */
  59340. frames: Array<number>;
  59341. }
  59342. /**
  59343. * This is a support class that generates a series of packed texture sets.
  59344. * @see https://doc.babylonjs.com/babylon101/materials
  59345. */
  59346. export class TexturePacker {
  59347. /** Packer Layout Constant 0 */
  59348. static readonly LAYOUT_STRIP: number;
  59349. /** Packer Layout Constant 1 */
  59350. static readonly LAYOUT_POWER2: number;
  59351. /** Packer Layout Constant 2 */
  59352. static readonly LAYOUT_COLNUM: number;
  59353. /** Packer Layout Constant 0 */
  59354. static readonly SUBUV_WRAP: number;
  59355. /** Packer Layout Constant 1 */
  59356. static readonly SUBUV_EXTEND: number;
  59357. /** Packer Layout Constant 2 */
  59358. static readonly SUBUV_COLOR: number;
  59359. /** The Name of the Texture Package */
  59360. name: string;
  59361. /** The scene scope of the TexturePacker */
  59362. scene: Scene;
  59363. /** The Meshes to target */
  59364. meshes: AbstractMesh[];
  59365. /** Arguments passed with the Constructor */
  59366. options: ITexturePackerOptions;
  59367. /** The promise that is started upon initialization */
  59368. promise: Nullable<Promise<TexturePacker | string>>;
  59369. /** The Container object for the channel sets that are generated */
  59370. sets: object;
  59371. /** The Container array for the frames that are generated */
  59372. frames: TexturePackerFrame[];
  59373. /** The expected number of textures the system is parsing. */
  59374. private _expecting;
  59375. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59376. private _paddingValue;
  59377. /**
  59378. * Initializes a texture package series from an array of meshes or a single mesh.
  59379. * @param name The name of the package
  59380. * @param meshes The target meshes to compose the package from
  59381. * @param options The arguments that texture packer should follow while building.
  59382. * @param scene The scene which the textures are scoped to.
  59383. * @returns TexturePacker
  59384. */
  59385. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59386. /**
  59387. * Starts the package process
  59388. * @param resolve The promises resolution function
  59389. * @returns TexturePacker
  59390. */
  59391. private _createFrames;
  59392. /**
  59393. * Calculates the Size of the Channel Sets
  59394. * @returns Vector2
  59395. */
  59396. private _calculateSize;
  59397. /**
  59398. * Calculates the UV data for the frames.
  59399. * @param baseSize the base frameSize
  59400. * @param padding the base frame padding
  59401. * @param dtSize size of the Dynamic Texture for that channel
  59402. * @param dtUnits is 1/dtSize
  59403. * @param update flag to update the input meshes
  59404. */
  59405. private _calculateMeshUVFrames;
  59406. /**
  59407. * Calculates the frames Offset.
  59408. * @param index of the frame
  59409. * @returns Vector2
  59410. */
  59411. private _getFrameOffset;
  59412. /**
  59413. * Updates a Mesh to the frame data
  59414. * @param mesh that is the target
  59415. * @param frameID or the frame index
  59416. */
  59417. private _updateMeshUV;
  59418. /**
  59419. * Updates a Meshes materials to use the texture packer channels
  59420. * @param m is the mesh to target
  59421. * @param force all channels on the packer to be set.
  59422. */
  59423. private _updateTextureReferences;
  59424. /**
  59425. * Public method to set a Mesh to a frame
  59426. * @param m that is the target
  59427. * @param frameID or the frame index
  59428. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59429. */
  59430. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59431. /**
  59432. * Starts the async promise to compile the texture packer.
  59433. * @returns Promise<void>
  59434. */
  59435. processAsync(): Promise<void>;
  59436. /**
  59437. * Disposes all textures associated with this packer
  59438. */
  59439. dispose(): void;
  59440. /**
  59441. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59442. * @param imageType is the image type to use.
  59443. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59444. */
  59445. download(imageType?: string, quality?: number): void;
  59446. /**
  59447. * Public method to load a texturePacker JSON file.
  59448. * @param data of the JSON file in string format.
  59449. */
  59450. updateFromJSON(data: string): void;
  59451. }
  59452. }
  59453. declare module "babylonjs/Materials/Textures/Packer/index" {
  59454. export * from "babylonjs/Materials/Textures/Packer/packer";
  59455. export * from "babylonjs/Materials/Textures/Packer/frame";
  59456. }
  59457. declare module "babylonjs/Materials/Textures/index" {
  59458. export * from "babylonjs/Materials/Textures/baseTexture";
  59459. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59460. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59461. export * from "babylonjs/Materials/Textures/cubeTexture";
  59462. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59463. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59464. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59465. export * from "babylonjs/Materials/Textures/internalTexture";
  59466. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59467. export * from "babylonjs/Materials/Textures/Loaders/index";
  59468. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59469. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59470. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59471. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59472. export * from "babylonjs/Materials/Textures/rawTexture";
  59473. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59474. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59475. export * from "babylonjs/Materials/Textures/refractionTexture";
  59476. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59477. export * from "babylonjs/Materials/Textures/texture";
  59478. export * from "babylonjs/Materials/Textures/videoTexture";
  59479. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59480. export * from "babylonjs/Materials/Textures/Packer/index";
  59481. }
  59482. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59483. /**
  59484. * Enum used to define the target of a block
  59485. */
  59486. export enum NodeMaterialBlockTargets {
  59487. /** Vertex shader */
  59488. Vertex = 1,
  59489. /** Fragment shader */
  59490. Fragment = 2,
  59491. /** Neutral */
  59492. Neutral = 4,
  59493. /** Vertex and Fragment */
  59494. VertexAndFragment = 3
  59495. }
  59496. }
  59497. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59498. /**
  59499. * Defines the kind of connection point for node based material
  59500. */
  59501. export enum NodeMaterialBlockConnectionPointTypes {
  59502. /** Float */
  59503. Float = 1,
  59504. /** Int */
  59505. Int = 2,
  59506. /** Vector2 */
  59507. Vector2 = 4,
  59508. /** Vector3 */
  59509. Vector3 = 8,
  59510. /** Vector4 */
  59511. Vector4 = 16,
  59512. /** Color3 */
  59513. Color3 = 32,
  59514. /** Color4 */
  59515. Color4 = 64,
  59516. /** Matrix */
  59517. Matrix = 128,
  59518. /** Detect type based on connection */
  59519. AutoDetect = 1024,
  59520. /** Output type that will be defined by input type */
  59521. BasedOnInput = 2048
  59522. }
  59523. }
  59524. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59525. /**
  59526. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59527. */
  59528. export enum NodeMaterialBlockConnectionPointMode {
  59529. /** Value is an uniform */
  59530. Uniform = 0,
  59531. /** Value is a mesh attribute */
  59532. Attribute = 1,
  59533. /** Value is a varying between vertex and fragment shaders */
  59534. Varying = 2,
  59535. /** Mode is undefined */
  59536. Undefined = 3
  59537. }
  59538. }
  59539. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59540. /**
  59541. * Enum used to define system values e.g. values automatically provided by the system
  59542. */
  59543. export enum NodeMaterialSystemValues {
  59544. /** World */
  59545. World = 1,
  59546. /** View */
  59547. View = 2,
  59548. /** Projection */
  59549. Projection = 3,
  59550. /** ViewProjection */
  59551. ViewProjection = 4,
  59552. /** WorldView */
  59553. WorldView = 5,
  59554. /** WorldViewProjection */
  59555. WorldViewProjection = 6,
  59556. /** CameraPosition */
  59557. CameraPosition = 7,
  59558. /** Fog Color */
  59559. FogColor = 8,
  59560. /** Delta time */
  59561. DeltaTime = 9
  59562. }
  59563. }
  59564. declare module "babylonjs/Materials/Node/Enums/index" {
  59565. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59566. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59567. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59568. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59569. }
  59570. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59572. /**
  59573. * Root class for all node material optimizers
  59574. */
  59575. export class NodeMaterialOptimizer {
  59576. /**
  59577. * Function used to optimize a NodeMaterial graph
  59578. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59579. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59580. */
  59581. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59582. }
  59583. }
  59584. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59588. import { Scene } from "babylonjs/scene";
  59589. /**
  59590. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59591. */
  59592. export class TransformBlock extends NodeMaterialBlock {
  59593. /**
  59594. * Defines the value to use to complement W value to transform it to a Vector4
  59595. */
  59596. complementW: number;
  59597. /**
  59598. * Defines the value to use to complement z value to transform it to a Vector4
  59599. */
  59600. complementZ: number;
  59601. /**
  59602. * Creates a new TransformBlock
  59603. * @param name defines the block name
  59604. */
  59605. constructor(name: string);
  59606. /**
  59607. * Gets the current class name
  59608. * @returns the class name
  59609. */
  59610. getClassName(): string;
  59611. /**
  59612. * Gets the vector input
  59613. */
  59614. get vector(): NodeMaterialConnectionPoint;
  59615. /**
  59616. * Gets the output component
  59617. */
  59618. get output(): NodeMaterialConnectionPoint;
  59619. /**
  59620. * Gets the xyz output component
  59621. */
  59622. get xyz(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the matrix transform input
  59625. */
  59626. get transform(): NodeMaterialConnectionPoint;
  59627. protected _buildBlock(state: NodeMaterialBuildState): this;
  59628. serialize(): any;
  59629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59630. protected _dumpPropertiesCode(): string;
  59631. }
  59632. }
  59633. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59637. /**
  59638. * Block used to output the vertex position
  59639. */
  59640. export class VertexOutputBlock extends NodeMaterialBlock {
  59641. /**
  59642. * Creates a new VertexOutputBlock
  59643. * @param name defines the block name
  59644. */
  59645. constructor(name: string);
  59646. /**
  59647. * Gets the current class name
  59648. * @returns the class name
  59649. */
  59650. getClassName(): string;
  59651. /**
  59652. * Gets the vector input component
  59653. */
  59654. get vector(): NodeMaterialConnectionPoint;
  59655. protected _buildBlock(state: NodeMaterialBuildState): this;
  59656. }
  59657. }
  59658. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59662. /**
  59663. * Block used to output the final color
  59664. */
  59665. export class FragmentOutputBlock extends NodeMaterialBlock {
  59666. /**
  59667. * Create a new FragmentOutputBlock
  59668. * @param name defines the block name
  59669. */
  59670. constructor(name: string);
  59671. /**
  59672. * Gets the current class name
  59673. * @returns the class name
  59674. */
  59675. getClassName(): string;
  59676. /**
  59677. * Gets the rgba input component
  59678. */
  59679. get rgba(): NodeMaterialConnectionPoint;
  59680. /**
  59681. * Gets the rgb input component
  59682. */
  59683. get rgb(): NodeMaterialConnectionPoint;
  59684. /**
  59685. * Gets the a input component
  59686. */
  59687. get a(): NodeMaterialConnectionPoint;
  59688. protected _buildBlock(state: NodeMaterialBuildState): this;
  59689. }
  59690. }
  59691. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59697. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59698. import { Effect } from "babylonjs/Materials/effect";
  59699. import { Mesh } from "babylonjs/Meshes/mesh";
  59700. import { Nullable } from "babylonjs/types";
  59701. import { Scene } from "babylonjs/scene";
  59702. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59703. /**
  59704. * Block used to read a reflection texture from a sampler
  59705. */
  59706. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59707. private _define3DName;
  59708. private _defineCubicName;
  59709. private _defineExplicitName;
  59710. private _defineProjectionName;
  59711. private _defineLocalCubicName;
  59712. private _defineSphericalName;
  59713. private _definePlanarName;
  59714. private _defineEquirectangularName;
  59715. private _defineMirroredEquirectangularFixedName;
  59716. private _defineEquirectangularFixedName;
  59717. private _defineSkyboxName;
  59718. private _cubeSamplerName;
  59719. private _2DSamplerName;
  59720. private _positionUVWName;
  59721. private _directionWName;
  59722. private _reflectionCoordsName;
  59723. private _reflection2DCoordsName;
  59724. private _reflectionColorName;
  59725. private _reflectionMatrixName;
  59726. /**
  59727. * Gets or sets the texture associated with the node
  59728. */
  59729. texture: Nullable<BaseTexture>;
  59730. /**
  59731. * Create a new TextureBlock
  59732. * @param name defines the block name
  59733. */
  59734. constructor(name: string);
  59735. /**
  59736. * Gets the current class name
  59737. * @returns the class name
  59738. */
  59739. getClassName(): string;
  59740. /**
  59741. * Gets the world position input component
  59742. */
  59743. get position(): NodeMaterialConnectionPoint;
  59744. /**
  59745. * Gets the world position input component
  59746. */
  59747. get worldPosition(): NodeMaterialConnectionPoint;
  59748. /**
  59749. * Gets the world normal input component
  59750. */
  59751. get worldNormal(): NodeMaterialConnectionPoint;
  59752. /**
  59753. * Gets the world input component
  59754. */
  59755. get world(): NodeMaterialConnectionPoint;
  59756. /**
  59757. * Gets the camera (or eye) position component
  59758. */
  59759. get cameraPosition(): NodeMaterialConnectionPoint;
  59760. /**
  59761. * Gets the view input component
  59762. */
  59763. get view(): NodeMaterialConnectionPoint;
  59764. /**
  59765. * Gets the rgb output component
  59766. */
  59767. get rgb(): NodeMaterialConnectionPoint;
  59768. /**
  59769. * Gets the r output component
  59770. */
  59771. get r(): NodeMaterialConnectionPoint;
  59772. /**
  59773. * Gets the g output component
  59774. */
  59775. get g(): NodeMaterialConnectionPoint;
  59776. /**
  59777. * Gets the b output component
  59778. */
  59779. get b(): NodeMaterialConnectionPoint;
  59780. autoConfigure(material: NodeMaterial): void;
  59781. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59782. isReady(): boolean;
  59783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59784. private _injectVertexCode;
  59785. private _writeOutput;
  59786. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59787. protected _dumpPropertiesCode(): string;
  59788. serialize(): any;
  59789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59790. }
  59791. }
  59792. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59794. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59795. import { Scene } from "babylonjs/scene";
  59796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59797. import { Matrix } from "babylonjs/Maths/math.vector";
  59798. import { Mesh } from "babylonjs/Meshes/mesh";
  59799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59800. import { Observable } from "babylonjs/Misc/observable";
  59801. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59802. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59803. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59804. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59805. import { Nullable } from "babylonjs/types";
  59806. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59807. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59808. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59809. /**
  59810. * Interface used to configure the node material editor
  59811. */
  59812. export interface INodeMaterialEditorOptions {
  59813. /** Define the URl to load node editor script */
  59814. editorURL?: string;
  59815. }
  59816. /** @hidden */
  59817. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59818. NORMAL: boolean;
  59819. TANGENT: boolean;
  59820. UV1: boolean;
  59821. /** BONES */
  59822. NUM_BONE_INFLUENCERS: number;
  59823. BonesPerMesh: number;
  59824. BONETEXTURE: boolean;
  59825. /** MORPH TARGETS */
  59826. MORPHTARGETS: boolean;
  59827. MORPHTARGETS_NORMAL: boolean;
  59828. MORPHTARGETS_TANGENT: boolean;
  59829. MORPHTARGETS_UV: boolean;
  59830. NUM_MORPH_INFLUENCERS: number;
  59831. /** IMAGE PROCESSING */
  59832. IMAGEPROCESSING: boolean;
  59833. VIGNETTE: boolean;
  59834. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59835. VIGNETTEBLENDMODEOPAQUE: boolean;
  59836. TONEMAPPING: boolean;
  59837. TONEMAPPING_ACES: boolean;
  59838. CONTRAST: boolean;
  59839. EXPOSURE: boolean;
  59840. COLORCURVES: boolean;
  59841. COLORGRADING: boolean;
  59842. COLORGRADING3D: boolean;
  59843. SAMPLER3DGREENDEPTH: boolean;
  59844. SAMPLER3DBGRMAP: boolean;
  59845. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59846. /** MISC. */
  59847. BUMPDIRECTUV: number;
  59848. constructor();
  59849. setValue(name: string, value: boolean): void;
  59850. }
  59851. /**
  59852. * Class used to configure NodeMaterial
  59853. */
  59854. export interface INodeMaterialOptions {
  59855. /**
  59856. * Defines if blocks should emit comments
  59857. */
  59858. emitComments: boolean;
  59859. }
  59860. /**
  59861. * Class used to create a node based material built by assembling shader blocks
  59862. */
  59863. export class NodeMaterial extends PushMaterial {
  59864. private static _BuildIdGenerator;
  59865. private _options;
  59866. private _vertexCompilationState;
  59867. private _fragmentCompilationState;
  59868. private _sharedData;
  59869. private _buildId;
  59870. private _buildWasSuccessful;
  59871. private _cachedWorldViewMatrix;
  59872. private _cachedWorldViewProjectionMatrix;
  59873. private _optimizers;
  59874. private _animationFrame;
  59875. /** Define the Url to load node editor script */
  59876. static EditorURL: string;
  59877. /** Define the Url to load snippets */
  59878. static SnippetUrl: string;
  59879. private BJSNODEMATERIALEDITOR;
  59880. /** Get the inspector from bundle or global */
  59881. private _getGlobalNodeMaterialEditor;
  59882. /**
  59883. * Gets or sets data used by visual editor
  59884. * @see https://nme.babylonjs.com
  59885. */
  59886. editorData: any;
  59887. /**
  59888. * 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)
  59889. */
  59890. ignoreAlpha: boolean;
  59891. /**
  59892. * Defines the maximum number of lights that can be used in the material
  59893. */
  59894. maxSimultaneousLights: number;
  59895. /**
  59896. * Observable raised when the material is built
  59897. */
  59898. onBuildObservable: Observable<NodeMaterial>;
  59899. /**
  59900. * Gets or sets the root nodes of the material vertex shader
  59901. */
  59902. _vertexOutputNodes: NodeMaterialBlock[];
  59903. /**
  59904. * Gets or sets the root nodes of the material fragment (pixel) shader
  59905. */
  59906. _fragmentOutputNodes: NodeMaterialBlock[];
  59907. /** Gets or sets options to control the node material overall behavior */
  59908. get options(): INodeMaterialOptions;
  59909. set options(options: INodeMaterialOptions);
  59910. /**
  59911. * Default configuration related to image processing available in the standard Material.
  59912. */
  59913. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59914. /**
  59915. * Gets the image processing configuration used either in this material.
  59916. */
  59917. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59918. /**
  59919. * Sets the Default image processing configuration used either in the this material.
  59920. *
  59921. * If sets to null, the scene one is in use.
  59922. */
  59923. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59924. /**
  59925. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59926. */
  59927. attachedBlocks: NodeMaterialBlock[];
  59928. /**
  59929. * Create a new node based material
  59930. * @param name defines the material name
  59931. * @param scene defines the hosting scene
  59932. * @param options defines creation option
  59933. */
  59934. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59935. /**
  59936. * Gets the current class name of the material e.g. "NodeMaterial"
  59937. * @returns the class name
  59938. */
  59939. getClassName(): string;
  59940. /**
  59941. * Keep track of the image processing observer to allow dispose and replace.
  59942. */
  59943. private _imageProcessingObserver;
  59944. /**
  59945. * Attaches a new image processing configuration to the Standard Material.
  59946. * @param configuration
  59947. */
  59948. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59949. /**
  59950. * Get a block by its name
  59951. * @param name defines the name of the block to retrieve
  59952. * @returns the required block or null if not found
  59953. */
  59954. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59955. /**
  59956. * Get a block by its name
  59957. * @param predicate defines the predicate used to find the good candidate
  59958. * @returns the required block or null if not found
  59959. */
  59960. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59961. /**
  59962. * Get an input block by its name
  59963. * @param predicate defines the predicate used to find the good candidate
  59964. * @returns the required input block or null if not found
  59965. */
  59966. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59967. /**
  59968. * Gets the list of input blocks attached to this material
  59969. * @returns an array of InputBlocks
  59970. */
  59971. getInputBlocks(): InputBlock[];
  59972. /**
  59973. * Adds a new optimizer to the list of optimizers
  59974. * @param optimizer defines the optimizers to add
  59975. * @returns the current material
  59976. */
  59977. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59978. /**
  59979. * Remove an optimizer from the list of optimizers
  59980. * @param optimizer defines the optimizers to remove
  59981. * @returns the current material
  59982. */
  59983. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59984. /**
  59985. * Add a new block to the list of output nodes
  59986. * @param node defines the node to add
  59987. * @returns the current material
  59988. */
  59989. addOutputNode(node: NodeMaterialBlock): this;
  59990. /**
  59991. * Remove a block from the list of root nodes
  59992. * @param node defines the node to remove
  59993. * @returns the current material
  59994. */
  59995. removeOutputNode(node: NodeMaterialBlock): this;
  59996. private _addVertexOutputNode;
  59997. private _removeVertexOutputNode;
  59998. private _addFragmentOutputNode;
  59999. private _removeFragmentOutputNode;
  60000. /**
  60001. * Specifies if the material will require alpha blending
  60002. * @returns a boolean specifying if alpha blending is needed
  60003. */
  60004. needAlphaBlending(): boolean;
  60005. /**
  60006. * Specifies if this material should be rendered in alpha test mode
  60007. * @returns a boolean specifying if an alpha test is needed.
  60008. */
  60009. needAlphaTesting(): boolean;
  60010. private _initializeBlock;
  60011. private _resetDualBlocks;
  60012. /**
  60013. * Remove a block from the current node material
  60014. * @param block defines the block to remove
  60015. */
  60016. removeBlock(block: NodeMaterialBlock): void;
  60017. /**
  60018. * Build the material and generates the inner effect
  60019. * @param verbose defines if the build should log activity
  60020. */
  60021. build(verbose?: boolean): void;
  60022. /**
  60023. * Runs an otpimization phase to try to improve the shader code
  60024. */
  60025. optimize(): void;
  60026. private _prepareDefinesForAttributes;
  60027. /**
  60028. * Get if the submesh is ready to be used and all its information available.
  60029. * Child classes can use it to update shaders
  60030. * @param mesh defines the mesh to check
  60031. * @param subMesh defines which submesh to check
  60032. * @param useInstances specifies that instances should be used
  60033. * @returns a boolean indicating that the submesh is ready or not
  60034. */
  60035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60036. /**
  60037. * Get a string representing the shaders built by the current node graph
  60038. */
  60039. get compiledShaders(): string;
  60040. /**
  60041. * Binds the world matrix to the material
  60042. * @param world defines the world transformation matrix
  60043. */
  60044. bindOnlyWorldMatrix(world: Matrix): void;
  60045. /**
  60046. * Binds the submesh to this material by preparing the effect and shader to draw
  60047. * @param world defines the world transformation matrix
  60048. * @param mesh defines the mesh containing the submesh
  60049. * @param subMesh defines the submesh to bind the material to
  60050. */
  60051. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60052. /**
  60053. * Gets the active textures from the material
  60054. * @returns an array of textures
  60055. */
  60056. getActiveTextures(): BaseTexture[];
  60057. /**
  60058. * Gets the list of texture blocks
  60059. * @returns an array of texture blocks
  60060. */
  60061. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60062. /**
  60063. * Specifies if the material uses a texture
  60064. * @param texture defines the texture to check against the material
  60065. * @returns a boolean specifying if the material uses the texture
  60066. */
  60067. hasTexture(texture: BaseTexture): boolean;
  60068. /**
  60069. * Disposes the material
  60070. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60071. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60072. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60073. */
  60074. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60075. /** Creates the node editor window. */
  60076. private _createNodeEditor;
  60077. /**
  60078. * Launch the node material editor
  60079. * @param config Define the configuration of the editor
  60080. * @return a promise fulfilled when the node editor is visible
  60081. */
  60082. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60083. /**
  60084. * Clear the current material
  60085. */
  60086. clear(): void;
  60087. /**
  60088. * Clear the current material and set it to a default state
  60089. */
  60090. setToDefault(): void;
  60091. /**
  60092. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60093. * @param url defines the url to load from
  60094. * @returns a promise that will fullfil when the material is fully loaded
  60095. */
  60096. loadAsync(url: string): Promise<void>;
  60097. private _gatherBlocks;
  60098. /**
  60099. * Generate a string containing the code declaration required to create an equivalent of this material
  60100. * @returns a string
  60101. */
  60102. generateCode(): string;
  60103. /**
  60104. * Serializes this material in a JSON representation
  60105. * @returns the serialized material object
  60106. */
  60107. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60108. private _restoreConnections;
  60109. /**
  60110. * Clear the current graph and load a new one from a serialization object
  60111. * @param source defines the JSON representation of the material
  60112. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60113. */
  60114. loadFromSerialization(source: any, rootUrl?: string): void;
  60115. /**
  60116. * Creates a node material from parsed material data
  60117. * @param source defines the JSON representation of the material
  60118. * @param scene defines the hosting scene
  60119. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60120. * @returns a new node material
  60121. */
  60122. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60123. /**
  60124. * Creates a node material from a snippet saved in a remote file
  60125. * @param name defines the name of the material to create
  60126. * @param url defines the url to load from
  60127. * @param scene defines the hosting scene
  60128. * @returns a promise that will resolve to the new node material
  60129. */
  60130. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60131. /**
  60132. * Creates a node material from a snippet saved by the node material editor
  60133. * @param snippetId defines the snippet to load
  60134. * @param scene defines the hosting scene
  60135. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60136. * @returns a promise that will resolve to the new node material
  60137. */
  60138. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  60139. /**
  60140. * Creates a new node material set to default basic configuration
  60141. * @param name defines the name of the material
  60142. * @param scene defines the hosting scene
  60143. * @returns a new NodeMaterial
  60144. */
  60145. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60146. }
  60147. }
  60148. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60149. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60150. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60151. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60154. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60155. import { Effect } from "babylonjs/Materials/effect";
  60156. import { Mesh } from "babylonjs/Meshes/mesh";
  60157. import { Nullable } from "babylonjs/types";
  60158. import { Texture } from "babylonjs/Materials/Textures/texture";
  60159. import { Scene } from "babylonjs/scene";
  60160. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60161. /**
  60162. * Block used to read a texture from a sampler
  60163. */
  60164. export class TextureBlock extends NodeMaterialBlock {
  60165. private _defineName;
  60166. private _linearDefineName;
  60167. private _tempTextureRead;
  60168. private _samplerName;
  60169. private _transformedUVName;
  60170. private _textureTransformName;
  60171. private _textureInfoName;
  60172. private _mainUVName;
  60173. private _mainUVDefineName;
  60174. /**
  60175. * Gets or sets the texture associated with the node
  60176. */
  60177. texture: Nullable<Texture>;
  60178. /**
  60179. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60180. */
  60181. convertToGammaSpace: boolean;
  60182. /**
  60183. * Create a new TextureBlock
  60184. * @param name defines the block name
  60185. */
  60186. constructor(name: string);
  60187. /**
  60188. * Gets the current class name
  60189. * @returns the class name
  60190. */
  60191. getClassName(): string;
  60192. /**
  60193. * Gets the uv input component
  60194. */
  60195. get uv(): NodeMaterialConnectionPoint;
  60196. /**
  60197. * Gets the rgba output component
  60198. */
  60199. get rgba(): NodeMaterialConnectionPoint;
  60200. /**
  60201. * Gets the rgb output component
  60202. */
  60203. get rgb(): NodeMaterialConnectionPoint;
  60204. /**
  60205. * Gets the r output component
  60206. */
  60207. get r(): NodeMaterialConnectionPoint;
  60208. /**
  60209. * Gets the g output component
  60210. */
  60211. get g(): NodeMaterialConnectionPoint;
  60212. /**
  60213. * Gets the b output component
  60214. */
  60215. get b(): NodeMaterialConnectionPoint;
  60216. /**
  60217. * Gets the a output component
  60218. */
  60219. get a(): NodeMaterialConnectionPoint;
  60220. get target(): NodeMaterialBlockTargets;
  60221. autoConfigure(material: NodeMaterial): void;
  60222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60224. isReady(): boolean;
  60225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60226. private get _isMixed();
  60227. private _injectVertexCode;
  60228. private _writeTextureRead;
  60229. private _writeOutput;
  60230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60231. protected _dumpPropertiesCode(): string;
  60232. serialize(): any;
  60233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60234. }
  60235. }
  60236. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60238. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60239. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60240. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60241. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60242. import { Scene } from "babylonjs/scene";
  60243. /**
  60244. * Class used to store shared data between 2 NodeMaterialBuildState
  60245. */
  60246. export class NodeMaterialBuildStateSharedData {
  60247. /**
  60248. * Gets the list of emitted varyings
  60249. */
  60250. temps: string[];
  60251. /**
  60252. * Gets the list of emitted varyings
  60253. */
  60254. varyings: string[];
  60255. /**
  60256. * Gets the varying declaration string
  60257. */
  60258. varyingDeclaration: string;
  60259. /**
  60260. * Input blocks
  60261. */
  60262. inputBlocks: InputBlock[];
  60263. /**
  60264. * Input blocks
  60265. */
  60266. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60267. /**
  60268. * Bindable blocks (Blocks that need to set data to the effect)
  60269. */
  60270. bindableBlocks: NodeMaterialBlock[];
  60271. /**
  60272. * List of blocks that can provide a compilation fallback
  60273. */
  60274. blocksWithFallbacks: NodeMaterialBlock[];
  60275. /**
  60276. * List of blocks that can provide a define update
  60277. */
  60278. blocksWithDefines: NodeMaterialBlock[];
  60279. /**
  60280. * List of blocks that can provide a repeatable content
  60281. */
  60282. repeatableContentBlocks: NodeMaterialBlock[];
  60283. /**
  60284. * List of blocks that can provide a dynamic list of uniforms
  60285. */
  60286. dynamicUniformBlocks: NodeMaterialBlock[];
  60287. /**
  60288. * List of blocks that can block the isReady function for the material
  60289. */
  60290. blockingBlocks: NodeMaterialBlock[];
  60291. /**
  60292. * Gets the list of animated inputs
  60293. */
  60294. animatedInputs: InputBlock[];
  60295. /**
  60296. * Build Id used to avoid multiple recompilations
  60297. */
  60298. buildId: number;
  60299. /** List of emitted variables */
  60300. variableNames: {
  60301. [key: string]: number;
  60302. };
  60303. /** List of emitted defines */
  60304. defineNames: {
  60305. [key: string]: number;
  60306. };
  60307. /** Should emit comments? */
  60308. emitComments: boolean;
  60309. /** Emit build activity */
  60310. verbose: boolean;
  60311. /** Gets or sets the hosting scene */
  60312. scene: Scene;
  60313. /**
  60314. * Gets the compilation hints emitted at compilation time
  60315. */
  60316. hints: {
  60317. needWorldViewMatrix: boolean;
  60318. needWorldViewProjectionMatrix: boolean;
  60319. needAlphaBlending: boolean;
  60320. needAlphaTesting: boolean;
  60321. };
  60322. /**
  60323. * List of compilation checks
  60324. */
  60325. checks: {
  60326. emitVertex: boolean;
  60327. emitFragment: boolean;
  60328. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60329. };
  60330. /** Creates a new shared data */
  60331. constructor();
  60332. /**
  60333. * Emits console errors and exceptions if there is a failing check
  60334. */
  60335. emitErrors(): void;
  60336. }
  60337. }
  60338. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60339. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60340. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60341. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60342. /**
  60343. * Class used to store node based material build state
  60344. */
  60345. export class NodeMaterialBuildState {
  60346. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60347. supportUniformBuffers: boolean;
  60348. /**
  60349. * Gets the list of emitted attributes
  60350. */
  60351. attributes: string[];
  60352. /**
  60353. * Gets the list of emitted uniforms
  60354. */
  60355. uniforms: string[];
  60356. /**
  60357. * Gets the list of emitted constants
  60358. */
  60359. constants: string[];
  60360. /**
  60361. * Gets the list of emitted samplers
  60362. */
  60363. samplers: string[];
  60364. /**
  60365. * Gets the list of emitted functions
  60366. */
  60367. functions: {
  60368. [key: string]: string;
  60369. };
  60370. /**
  60371. * Gets the list of emitted extensions
  60372. */
  60373. extensions: {
  60374. [key: string]: string;
  60375. };
  60376. /**
  60377. * Gets the target of the compilation state
  60378. */
  60379. target: NodeMaterialBlockTargets;
  60380. /**
  60381. * Gets the list of emitted counters
  60382. */
  60383. counters: {
  60384. [key: string]: number;
  60385. };
  60386. /**
  60387. * Shared data between multiple NodeMaterialBuildState instances
  60388. */
  60389. sharedData: NodeMaterialBuildStateSharedData;
  60390. /** @hidden */
  60391. _vertexState: NodeMaterialBuildState;
  60392. /** @hidden */
  60393. _attributeDeclaration: string;
  60394. /** @hidden */
  60395. _uniformDeclaration: string;
  60396. /** @hidden */
  60397. _constantDeclaration: string;
  60398. /** @hidden */
  60399. _samplerDeclaration: string;
  60400. /** @hidden */
  60401. _varyingTransfer: string;
  60402. private _repeatableContentAnchorIndex;
  60403. /** @hidden */
  60404. _builtCompilationString: string;
  60405. /**
  60406. * Gets the emitted compilation strings
  60407. */
  60408. compilationString: string;
  60409. /**
  60410. * Finalize the compilation strings
  60411. * @param state defines the current compilation state
  60412. */
  60413. finalize(state: NodeMaterialBuildState): void;
  60414. /** @hidden */
  60415. get _repeatableContentAnchor(): string;
  60416. /** @hidden */
  60417. _getFreeVariableName(prefix: string): string;
  60418. /** @hidden */
  60419. _getFreeDefineName(prefix: string): string;
  60420. /** @hidden */
  60421. _excludeVariableName(name: string): void;
  60422. /** @hidden */
  60423. _emit2DSampler(name: string): void;
  60424. /** @hidden */
  60425. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60426. /** @hidden */
  60427. _emitExtension(name: string, extension: string): void;
  60428. /** @hidden */
  60429. _emitFunction(name: string, code: string, comments: string): void;
  60430. /** @hidden */
  60431. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60432. replaceStrings?: {
  60433. search: RegExp;
  60434. replace: string;
  60435. }[];
  60436. repeatKey?: string;
  60437. }): string;
  60438. /** @hidden */
  60439. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60440. repeatKey?: string;
  60441. removeAttributes?: boolean;
  60442. removeUniforms?: boolean;
  60443. removeVaryings?: boolean;
  60444. removeIfDef?: boolean;
  60445. replaceStrings?: {
  60446. search: RegExp;
  60447. replace: string;
  60448. }[];
  60449. }, storeKey?: string): void;
  60450. /** @hidden */
  60451. _registerTempVariable(name: string): boolean;
  60452. /** @hidden */
  60453. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60454. /** @hidden */
  60455. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60456. /** @hidden */
  60457. _emitFloat(value: number): string;
  60458. }
  60459. }
  60460. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60461. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60462. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60463. import { Nullable } from "babylonjs/types";
  60464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60465. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60466. import { Effect } from "babylonjs/Materials/effect";
  60467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60468. import { Mesh } from "babylonjs/Meshes/mesh";
  60469. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60470. import { Scene } from "babylonjs/scene";
  60471. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60472. /**
  60473. * Defines a block that can be used inside a node based material
  60474. */
  60475. export class NodeMaterialBlock {
  60476. private _buildId;
  60477. private _buildTarget;
  60478. private _target;
  60479. private _isFinalMerger;
  60480. private _isInput;
  60481. protected _isUnique: boolean;
  60482. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60483. inputsAreExclusive: boolean;
  60484. /** @hidden */
  60485. _codeVariableName: string;
  60486. /** @hidden */
  60487. _inputs: NodeMaterialConnectionPoint[];
  60488. /** @hidden */
  60489. _outputs: NodeMaterialConnectionPoint[];
  60490. /** @hidden */
  60491. _preparationId: number;
  60492. /**
  60493. * Gets or sets the name of the block
  60494. */
  60495. name: string;
  60496. /**
  60497. * Gets or sets the unique id of the node
  60498. */
  60499. uniqueId: number;
  60500. /**
  60501. * Gets or sets the comments associated with this block
  60502. */
  60503. comments: string;
  60504. /**
  60505. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60506. */
  60507. get isUnique(): boolean;
  60508. /**
  60509. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60510. */
  60511. get isFinalMerger(): boolean;
  60512. /**
  60513. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60514. */
  60515. get isInput(): boolean;
  60516. /**
  60517. * Gets or sets the build Id
  60518. */
  60519. get buildId(): number;
  60520. set buildId(value: number);
  60521. /**
  60522. * Gets or sets the target of the block
  60523. */
  60524. get target(): NodeMaterialBlockTargets;
  60525. set target(value: NodeMaterialBlockTargets);
  60526. /**
  60527. * Gets the list of input points
  60528. */
  60529. get inputs(): NodeMaterialConnectionPoint[];
  60530. /** Gets the list of output points */
  60531. get outputs(): NodeMaterialConnectionPoint[];
  60532. /**
  60533. * Find an input by its name
  60534. * @param name defines the name of the input to look for
  60535. * @returns the input or null if not found
  60536. */
  60537. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60538. /**
  60539. * Find an output by its name
  60540. * @param name defines the name of the outputto look for
  60541. * @returns the output or null if not found
  60542. */
  60543. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60544. /**
  60545. * Creates a new NodeMaterialBlock
  60546. * @param name defines the block name
  60547. * @param target defines the target of that block (Vertex by default)
  60548. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60549. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60550. */
  60551. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60552. /**
  60553. * Initialize the block and prepare the context for build
  60554. * @param state defines the state that will be used for the build
  60555. */
  60556. initialize(state: NodeMaterialBuildState): void;
  60557. /**
  60558. * Bind data to effect. Will only be called for blocks with isBindable === true
  60559. * @param effect defines the effect to bind data to
  60560. * @param nodeMaterial defines the hosting NodeMaterial
  60561. * @param mesh defines the mesh that will be rendered
  60562. */
  60563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60564. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60565. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60566. protected _writeFloat(value: number): string;
  60567. /**
  60568. * Gets the current class name e.g. "NodeMaterialBlock"
  60569. * @returns the class name
  60570. */
  60571. getClassName(): string;
  60572. /**
  60573. * Register a new input. Must be called inside a block constructor
  60574. * @param name defines the connection point name
  60575. * @param type defines the connection point type
  60576. * @param isOptional defines a boolean indicating that this input can be omitted
  60577. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60578. * @returns the current block
  60579. */
  60580. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60581. /**
  60582. * Register a new output. Must be called inside a block constructor
  60583. * @param name defines the connection point name
  60584. * @param type defines the connection point type
  60585. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60586. * @returns the current block
  60587. */
  60588. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60589. /**
  60590. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60591. * @param forOutput defines an optional connection point to check compatibility with
  60592. * @returns the first available input or null
  60593. */
  60594. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60595. /**
  60596. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60597. * @param forBlock defines an optional block to check compatibility with
  60598. * @returns the first available input or null
  60599. */
  60600. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60601. /**
  60602. * Gets the sibling of the given output
  60603. * @param current defines the current output
  60604. * @returns the next output in the list or null
  60605. */
  60606. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60607. /**
  60608. * Connect current block with another block
  60609. * @param other defines the block to connect with
  60610. * @param options define the various options to help pick the right connections
  60611. * @returns the current block
  60612. */
  60613. connectTo(other: NodeMaterialBlock, options?: {
  60614. input?: string;
  60615. output?: string;
  60616. outputSwizzle?: string;
  60617. }): this | undefined;
  60618. protected _buildBlock(state: NodeMaterialBuildState): void;
  60619. /**
  60620. * Add uniforms, samplers and uniform buffers at compilation time
  60621. * @param state defines the state to update
  60622. * @param nodeMaterial defines the node material requesting the update
  60623. * @param defines defines the material defines to update
  60624. * @param uniformBuffers defines the list of uniform buffer names
  60625. */
  60626. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60627. /**
  60628. * Add potential fallbacks if shader compilation fails
  60629. * @param mesh defines the mesh to be rendered
  60630. * @param fallbacks defines the current prioritized list of fallbacks
  60631. */
  60632. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60633. /**
  60634. * Initialize defines for shader compilation
  60635. * @param mesh defines the mesh to be rendered
  60636. * @param nodeMaterial defines the node material requesting the update
  60637. * @param defines defines the material defines to update
  60638. * @param useInstances specifies that instances should be used
  60639. */
  60640. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60641. /**
  60642. * Update defines for shader compilation
  60643. * @param mesh defines the mesh to be rendered
  60644. * @param nodeMaterial defines the node material requesting the update
  60645. * @param defines defines the material defines to update
  60646. * @param useInstances specifies that instances should be used
  60647. */
  60648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60649. /**
  60650. * Lets the block try to connect some inputs automatically
  60651. * @param material defines the hosting NodeMaterial
  60652. */
  60653. autoConfigure(material: NodeMaterial): void;
  60654. /**
  60655. * Function called when a block is declared as repeatable content generator
  60656. * @param vertexShaderState defines the current compilation state for the vertex shader
  60657. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60658. * @param mesh defines the mesh to be rendered
  60659. * @param defines defines the material defines to update
  60660. */
  60661. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60662. /**
  60663. * Checks if the block is ready
  60664. * @param mesh defines the mesh to be rendered
  60665. * @param nodeMaterial defines the node material requesting the update
  60666. * @param defines defines the material defines to update
  60667. * @param useInstances specifies that instances should be used
  60668. * @returns true if the block is ready
  60669. */
  60670. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60671. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60672. private _processBuild;
  60673. /**
  60674. * Compile the current node and generate the shader code
  60675. * @param state defines the current compilation state (uniforms, samplers, current string)
  60676. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60677. * @returns true if already built
  60678. */
  60679. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60680. protected _inputRename(name: string): string;
  60681. protected _outputRename(name: string): string;
  60682. protected _dumpPropertiesCode(): string;
  60683. /** @hidden */
  60684. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60685. /** @hidden */
  60686. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60687. /**
  60688. * Clone the current block to a new identical block
  60689. * @param scene defines the hosting scene
  60690. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60691. * @returns a copy of the current block
  60692. */
  60693. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60694. /**
  60695. * Serializes this block in a JSON representation
  60696. * @returns the serialized block object
  60697. */
  60698. serialize(): any;
  60699. /** @hidden */
  60700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60701. /**
  60702. * Release resources
  60703. */
  60704. dispose(): void;
  60705. }
  60706. }
  60707. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60708. /**
  60709. * Enum defining the type of animations supported by InputBlock
  60710. */
  60711. export enum AnimatedInputBlockTypes {
  60712. /** No animation */
  60713. None = 0,
  60714. /** Time based animation. Will only work for floats */
  60715. Time = 1
  60716. }
  60717. }
  60718. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60720. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60721. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60722. import { Nullable } from "babylonjs/types";
  60723. import { Effect } from "babylonjs/Materials/effect";
  60724. import { Matrix } from "babylonjs/Maths/math.vector";
  60725. import { Scene } from "babylonjs/scene";
  60726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60728. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60729. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60730. import { Observable } from "babylonjs/Misc/observable";
  60731. /**
  60732. * Block used to expose an input value
  60733. */
  60734. export class InputBlock extends NodeMaterialBlock {
  60735. private _mode;
  60736. private _associatedVariableName;
  60737. private _storedValue;
  60738. private _valueCallback;
  60739. private _type;
  60740. private _animationType;
  60741. /** Gets or set a value used to limit the range of float values */
  60742. min: number;
  60743. /** Gets or set a value used to limit the range of float values */
  60744. max: number;
  60745. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60746. isBoolean: boolean;
  60747. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60748. matrixMode: number;
  60749. /** @hidden */
  60750. _systemValue: Nullable<NodeMaterialSystemValues>;
  60751. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60752. visibleInInspector: boolean;
  60753. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60754. isConstant: boolean;
  60755. /** Gets or sets the group to use to display this block in the Inspector */
  60756. groupInInspector: string;
  60757. /** Gets an observable raised when the value is changed */
  60758. onValueChangedObservable: Observable<InputBlock>;
  60759. /**
  60760. * Gets or sets the connection point type (default is float)
  60761. */
  60762. get type(): NodeMaterialBlockConnectionPointTypes;
  60763. /**
  60764. * Creates a new InputBlock
  60765. * @param name defines the block name
  60766. * @param target defines the target of that block (Vertex by default)
  60767. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60768. */
  60769. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60770. /**
  60771. * Gets the output component
  60772. */
  60773. get output(): NodeMaterialConnectionPoint;
  60774. /**
  60775. * Set the source of this connection point to a vertex attribute
  60776. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60777. * @returns the current connection point
  60778. */
  60779. setAsAttribute(attributeName?: string): InputBlock;
  60780. /**
  60781. * Set the source of this connection point to a system value
  60782. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60783. * @returns the current connection point
  60784. */
  60785. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60786. /**
  60787. * Gets or sets the value of that point.
  60788. * Please note that this value will be ignored if valueCallback is defined
  60789. */
  60790. get value(): any;
  60791. set value(value: any);
  60792. /**
  60793. * Gets or sets a callback used to get the value of that point.
  60794. * Please note that setting this value will force the connection point to ignore the value property
  60795. */
  60796. get valueCallback(): () => any;
  60797. set valueCallback(value: () => any);
  60798. /**
  60799. * Gets or sets the associated variable name in the shader
  60800. */
  60801. get associatedVariableName(): string;
  60802. set associatedVariableName(value: string);
  60803. /** Gets or sets the type of animation applied to the input */
  60804. get animationType(): AnimatedInputBlockTypes;
  60805. set animationType(value: AnimatedInputBlockTypes);
  60806. /**
  60807. * Gets a boolean indicating that this connection point not defined yet
  60808. */
  60809. get isUndefined(): boolean;
  60810. /**
  60811. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60812. * In this case the connection point name must be the name of the uniform to use.
  60813. * Can only be set on inputs
  60814. */
  60815. get isUniform(): boolean;
  60816. set isUniform(value: boolean);
  60817. /**
  60818. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60819. * In this case the connection point name must be the name of the attribute to use
  60820. * Can only be set on inputs
  60821. */
  60822. get isAttribute(): boolean;
  60823. set isAttribute(value: boolean);
  60824. /**
  60825. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60826. * Can only be set on exit points
  60827. */
  60828. get isVarying(): boolean;
  60829. set isVarying(value: boolean);
  60830. /**
  60831. * Gets a boolean indicating that the current connection point is a system value
  60832. */
  60833. get isSystemValue(): boolean;
  60834. /**
  60835. * Gets or sets the current well known value or null if not defined as a system value
  60836. */
  60837. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60838. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60839. /**
  60840. * Gets the current class name
  60841. * @returns the class name
  60842. */
  60843. getClassName(): string;
  60844. /**
  60845. * Animate the input if animationType !== None
  60846. * @param scene defines the rendering scene
  60847. */
  60848. animate(scene: Scene): void;
  60849. private _emitDefine;
  60850. initialize(state: NodeMaterialBuildState): void;
  60851. /**
  60852. * Set the input block to its default value (based on its type)
  60853. */
  60854. setDefaultValue(): void;
  60855. private _emitConstant;
  60856. private _emit;
  60857. /** @hidden */
  60858. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60859. /** @hidden */
  60860. _transmit(effect: Effect, scene: Scene): void;
  60861. protected _buildBlock(state: NodeMaterialBuildState): void;
  60862. protected _dumpPropertiesCode(): string;
  60863. dispose(): void;
  60864. serialize(): any;
  60865. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60866. }
  60867. }
  60868. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60869. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60870. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60871. import { Nullable } from "babylonjs/types";
  60872. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60873. import { Observable } from "babylonjs/Misc/observable";
  60874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60875. /**
  60876. * Enum used to define the compatibility state between two connection points
  60877. */
  60878. export enum NodeMaterialConnectionPointCompatibilityStates {
  60879. /** Points are compatibles */
  60880. Compatible = 0,
  60881. /** Points are incompatible because of their types */
  60882. TypeIncompatible = 1,
  60883. /** Points are incompatible because of their targets (vertex vs fragment) */
  60884. TargetIncompatible = 2
  60885. }
  60886. /**
  60887. * Defines the direction of a connection point
  60888. */
  60889. export enum NodeMaterialConnectionPointDirection {
  60890. /** Input */
  60891. Input = 0,
  60892. /** Output */
  60893. Output = 1
  60894. }
  60895. /**
  60896. * Defines a connection point for a block
  60897. */
  60898. export class NodeMaterialConnectionPoint {
  60899. /** @hidden */
  60900. _ownerBlock: NodeMaterialBlock;
  60901. /** @hidden */
  60902. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60903. private _endpoints;
  60904. private _associatedVariableName;
  60905. private _direction;
  60906. /** @hidden */
  60907. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60908. /** @hidden */
  60909. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60910. private _type;
  60911. /** @hidden */
  60912. _enforceAssociatedVariableName: boolean;
  60913. /** Gets the direction of the point */
  60914. get direction(): NodeMaterialConnectionPointDirection;
  60915. /**
  60916. * Gets or sets the additional types supported by this connection point
  60917. */
  60918. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60919. /**
  60920. * Gets or sets the additional types excluded by this connection point
  60921. */
  60922. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60923. /**
  60924. * Observable triggered when this point is connected
  60925. */
  60926. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60927. /**
  60928. * Gets or sets the associated variable name in the shader
  60929. */
  60930. get associatedVariableName(): string;
  60931. set associatedVariableName(value: string);
  60932. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60933. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60934. /**
  60935. * Gets or sets the connection point type (default is float)
  60936. */
  60937. get type(): NodeMaterialBlockConnectionPointTypes;
  60938. set type(value: NodeMaterialBlockConnectionPointTypes);
  60939. /**
  60940. * Gets or sets the connection point name
  60941. */
  60942. name: string;
  60943. /**
  60944. * Gets or sets a boolean indicating that this connection point can be omitted
  60945. */
  60946. isOptional: boolean;
  60947. /**
  60948. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60949. */
  60950. define: string;
  60951. /** @hidden */
  60952. _prioritizeVertex: boolean;
  60953. private _target;
  60954. /** Gets or sets the target of that connection point */
  60955. get target(): NodeMaterialBlockTargets;
  60956. set target(value: NodeMaterialBlockTargets);
  60957. /**
  60958. * Gets a boolean indicating that the current point is connected
  60959. */
  60960. get isConnected(): boolean;
  60961. /**
  60962. * Gets a boolean indicating that the current point is connected to an input block
  60963. */
  60964. get isConnectedToInputBlock(): boolean;
  60965. /**
  60966. * Gets a the connected input block (if any)
  60967. */
  60968. get connectInputBlock(): Nullable<InputBlock>;
  60969. /** Get the other side of the connection (if any) */
  60970. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60971. /** Get the block that owns this connection point */
  60972. get ownerBlock(): NodeMaterialBlock;
  60973. /** Get the block connected on the other side of this connection (if any) */
  60974. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60975. /** Get the block connected on the endpoints of this connection (if any) */
  60976. get connectedBlocks(): Array<NodeMaterialBlock>;
  60977. /** Gets the list of connected endpoints */
  60978. get endpoints(): NodeMaterialConnectionPoint[];
  60979. /** Gets a boolean indicating if that output point is connected to at least one input */
  60980. get hasEndpoints(): boolean;
  60981. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60982. get isConnectedInVertexShader(): boolean;
  60983. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60984. get isConnectedInFragmentShader(): boolean;
  60985. /**
  60986. * Creates a new connection point
  60987. * @param name defines the connection point name
  60988. * @param ownerBlock defines the block hosting this connection point
  60989. * @param direction defines the direction of the connection point
  60990. */
  60991. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60992. /**
  60993. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60994. * @returns the class name
  60995. */
  60996. getClassName(): string;
  60997. /**
  60998. * Gets a boolean indicating if the current point can be connected to another point
  60999. * @param connectionPoint defines the other connection point
  61000. * @returns a boolean
  61001. */
  61002. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61003. /**
  61004. * Gets a number indicating if the current point can be connected to another point
  61005. * @param connectionPoint defines the other connection point
  61006. * @returns a number defining the compatibility state
  61007. */
  61008. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61009. /**
  61010. * Connect this point to another connection point
  61011. * @param connectionPoint defines the other connection point
  61012. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61013. * @returns the current connection point
  61014. */
  61015. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61016. /**
  61017. * Disconnect this point from one of his endpoint
  61018. * @param endpoint defines the other connection point
  61019. * @returns the current connection point
  61020. */
  61021. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61022. /**
  61023. * Serializes this point in a JSON representation
  61024. * @returns the serialized point object
  61025. */
  61026. serialize(): any;
  61027. /**
  61028. * Release resources
  61029. */
  61030. dispose(): void;
  61031. }
  61032. }
  61033. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61037. import { Mesh } from "babylonjs/Meshes/mesh";
  61038. import { Effect } from "babylonjs/Materials/effect";
  61039. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61040. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61041. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61042. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61043. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61044. /**
  61045. * Block used to add support for vertex skinning (bones)
  61046. */
  61047. export class BonesBlock extends NodeMaterialBlock {
  61048. /**
  61049. * Creates a new BonesBlock
  61050. * @param name defines the block name
  61051. */
  61052. constructor(name: string);
  61053. /**
  61054. * Initialize the block and prepare the context for build
  61055. * @param state defines the state that will be used for the build
  61056. */
  61057. initialize(state: NodeMaterialBuildState): void;
  61058. /**
  61059. * Gets the current class name
  61060. * @returns the class name
  61061. */
  61062. getClassName(): string;
  61063. /**
  61064. * Gets the matrix indices input component
  61065. */
  61066. get matricesIndices(): NodeMaterialConnectionPoint;
  61067. /**
  61068. * Gets the matrix weights input component
  61069. */
  61070. get matricesWeights(): NodeMaterialConnectionPoint;
  61071. /**
  61072. * Gets the extra matrix indices input component
  61073. */
  61074. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61075. /**
  61076. * Gets the extra matrix weights input component
  61077. */
  61078. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61079. /**
  61080. * Gets the world input component
  61081. */
  61082. get world(): NodeMaterialConnectionPoint;
  61083. /**
  61084. * Gets the output component
  61085. */
  61086. get output(): NodeMaterialConnectionPoint;
  61087. autoConfigure(material: NodeMaterial): void;
  61088. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61091. protected _buildBlock(state: NodeMaterialBuildState): this;
  61092. }
  61093. }
  61094. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61099. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61100. /**
  61101. * Block used to add support for instances
  61102. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61103. */
  61104. export class InstancesBlock extends NodeMaterialBlock {
  61105. /**
  61106. * Creates a new InstancesBlock
  61107. * @param name defines the block name
  61108. */
  61109. constructor(name: string);
  61110. /**
  61111. * Gets the current class name
  61112. * @returns the class name
  61113. */
  61114. getClassName(): string;
  61115. /**
  61116. * Gets the first world row input component
  61117. */
  61118. get world0(): NodeMaterialConnectionPoint;
  61119. /**
  61120. * Gets the second world row input component
  61121. */
  61122. get world1(): NodeMaterialConnectionPoint;
  61123. /**
  61124. * Gets the third world row input component
  61125. */
  61126. get world2(): NodeMaterialConnectionPoint;
  61127. /**
  61128. * Gets the forth world row input component
  61129. */
  61130. get world3(): NodeMaterialConnectionPoint;
  61131. /**
  61132. * Gets the world input component
  61133. */
  61134. get world(): NodeMaterialConnectionPoint;
  61135. /**
  61136. * Gets the output component
  61137. */
  61138. get output(): NodeMaterialConnectionPoint;
  61139. /**
  61140. * Gets the isntanceID component
  61141. */
  61142. get instanceID(): NodeMaterialConnectionPoint;
  61143. autoConfigure(material: NodeMaterial): void;
  61144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61145. protected _buildBlock(state: NodeMaterialBuildState): this;
  61146. }
  61147. }
  61148. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61149. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61150. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61151. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61153. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61154. import { Effect } from "babylonjs/Materials/effect";
  61155. import { Mesh } from "babylonjs/Meshes/mesh";
  61156. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61157. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61158. /**
  61159. * Block used to add morph targets support to vertex shader
  61160. */
  61161. export class MorphTargetsBlock extends NodeMaterialBlock {
  61162. private _repeatableContentAnchor;
  61163. /**
  61164. * Create a new MorphTargetsBlock
  61165. * @param name defines the block name
  61166. */
  61167. constructor(name: string);
  61168. /**
  61169. * Gets the current class name
  61170. * @returns the class name
  61171. */
  61172. getClassName(): string;
  61173. /**
  61174. * Gets the position input component
  61175. */
  61176. get position(): NodeMaterialConnectionPoint;
  61177. /**
  61178. * Gets the normal input component
  61179. */
  61180. get normal(): NodeMaterialConnectionPoint;
  61181. /**
  61182. * Gets the tangent input component
  61183. */
  61184. get tangent(): NodeMaterialConnectionPoint;
  61185. /**
  61186. * Gets the tangent input component
  61187. */
  61188. get uv(): NodeMaterialConnectionPoint;
  61189. /**
  61190. * Gets the position output component
  61191. */
  61192. get positionOutput(): NodeMaterialConnectionPoint;
  61193. /**
  61194. * Gets the normal output component
  61195. */
  61196. get normalOutput(): NodeMaterialConnectionPoint;
  61197. /**
  61198. * Gets the tangent output component
  61199. */
  61200. get tangentOutput(): NodeMaterialConnectionPoint;
  61201. /**
  61202. * Gets the tangent output component
  61203. */
  61204. get uvOutput(): NodeMaterialConnectionPoint;
  61205. initialize(state: NodeMaterialBuildState): void;
  61206. autoConfigure(material: NodeMaterial): void;
  61207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61208. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61209. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61210. protected _buildBlock(state: NodeMaterialBuildState): this;
  61211. }
  61212. }
  61213. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61217. import { Nullable } from "babylonjs/types";
  61218. import { Scene } from "babylonjs/scene";
  61219. import { Effect } from "babylonjs/Materials/effect";
  61220. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61221. import { Mesh } from "babylonjs/Meshes/mesh";
  61222. import { Light } from "babylonjs/Lights/light";
  61223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61224. /**
  61225. * Block used to get data information from a light
  61226. */
  61227. export class LightInformationBlock extends NodeMaterialBlock {
  61228. private _lightDataUniformName;
  61229. private _lightColorUniformName;
  61230. private _lightTypeDefineName;
  61231. /**
  61232. * Gets or sets the light associated with this block
  61233. */
  61234. light: Nullable<Light>;
  61235. /**
  61236. * Creates a new LightInformationBlock
  61237. * @param name defines the block name
  61238. */
  61239. constructor(name: string);
  61240. /**
  61241. * Gets the current class name
  61242. * @returns the class name
  61243. */
  61244. getClassName(): string;
  61245. /**
  61246. * Gets the world position input component
  61247. */
  61248. get worldPosition(): NodeMaterialConnectionPoint;
  61249. /**
  61250. * Gets the direction output component
  61251. */
  61252. get direction(): NodeMaterialConnectionPoint;
  61253. /**
  61254. * Gets the direction output component
  61255. */
  61256. get color(): NodeMaterialConnectionPoint;
  61257. /**
  61258. * Gets the direction output component
  61259. */
  61260. get intensity(): NodeMaterialConnectionPoint;
  61261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61263. protected _buildBlock(state: NodeMaterialBuildState): this;
  61264. serialize(): any;
  61265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61266. }
  61267. }
  61268. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61269. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61270. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61271. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61272. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61273. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61274. }
  61275. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61277. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61278. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61280. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61281. import { Effect } from "babylonjs/Materials/effect";
  61282. import { Mesh } from "babylonjs/Meshes/mesh";
  61283. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61284. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61285. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61286. /**
  61287. * Block used to add image processing support to fragment shader
  61288. */
  61289. export class ImageProcessingBlock extends NodeMaterialBlock {
  61290. /**
  61291. * Create a new ImageProcessingBlock
  61292. * @param name defines the block name
  61293. */
  61294. constructor(name: string);
  61295. /**
  61296. * Gets the current class name
  61297. * @returns the class name
  61298. */
  61299. getClassName(): string;
  61300. /**
  61301. * Gets the color input component
  61302. */
  61303. get color(): NodeMaterialConnectionPoint;
  61304. /**
  61305. * Gets the output component
  61306. */
  61307. get output(): NodeMaterialConnectionPoint;
  61308. /**
  61309. * Initialize the block and prepare the context for build
  61310. * @param state defines the state that will be used for the build
  61311. */
  61312. initialize(state: NodeMaterialBuildState): void;
  61313. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61316. protected _buildBlock(state: NodeMaterialBuildState): this;
  61317. }
  61318. }
  61319. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61323. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61325. import { Effect } from "babylonjs/Materials/effect";
  61326. import { Mesh } from "babylonjs/Meshes/mesh";
  61327. import { Scene } from "babylonjs/scene";
  61328. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61329. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61330. /**
  61331. * Block used to pertub normals based on a normal map
  61332. */
  61333. export class PerturbNormalBlock extends NodeMaterialBlock {
  61334. private _tangentSpaceParameterName;
  61335. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61336. invertX: boolean;
  61337. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61338. invertY: boolean;
  61339. /**
  61340. * Create a new PerturbNormalBlock
  61341. * @param name defines the block name
  61342. */
  61343. constructor(name: string);
  61344. /**
  61345. * Gets the current class name
  61346. * @returns the class name
  61347. */
  61348. getClassName(): string;
  61349. /**
  61350. * Gets the world position input component
  61351. */
  61352. get worldPosition(): NodeMaterialConnectionPoint;
  61353. /**
  61354. * Gets the world normal input component
  61355. */
  61356. get worldNormal(): NodeMaterialConnectionPoint;
  61357. /**
  61358. * Gets the world tangent input component
  61359. */
  61360. get worldTangent(): NodeMaterialConnectionPoint;
  61361. /**
  61362. * Gets the uv input component
  61363. */
  61364. get uv(): NodeMaterialConnectionPoint;
  61365. /**
  61366. * Gets the normal map color input component
  61367. */
  61368. get normalMapColor(): NodeMaterialConnectionPoint;
  61369. /**
  61370. * Gets the strength input component
  61371. */
  61372. get strength(): NodeMaterialConnectionPoint;
  61373. /**
  61374. * Gets the output component
  61375. */
  61376. get output(): NodeMaterialConnectionPoint;
  61377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61379. autoConfigure(material: NodeMaterial): void;
  61380. protected _buildBlock(state: NodeMaterialBuildState): this;
  61381. protected _dumpPropertiesCode(): string;
  61382. serialize(): any;
  61383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61384. }
  61385. }
  61386. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61390. /**
  61391. * Block used to discard a pixel if a value is smaller than a cutoff
  61392. */
  61393. export class DiscardBlock extends NodeMaterialBlock {
  61394. /**
  61395. * Create a new DiscardBlock
  61396. * @param name defines the block name
  61397. */
  61398. constructor(name: string);
  61399. /**
  61400. * Gets the current class name
  61401. * @returns the class name
  61402. */
  61403. getClassName(): string;
  61404. /**
  61405. * Gets the color input component
  61406. */
  61407. get value(): NodeMaterialConnectionPoint;
  61408. /**
  61409. * Gets the cutoff input component
  61410. */
  61411. get cutoff(): NodeMaterialConnectionPoint;
  61412. protected _buildBlock(state: NodeMaterialBuildState): this;
  61413. }
  61414. }
  61415. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61419. /**
  61420. * Block used to test if the fragment shader is front facing
  61421. */
  61422. export class FrontFacingBlock extends NodeMaterialBlock {
  61423. /**
  61424. * Creates a new FrontFacingBlock
  61425. * @param name defines the block name
  61426. */
  61427. constructor(name: string);
  61428. /**
  61429. * Gets the current class name
  61430. * @returns the class name
  61431. */
  61432. getClassName(): string;
  61433. /**
  61434. * Gets the output component
  61435. */
  61436. get output(): NodeMaterialConnectionPoint;
  61437. protected _buildBlock(state: NodeMaterialBuildState): this;
  61438. }
  61439. }
  61440. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61444. /**
  61445. * Block used to get the derivative value on x and y of a given input
  61446. */
  61447. export class DerivativeBlock extends NodeMaterialBlock {
  61448. /**
  61449. * Create a new DerivativeBlock
  61450. * @param name defines the block name
  61451. */
  61452. constructor(name: string);
  61453. /**
  61454. * Gets the current class name
  61455. * @returns the class name
  61456. */
  61457. getClassName(): string;
  61458. /**
  61459. * Gets the input component
  61460. */
  61461. get input(): NodeMaterialConnectionPoint;
  61462. /**
  61463. * Gets the derivative output on x
  61464. */
  61465. get dx(): NodeMaterialConnectionPoint;
  61466. /**
  61467. * Gets the derivative output on y
  61468. */
  61469. get dy(): NodeMaterialConnectionPoint;
  61470. protected _buildBlock(state: NodeMaterialBuildState): this;
  61471. }
  61472. }
  61473. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61474. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61475. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61476. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61477. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61478. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61479. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61480. }
  61481. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61484. import { Mesh } from "babylonjs/Meshes/mesh";
  61485. import { Effect } from "babylonjs/Materials/effect";
  61486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61488. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61489. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61490. /**
  61491. * Block used to add support for scene fog
  61492. */
  61493. export class FogBlock extends NodeMaterialBlock {
  61494. private _fogDistanceName;
  61495. private _fogParameters;
  61496. /**
  61497. * Create a new FogBlock
  61498. * @param name defines the block name
  61499. */
  61500. constructor(name: string);
  61501. /**
  61502. * Gets the current class name
  61503. * @returns the class name
  61504. */
  61505. getClassName(): string;
  61506. /**
  61507. * Gets the world position input component
  61508. */
  61509. get worldPosition(): NodeMaterialConnectionPoint;
  61510. /**
  61511. * Gets the view input component
  61512. */
  61513. get view(): NodeMaterialConnectionPoint;
  61514. /**
  61515. * Gets the color input component
  61516. */
  61517. get input(): NodeMaterialConnectionPoint;
  61518. /**
  61519. * Gets the fog color input component
  61520. */
  61521. get fogColor(): NodeMaterialConnectionPoint;
  61522. /**
  61523. * Gets the output component
  61524. */
  61525. get output(): NodeMaterialConnectionPoint;
  61526. autoConfigure(material: NodeMaterial): void;
  61527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61528. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61529. protected _buildBlock(state: NodeMaterialBuildState): this;
  61530. }
  61531. }
  61532. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61537. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61538. import { Effect } from "babylonjs/Materials/effect";
  61539. import { Mesh } from "babylonjs/Meshes/mesh";
  61540. import { Light } from "babylonjs/Lights/light";
  61541. import { Nullable } from "babylonjs/types";
  61542. import { Scene } from "babylonjs/scene";
  61543. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61544. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61545. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61546. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61547. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61548. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61549. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61550. /**
  61551. * Block used to add light in the fragment shader
  61552. */
  61553. export class LightBlock extends NodeMaterialBlock {
  61554. private _lightId;
  61555. /**
  61556. * Gets or sets the light associated with this block
  61557. */
  61558. light: Nullable<Light>;
  61559. /**
  61560. * Create a new LightBlock
  61561. * @param name defines the block name
  61562. */
  61563. constructor(name: string);
  61564. /**
  61565. * Gets the current class name
  61566. * @returns the class name
  61567. */
  61568. getClassName(): string;
  61569. /**
  61570. * Gets the world position input component
  61571. */
  61572. get worldPosition(): NodeMaterialConnectionPoint;
  61573. /**
  61574. * Gets the world normal input component
  61575. */
  61576. get worldNormal(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the camera (or eye) position component
  61579. */
  61580. get cameraPosition(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the glossiness component
  61583. */
  61584. get glossiness(): NodeMaterialConnectionPoint;
  61585. /**
  61586. * Gets the glossinness power component
  61587. */
  61588. get glossPower(): NodeMaterialConnectionPoint;
  61589. /**
  61590. * Gets the diffuse color component
  61591. */
  61592. get diffuseColor(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the specular color component
  61595. */
  61596. get specularColor(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the diffuse output component
  61599. */
  61600. get diffuseOutput(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the specular output component
  61603. */
  61604. get specularOutput(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the shadow output component
  61607. */
  61608. get shadow(): NodeMaterialConnectionPoint;
  61609. autoConfigure(material: NodeMaterial): void;
  61610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61611. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61612. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61613. private _injectVertexCode;
  61614. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61615. serialize(): any;
  61616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61617. }
  61618. }
  61619. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61620. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61621. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61622. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61623. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61624. }
  61625. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61626. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61627. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61628. }
  61629. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61633. /**
  61634. * Block used to multiply 2 values
  61635. */
  61636. export class MultiplyBlock extends NodeMaterialBlock {
  61637. /**
  61638. * Creates a new MultiplyBlock
  61639. * @param name defines the block name
  61640. */
  61641. constructor(name: string);
  61642. /**
  61643. * Gets the current class name
  61644. * @returns the class name
  61645. */
  61646. getClassName(): string;
  61647. /**
  61648. * Gets the left operand input component
  61649. */
  61650. get left(): NodeMaterialConnectionPoint;
  61651. /**
  61652. * Gets the right operand input component
  61653. */
  61654. get right(): NodeMaterialConnectionPoint;
  61655. /**
  61656. * Gets the output component
  61657. */
  61658. get output(): NodeMaterialConnectionPoint;
  61659. protected _buildBlock(state: NodeMaterialBuildState): this;
  61660. }
  61661. }
  61662. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61666. /**
  61667. * Block used to add 2 vectors
  61668. */
  61669. export class AddBlock extends NodeMaterialBlock {
  61670. /**
  61671. * Creates a new AddBlock
  61672. * @param name defines the block name
  61673. */
  61674. constructor(name: string);
  61675. /**
  61676. * Gets the current class name
  61677. * @returns the class name
  61678. */
  61679. getClassName(): string;
  61680. /**
  61681. * Gets the left operand input component
  61682. */
  61683. get left(): NodeMaterialConnectionPoint;
  61684. /**
  61685. * Gets the right operand input component
  61686. */
  61687. get right(): NodeMaterialConnectionPoint;
  61688. /**
  61689. * Gets the output component
  61690. */
  61691. get output(): NodeMaterialConnectionPoint;
  61692. protected _buildBlock(state: NodeMaterialBuildState): this;
  61693. }
  61694. }
  61695. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61699. /**
  61700. * Block used to scale a vector by a float
  61701. */
  61702. export class ScaleBlock extends NodeMaterialBlock {
  61703. /**
  61704. * Creates a new ScaleBlock
  61705. * @param name defines the block name
  61706. */
  61707. constructor(name: string);
  61708. /**
  61709. * Gets the current class name
  61710. * @returns the class name
  61711. */
  61712. getClassName(): string;
  61713. /**
  61714. * Gets the input component
  61715. */
  61716. get input(): NodeMaterialConnectionPoint;
  61717. /**
  61718. * Gets the factor input component
  61719. */
  61720. get factor(): NodeMaterialConnectionPoint;
  61721. /**
  61722. * Gets the output component
  61723. */
  61724. get output(): NodeMaterialConnectionPoint;
  61725. protected _buildBlock(state: NodeMaterialBuildState): this;
  61726. }
  61727. }
  61728. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61732. import { Scene } from "babylonjs/scene";
  61733. /**
  61734. * Block used to clamp a float
  61735. */
  61736. export class ClampBlock extends NodeMaterialBlock {
  61737. /** Gets or sets the minimum range */
  61738. minimum: number;
  61739. /** Gets or sets the maximum range */
  61740. maximum: number;
  61741. /**
  61742. * Creates a new ClampBlock
  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 value input component
  61753. */
  61754. get value(): NodeMaterialConnectionPoint;
  61755. /**
  61756. * Gets the output component
  61757. */
  61758. get output(): NodeMaterialConnectionPoint;
  61759. protected _buildBlock(state: NodeMaterialBuildState): this;
  61760. protected _dumpPropertiesCode(): string;
  61761. serialize(): any;
  61762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61763. }
  61764. }
  61765. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61769. /**
  61770. * Block used to apply a cross product between 2 vectors
  61771. */
  61772. export class CrossBlock extends NodeMaterialBlock {
  61773. /**
  61774. * Creates a new CrossBlock
  61775. * @param name defines the block name
  61776. */
  61777. constructor(name: string);
  61778. /**
  61779. * Gets the current class name
  61780. * @returns the class name
  61781. */
  61782. getClassName(): string;
  61783. /**
  61784. * Gets the left operand input component
  61785. */
  61786. get left(): NodeMaterialConnectionPoint;
  61787. /**
  61788. * Gets the right operand input component
  61789. */
  61790. get right(): NodeMaterialConnectionPoint;
  61791. /**
  61792. * Gets the output component
  61793. */
  61794. get output(): NodeMaterialConnectionPoint;
  61795. protected _buildBlock(state: NodeMaterialBuildState): this;
  61796. }
  61797. }
  61798. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61802. /**
  61803. * Block used to apply a dot product between 2 vectors
  61804. */
  61805. export class DotBlock extends NodeMaterialBlock {
  61806. /**
  61807. * Creates a new DotBlock
  61808. * @param name defines the block name
  61809. */
  61810. constructor(name: string);
  61811. /**
  61812. * Gets the current class name
  61813. * @returns the class name
  61814. */
  61815. getClassName(): string;
  61816. /**
  61817. * Gets the left operand input component
  61818. */
  61819. get left(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the right operand input component
  61822. */
  61823. get right(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the output component
  61826. */
  61827. get output(): NodeMaterialConnectionPoint;
  61828. protected _buildBlock(state: NodeMaterialBuildState): this;
  61829. }
  61830. }
  61831. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61835. import { Vector2 } from "babylonjs/Maths/math.vector";
  61836. import { Scene } from "babylonjs/scene";
  61837. /**
  61838. * Block used to remap a float from a range to a new one
  61839. */
  61840. export class RemapBlock extends NodeMaterialBlock {
  61841. /**
  61842. * Gets or sets the source range
  61843. */
  61844. sourceRange: Vector2;
  61845. /**
  61846. * Gets or sets the target range
  61847. */
  61848. targetRange: Vector2;
  61849. /**
  61850. * Creates a new RemapBlock
  61851. * @param name defines the block name
  61852. */
  61853. constructor(name: string);
  61854. /**
  61855. * Gets the current class name
  61856. * @returns the class name
  61857. */
  61858. getClassName(): string;
  61859. /**
  61860. * Gets the input component
  61861. */
  61862. get input(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the source min input component
  61865. */
  61866. get sourceMin(): NodeMaterialConnectionPoint;
  61867. /**
  61868. * Gets the source max input component
  61869. */
  61870. get sourceMax(): NodeMaterialConnectionPoint;
  61871. /**
  61872. * Gets the target min input component
  61873. */
  61874. get targetMin(): NodeMaterialConnectionPoint;
  61875. /**
  61876. * Gets the target max input component
  61877. */
  61878. get targetMax(): NodeMaterialConnectionPoint;
  61879. /**
  61880. * Gets the output component
  61881. */
  61882. get output(): NodeMaterialConnectionPoint;
  61883. protected _buildBlock(state: NodeMaterialBuildState): this;
  61884. protected _dumpPropertiesCode(): string;
  61885. serialize(): any;
  61886. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61887. }
  61888. }
  61889. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61893. /**
  61894. * Block used to normalize a vector
  61895. */
  61896. export class NormalizeBlock extends NodeMaterialBlock {
  61897. /**
  61898. * Creates a new NormalizeBlock
  61899. * @param name defines the block name
  61900. */
  61901. constructor(name: string);
  61902. /**
  61903. * Gets the current class name
  61904. * @returns the class name
  61905. */
  61906. getClassName(): string;
  61907. /**
  61908. * Gets the input component
  61909. */
  61910. get input(): NodeMaterialConnectionPoint;
  61911. /**
  61912. * Gets the output component
  61913. */
  61914. get output(): NodeMaterialConnectionPoint;
  61915. protected _buildBlock(state: NodeMaterialBuildState): this;
  61916. }
  61917. }
  61918. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61922. import { Scene } from "babylonjs/scene";
  61923. /**
  61924. * Operations supported by the Trigonometry block
  61925. */
  61926. export enum TrigonometryBlockOperations {
  61927. /** Cos */
  61928. Cos = 0,
  61929. /** Sin */
  61930. Sin = 1,
  61931. /** Abs */
  61932. Abs = 2,
  61933. /** Exp */
  61934. Exp = 3,
  61935. /** Exp2 */
  61936. Exp2 = 4,
  61937. /** Round */
  61938. Round = 5,
  61939. /** Floor */
  61940. Floor = 6,
  61941. /** Ceiling */
  61942. Ceiling = 7,
  61943. /** Square root */
  61944. Sqrt = 8,
  61945. /** Log */
  61946. Log = 9,
  61947. /** Tangent */
  61948. Tan = 10,
  61949. /** Arc tangent */
  61950. ArcTan = 11,
  61951. /** Arc cosinus */
  61952. ArcCos = 12,
  61953. /** Arc sinus */
  61954. ArcSin = 13,
  61955. /** Fraction */
  61956. Fract = 14,
  61957. /** Sign */
  61958. Sign = 15,
  61959. /** To radians (from degrees) */
  61960. Radians = 16,
  61961. /** To degrees (from radians) */
  61962. Degrees = 17
  61963. }
  61964. /**
  61965. * Block used to apply trigonometry operation to floats
  61966. */
  61967. export class TrigonometryBlock extends NodeMaterialBlock {
  61968. /**
  61969. * Gets or sets the operation applied by the block
  61970. */
  61971. operation: TrigonometryBlockOperations;
  61972. /**
  61973. * Creates a new TrigonometryBlock
  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 input component
  61984. */
  61985. get input(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the output component
  61988. */
  61989. get output(): NodeMaterialConnectionPoint;
  61990. protected _buildBlock(state: NodeMaterialBuildState): this;
  61991. serialize(): any;
  61992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61993. protected _dumpPropertiesCode(): string;
  61994. }
  61995. }
  61996. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62000. /**
  62001. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62002. */
  62003. export class ColorMergerBlock extends NodeMaterialBlock {
  62004. /**
  62005. * Create a new ColorMergerBlock
  62006. * @param name defines the block name
  62007. */
  62008. constructor(name: string);
  62009. /**
  62010. * Gets the current class name
  62011. * @returns the class name
  62012. */
  62013. getClassName(): string;
  62014. /**
  62015. * Gets the rgb component (input)
  62016. */
  62017. get rgbIn(): NodeMaterialConnectionPoint;
  62018. /**
  62019. * Gets the r component (input)
  62020. */
  62021. get r(): NodeMaterialConnectionPoint;
  62022. /**
  62023. * Gets the g component (input)
  62024. */
  62025. get g(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the b component (input)
  62028. */
  62029. get b(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the a component (input)
  62032. */
  62033. get a(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the rgba component (output)
  62036. */
  62037. get rgba(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the rgb component (output)
  62040. */
  62041. get rgbOut(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the rgb component (output)
  62044. * @deprecated Please use rgbOut instead.
  62045. */
  62046. get rgb(): NodeMaterialConnectionPoint;
  62047. protected _buildBlock(state: NodeMaterialBuildState): this;
  62048. }
  62049. }
  62050. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62054. /**
  62055. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62056. */
  62057. export class VectorMergerBlock extends NodeMaterialBlock {
  62058. /**
  62059. * Create a new VectorMergerBlock
  62060. * @param name defines the block name
  62061. */
  62062. constructor(name: string);
  62063. /**
  62064. * Gets the current class name
  62065. * @returns the class name
  62066. */
  62067. getClassName(): string;
  62068. /**
  62069. * Gets the xyz component (input)
  62070. */
  62071. get xyzIn(): NodeMaterialConnectionPoint;
  62072. /**
  62073. * Gets the xy component (input)
  62074. */
  62075. get xyIn(): NodeMaterialConnectionPoint;
  62076. /**
  62077. * Gets the x component (input)
  62078. */
  62079. get x(): NodeMaterialConnectionPoint;
  62080. /**
  62081. * Gets the y component (input)
  62082. */
  62083. get y(): NodeMaterialConnectionPoint;
  62084. /**
  62085. * Gets the z component (input)
  62086. */
  62087. get z(): NodeMaterialConnectionPoint;
  62088. /**
  62089. * Gets the w component (input)
  62090. */
  62091. get w(): NodeMaterialConnectionPoint;
  62092. /**
  62093. * Gets the xyzw component (output)
  62094. */
  62095. get xyzw(): NodeMaterialConnectionPoint;
  62096. /**
  62097. * Gets the xyz component (output)
  62098. */
  62099. get xyzOut(): NodeMaterialConnectionPoint;
  62100. /**
  62101. * Gets the xy component (output)
  62102. */
  62103. get xyOut(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the xy component (output)
  62106. * @deprecated Please use xyOut instead.
  62107. */
  62108. get xy(): NodeMaterialConnectionPoint;
  62109. /**
  62110. * Gets the xyz component (output)
  62111. * @deprecated Please use xyzOut instead.
  62112. */
  62113. get xyz(): NodeMaterialConnectionPoint;
  62114. protected _buildBlock(state: NodeMaterialBuildState): this;
  62115. }
  62116. }
  62117. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62121. /**
  62122. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62123. */
  62124. export class ColorSplitterBlock extends NodeMaterialBlock {
  62125. /**
  62126. * Create a new ColorSplitterBlock
  62127. * @param name defines the block name
  62128. */
  62129. constructor(name: string);
  62130. /**
  62131. * Gets the current class name
  62132. * @returns the class name
  62133. */
  62134. getClassName(): string;
  62135. /**
  62136. * Gets the rgba component (input)
  62137. */
  62138. get rgba(): NodeMaterialConnectionPoint;
  62139. /**
  62140. * Gets the rgb component (input)
  62141. */
  62142. get rgbIn(): NodeMaterialConnectionPoint;
  62143. /**
  62144. * Gets the rgb component (output)
  62145. */
  62146. get rgbOut(): NodeMaterialConnectionPoint;
  62147. /**
  62148. * Gets the r component (output)
  62149. */
  62150. get r(): NodeMaterialConnectionPoint;
  62151. /**
  62152. * Gets the g component (output)
  62153. */
  62154. get g(): NodeMaterialConnectionPoint;
  62155. /**
  62156. * Gets the b component (output)
  62157. */
  62158. get b(): NodeMaterialConnectionPoint;
  62159. /**
  62160. * Gets the a component (output)
  62161. */
  62162. get a(): NodeMaterialConnectionPoint;
  62163. protected _inputRename(name: string): string;
  62164. protected _outputRename(name: string): string;
  62165. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62166. }
  62167. }
  62168. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62172. /**
  62173. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62174. */
  62175. export class VectorSplitterBlock extends NodeMaterialBlock {
  62176. /**
  62177. * Create a new VectorSplitterBlock
  62178. * @param name defines the block name
  62179. */
  62180. constructor(name: string);
  62181. /**
  62182. * Gets the current class name
  62183. * @returns the class name
  62184. */
  62185. getClassName(): string;
  62186. /**
  62187. * Gets the xyzw component (input)
  62188. */
  62189. get xyzw(): NodeMaterialConnectionPoint;
  62190. /**
  62191. * Gets the xyz component (input)
  62192. */
  62193. get xyzIn(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the xy component (input)
  62196. */
  62197. get xyIn(): NodeMaterialConnectionPoint;
  62198. /**
  62199. * Gets the xyz component (output)
  62200. */
  62201. get xyzOut(): NodeMaterialConnectionPoint;
  62202. /**
  62203. * Gets the xy component (output)
  62204. */
  62205. get xyOut(): NodeMaterialConnectionPoint;
  62206. /**
  62207. * Gets the x component (output)
  62208. */
  62209. get x(): NodeMaterialConnectionPoint;
  62210. /**
  62211. * Gets the y component (output)
  62212. */
  62213. get y(): NodeMaterialConnectionPoint;
  62214. /**
  62215. * Gets the z component (output)
  62216. */
  62217. get z(): NodeMaterialConnectionPoint;
  62218. /**
  62219. * Gets the w component (output)
  62220. */
  62221. get w(): NodeMaterialConnectionPoint;
  62222. protected _inputRename(name: string): string;
  62223. protected _outputRename(name: string): string;
  62224. protected _buildBlock(state: NodeMaterialBuildState): this;
  62225. }
  62226. }
  62227. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62231. /**
  62232. * Block used to lerp between 2 values
  62233. */
  62234. export class LerpBlock extends NodeMaterialBlock {
  62235. /**
  62236. * Creates a new LerpBlock
  62237. * @param name defines the block name
  62238. */
  62239. constructor(name: string);
  62240. /**
  62241. * Gets the current class name
  62242. * @returns the class name
  62243. */
  62244. getClassName(): string;
  62245. /**
  62246. * Gets the left operand input component
  62247. */
  62248. get left(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the right operand input component
  62251. */
  62252. get right(): NodeMaterialConnectionPoint;
  62253. /**
  62254. * Gets the gradient operand input component
  62255. */
  62256. get gradient(): NodeMaterialConnectionPoint;
  62257. /**
  62258. * Gets the output component
  62259. */
  62260. get output(): NodeMaterialConnectionPoint;
  62261. protected _buildBlock(state: NodeMaterialBuildState): this;
  62262. }
  62263. }
  62264. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62268. /**
  62269. * Block used to divide 2 vectors
  62270. */
  62271. export class DivideBlock extends NodeMaterialBlock {
  62272. /**
  62273. * Creates a new DivideBlock
  62274. * @param name defines the block name
  62275. */
  62276. constructor(name: string);
  62277. /**
  62278. * Gets the current class name
  62279. * @returns the class name
  62280. */
  62281. getClassName(): string;
  62282. /**
  62283. * Gets the left operand input component
  62284. */
  62285. get left(): NodeMaterialConnectionPoint;
  62286. /**
  62287. * Gets the right operand input component
  62288. */
  62289. get right(): NodeMaterialConnectionPoint;
  62290. /**
  62291. * Gets the output component
  62292. */
  62293. get output(): NodeMaterialConnectionPoint;
  62294. protected _buildBlock(state: NodeMaterialBuildState): this;
  62295. }
  62296. }
  62297. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62301. /**
  62302. * Block used to subtract 2 vectors
  62303. */
  62304. export class SubtractBlock extends NodeMaterialBlock {
  62305. /**
  62306. * Creates a new SubtractBlock
  62307. * @param name defines the block name
  62308. */
  62309. constructor(name: string);
  62310. /**
  62311. * Gets the current class name
  62312. * @returns the class name
  62313. */
  62314. getClassName(): string;
  62315. /**
  62316. * Gets the left operand input component
  62317. */
  62318. get left(): NodeMaterialConnectionPoint;
  62319. /**
  62320. * Gets the right operand input component
  62321. */
  62322. get right(): NodeMaterialConnectionPoint;
  62323. /**
  62324. * Gets the output component
  62325. */
  62326. get output(): NodeMaterialConnectionPoint;
  62327. protected _buildBlock(state: NodeMaterialBuildState): this;
  62328. }
  62329. }
  62330. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62334. /**
  62335. * Block used to step a value
  62336. */
  62337. export class StepBlock extends NodeMaterialBlock {
  62338. /**
  62339. * Creates a new StepBlock
  62340. * @param name defines the block name
  62341. */
  62342. constructor(name: string);
  62343. /**
  62344. * Gets the current class name
  62345. * @returns the class name
  62346. */
  62347. getClassName(): string;
  62348. /**
  62349. * Gets the value operand input component
  62350. */
  62351. get value(): NodeMaterialConnectionPoint;
  62352. /**
  62353. * Gets the edge operand input component
  62354. */
  62355. get edge(): NodeMaterialConnectionPoint;
  62356. /**
  62357. * Gets the output component
  62358. */
  62359. get output(): NodeMaterialConnectionPoint;
  62360. protected _buildBlock(state: NodeMaterialBuildState): this;
  62361. }
  62362. }
  62363. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62367. /**
  62368. * Block used to get the opposite (1 - x) of a value
  62369. */
  62370. export class OneMinusBlock extends NodeMaterialBlock {
  62371. /**
  62372. * Creates a new OneMinusBlock
  62373. * @param name defines the block name
  62374. */
  62375. constructor(name: string);
  62376. /**
  62377. * Gets the current class name
  62378. * @returns the class name
  62379. */
  62380. getClassName(): string;
  62381. /**
  62382. * Gets the input component
  62383. */
  62384. get input(): NodeMaterialConnectionPoint;
  62385. /**
  62386. * Gets the output component
  62387. */
  62388. get output(): NodeMaterialConnectionPoint;
  62389. protected _buildBlock(state: NodeMaterialBuildState): this;
  62390. }
  62391. }
  62392. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62396. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62397. /**
  62398. * Block used to get the view direction
  62399. */
  62400. export class ViewDirectionBlock extends NodeMaterialBlock {
  62401. /**
  62402. * Creates a new ViewDirectionBlock
  62403. * @param name defines the block name
  62404. */
  62405. constructor(name: string);
  62406. /**
  62407. * Gets the current class name
  62408. * @returns the class name
  62409. */
  62410. getClassName(): string;
  62411. /**
  62412. * Gets the world position component
  62413. */
  62414. get worldPosition(): NodeMaterialConnectionPoint;
  62415. /**
  62416. * Gets the camera position component
  62417. */
  62418. get cameraPosition(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the output component
  62421. */
  62422. get output(): NodeMaterialConnectionPoint;
  62423. autoConfigure(material: NodeMaterial): void;
  62424. protected _buildBlock(state: NodeMaterialBuildState): this;
  62425. }
  62426. }
  62427. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62430. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62431. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62432. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62433. /**
  62434. * Block used to compute fresnel value
  62435. */
  62436. export class FresnelBlock extends NodeMaterialBlock {
  62437. /**
  62438. * Create a new FresnelBlock
  62439. * @param name defines the block name
  62440. */
  62441. constructor(name: string);
  62442. /**
  62443. * Gets the current class name
  62444. * @returns the class name
  62445. */
  62446. getClassName(): string;
  62447. /**
  62448. * Gets the world normal input component
  62449. */
  62450. get worldNormal(): NodeMaterialConnectionPoint;
  62451. /**
  62452. * Gets the view direction input component
  62453. */
  62454. get viewDirection(): NodeMaterialConnectionPoint;
  62455. /**
  62456. * Gets the bias input component
  62457. */
  62458. get bias(): NodeMaterialConnectionPoint;
  62459. /**
  62460. * Gets the camera (or eye) position component
  62461. */
  62462. get power(): NodeMaterialConnectionPoint;
  62463. /**
  62464. * Gets the fresnel output component
  62465. */
  62466. get fresnel(): NodeMaterialConnectionPoint;
  62467. autoConfigure(material: NodeMaterial): void;
  62468. protected _buildBlock(state: NodeMaterialBuildState): this;
  62469. }
  62470. }
  62471. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62475. /**
  62476. * Block used to get the max of 2 values
  62477. */
  62478. export class MaxBlock extends NodeMaterialBlock {
  62479. /**
  62480. * Creates a new MaxBlock
  62481. * @param name defines the block name
  62482. */
  62483. constructor(name: string);
  62484. /**
  62485. * Gets the current class name
  62486. * @returns the class name
  62487. */
  62488. getClassName(): string;
  62489. /**
  62490. * Gets the left operand input component
  62491. */
  62492. get left(): NodeMaterialConnectionPoint;
  62493. /**
  62494. * Gets the right operand input component
  62495. */
  62496. get right(): NodeMaterialConnectionPoint;
  62497. /**
  62498. * Gets the output component
  62499. */
  62500. get output(): NodeMaterialConnectionPoint;
  62501. protected _buildBlock(state: NodeMaterialBuildState): this;
  62502. }
  62503. }
  62504. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62508. /**
  62509. * Block used to get the min of 2 values
  62510. */
  62511. export class MinBlock extends NodeMaterialBlock {
  62512. /**
  62513. * Creates a new MinBlock
  62514. * @param name defines the block name
  62515. */
  62516. constructor(name: string);
  62517. /**
  62518. * Gets the current class name
  62519. * @returns the class name
  62520. */
  62521. getClassName(): string;
  62522. /**
  62523. * Gets the left operand input component
  62524. */
  62525. get left(): NodeMaterialConnectionPoint;
  62526. /**
  62527. * Gets the right operand input component
  62528. */
  62529. get right(): NodeMaterialConnectionPoint;
  62530. /**
  62531. * Gets the output component
  62532. */
  62533. get output(): NodeMaterialConnectionPoint;
  62534. protected _buildBlock(state: NodeMaterialBuildState): this;
  62535. }
  62536. }
  62537. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62541. /**
  62542. * Block used to get the distance between 2 values
  62543. */
  62544. export class DistanceBlock extends NodeMaterialBlock {
  62545. /**
  62546. * Creates a new DistanceBlock
  62547. * @param name defines the block name
  62548. */
  62549. constructor(name: string);
  62550. /**
  62551. * Gets the current class name
  62552. * @returns the class name
  62553. */
  62554. getClassName(): string;
  62555. /**
  62556. * Gets the left operand input component
  62557. */
  62558. get left(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the right operand input component
  62561. */
  62562. get right(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the output component
  62565. */
  62566. get output(): NodeMaterialConnectionPoint;
  62567. protected _buildBlock(state: NodeMaterialBuildState): this;
  62568. }
  62569. }
  62570. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62574. /**
  62575. * Block used to get the length of a vector
  62576. */
  62577. export class LengthBlock extends NodeMaterialBlock {
  62578. /**
  62579. * Creates a new LengthBlock
  62580. * @param name defines the block name
  62581. */
  62582. constructor(name: string);
  62583. /**
  62584. * Gets the current class name
  62585. * @returns the class name
  62586. */
  62587. getClassName(): string;
  62588. /**
  62589. * Gets the value input component
  62590. */
  62591. get value(): NodeMaterialConnectionPoint;
  62592. /**
  62593. * Gets the output component
  62594. */
  62595. get output(): NodeMaterialConnectionPoint;
  62596. protected _buildBlock(state: NodeMaterialBuildState): this;
  62597. }
  62598. }
  62599. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62603. /**
  62604. * Block used to get negative version of a value (i.e. x * -1)
  62605. */
  62606. export class NegateBlock extends NodeMaterialBlock {
  62607. /**
  62608. * Creates a new NegateBlock
  62609. * @param name defines the block name
  62610. */
  62611. constructor(name: string);
  62612. /**
  62613. * Gets the current class name
  62614. * @returns the class name
  62615. */
  62616. getClassName(): string;
  62617. /**
  62618. * Gets the value input component
  62619. */
  62620. get value(): NodeMaterialConnectionPoint;
  62621. /**
  62622. * Gets the output component
  62623. */
  62624. get output(): NodeMaterialConnectionPoint;
  62625. protected _buildBlock(state: NodeMaterialBuildState): this;
  62626. }
  62627. }
  62628. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62632. /**
  62633. * Block used to get the value of the first parameter raised to the power of the second
  62634. */
  62635. export class PowBlock extends NodeMaterialBlock {
  62636. /**
  62637. * Creates a new PowBlock
  62638. * @param name defines the block name
  62639. */
  62640. constructor(name: string);
  62641. /**
  62642. * Gets the current class name
  62643. * @returns the class name
  62644. */
  62645. getClassName(): string;
  62646. /**
  62647. * Gets the value operand input component
  62648. */
  62649. get value(): NodeMaterialConnectionPoint;
  62650. /**
  62651. * Gets the power operand input component
  62652. */
  62653. get power(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the output component
  62656. */
  62657. get output(): NodeMaterialConnectionPoint;
  62658. protected _buildBlock(state: NodeMaterialBuildState): this;
  62659. }
  62660. }
  62661. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62665. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62666. /**
  62667. * Block used to get a random number
  62668. */
  62669. export class RandomNumberBlock extends NodeMaterialBlock {
  62670. /**
  62671. * Creates a new RandomNumberBlock
  62672. * @param name defines the block name
  62673. */
  62674. constructor(name: string);
  62675. /**
  62676. * Gets the current class name
  62677. * @returns the class name
  62678. */
  62679. getClassName(): string;
  62680. /**
  62681. * Gets the seed input component
  62682. */
  62683. get seed(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the output component
  62686. */
  62687. get output(): NodeMaterialConnectionPoint;
  62688. protected _buildBlock(state: NodeMaterialBuildState): this;
  62689. }
  62690. }
  62691. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62695. /**
  62696. * Block used to compute arc tangent of 2 values
  62697. */
  62698. export class ArcTan2Block extends NodeMaterialBlock {
  62699. /**
  62700. * Creates a new ArcTan2Block
  62701. * @param name defines the block name
  62702. */
  62703. constructor(name: string);
  62704. /**
  62705. * Gets the current class name
  62706. * @returns the class name
  62707. */
  62708. getClassName(): string;
  62709. /**
  62710. * Gets the x operand input component
  62711. */
  62712. get x(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the y operand input component
  62715. */
  62716. get y(): NodeMaterialConnectionPoint;
  62717. /**
  62718. * Gets the output component
  62719. */
  62720. get output(): NodeMaterialConnectionPoint;
  62721. protected _buildBlock(state: NodeMaterialBuildState): this;
  62722. }
  62723. }
  62724. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62728. /**
  62729. * Block used to smooth step a value
  62730. */
  62731. export class SmoothStepBlock extends NodeMaterialBlock {
  62732. /**
  62733. * Creates a new SmoothStepBlock
  62734. * @param name defines the block name
  62735. */
  62736. constructor(name: string);
  62737. /**
  62738. * Gets the current class name
  62739. * @returns the class name
  62740. */
  62741. getClassName(): string;
  62742. /**
  62743. * Gets the value operand input component
  62744. */
  62745. get value(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the first edge operand input component
  62748. */
  62749. get edge0(): NodeMaterialConnectionPoint;
  62750. /**
  62751. * Gets the second edge operand input component
  62752. */
  62753. get edge1(): NodeMaterialConnectionPoint;
  62754. /**
  62755. * Gets the output component
  62756. */
  62757. get output(): NodeMaterialConnectionPoint;
  62758. protected _buildBlock(state: NodeMaterialBuildState): this;
  62759. }
  62760. }
  62761. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62765. /**
  62766. * Block used to get the reciprocal (1 / x) of a value
  62767. */
  62768. export class ReciprocalBlock extends NodeMaterialBlock {
  62769. /**
  62770. * Creates a new ReciprocalBlock
  62771. * @param name defines the block name
  62772. */
  62773. constructor(name: string);
  62774. /**
  62775. * Gets the current class name
  62776. * @returns the class name
  62777. */
  62778. getClassName(): string;
  62779. /**
  62780. * Gets the input component
  62781. */
  62782. get input(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the output component
  62785. */
  62786. get output(): NodeMaterialConnectionPoint;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. }
  62789. }
  62790. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62794. /**
  62795. * Block used to replace a color by another one
  62796. */
  62797. export class ReplaceColorBlock extends NodeMaterialBlock {
  62798. /**
  62799. * Creates a new ReplaceColorBlock
  62800. * @param name defines the block name
  62801. */
  62802. constructor(name: string);
  62803. /**
  62804. * Gets the current class name
  62805. * @returns the class name
  62806. */
  62807. getClassName(): string;
  62808. /**
  62809. * Gets the value input component
  62810. */
  62811. get value(): NodeMaterialConnectionPoint;
  62812. /**
  62813. * Gets the reference input component
  62814. */
  62815. get reference(): NodeMaterialConnectionPoint;
  62816. /**
  62817. * Gets the distance input component
  62818. */
  62819. get distance(): NodeMaterialConnectionPoint;
  62820. /**
  62821. * Gets the replacement input component
  62822. */
  62823. get replacement(): NodeMaterialConnectionPoint;
  62824. /**
  62825. * Gets the output component
  62826. */
  62827. get output(): NodeMaterialConnectionPoint;
  62828. protected _buildBlock(state: NodeMaterialBuildState): this;
  62829. }
  62830. }
  62831. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62835. /**
  62836. * Block used to posterize a value
  62837. * @see https://en.wikipedia.org/wiki/Posterization
  62838. */
  62839. export class PosterizeBlock extends NodeMaterialBlock {
  62840. /**
  62841. * Creates a new PosterizeBlock
  62842. * @param name defines the block name
  62843. */
  62844. constructor(name: string);
  62845. /**
  62846. * Gets the current class name
  62847. * @returns the class name
  62848. */
  62849. getClassName(): string;
  62850. /**
  62851. * Gets the value input component
  62852. */
  62853. get value(): NodeMaterialConnectionPoint;
  62854. /**
  62855. * Gets the steps input component
  62856. */
  62857. get steps(): NodeMaterialConnectionPoint;
  62858. /**
  62859. * Gets the output component
  62860. */
  62861. get output(): NodeMaterialConnectionPoint;
  62862. protected _buildBlock(state: NodeMaterialBuildState): this;
  62863. }
  62864. }
  62865. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62869. import { Scene } from "babylonjs/scene";
  62870. /**
  62871. * Operations supported by the Wave block
  62872. */
  62873. export enum WaveBlockKind {
  62874. /** SawTooth */
  62875. SawTooth = 0,
  62876. /** Square */
  62877. Square = 1,
  62878. /** Triangle */
  62879. Triangle = 2
  62880. }
  62881. /**
  62882. * Block used to apply wave operation to floats
  62883. */
  62884. export class WaveBlock extends NodeMaterialBlock {
  62885. /**
  62886. * Gets or sets the kibnd of wave to be applied by the block
  62887. */
  62888. kind: WaveBlockKind;
  62889. /**
  62890. * Creates a new WaveBlock
  62891. * @param name defines the block name
  62892. */
  62893. constructor(name: string);
  62894. /**
  62895. * Gets the current class name
  62896. * @returns the class name
  62897. */
  62898. getClassName(): string;
  62899. /**
  62900. * Gets the input component
  62901. */
  62902. get input(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the output component
  62905. */
  62906. get output(): NodeMaterialConnectionPoint;
  62907. protected _buildBlock(state: NodeMaterialBuildState): this;
  62908. serialize(): any;
  62909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62910. }
  62911. }
  62912. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62916. import { Color3 } from "babylonjs/Maths/math.color";
  62917. import { Scene } from "babylonjs/scene";
  62918. /**
  62919. * Class used to store a color step for the GradientBlock
  62920. */
  62921. export class GradientBlockColorStep {
  62922. /**
  62923. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62924. */
  62925. step: number;
  62926. /**
  62927. * Gets or sets the color associated with this step
  62928. */
  62929. color: Color3;
  62930. /**
  62931. * Creates a new GradientBlockColorStep
  62932. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62933. * @param color defines the color associated with this step
  62934. */
  62935. constructor(
  62936. /**
  62937. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62938. */
  62939. step: number,
  62940. /**
  62941. * Gets or sets the color associated with this step
  62942. */
  62943. color: Color3);
  62944. }
  62945. /**
  62946. * Block used to return a color from a gradient based on an input value between 0 and 1
  62947. */
  62948. export class GradientBlock extends NodeMaterialBlock {
  62949. /**
  62950. * Gets or sets the list of color steps
  62951. */
  62952. colorSteps: GradientBlockColorStep[];
  62953. /**
  62954. * Creates a new GradientBlock
  62955. * @param name defines the block name
  62956. */
  62957. constructor(name: string);
  62958. /**
  62959. * Gets the current class name
  62960. * @returns the class name
  62961. */
  62962. getClassName(): string;
  62963. /**
  62964. * Gets the gradient input component
  62965. */
  62966. get gradient(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the output component
  62969. */
  62970. get output(): NodeMaterialConnectionPoint;
  62971. private _writeColorConstant;
  62972. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62973. serialize(): any;
  62974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62975. protected _dumpPropertiesCode(): string;
  62976. }
  62977. }
  62978. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62982. /**
  62983. * Block used to normalize lerp between 2 values
  62984. */
  62985. export class NLerpBlock extends NodeMaterialBlock {
  62986. /**
  62987. * Creates a new NLerpBlock
  62988. * @param name defines the block name
  62989. */
  62990. constructor(name: string);
  62991. /**
  62992. * Gets the current class name
  62993. * @returns the class name
  62994. */
  62995. getClassName(): string;
  62996. /**
  62997. * Gets the left operand input component
  62998. */
  62999. get left(): NodeMaterialConnectionPoint;
  63000. /**
  63001. * Gets the right operand input component
  63002. */
  63003. get right(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the gradient operand input component
  63006. */
  63007. get gradient(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the output component
  63010. */
  63011. get output(): NodeMaterialConnectionPoint;
  63012. protected _buildBlock(state: NodeMaterialBuildState): this;
  63013. }
  63014. }
  63015. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63019. import { Scene } from "babylonjs/scene";
  63020. /**
  63021. * block used to Generate a Worley Noise 3D Noise Pattern
  63022. */
  63023. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63024. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63025. manhattanDistance: boolean;
  63026. /**
  63027. * Creates a new WorleyNoise3DBlock
  63028. * @param name defines the block name
  63029. */
  63030. constructor(name: string);
  63031. /**
  63032. * Gets the current class name
  63033. * @returns the class name
  63034. */
  63035. getClassName(): string;
  63036. /**
  63037. * Gets the seed input component
  63038. */
  63039. get seed(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the jitter input component
  63042. */
  63043. get jitter(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the output component
  63046. */
  63047. get output(): NodeMaterialConnectionPoint;
  63048. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63049. /**
  63050. * Exposes the properties to the UI?
  63051. */
  63052. protected _dumpPropertiesCode(): string;
  63053. /**
  63054. * Exposes the properties to the Seralize?
  63055. */
  63056. serialize(): any;
  63057. /**
  63058. * Exposes the properties to the deseralize?
  63059. */
  63060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63061. }
  63062. }
  63063. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63067. /**
  63068. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63069. */
  63070. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63071. /**
  63072. * Creates a new SimplexPerlin3DBlock
  63073. * @param name defines the block name
  63074. */
  63075. constructor(name: string);
  63076. /**
  63077. * Gets the current class name
  63078. * @returns the class name
  63079. */
  63080. getClassName(): string;
  63081. /**
  63082. * Gets the seed operand input component
  63083. */
  63084. get seed(): NodeMaterialConnectionPoint;
  63085. /**
  63086. * Gets the output component
  63087. */
  63088. get output(): NodeMaterialConnectionPoint;
  63089. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63090. }
  63091. }
  63092. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63096. /**
  63097. * Block used to blend normals
  63098. */
  63099. export class NormalBlendBlock extends NodeMaterialBlock {
  63100. /**
  63101. * Creates a new NormalBlendBlock
  63102. * @param name defines the block name
  63103. */
  63104. constructor(name: string);
  63105. /**
  63106. * Gets the current class name
  63107. * @returns the class name
  63108. */
  63109. getClassName(): string;
  63110. /**
  63111. * Gets the first input component
  63112. */
  63113. get normalMap0(): NodeMaterialConnectionPoint;
  63114. /**
  63115. * Gets the second input component
  63116. */
  63117. get normalMap1(): NodeMaterialConnectionPoint;
  63118. /**
  63119. * Gets the output component
  63120. */
  63121. get output(): NodeMaterialConnectionPoint;
  63122. protected _buildBlock(state: NodeMaterialBuildState): this;
  63123. }
  63124. }
  63125. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63129. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63130. /**
  63131. * Block used to rotate a 2d vector by a given angle
  63132. */
  63133. export class Rotate2dBlock extends NodeMaterialBlock {
  63134. /**
  63135. * Creates a new Rotate2dBlock
  63136. * @param name defines the block name
  63137. */
  63138. constructor(name: string);
  63139. /**
  63140. * Gets the current class name
  63141. * @returns the class name
  63142. */
  63143. getClassName(): string;
  63144. /**
  63145. * Gets the input vector
  63146. */
  63147. get input(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the input angle
  63150. */
  63151. get angle(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the output component
  63154. */
  63155. get output(): NodeMaterialConnectionPoint;
  63156. autoConfigure(material: NodeMaterial): void;
  63157. protected _buildBlock(state: NodeMaterialBuildState): this;
  63158. }
  63159. }
  63160. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63164. /**
  63165. * Block used to get the reflected vector from a direction and a normal
  63166. */
  63167. export class ReflectBlock extends NodeMaterialBlock {
  63168. /**
  63169. * Creates a new ReflectBlock
  63170. * @param name defines the block name
  63171. */
  63172. constructor(name: string);
  63173. /**
  63174. * Gets the current class name
  63175. * @returns the class name
  63176. */
  63177. getClassName(): string;
  63178. /**
  63179. * Gets the incident component
  63180. */
  63181. get incident(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the normal component
  63184. */
  63185. get normal(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the output component
  63188. */
  63189. get output(): NodeMaterialConnectionPoint;
  63190. protected _buildBlock(state: NodeMaterialBuildState): this;
  63191. }
  63192. }
  63193. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63197. /**
  63198. * Block used to get the refracted vector from a direction and a normal
  63199. */
  63200. export class RefractBlock extends NodeMaterialBlock {
  63201. /**
  63202. * Creates a new RefractBlock
  63203. * @param name defines the block name
  63204. */
  63205. constructor(name: string);
  63206. /**
  63207. * Gets the current class name
  63208. * @returns the class name
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Gets the incident component
  63213. */
  63214. get incident(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the normal component
  63217. */
  63218. get normal(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the index of refraction component
  63221. */
  63222. get ior(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the output component
  63225. */
  63226. get output(): NodeMaterialConnectionPoint;
  63227. protected _buildBlock(state: NodeMaterialBuildState): this;
  63228. }
  63229. }
  63230. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63234. /**
  63235. * Block used to desaturate a color
  63236. */
  63237. export class DesaturateBlock extends NodeMaterialBlock {
  63238. /**
  63239. * Creates a new DesaturateBlock
  63240. * @param name defines the block name
  63241. */
  63242. constructor(name: string);
  63243. /**
  63244. * Gets the current class name
  63245. * @returns the class name
  63246. */
  63247. getClassName(): string;
  63248. /**
  63249. * Gets the color operand input component
  63250. */
  63251. get color(): NodeMaterialConnectionPoint;
  63252. /**
  63253. * Gets the level operand input component
  63254. */
  63255. get level(): NodeMaterialConnectionPoint;
  63256. /**
  63257. * Gets the output component
  63258. */
  63259. get output(): NodeMaterialConnectionPoint;
  63260. protected _buildBlock(state: NodeMaterialBuildState): this;
  63261. }
  63262. }
  63263. declare module "babylonjs/Materials/Node/Blocks/index" {
  63264. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63265. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63266. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63267. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63268. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63269. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63270. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63271. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63272. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63273. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63274. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63275. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63276. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63277. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63278. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63279. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63280. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63281. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63282. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63283. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63284. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63285. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63286. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63287. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63288. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63289. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63290. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63291. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63292. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63293. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63294. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63295. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63296. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63297. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63298. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63299. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63300. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63301. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63302. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63303. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63304. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63305. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63306. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63307. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63308. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63309. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63310. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63311. }
  63312. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63313. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63314. }
  63315. declare module "babylonjs/Materials/Node/index" {
  63316. export * from "babylonjs/Materials/Node/Enums/index";
  63317. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63318. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63319. export * from "babylonjs/Materials/Node/nodeMaterial";
  63320. export * from "babylonjs/Materials/Node/Blocks/index";
  63321. export * from "babylonjs/Materials/Node/Optimizers/index";
  63322. }
  63323. declare module "babylonjs/Materials/effectRenderer" {
  63324. import { Nullable } from "babylonjs/types";
  63325. import { Texture } from "babylonjs/Materials/Textures/texture";
  63326. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63327. import { Viewport } from "babylonjs/Maths/math.viewport";
  63328. import { Observable } from "babylonjs/Misc/observable";
  63329. import { Effect } from "babylonjs/Materials/effect";
  63330. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63331. import "babylonjs/Shaders/postprocess.vertex";
  63332. /**
  63333. * Effect Render Options
  63334. */
  63335. export interface IEffectRendererOptions {
  63336. /**
  63337. * Defines the vertices positions.
  63338. */
  63339. positions?: number[];
  63340. /**
  63341. * Defines the indices.
  63342. */
  63343. indices?: number[];
  63344. }
  63345. /**
  63346. * Helper class to render one or more effects
  63347. */
  63348. export class EffectRenderer {
  63349. private engine;
  63350. private static _DefaultOptions;
  63351. private _vertexBuffers;
  63352. private _indexBuffer;
  63353. private _ringBufferIndex;
  63354. private _ringScreenBuffer;
  63355. private _fullscreenViewport;
  63356. private _getNextFrameBuffer;
  63357. /**
  63358. * Creates an effect renderer
  63359. * @param engine the engine to use for rendering
  63360. * @param options defines the options of the effect renderer
  63361. */
  63362. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63363. /**
  63364. * Sets the current viewport in normalized coordinates 0-1
  63365. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63366. */
  63367. setViewport(viewport?: Viewport): void;
  63368. /**
  63369. * Binds the embedded attributes buffer to the effect.
  63370. * @param effect Defines the effect to bind the attributes for
  63371. */
  63372. bindBuffers(effect: Effect): void;
  63373. /**
  63374. * Sets the current effect wrapper to use during draw.
  63375. * The effect needs to be ready before calling this api.
  63376. * This also sets the default full screen position attribute.
  63377. * @param effectWrapper Defines the effect to draw with
  63378. */
  63379. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63380. /**
  63381. * Draws a full screen quad.
  63382. */
  63383. draw(): void;
  63384. /**
  63385. * renders one or more effects to a specified texture
  63386. * @param effectWrappers list of effects to renderer
  63387. * @param outputTexture texture to draw to, if null it will render to the screen
  63388. */
  63389. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63390. /**
  63391. * Disposes of the effect renderer
  63392. */
  63393. dispose(): void;
  63394. }
  63395. /**
  63396. * Options to create an EffectWrapper
  63397. */
  63398. interface EffectWrapperCreationOptions {
  63399. /**
  63400. * Engine to use to create the effect
  63401. */
  63402. engine: ThinEngine;
  63403. /**
  63404. * Fragment shader for the effect
  63405. */
  63406. fragmentShader: string;
  63407. /**
  63408. * Vertex shader for the effect
  63409. */
  63410. vertexShader?: string;
  63411. /**
  63412. * Attributes to use in the shader
  63413. */
  63414. attributeNames?: Array<string>;
  63415. /**
  63416. * Uniforms to use in the shader
  63417. */
  63418. uniformNames?: Array<string>;
  63419. /**
  63420. * Texture sampler names to use in the shader
  63421. */
  63422. samplerNames?: Array<string>;
  63423. /**
  63424. * The friendly name of the effect displayed in Spector.
  63425. */
  63426. name?: string;
  63427. }
  63428. /**
  63429. * Wraps an effect to be used for rendering
  63430. */
  63431. export class EffectWrapper {
  63432. /**
  63433. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63434. */
  63435. onApplyObservable: Observable<{}>;
  63436. /**
  63437. * The underlying effect
  63438. */
  63439. effect: Effect;
  63440. /**
  63441. * Creates an effect to be renderer
  63442. * @param creationOptions options to create the effect
  63443. */
  63444. constructor(creationOptions: EffectWrapperCreationOptions);
  63445. /**
  63446. * Disposes of the effect wrapper
  63447. */
  63448. dispose(): void;
  63449. }
  63450. }
  63451. declare module "babylonjs/Materials/index" {
  63452. export * from "babylonjs/Materials/Background/index";
  63453. export * from "babylonjs/Materials/colorCurves";
  63454. export * from "babylonjs/Materials/iEffectFallbacks";
  63455. export * from "babylonjs/Materials/effectFallbacks";
  63456. export * from "babylonjs/Materials/effect";
  63457. export * from "babylonjs/Materials/fresnelParameters";
  63458. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63459. export * from "babylonjs/Materials/material";
  63460. export * from "babylonjs/Materials/materialDefines";
  63461. export * from "babylonjs/Materials/materialHelper";
  63462. export * from "babylonjs/Materials/multiMaterial";
  63463. export * from "babylonjs/Materials/PBR/index";
  63464. export * from "babylonjs/Materials/pushMaterial";
  63465. export * from "babylonjs/Materials/shaderMaterial";
  63466. export * from "babylonjs/Materials/standardMaterial";
  63467. export * from "babylonjs/Materials/Textures/index";
  63468. export * from "babylonjs/Materials/uniformBuffer";
  63469. export * from "babylonjs/Materials/materialFlags";
  63470. export * from "babylonjs/Materials/Node/index";
  63471. export * from "babylonjs/Materials/effectRenderer";
  63472. }
  63473. declare module "babylonjs/Maths/index" {
  63474. export * from "babylonjs/Maths/math.scalar";
  63475. export * from "babylonjs/Maths/math";
  63476. export * from "babylonjs/Maths/sphericalPolynomial";
  63477. }
  63478. declare module "babylonjs/Misc/workerPool" {
  63479. import { IDisposable } from "babylonjs/scene";
  63480. /**
  63481. * Helper class to push actions to a pool of workers.
  63482. */
  63483. export class WorkerPool implements IDisposable {
  63484. private _workerInfos;
  63485. private _pendingActions;
  63486. /**
  63487. * Constructor
  63488. * @param workers Array of workers to use for actions
  63489. */
  63490. constructor(workers: Array<Worker>);
  63491. /**
  63492. * Terminates all workers and clears any pending actions.
  63493. */
  63494. dispose(): void;
  63495. /**
  63496. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63497. * pended until a worker has completed its action.
  63498. * @param action The action to perform. Call onComplete when the action is complete.
  63499. */
  63500. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63501. private _execute;
  63502. }
  63503. }
  63504. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63505. import { IDisposable } from "babylonjs/scene";
  63506. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63507. /**
  63508. * Configuration for Draco compression
  63509. */
  63510. export interface IDracoCompressionConfiguration {
  63511. /**
  63512. * Configuration for the decoder.
  63513. */
  63514. decoder: {
  63515. /**
  63516. * The url to the WebAssembly module.
  63517. */
  63518. wasmUrl?: string;
  63519. /**
  63520. * The url to the WebAssembly binary.
  63521. */
  63522. wasmBinaryUrl?: string;
  63523. /**
  63524. * The url to the fallback JavaScript module.
  63525. */
  63526. fallbackUrl?: string;
  63527. };
  63528. }
  63529. /**
  63530. * Draco compression (https://google.github.io/draco/)
  63531. *
  63532. * This class wraps the Draco module.
  63533. *
  63534. * **Encoder**
  63535. *
  63536. * The encoder is not currently implemented.
  63537. *
  63538. * **Decoder**
  63539. *
  63540. * 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.
  63541. *
  63542. * To update the configuration, use the following code:
  63543. * ```javascript
  63544. * DracoCompression.Configuration = {
  63545. * decoder: {
  63546. * wasmUrl: "<url to the WebAssembly library>",
  63547. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63548. * fallbackUrl: "<url to the fallback JavaScript library>",
  63549. * }
  63550. * };
  63551. * ```
  63552. *
  63553. * 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.
  63554. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63555. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63556. *
  63557. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63558. * ```javascript
  63559. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63560. * ```
  63561. *
  63562. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63563. */
  63564. export class DracoCompression implements IDisposable {
  63565. private _workerPoolPromise?;
  63566. private _decoderModulePromise?;
  63567. /**
  63568. * The configuration. Defaults to the following urls:
  63569. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63570. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63571. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63572. */
  63573. static Configuration: IDracoCompressionConfiguration;
  63574. /**
  63575. * Returns true if the decoder configuration is available.
  63576. */
  63577. static get DecoderAvailable(): boolean;
  63578. /**
  63579. * Default number of workers to create when creating the draco compression object.
  63580. */
  63581. static DefaultNumWorkers: number;
  63582. private static GetDefaultNumWorkers;
  63583. private static _Default;
  63584. /**
  63585. * Default instance for the draco compression object.
  63586. */
  63587. static get Default(): DracoCompression;
  63588. /**
  63589. * Constructor
  63590. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63591. */
  63592. constructor(numWorkers?: number);
  63593. /**
  63594. * Stop all async operations and release resources.
  63595. */
  63596. dispose(): void;
  63597. /**
  63598. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63599. * @returns a promise that resolves when ready
  63600. */
  63601. whenReadyAsync(): Promise<void>;
  63602. /**
  63603. * Decode Draco compressed mesh data to vertex data.
  63604. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63605. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63606. * @returns A promise that resolves with the decoded vertex data
  63607. */
  63608. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63609. [kind: string]: number;
  63610. }): Promise<VertexData>;
  63611. }
  63612. }
  63613. declare module "babylonjs/Meshes/Compression/index" {
  63614. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63615. }
  63616. declare module "babylonjs/Meshes/csg" {
  63617. import { Nullable } from "babylonjs/types";
  63618. import { Scene } from "babylonjs/scene";
  63619. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63620. import { Mesh } from "babylonjs/Meshes/mesh";
  63621. import { Material } from "babylonjs/Materials/material";
  63622. /**
  63623. * Class for building Constructive Solid Geometry
  63624. */
  63625. export class CSG {
  63626. private polygons;
  63627. /**
  63628. * The world matrix
  63629. */
  63630. matrix: Matrix;
  63631. /**
  63632. * Stores the position
  63633. */
  63634. position: Vector3;
  63635. /**
  63636. * Stores the rotation
  63637. */
  63638. rotation: Vector3;
  63639. /**
  63640. * Stores the rotation quaternion
  63641. */
  63642. rotationQuaternion: Nullable<Quaternion>;
  63643. /**
  63644. * Stores the scaling vector
  63645. */
  63646. scaling: Vector3;
  63647. /**
  63648. * Convert the Mesh to CSG
  63649. * @param mesh The Mesh to convert to CSG
  63650. * @returns A new CSG from the Mesh
  63651. */
  63652. static FromMesh(mesh: Mesh): CSG;
  63653. /**
  63654. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63655. * @param polygons Polygons used to construct a CSG solid
  63656. */
  63657. private static FromPolygons;
  63658. /**
  63659. * Clones, or makes a deep copy, of the CSG
  63660. * @returns A new CSG
  63661. */
  63662. clone(): CSG;
  63663. /**
  63664. * Unions this CSG with another CSG
  63665. * @param csg The CSG to union against this CSG
  63666. * @returns The unioned CSG
  63667. */
  63668. union(csg: CSG): CSG;
  63669. /**
  63670. * Unions this CSG with another CSG in place
  63671. * @param csg The CSG to union against this CSG
  63672. */
  63673. unionInPlace(csg: CSG): void;
  63674. /**
  63675. * Subtracts this CSG with another CSG
  63676. * @param csg The CSG to subtract against this CSG
  63677. * @returns A new CSG
  63678. */
  63679. subtract(csg: CSG): CSG;
  63680. /**
  63681. * Subtracts this CSG with another CSG in place
  63682. * @param csg The CSG to subtact against this CSG
  63683. */
  63684. subtractInPlace(csg: CSG): void;
  63685. /**
  63686. * Intersect this CSG with another CSG
  63687. * @param csg The CSG to intersect against this CSG
  63688. * @returns A new CSG
  63689. */
  63690. intersect(csg: CSG): CSG;
  63691. /**
  63692. * Intersects this CSG with another CSG in place
  63693. * @param csg The CSG to intersect against this CSG
  63694. */
  63695. intersectInPlace(csg: CSG): void;
  63696. /**
  63697. * Return a new CSG solid with solid and empty space switched. This solid is
  63698. * not modified.
  63699. * @returns A new CSG solid with solid and empty space switched
  63700. */
  63701. inverse(): CSG;
  63702. /**
  63703. * Inverses the CSG in place
  63704. */
  63705. inverseInPlace(): void;
  63706. /**
  63707. * This is used to keep meshes transformations so they can be restored
  63708. * when we build back a Babylon Mesh
  63709. * NB : All CSG operations are performed in world coordinates
  63710. * @param csg The CSG to copy the transform attributes from
  63711. * @returns This CSG
  63712. */
  63713. copyTransformAttributes(csg: CSG): CSG;
  63714. /**
  63715. * Build Raw mesh from CSG
  63716. * Coordinates here are in world space
  63717. * @param name The name of the mesh geometry
  63718. * @param scene The Scene
  63719. * @param keepSubMeshes Specifies if the submeshes should be kept
  63720. * @returns A new Mesh
  63721. */
  63722. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63723. /**
  63724. * Build Mesh from CSG taking material and transforms into account
  63725. * @param name The name of the Mesh
  63726. * @param material The material of the Mesh
  63727. * @param scene The Scene
  63728. * @param keepSubMeshes Specifies if submeshes should be kept
  63729. * @returns The new Mesh
  63730. */
  63731. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63732. }
  63733. }
  63734. declare module "babylonjs/Meshes/trailMesh" {
  63735. import { Mesh } from "babylonjs/Meshes/mesh";
  63736. import { Scene } from "babylonjs/scene";
  63737. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63738. /**
  63739. * Class used to create a trail following a mesh
  63740. */
  63741. export class TrailMesh extends Mesh {
  63742. private _generator;
  63743. private _autoStart;
  63744. private _running;
  63745. private _diameter;
  63746. private _length;
  63747. private _sectionPolygonPointsCount;
  63748. private _sectionVectors;
  63749. private _sectionNormalVectors;
  63750. private _beforeRenderObserver;
  63751. /**
  63752. * @constructor
  63753. * @param name The value used by scene.getMeshByName() to do a lookup.
  63754. * @param generator The mesh or transform node to generate a trail.
  63755. * @param scene The scene to add this mesh to.
  63756. * @param diameter Diameter of trailing mesh. Default is 1.
  63757. * @param length Length of trailing mesh. Default is 60.
  63758. * @param autoStart Automatically start trailing mesh. Default true.
  63759. */
  63760. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63761. /**
  63762. * "TrailMesh"
  63763. * @returns "TrailMesh"
  63764. */
  63765. getClassName(): string;
  63766. private _createMesh;
  63767. /**
  63768. * Start trailing mesh.
  63769. */
  63770. start(): void;
  63771. /**
  63772. * Stop trailing mesh.
  63773. */
  63774. stop(): void;
  63775. /**
  63776. * Update trailing mesh geometry.
  63777. */
  63778. update(): void;
  63779. /**
  63780. * Returns a new TrailMesh object.
  63781. * @param name is a string, the name given to the new mesh
  63782. * @param newGenerator use new generator object for cloned trail mesh
  63783. * @returns a new mesh
  63784. */
  63785. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63786. /**
  63787. * Serializes this trail mesh
  63788. * @param serializationObject object to write serialization to
  63789. */
  63790. serialize(serializationObject: any): void;
  63791. /**
  63792. * Parses a serialized trail mesh
  63793. * @param parsedMesh the serialized mesh
  63794. * @param scene the scene to create the trail mesh in
  63795. * @returns the created trail mesh
  63796. */
  63797. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63798. }
  63799. }
  63800. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63801. import { Nullable } from "babylonjs/types";
  63802. import { Scene } from "babylonjs/scene";
  63803. import { Vector4 } from "babylonjs/Maths/math.vector";
  63804. import { Color4 } from "babylonjs/Maths/math.color";
  63805. import { Mesh } from "babylonjs/Meshes/mesh";
  63806. /**
  63807. * Class containing static functions to help procedurally build meshes
  63808. */
  63809. export class TiledBoxBuilder {
  63810. /**
  63811. * Creates a box mesh
  63812. * 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)
  63813. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63817. * @param name defines the name of the mesh
  63818. * @param options defines the options used to create the mesh
  63819. * @param scene defines the hosting scene
  63820. * @returns the box mesh
  63821. */
  63822. static CreateTiledBox(name: string, options: {
  63823. pattern?: number;
  63824. width?: number;
  63825. height?: number;
  63826. depth?: number;
  63827. tileSize?: number;
  63828. tileWidth?: number;
  63829. tileHeight?: number;
  63830. alignHorizontal?: number;
  63831. alignVertical?: number;
  63832. faceUV?: Vector4[];
  63833. faceColors?: Color4[];
  63834. sideOrientation?: number;
  63835. updatable?: boolean;
  63836. }, scene?: Nullable<Scene>): Mesh;
  63837. }
  63838. }
  63839. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63840. import { Vector4 } from "babylonjs/Maths/math.vector";
  63841. import { Mesh } from "babylonjs/Meshes/mesh";
  63842. /**
  63843. * Class containing static functions to help procedurally build meshes
  63844. */
  63845. export class TorusKnotBuilder {
  63846. /**
  63847. * Creates a torus knot mesh
  63848. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63849. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63850. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63851. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63855. * @param name defines the name of the mesh
  63856. * @param options defines the options used to create the mesh
  63857. * @param scene defines the hosting scene
  63858. * @returns the torus knot mesh
  63859. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63860. */
  63861. static CreateTorusKnot(name: string, options: {
  63862. radius?: number;
  63863. tube?: number;
  63864. radialSegments?: number;
  63865. tubularSegments?: number;
  63866. p?: number;
  63867. q?: number;
  63868. updatable?: boolean;
  63869. sideOrientation?: number;
  63870. frontUVs?: Vector4;
  63871. backUVs?: Vector4;
  63872. }, scene: any): Mesh;
  63873. }
  63874. }
  63875. declare module "babylonjs/Meshes/polygonMesh" {
  63876. import { Scene } from "babylonjs/scene";
  63877. import { Vector2 } from "babylonjs/Maths/math.vector";
  63878. import { Mesh } from "babylonjs/Meshes/mesh";
  63879. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63880. import { Path2 } from "babylonjs/Maths/math.path";
  63881. /**
  63882. * Polygon
  63883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63884. */
  63885. export class Polygon {
  63886. /**
  63887. * Creates a rectangle
  63888. * @param xmin bottom X coord
  63889. * @param ymin bottom Y coord
  63890. * @param xmax top X coord
  63891. * @param ymax top Y coord
  63892. * @returns points that make the resulting rectation
  63893. */
  63894. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63895. /**
  63896. * Creates a circle
  63897. * @param radius radius of circle
  63898. * @param cx scale in x
  63899. * @param cy scale in y
  63900. * @param numberOfSides number of sides that make up the circle
  63901. * @returns points that make the resulting circle
  63902. */
  63903. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63904. /**
  63905. * Creates a polygon from input string
  63906. * @param input Input polygon data
  63907. * @returns the parsed points
  63908. */
  63909. static Parse(input: string): Vector2[];
  63910. /**
  63911. * Starts building a polygon from x and y coordinates
  63912. * @param x x coordinate
  63913. * @param y y coordinate
  63914. * @returns the started path2
  63915. */
  63916. static StartingAt(x: number, y: number): Path2;
  63917. }
  63918. /**
  63919. * Builds a polygon
  63920. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63921. */
  63922. export class PolygonMeshBuilder {
  63923. private _points;
  63924. private _outlinepoints;
  63925. private _holes;
  63926. private _name;
  63927. private _scene;
  63928. private _epoints;
  63929. private _eholes;
  63930. private _addToepoint;
  63931. /**
  63932. * Babylon reference to the earcut plugin.
  63933. */
  63934. bjsEarcut: any;
  63935. /**
  63936. * Creates a PolygonMeshBuilder
  63937. * @param name name of the builder
  63938. * @param contours Path of the polygon
  63939. * @param scene scene to add to when creating the mesh
  63940. * @param earcutInjection can be used to inject your own earcut reference
  63941. */
  63942. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63943. /**
  63944. * Adds a whole within the polygon
  63945. * @param hole Array of points defining the hole
  63946. * @returns this
  63947. */
  63948. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63949. /**
  63950. * Creates the polygon
  63951. * @param updatable If the mesh should be updatable
  63952. * @param depth The depth of the mesh created
  63953. * @returns the created mesh
  63954. */
  63955. build(updatable?: boolean, depth?: number): Mesh;
  63956. /**
  63957. * Creates the polygon
  63958. * @param depth The depth of the mesh created
  63959. * @returns the created VertexData
  63960. */
  63961. buildVertexData(depth?: number): VertexData;
  63962. /**
  63963. * Adds a side to the polygon
  63964. * @param positions points that make the polygon
  63965. * @param normals normals of the polygon
  63966. * @param uvs uvs of the polygon
  63967. * @param indices indices of the polygon
  63968. * @param bounds bounds of the polygon
  63969. * @param points points of the polygon
  63970. * @param depth depth of the polygon
  63971. * @param flip flip of the polygon
  63972. */
  63973. private addSide;
  63974. }
  63975. }
  63976. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63977. import { Scene } from "babylonjs/scene";
  63978. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63979. import { Color4 } from "babylonjs/Maths/math.color";
  63980. import { Mesh } from "babylonjs/Meshes/mesh";
  63981. import { Nullable } from "babylonjs/types";
  63982. /**
  63983. * Class containing static functions to help procedurally build meshes
  63984. */
  63985. export class PolygonBuilder {
  63986. /**
  63987. * Creates a polygon mesh
  63988. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63989. * * 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
  63990. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63993. * * Remember you can only change the shape positions, not their number when updating a polygon
  63994. * @param name defines the name of the mesh
  63995. * @param options defines the options used to create the mesh
  63996. * @param scene defines the hosting scene
  63997. * @param earcutInjection can be used to inject your own earcut reference
  63998. * @returns the polygon mesh
  63999. */
  64000. static CreatePolygon(name: string, options: {
  64001. shape: Vector3[];
  64002. holes?: Vector3[][];
  64003. depth?: number;
  64004. faceUV?: Vector4[];
  64005. faceColors?: Color4[];
  64006. updatable?: boolean;
  64007. sideOrientation?: number;
  64008. frontUVs?: Vector4;
  64009. backUVs?: Vector4;
  64010. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64011. /**
  64012. * Creates an extruded polygon mesh, with depth in the Y direction.
  64013. * * 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)
  64014. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64015. * @param name defines the name of the mesh
  64016. * @param options defines the options used to create the mesh
  64017. * @param scene defines the hosting scene
  64018. * @param earcutInjection can be used to inject your own earcut reference
  64019. * @returns the polygon mesh
  64020. */
  64021. static ExtrudePolygon(name: string, options: {
  64022. shape: Vector3[];
  64023. holes?: Vector3[][];
  64024. depth?: number;
  64025. faceUV?: Vector4[];
  64026. faceColors?: Color4[];
  64027. updatable?: boolean;
  64028. sideOrientation?: number;
  64029. frontUVs?: Vector4;
  64030. backUVs?: Vector4;
  64031. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64032. }
  64033. }
  64034. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64035. import { Scene } from "babylonjs/scene";
  64036. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64037. import { Mesh } from "babylonjs/Meshes/mesh";
  64038. import { Nullable } from "babylonjs/types";
  64039. /**
  64040. * Class containing static functions to help procedurally build meshes
  64041. */
  64042. export class LatheBuilder {
  64043. /**
  64044. * Creates lathe mesh.
  64045. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64046. * * 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
  64047. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64048. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64049. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64050. * * 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
  64051. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64052. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64057. * @param name defines the name of the mesh
  64058. * @param options defines the options used to create the mesh
  64059. * @param scene defines the hosting scene
  64060. * @returns the lathe mesh
  64061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64062. */
  64063. static CreateLathe(name: string, options: {
  64064. shape: Vector3[];
  64065. radius?: number;
  64066. tessellation?: number;
  64067. clip?: number;
  64068. arc?: number;
  64069. closed?: boolean;
  64070. updatable?: boolean;
  64071. sideOrientation?: number;
  64072. frontUVs?: Vector4;
  64073. backUVs?: Vector4;
  64074. cap?: number;
  64075. invertUV?: boolean;
  64076. }, scene?: Nullable<Scene>): Mesh;
  64077. }
  64078. }
  64079. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64080. import { Nullable } from "babylonjs/types";
  64081. import { Scene } from "babylonjs/scene";
  64082. import { Vector4 } from "babylonjs/Maths/math.vector";
  64083. import { Mesh } from "babylonjs/Meshes/mesh";
  64084. /**
  64085. * Class containing static functions to help procedurally build meshes
  64086. */
  64087. export class TiledPlaneBuilder {
  64088. /**
  64089. * Creates a tiled plane mesh
  64090. * * The parameter `pattern` will, depending on value, do nothing or
  64091. * * * flip (reflect about central vertical) alternate tiles across and up
  64092. * * * flip every tile on alternate rows
  64093. * * * rotate (180 degs) alternate tiles across and up
  64094. * * * rotate every tile on alternate rows
  64095. * * * flip and rotate alternate tiles across and up
  64096. * * * flip and rotate every tile on alternate rows
  64097. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64098. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64101. * * 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)
  64102. * * 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)
  64103. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64104. * @param name defines the name of the mesh
  64105. * @param options defines the options used to create the mesh
  64106. * @param scene defines the hosting scene
  64107. * @returns the box mesh
  64108. */
  64109. static CreateTiledPlane(name: string, options: {
  64110. pattern?: number;
  64111. tileSize?: number;
  64112. tileWidth?: number;
  64113. tileHeight?: number;
  64114. size?: number;
  64115. width?: number;
  64116. height?: number;
  64117. alignHorizontal?: number;
  64118. alignVertical?: number;
  64119. sideOrientation?: number;
  64120. frontUVs?: Vector4;
  64121. backUVs?: Vector4;
  64122. updatable?: boolean;
  64123. }, scene?: Nullable<Scene>): Mesh;
  64124. }
  64125. }
  64126. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64127. import { Nullable } from "babylonjs/types";
  64128. import { Scene } from "babylonjs/scene";
  64129. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64130. import { Mesh } from "babylonjs/Meshes/mesh";
  64131. /**
  64132. * Class containing static functions to help procedurally build meshes
  64133. */
  64134. export class TubeBuilder {
  64135. /**
  64136. * Creates a tube mesh.
  64137. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64138. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64139. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64140. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64141. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64142. * * 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)
  64143. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64144. * * 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
  64145. * * 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
  64146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64150. * @param name defines the name of the mesh
  64151. * @param options defines the options used to create the mesh
  64152. * @param scene defines the hosting scene
  64153. * @returns the tube mesh
  64154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64155. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64156. */
  64157. static CreateTube(name: string, options: {
  64158. path: Vector3[];
  64159. radius?: number;
  64160. tessellation?: number;
  64161. radiusFunction?: {
  64162. (i: number, distance: number): number;
  64163. };
  64164. cap?: number;
  64165. arc?: number;
  64166. updatable?: boolean;
  64167. sideOrientation?: number;
  64168. frontUVs?: Vector4;
  64169. backUVs?: Vector4;
  64170. instance?: Mesh;
  64171. invertUV?: boolean;
  64172. }, scene?: Nullable<Scene>): Mesh;
  64173. }
  64174. }
  64175. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64176. import { Scene } from "babylonjs/scene";
  64177. import { Vector4 } from "babylonjs/Maths/math.vector";
  64178. import { Mesh } from "babylonjs/Meshes/mesh";
  64179. import { Nullable } from "babylonjs/types";
  64180. /**
  64181. * Class containing static functions to help procedurally build meshes
  64182. */
  64183. export class IcoSphereBuilder {
  64184. /**
  64185. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64186. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64187. * * 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`)
  64188. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64189. * * 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
  64190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64193. * @param name defines the name of the mesh
  64194. * @param options defines the options used to create the mesh
  64195. * @param scene defines the hosting scene
  64196. * @returns the icosahedron mesh
  64197. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64198. */
  64199. static CreateIcoSphere(name: string, options: {
  64200. radius?: number;
  64201. radiusX?: number;
  64202. radiusY?: number;
  64203. radiusZ?: number;
  64204. flat?: boolean;
  64205. subdivisions?: number;
  64206. sideOrientation?: number;
  64207. frontUVs?: Vector4;
  64208. backUVs?: Vector4;
  64209. updatable?: boolean;
  64210. }, scene?: Nullable<Scene>): Mesh;
  64211. }
  64212. }
  64213. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64214. import { Vector3 } from "babylonjs/Maths/math.vector";
  64215. import { Mesh } from "babylonjs/Meshes/mesh";
  64216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64217. /**
  64218. * Class containing static functions to help procedurally build meshes
  64219. */
  64220. export class DecalBuilder {
  64221. /**
  64222. * Creates a decal mesh.
  64223. * 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
  64224. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64225. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64226. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64227. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64228. * @param name defines the name of the mesh
  64229. * @param sourceMesh defines the mesh where the decal must be applied
  64230. * @param options defines the options used to create the mesh
  64231. * @param scene defines the hosting scene
  64232. * @returns the decal mesh
  64233. * @see https://doc.babylonjs.com/how_to/decals
  64234. */
  64235. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64236. position?: Vector3;
  64237. normal?: Vector3;
  64238. size?: Vector3;
  64239. angle?: number;
  64240. }): Mesh;
  64241. }
  64242. }
  64243. declare module "babylonjs/Meshes/meshBuilder" {
  64244. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64245. import { Nullable } from "babylonjs/types";
  64246. import { Scene } from "babylonjs/scene";
  64247. import { Mesh } from "babylonjs/Meshes/mesh";
  64248. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64249. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64251. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64252. import { Plane } from "babylonjs/Maths/math.plane";
  64253. /**
  64254. * Class containing static functions to help procedurally build meshes
  64255. */
  64256. export class MeshBuilder {
  64257. /**
  64258. * Creates a box mesh
  64259. * * The parameter `size` sets the size (float) of each box side (default 1)
  64260. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64261. * * 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)
  64262. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64266. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64267. * @param name defines the name of the mesh
  64268. * @param options defines the options used to create the mesh
  64269. * @param scene defines the hosting scene
  64270. * @returns the box mesh
  64271. */
  64272. static CreateBox(name: string, options: {
  64273. size?: number;
  64274. width?: number;
  64275. height?: number;
  64276. depth?: number;
  64277. faceUV?: Vector4[];
  64278. faceColors?: Color4[];
  64279. sideOrientation?: number;
  64280. frontUVs?: Vector4;
  64281. backUVs?: Vector4;
  64282. wrap?: boolean;
  64283. topBaseAt?: number;
  64284. bottomBaseAt?: number;
  64285. updatable?: boolean;
  64286. }, scene?: Nullable<Scene>): Mesh;
  64287. /**
  64288. * Creates a tiled box mesh
  64289. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64291. * @param name defines the name of the mesh
  64292. * @param options defines the options used to create the mesh
  64293. * @param scene defines the hosting scene
  64294. * @returns the tiled box mesh
  64295. */
  64296. static CreateTiledBox(name: string, options: {
  64297. pattern?: number;
  64298. size?: number;
  64299. width?: number;
  64300. height?: number;
  64301. depth: number;
  64302. tileSize?: number;
  64303. tileWidth?: number;
  64304. tileHeight?: number;
  64305. faceUV?: Vector4[];
  64306. faceColors?: Color4[];
  64307. alignHorizontal?: number;
  64308. alignVertical?: number;
  64309. sideOrientation?: number;
  64310. updatable?: boolean;
  64311. }, scene?: Nullable<Scene>): Mesh;
  64312. /**
  64313. * Creates a sphere mesh
  64314. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64315. * * 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`)
  64316. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64317. * * 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
  64318. * * 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)
  64319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64322. * @param name defines the name of the mesh
  64323. * @param options defines the options used to create the mesh
  64324. * @param scene defines the hosting scene
  64325. * @returns the sphere mesh
  64326. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64327. */
  64328. static CreateSphere(name: string, options: {
  64329. segments?: number;
  64330. diameter?: number;
  64331. diameterX?: number;
  64332. diameterY?: number;
  64333. diameterZ?: number;
  64334. arc?: number;
  64335. slice?: number;
  64336. sideOrientation?: number;
  64337. frontUVs?: Vector4;
  64338. backUVs?: Vector4;
  64339. updatable?: boolean;
  64340. }, scene?: Nullable<Scene>): Mesh;
  64341. /**
  64342. * Creates a plane polygonal mesh. By default, this is a disc
  64343. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64344. * * 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
  64345. * * 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
  64346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64349. * @param name defines the name of the mesh
  64350. * @param options defines the options used to create the mesh
  64351. * @param scene defines the hosting scene
  64352. * @returns the plane polygonal mesh
  64353. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64354. */
  64355. static CreateDisc(name: string, options: {
  64356. radius?: number;
  64357. tessellation?: number;
  64358. arc?: number;
  64359. updatable?: boolean;
  64360. sideOrientation?: number;
  64361. frontUVs?: Vector4;
  64362. backUVs?: Vector4;
  64363. }, scene?: Nullable<Scene>): Mesh;
  64364. /**
  64365. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64366. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64367. * * 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`)
  64368. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64369. * * 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
  64370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64373. * @param name defines the name of the mesh
  64374. * @param options defines the options used to create the mesh
  64375. * @param scene defines the hosting scene
  64376. * @returns the icosahedron mesh
  64377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64378. */
  64379. static CreateIcoSphere(name: string, options: {
  64380. radius?: number;
  64381. radiusX?: number;
  64382. radiusY?: number;
  64383. radiusZ?: number;
  64384. flat?: boolean;
  64385. subdivisions?: number;
  64386. sideOrientation?: number;
  64387. frontUVs?: Vector4;
  64388. backUVs?: Vector4;
  64389. updatable?: boolean;
  64390. }, scene?: Nullable<Scene>): Mesh;
  64391. /**
  64392. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64393. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64394. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64395. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64396. * * 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
  64397. * * 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
  64398. * * 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
  64399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64402. * * 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
  64403. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64404. * * 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
  64405. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64407. * @param name defines the name of the mesh
  64408. * @param options defines the options used to create the mesh
  64409. * @param scene defines the hosting scene
  64410. * @returns the ribbon mesh
  64411. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64413. */
  64414. static CreateRibbon(name: string, options: {
  64415. pathArray: Vector3[][];
  64416. closeArray?: boolean;
  64417. closePath?: boolean;
  64418. offset?: number;
  64419. updatable?: boolean;
  64420. sideOrientation?: number;
  64421. frontUVs?: Vector4;
  64422. backUVs?: Vector4;
  64423. instance?: Mesh;
  64424. invertUV?: boolean;
  64425. uvs?: Vector2[];
  64426. colors?: Color4[];
  64427. }, scene?: Nullable<Scene>): Mesh;
  64428. /**
  64429. * Creates a cylinder or a cone mesh
  64430. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64431. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64432. * * 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.
  64433. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64434. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64435. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64436. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64437. * * 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).
  64438. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64439. * * 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).
  64440. * * 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
  64441. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64442. * * 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
  64443. * * 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.
  64444. * * If `enclose` is false, a ring surface is one element.
  64445. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64446. * * 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
  64447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64450. * @param name defines the name of the mesh
  64451. * @param options defines the options used to create the mesh
  64452. * @param scene defines the hosting scene
  64453. * @returns the cylinder mesh
  64454. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64455. */
  64456. static CreateCylinder(name: string, options: {
  64457. height?: number;
  64458. diameterTop?: number;
  64459. diameterBottom?: number;
  64460. diameter?: number;
  64461. tessellation?: number;
  64462. subdivisions?: number;
  64463. arc?: number;
  64464. faceColors?: Color4[];
  64465. faceUV?: Vector4[];
  64466. updatable?: boolean;
  64467. hasRings?: boolean;
  64468. enclose?: boolean;
  64469. cap?: number;
  64470. sideOrientation?: number;
  64471. frontUVs?: Vector4;
  64472. backUVs?: Vector4;
  64473. }, scene?: Nullable<Scene>): Mesh;
  64474. /**
  64475. * Creates a torus mesh
  64476. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64477. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64478. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64482. * @param name defines the name of the mesh
  64483. * @param options defines the options used to create the mesh
  64484. * @param scene defines the hosting scene
  64485. * @returns the torus mesh
  64486. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64487. */
  64488. static CreateTorus(name: string, options: {
  64489. diameter?: number;
  64490. thickness?: number;
  64491. tessellation?: number;
  64492. updatable?: boolean;
  64493. sideOrientation?: number;
  64494. frontUVs?: Vector4;
  64495. backUVs?: Vector4;
  64496. }, scene?: Nullable<Scene>): Mesh;
  64497. /**
  64498. * Creates a torus knot mesh
  64499. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64500. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64501. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64502. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64506. * @param name defines the name of the mesh
  64507. * @param options defines the options used to create the mesh
  64508. * @param scene defines the hosting scene
  64509. * @returns the torus knot mesh
  64510. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64511. */
  64512. static CreateTorusKnot(name: string, options: {
  64513. radius?: number;
  64514. tube?: number;
  64515. radialSegments?: number;
  64516. tubularSegments?: number;
  64517. p?: number;
  64518. q?: number;
  64519. updatable?: boolean;
  64520. sideOrientation?: number;
  64521. frontUVs?: Vector4;
  64522. backUVs?: Vector4;
  64523. }, scene?: Nullable<Scene>): Mesh;
  64524. /**
  64525. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64526. * * 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
  64527. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64528. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64529. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64530. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64531. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64532. * * 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
  64533. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64536. * @param name defines the name of the new line system
  64537. * @param options defines the options used to create the line system
  64538. * @param scene defines the hosting scene
  64539. * @returns a new line system mesh
  64540. */
  64541. static CreateLineSystem(name: string, options: {
  64542. lines: Vector3[][];
  64543. updatable?: boolean;
  64544. instance?: Nullable<LinesMesh>;
  64545. colors?: Nullable<Color4[][]>;
  64546. useVertexAlpha?: boolean;
  64547. }, scene: Nullable<Scene>): LinesMesh;
  64548. /**
  64549. * Creates a line mesh
  64550. * 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
  64551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64552. * * The parameter `points` is an array successive Vector3
  64553. * * 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
  64554. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64555. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64556. * * When updating an instance, remember that only point positions can change, not the number of points
  64557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64559. * @param name defines the name of the new line system
  64560. * @param options defines the options used to create the line system
  64561. * @param scene defines the hosting scene
  64562. * @returns a new line mesh
  64563. */
  64564. static CreateLines(name: string, options: {
  64565. points: Vector3[];
  64566. updatable?: boolean;
  64567. instance?: Nullable<LinesMesh>;
  64568. colors?: Color4[];
  64569. useVertexAlpha?: boolean;
  64570. }, scene?: Nullable<Scene>): LinesMesh;
  64571. /**
  64572. * Creates a dashed line mesh
  64573. * * 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
  64574. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64575. * * The parameter `points` is an array successive Vector3
  64576. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64577. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64578. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64579. * * 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
  64580. * * When updating an instance, remember that only point positions can change, not the number of points
  64581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64582. * @param name defines the name of the mesh
  64583. * @param options defines the options used to create the mesh
  64584. * @param scene defines the hosting scene
  64585. * @returns the dashed line mesh
  64586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64587. */
  64588. static CreateDashedLines(name: string, options: {
  64589. points: Vector3[];
  64590. dashSize?: number;
  64591. gapSize?: number;
  64592. dashNb?: number;
  64593. updatable?: boolean;
  64594. instance?: LinesMesh;
  64595. }, scene?: Nullable<Scene>): LinesMesh;
  64596. /**
  64597. * 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.
  64598. * * 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.
  64599. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64600. * * 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.
  64601. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64602. * * 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
  64603. * * 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
  64604. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64609. * @param name defines the name of the mesh
  64610. * @param options defines the options used to create the mesh
  64611. * @param scene defines the hosting scene
  64612. * @returns the extruded shape mesh
  64613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64615. */
  64616. static ExtrudeShape(name: string, options: {
  64617. shape: Vector3[];
  64618. path: Vector3[];
  64619. scale?: number;
  64620. rotation?: number;
  64621. cap?: number;
  64622. updatable?: boolean;
  64623. sideOrientation?: number;
  64624. frontUVs?: Vector4;
  64625. backUVs?: Vector4;
  64626. instance?: Mesh;
  64627. invertUV?: boolean;
  64628. }, scene?: Nullable<Scene>): Mesh;
  64629. /**
  64630. * Creates an custom extruded shape mesh.
  64631. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64632. * * 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.
  64633. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64634. * * 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
  64635. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64636. * * 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
  64637. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64638. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64639. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64640. * * 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
  64641. * * 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
  64642. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64645. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64647. * @param name defines the name of the mesh
  64648. * @param options defines the options used to create the mesh
  64649. * @param scene defines the hosting scene
  64650. * @returns the custom extruded shape mesh
  64651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64654. */
  64655. static ExtrudeShapeCustom(name: string, options: {
  64656. shape: Vector3[];
  64657. path: Vector3[];
  64658. scaleFunction?: any;
  64659. rotationFunction?: any;
  64660. ribbonCloseArray?: boolean;
  64661. ribbonClosePath?: boolean;
  64662. cap?: number;
  64663. updatable?: boolean;
  64664. sideOrientation?: number;
  64665. frontUVs?: Vector4;
  64666. backUVs?: Vector4;
  64667. instance?: Mesh;
  64668. invertUV?: boolean;
  64669. }, scene?: Nullable<Scene>): Mesh;
  64670. /**
  64671. * Creates lathe mesh.
  64672. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64673. * * 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
  64674. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64675. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64676. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64677. * * 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
  64678. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64679. * * 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
  64680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64684. * @param name defines the name of the mesh
  64685. * @param options defines the options used to create the mesh
  64686. * @param scene defines the hosting scene
  64687. * @returns the lathe mesh
  64688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64689. */
  64690. static CreateLathe(name: string, options: {
  64691. shape: Vector3[];
  64692. radius?: number;
  64693. tessellation?: number;
  64694. clip?: number;
  64695. arc?: number;
  64696. closed?: boolean;
  64697. updatable?: boolean;
  64698. sideOrientation?: number;
  64699. frontUVs?: Vector4;
  64700. backUVs?: Vector4;
  64701. cap?: number;
  64702. invertUV?: boolean;
  64703. }, scene?: Nullable<Scene>): Mesh;
  64704. /**
  64705. * Creates a tiled plane mesh
  64706. * * You can set a limited pattern arrangement with the tiles
  64707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64710. * @param name defines the name of the mesh
  64711. * @param options defines the options used to create the mesh
  64712. * @param scene defines the hosting scene
  64713. * @returns the plane mesh
  64714. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64715. */
  64716. static CreateTiledPlane(name: string, options: {
  64717. pattern?: number;
  64718. tileSize?: number;
  64719. tileWidth?: number;
  64720. tileHeight?: number;
  64721. size?: number;
  64722. width?: number;
  64723. height?: number;
  64724. alignHorizontal?: number;
  64725. alignVertical?: number;
  64726. sideOrientation?: number;
  64727. frontUVs?: Vector4;
  64728. backUVs?: Vector4;
  64729. updatable?: boolean;
  64730. }, scene?: Nullable<Scene>): Mesh;
  64731. /**
  64732. * Creates a plane mesh
  64733. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64734. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64735. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64739. * @param name defines the name of the mesh
  64740. * @param options defines the options used to create the mesh
  64741. * @param scene defines the hosting scene
  64742. * @returns the plane mesh
  64743. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64744. */
  64745. static CreatePlane(name: string, options: {
  64746. size?: number;
  64747. width?: number;
  64748. height?: number;
  64749. sideOrientation?: number;
  64750. frontUVs?: Vector4;
  64751. backUVs?: Vector4;
  64752. updatable?: boolean;
  64753. sourcePlane?: Plane;
  64754. }, scene?: Nullable<Scene>): Mesh;
  64755. /**
  64756. * Creates a ground mesh
  64757. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64758. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64760. * @param name defines the name of the mesh
  64761. * @param options defines the options used to create the mesh
  64762. * @param scene defines the hosting scene
  64763. * @returns the ground mesh
  64764. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64765. */
  64766. static CreateGround(name: string, options: {
  64767. width?: number;
  64768. height?: number;
  64769. subdivisions?: number;
  64770. subdivisionsX?: number;
  64771. subdivisionsY?: number;
  64772. updatable?: boolean;
  64773. }, scene?: Nullable<Scene>): Mesh;
  64774. /**
  64775. * Creates a tiled ground mesh
  64776. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64777. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64778. * * 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
  64779. * * 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
  64780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64781. * @param name defines the name of the mesh
  64782. * @param options defines the options used to create the mesh
  64783. * @param scene defines the hosting scene
  64784. * @returns the tiled ground mesh
  64785. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64786. */
  64787. static CreateTiledGround(name: string, options: {
  64788. xmin: number;
  64789. zmin: number;
  64790. xmax: number;
  64791. zmax: number;
  64792. subdivisions?: {
  64793. w: number;
  64794. h: number;
  64795. };
  64796. precision?: {
  64797. w: number;
  64798. h: number;
  64799. };
  64800. updatable?: boolean;
  64801. }, scene?: Nullable<Scene>): Mesh;
  64802. /**
  64803. * Creates a ground mesh from a height map
  64804. * * The parameter `url` sets the URL of the height map image resource.
  64805. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64806. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64807. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64808. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64809. * * 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.
  64810. * * 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).
  64811. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64813. * @param name defines the name of the mesh
  64814. * @param url defines the url to the height map
  64815. * @param options defines the options used to create the mesh
  64816. * @param scene defines the hosting scene
  64817. * @returns the ground mesh
  64818. * @see https://doc.babylonjs.com/babylon101/height_map
  64819. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64820. */
  64821. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64822. width?: number;
  64823. height?: number;
  64824. subdivisions?: number;
  64825. minHeight?: number;
  64826. maxHeight?: number;
  64827. colorFilter?: Color3;
  64828. alphaFilter?: number;
  64829. updatable?: boolean;
  64830. onReady?: (mesh: GroundMesh) => void;
  64831. }, scene?: Nullable<Scene>): GroundMesh;
  64832. /**
  64833. * Creates a polygon mesh
  64834. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64835. * * 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
  64836. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64839. * * Remember you can only change the shape positions, not their number when updating a polygon
  64840. * @param name defines the name of the mesh
  64841. * @param options defines the options used to create the mesh
  64842. * @param scene defines the hosting scene
  64843. * @param earcutInjection can be used to inject your own earcut reference
  64844. * @returns the polygon mesh
  64845. */
  64846. static CreatePolygon(name: string, options: {
  64847. shape: Vector3[];
  64848. holes?: Vector3[][];
  64849. depth?: number;
  64850. faceUV?: Vector4[];
  64851. faceColors?: Color4[];
  64852. updatable?: boolean;
  64853. sideOrientation?: number;
  64854. frontUVs?: Vector4;
  64855. backUVs?: Vector4;
  64856. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64857. /**
  64858. * Creates an extruded polygon mesh, with depth in the Y direction.
  64859. * * 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)
  64860. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64861. * @param name defines the name of the mesh
  64862. * @param options defines the options used to create the mesh
  64863. * @param scene defines the hosting scene
  64864. * @param earcutInjection can be used to inject your own earcut reference
  64865. * @returns the polygon mesh
  64866. */
  64867. static ExtrudePolygon(name: string, options: {
  64868. shape: Vector3[];
  64869. holes?: Vector3[][];
  64870. depth?: number;
  64871. faceUV?: Vector4[];
  64872. faceColors?: Color4[];
  64873. updatable?: boolean;
  64874. sideOrientation?: number;
  64875. frontUVs?: Vector4;
  64876. backUVs?: Vector4;
  64877. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64878. /**
  64879. * Creates a tube mesh.
  64880. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64881. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64882. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64883. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64884. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64885. * * 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)
  64886. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64887. * * 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
  64888. * * 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
  64889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64891. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64893. * @param name defines the name of the mesh
  64894. * @param options defines the options used to create the mesh
  64895. * @param scene defines the hosting scene
  64896. * @returns the tube mesh
  64897. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64898. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64899. */
  64900. static CreateTube(name: string, options: {
  64901. path: Vector3[];
  64902. radius?: number;
  64903. tessellation?: number;
  64904. radiusFunction?: {
  64905. (i: number, distance: number): number;
  64906. };
  64907. cap?: number;
  64908. arc?: number;
  64909. updatable?: boolean;
  64910. sideOrientation?: number;
  64911. frontUVs?: Vector4;
  64912. backUVs?: Vector4;
  64913. instance?: Mesh;
  64914. invertUV?: boolean;
  64915. }, scene?: Nullable<Scene>): Mesh;
  64916. /**
  64917. * Creates a polyhedron mesh
  64918. * * 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
  64919. * * The parameter `size` (positive float, default 1) sets the polygon size
  64920. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64921. * * 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`
  64922. * * 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
  64923. * * 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)`)
  64924. * * 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
  64925. * * 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
  64926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64929. * @param name defines the name of the mesh
  64930. * @param options defines the options used to create the mesh
  64931. * @param scene defines the hosting scene
  64932. * @returns the polyhedron mesh
  64933. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64934. */
  64935. static CreatePolyhedron(name: string, options: {
  64936. type?: number;
  64937. size?: number;
  64938. sizeX?: number;
  64939. sizeY?: number;
  64940. sizeZ?: number;
  64941. custom?: any;
  64942. faceUV?: Vector4[];
  64943. faceColors?: Color4[];
  64944. flat?: boolean;
  64945. updatable?: boolean;
  64946. sideOrientation?: number;
  64947. frontUVs?: Vector4;
  64948. backUVs?: Vector4;
  64949. }, scene?: Nullable<Scene>): Mesh;
  64950. /**
  64951. * Creates a decal mesh.
  64952. * 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
  64953. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64954. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64955. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64956. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64957. * @param name defines the name of the mesh
  64958. * @param sourceMesh defines the mesh where the decal must be applied
  64959. * @param options defines the options used to create the mesh
  64960. * @param scene defines the hosting scene
  64961. * @returns the decal mesh
  64962. * @see https://doc.babylonjs.com/how_to/decals
  64963. */
  64964. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64965. position?: Vector3;
  64966. normal?: Vector3;
  64967. size?: Vector3;
  64968. angle?: number;
  64969. }): Mesh;
  64970. }
  64971. }
  64972. declare module "babylonjs/Meshes/meshSimplification" {
  64973. import { Mesh } from "babylonjs/Meshes/mesh";
  64974. /**
  64975. * A simplifier interface for future simplification implementations
  64976. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64977. */
  64978. export interface ISimplifier {
  64979. /**
  64980. * Simplification of a given mesh according to the given settings.
  64981. * Since this requires computation, it is assumed that the function runs async.
  64982. * @param settings The settings of the simplification, including quality and distance
  64983. * @param successCallback A callback that will be called after the mesh was simplified.
  64984. * @param errorCallback in case of an error, this callback will be called. optional.
  64985. */
  64986. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64987. }
  64988. /**
  64989. * Expected simplification settings.
  64990. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64992. */
  64993. export interface ISimplificationSettings {
  64994. /**
  64995. * Gets or sets the expected quality
  64996. */
  64997. quality: number;
  64998. /**
  64999. * Gets or sets the distance when this optimized version should be used
  65000. */
  65001. distance: number;
  65002. /**
  65003. * Gets an already optimized mesh
  65004. */
  65005. optimizeMesh?: boolean;
  65006. }
  65007. /**
  65008. * Class used to specify simplification options
  65009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65010. */
  65011. export class SimplificationSettings implements ISimplificationSettings {
  65012. /** expected quality */
  65013. quality: number;
  65014. /** distance when this optimized version should be used */
  65015. distance: number;
  65016. /** already optimized mesh */
  65017. optimizeMesh?: boolean | undefined;
  65018. /**
  65019. * Creates a SimplificationSettings
  65020. * @param quality expected quality
  65021. * @param distance distance when this optimized version should be used
  65022. * @param optimizeMesh already optimized mesh
  65023. */
  65024. constructor(
  65025. /** expected quality */
  65026. quality: number,
  65027. /** distance when this optimized version should be used */
  65028. distance: number,
  65029. /** already optimized mesh */
  65030. optimizeMesh?: boolean | undefined);
  65031. }
  65032. /**
  65033. * Interface used to define a simplification task
  65034. */
  65035. export interface ISimplificationTask {
  65036. /**
  65037. * Array of settings
  65038. */
  65039. settings: Array<ISimplificationSettings>;
  65040. /**
  65041. * Simplification type
  65042. */
  65043. simplificationType: SimplificationType;
  65044. /**
  65045. * Mesh to simplify
  65046. */
  65047. mesh: Mesh;
  65048. /**
  65049. * Callback called on success
  65050. */
  65051. successCallback?: () => void;
  65052. /**
  65053. * Defines if parallel processing can be used
  65054. */
  65055. parallelProcessing: boolean;
  65056. }
  65057. /**
  65058. * Queue used to order the simplification tasks
  65059. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65060. */
  65061. export class SimplificationQueue {
  65062. private _simplificationArray;
  65063. /**
  65064. * Gets a boolean indicating that the process is still running
  65065. */
  65066. running: boolean;
  65067. /**
  65068. * Creates a new queue
  65069. */
  65070. constructor();
  65071. /**
  65072. * Adds a new simplification task
  65073. * @param task defines a task to add
  65074. */
  65075. addTask(task: ISimplificationTask): void;
  65076. /**
  65077. * Execute next task
  65078. */
  65079. executeNext(): void;
  65080. /**
  65081. * Execute a simplification task
  65082. * @param task defines the task to run
  65083. */
  65084. runSimplification(task: ISimplificationTask): void;
  65085. private getSimplifier;
  65086. }
  65087. /**
  65088. * The implemented types of simplification
  65089. * At the moment only Quadratic Error Decimation is implemented
  65090. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65091. */
  65092. export enum SimplificationType {
  65093. /** Quadratic error decimation */
  65094. QUADRATIC = 0
  65095. }
  65096. /**
  65097. * An implementation of the Quadratic Error simplification algorithm.
  65098. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65099. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65100. * @author RaananW
  65101. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65102. */
  65103. export class QuadraticErrorSimplification implements ISimplifier {
  65104. private _mesh;
  65105. private triangles;
  65106. private vertices;
  65107. private references;
  65108. private _reconstructedMesh;
  65109. /** Gets or sets the number pf sync interations */
  65110. syncIterations: number;
  65111. /** Gets or sets the aggressiveness of the simplifier */
  65112. aggressiveness: number;
  65113. /** Gets or sets the number of allowed iterations for decimation */
  65114. decimationIterations: number;
  65115. /** Gets or sets the espilon to use for bounding box computation */
  65116. boundingBoxEpsilon: number;
  65117. /**
  65118. * Creates a new QuadraticErrorSimplification
  65119. * @param _mesh defines the target mesh
  65120. */
  65121. constructor(_mesh: Mesh);
  65122. /**
  65123. * Simplification of a given mesh according to the given settings.
  65124. * Since this requires computation, it is assumed that the function runs async.
  65125. * @param settings The settings of the simplification, including quality and distance
  65126. * @param successCallback A callback that will be called after the mesh was simplified.
  65127. */
  65128. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65129. private runDecimation;
  65130. private initWithMesh;
  65131. private init;
  65132. private reconstructMesh;
  65133. private initDecimatedMesh;
  65134. private isFlipped;
  65135. private updateTriangles;
  65136. private identifyBorder;
  65137. private updateMesh;
  65138. private vertexError;
  65139. private calculateError;
  65140. }
  65141. }
  65142. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65143. import { Scene } from "babylonjs/scene";
  65144. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65145. import { ISceneComponent } from "babylonjs/sceneComponent";
  65146. module "babylonjs/scene" {
  65147. interface Scene {
  65148. /** @hidden (Backing field) */
  65149. _simplificationQueue: SimplificationQueue;
  65150. /**
  65151. * Gets or sets the simplification queue attached to the scene
  65152. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65153. */
  65154. simplificationQueue: SimplificationQueue;
  65155. }
  65156. }
  65157. module "babylonjs/Meshes/mesh" {
  65158. interface Mesh {
  65159. /**
  65160. * Simplify the mesh according to the given array of settings.
  65161. * Function will return immediately and will simplify async
  65162. * @param settings a collection of simplification settings
  65163. * @param parallelProcessing should all levels calculate parallel or one after the other
  65164. * @param simplificationType the type of simplification to run
  65165. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65166. * @returns the current mesh
  65167. */
  65168. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65169. }
  65170. }
  65171. /**
  65172. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65173. * created in a scene
  65174. */
  65175. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65176. /**
  65177. * The component name helpfull to identify the component in the list of scene components.
  65178. */
  65179. readonly name: string;
  65180. /**
  65181. * The scene the component belongs to.
  65182. */
  65183. scene: Scene;
  65184. /**
  65185. * Creates a new instance of the component for the given scene
  65186. * @param scene Defines the scene to register the component in
  65187. */
  65188. constructor(scene: Scene);
  65189. /**
  65190. * Registers the component in a given scene
  65191. */
  65192. register(): void;
  65193. /**
  65194. * Rebuilds the elements related to this component in case of
  65195. * context lost for instance.
  65196. */
  65197. rebuild(): void;
  65198. /**
  65199. * Disposes the component and the associated ressources
  65200. */
  65201. dispose(): void;
  65202. private _beforeCameraUpdate;
  65203. }
  65204. }
  65205. declare module "babylonjs/Meshes/Builders/index" {
  65206. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65207. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65208. export * from "babylonjs/Meshes/Builders/discBuilder";
  65209. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65210. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65211. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65212. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65213. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65214. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65215. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65216. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65217. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65218. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65219. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65220. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65221. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65222. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65223. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65224. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65225. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65226. }
  65227. declare module "babylonjs/Meshes/index" {
  65228. export * from "babylonjs/Meshes/abstractMesh";
  65229. export * from "babylonjs/Meshes/buffer";
  65230. export * from "babylonjs/Meshes/Compression/index";
  65231. export * from "babylonjs/Meshes/csg";
  65232. export * from "babylonjs/Meshes/geometry";
  65233. export * from "babylonjs/Meshes/groundMesh";
  65234. export * from "babylonjs/Meshes/trailMesh";
  65235. export * from "babylonjs/Meshes/instancedMesh";
  65236. export * from "babylonjs/Meshes/linesMesh";
  65237. export * from "babylonjs/Meshes/mesh";
  65238. export * from "babylonjs/Meshes/mesh.vertexData";
  65239. export * from "babylonjs/Meshes/meshBuilder";
  65240. export * from "babylonjs/Meshes/meshSimplification";
  65241. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65242. export * from "babylonjs/Meshes/polygonMesh";
  65243. export * from "babylonjs/Meshes/subMesh";
  65244. export * from "babylonjs/Meshes/meshLODLevel";
  65245. export * from "babylonjs/Meshes/transformNode";
  65246. export * from "babylonjs/Meshes/Builders/index";
  65247. export * from "babylonjs/Meshes/dataBuffer";
  65248. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65249. }
  65250. declare module "babylonjs/Morph/index" {
  65251. export * from "babylonjs/Morph/morphTarget";
  65252. export * from "babylonjs/Morph/morphTargetManager";
  65253. }
  65254. declare module "babylonjs/Navigation/INavigationEngine" {
  65255. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65256. import { Vector3 } from "babylonjs/Maths/math";
  65257. import { Mesh } from "babylonjs/Meshes/mesh";
  65258. import { Scene } from "babylonjs/scene";
  65259. /**
  65260. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65261. */
  65262. export interface INavigationEnginePlugin {
  65263. /**
  65264. * plugin name
  65265. */
  65266. name: string;
  65267. /**
  65268. * Creates a navigation mesh
  65269. * @param meshes array of all the geometry used to compute the navigatio mesh
  65270. * @param parameters bunch of parameters used to filter geometry
  65271. */
  65272. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65273. /**
  65274. * Create a navigation mesh debug mesh
  65275. * @param scene is where the mesh will be added
  65276. * @returns debug display mesh
  65277. */
  65278. createDebugNavMesh(scene: Scene): Mesh;
  65279. /**
  65280. * Get a navigation mesh constrained position, closest to the parameter position
  65281. * @param position world position
  65282. * @returns the closest point to position constrained by the navigation mesh
  65283. */
  65284. getClosestPoint(position: Vector3): Vector3;
  65285. /**
  65286. * Get a navigation mesh constrained position, closest to the parameter position
  65287. * @param position world position
  65288. * @param result output the closest point to position constrained by the navigation mesh
  65289. */
  65290. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65291. /**
  65292. * Get a navigation mesh constrained position, within a particular radius
  65293. * @param position world position
  65294. * @param maxRadius the maximum distance to the constrained world position
  65295. * @returns the closest point to position constrained by the navigation mesh
  65296. */
  65297. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65298. /**
  65299. * Get a navigation mesh constrained position, within a particular radius
  65300. * @param position world position
  65301. * @param maxRadius the maximum distance to the constrained world position
  65302. * @param result output the closest point to position constrained by the navigation mesh
  65303. */
  65304. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65305. /**
  65306. * Compute the final position from a segment made of destination-position
  65307. * @param position world position
  65308. * @param destination world position
  65309. * @returns the resulting point along the navmesh
  65310. */
  65311. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65312. /**
  65313. * Compute the final position from a segment made of destination-position
  65314. * @param position world position
  65315. * @param destination world position
  65316. * @param result output the resulting point along the navmesh
  65317. */
  65318. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65319. /**
  65320. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65321. * @param start world position
  65322. * @param end world position
  65323. * @returns array containing world position composing the path
  65324. */
  65325. computePath(start: Vector3, end: Vector3): Vector3[];
  65326. /**
  65327. * If this plugin is supported
  65328. * @returns true if plugin is supported
  65329. */
  65330. isSupported(): boolean;
  65331. /**
  65332. * Create a new Crowd so you can add agents
  65333. * @param maxAgents the maximum agent count in the crowd
  65334. * @param maxAgentRadius the maximum radius an agent can have
  65335. * @param scene to attach the crowd to
  65336. * @returns the crowd you can add agents to
  65337. */
  65338. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65339. /**
  65340. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65341. * The queries will try to find a solution within those bounds
  65342. * default is (1,1,1)
  65343. * @param extent x,y,z value that define the extent around the queries point of reference
  65344. */
  65345. setDefaultQueryExtent(extent: Vector3): void;
  65346. /**
  65347. * Get the Bounding box extent specified by setDefaultQueryExtent
  65348. * @returns the box extent values
  65349. */
  65350. getDefaultQueryExtent(): Vector3;
  65351. /**
  65352. * build the navmesh from a previously saved state using getNavmeshData
  65353. * @param data the Uint8Array returned by getNavmeshData
  65354. */
  65355. buildFromNavmeshData(data: Uint8Array): void;
  65356. /**
  65357. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65358. * @returns data the Uint8Array that can be saved and reused
  65359. */
  65360. getNavmeshData(): Uint8Array;
  65361. /**
  65362. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65363. * @param result output the box extent values
  65364. */
  65365. getDefaultQueryExtentToRef(result: Vector3): void;
  65366. /**
  65367. * Release all resources
  65368. */
  65369. dispose(): void;
  65370. }
  65371. /**
  65372. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65373. */
  65374. export interface ICrowd {
  65375. /**
  65376. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65377. * You can attach anything to that node. The node position is updated in the scene update tick.
  65378. * @param pos world position that will be constrained by the navigation mesh
  65379. * @param parameters agent parameters
  65380. * @param transform hooked to the agent that will be update by the scene
  65381. * @returns agent index
  65382. */
  65383. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65384. /**
  65385. * Returns the agent position in world space
  65386. * @param index agent index returned by addAgent
  65387. * @returns world space position
  65388. */
  65389. getAgentPosition(index: number): Vector3;
  65390. /**
  65391. * Gets the agent position result in world space
  65392. * @param index agent index returned by addAgent
  65393. * @param result output world space position
  65394. */
  65395. getAgentPositionToRef(index: number, result: Vector3): void;
  65396. /**
  65397. * Gets the agent velocity in world space
  65398. * @param index agent index returned by addAgent
  65399. * @returns world space velocity
  65400. */
  65401. getAgentVelocity(index: number): Vector3;
  65402. /**
  65403. * Gets the agent velocity result in world space
  65404. * @param index agent index returned by addAgent
  65405. * @param result output world space velocity
  65406. */
  65407. getAgentVelocityToRef(index: number, result: Vector3): void;
  65408. /**
  65409. * remove a particular agent previously created
  65410. * @param index agent index returned by addAgent
  65411. */
  65412. removeAgent(index: number): void;
  65413. /**
  65414. * get the list of all agents attached to this crowd
  65415. * @returns list of agent indices
  65416. */
  65417. getAgents(): number[];
  65418. /**
  65419. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65420. * @param deltaTime in seconds
  65421. */
  65422. update(deltaTime: number): void;
  65423. /**
  65424. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65425. * @param index agent index returned by addAgent
  65426. * @param destination targeted world position
  65427. */
  65428. agentGoto(index: number, destination: Vector3): void;
  65429. /**
  65430. * Teleport the agent to a new position
  65431. * @param index agent index returned by addAgent
  65432. * @param destination targeted world position
  65433. */
  65434. agentTeleport(index: number, destination: Vector3): void;
  65435. /**
  65436. * Update agent parameters
  65437. * @param index agent index returned by addAgent
  65438. * @param parameters agent parameters
  65439. */
  65440. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65441. /**
  65442. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65443. * The queries will try to find a solution within those bounds
  65444. * default is (1,1,1)
  65445. * @param extent x,y,z value that define the extent around the queries point of reference
  65446. */
  65447. setDefaultQueryExtent(extent: Vector3): void;
  65448. /**
  65449. * Get the Bounding box extent specified by setDefaultQueryExtent
  65450. * @returns the box extent values
  65451. */
  65452. getDefaultQueryExtent(): Vector3;
  65453. /**
  65454. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65455. * @param result output the box extent values
  65456. */
  65457. getDefaultQueryExtentToRef(result: Vector3): void;
  65458. /**
  65459. * Release all resources
  65460. */
  65461. dispose(): void;
  65462. }
  65463. /**
  65464. * Configures an agent
  65465. */
  65466. export interface IAgentParameters {
  65467. /**
  65468. * Agent radius. [Limit: >= 0]
  65469. */
  65470. radius: number;
  65471. /**
  65472. * Agent height. [Limit: > 0]
  65473. */
  65474. height: number;
  65475. /**
  65476. * Maximum allowed acceleration. [Limit: >= 0]
  65477. */
  65478. maxAcceleration: number;
  65479. /**
  65480. * Maximum allowed speed. [Limit: >= 0]
  65481. */
  65482. maxSpeed: number;
  65483. /**
  65484. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65485. */
  65486. collisionQueryRange: number;
  65487. /**
  65488. * The path visibility optimization range. [Limit: > 0]
  65489. */
  65490. pathOptimizationRange: number;
  65491. /**
  65492. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65493. */
  65494. separationWeight: number;
  65495. }
  65496. /**
  65497. * Configures the navigation mesh creation
  65498. */
  65499. export interface INavMeshParameters {
  65500. /**
  65501. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65502. */
  65503. cs: number;
  65504. /**
  65505. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65506. */
  65507. ch: number;
  65508. /**
  65509. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65510. */
  65511. walkableSlopeAngle: number;
  65512. /**
  65513. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65514. * be considered walkable. [Limit: >= 3] [Units: vx]
  65515. */
  65516. walkableHeight: number;
  65517. /**
  65518. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65519. */
  65520. walkableClimb: number;
  65521. /**
  65522. * The distance to erode/shrink the walkable area of the heightfield away from
  65523. * obstructions. [Limit: >=0] [Units: vx]
  65524. */
  65525. walkableRadius: number;
  65526. /**
  65527. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65528. */
  65529. maxEdgeLen: number;
  65530. /**
  65531. * The maximum distance a simplfied contour's border edges should deviate
  65532. * the original raw contour. [Limit: >=0] [Units: vx]
  65533. */
  65534. maxSimplificationError: number;
  65535. /**
  65536. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65537. */
  65538. minRegionArea: number;
  65539. /**
  65540. * Any regions with a span count smaller than this value will, if possible,
  65541. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65542. */
  65543. mergeRegionArea: number;
  65544. /**
  65545. * The maximum number of vertices allowed for polygons generated during the
  65546. * contour to polygon conversion process. [Limit: >= 3]
  65547. */
  65548. maxVertsPerPoly: number;
  65549. /**
  65550. * Sets the sampling distance to use when generating the detail mesh.
  65551. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65552. */
  65553. detailSampleDist: number;
  65554. /**
  65555. * The maximum distance the detail mesh surface should deviate from heightfield
  65556. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65557. */
  65558. detailSampleMaxError: number;
  65559. }
  65560. }
  65561. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65562. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65563. import { Mesh } from "babylonjs/Meshes/mesh";
  65564. import { Scene } from "babylonjs/scene";
  65565. import { Vector3 } from "babylonjs/Maths/math";
  65566. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65567. /**
  65568. * RecastJS navigation plugin
  65569. */
  65570. export class RecastJSPlugin implements INavigationEnginePlugin {
  65571. /**
  65572. * Reference to the Recast library
  65573. */
  65574. bjsRECAST: any;
  65575. /**
  65576. * plugin name
  65577. */
  65578. name: string;
  65579. /**
  65580. * the first navmesh created. We might extend this to support multiple navmeshes
  65581. */
  65582. navMesh: any;
  65583. /**
  65584. * Initializes the recastJS plugin
  65585. * @param recastInjection can be used to inject your own recast reference
  65586. */
  65587. constructor(recastInjection?: any);
  65588. /**
  65589. * Creates a navigation mesh
  65590. * @param meshes array of all the geometry used to compute the navigatio mesh
  65591. * @param parameters bunch of parameters used to filter geometry
  65592. */
  65593. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65594. /**
  65595. * Create a navigation mesh debug mesh
  65596. * @param scene is where the mesh will be added
  65597. * @returns debug display mesh
  65598. */
  65599. createDebugNavMesh(scene: Scene): Mesh;
  65600. /**
  65601. * Get a navigation mesh constrained position, closest to the parameter position
  65602. * @param position world position
  65603. * @returns the closest point to position constrained by the navigation mesh
  65604. */
  65605. getClosestPoint(position: Vector3): Vector3;
  65606. /**
  65607. * Get a navigation mesh constrained position, closest to the parameter position
  65608. * @param position world position
  65609. * @param result output the closest point to position constrained by the navigation mesh
  65610. */
  65611. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65612. /**
  65613. * Get a navigation mesh constrained position, within a particular radius
  65614. * @param position world position
  65615. * @param maxRadius the maximum distance to the constrained world position
  65616. * @returns the closest point to position constrained by the navigation mesh
  65617. */
  65618. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65619. /**
  65620. * Get a navigation mesh constrained position, within a particular radius
  65621. * @param position world position
  65622. * @param maxRadius the maximum distance to the constrained world position
  65623. * @param result output the closest point to position constrained by the navigation mesh
  65624. */
  65625. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65626. /**
  65627. * Compute the final position from a segment made of destination-position
  65628. * @param position world position
  65629. * @param destination world position
  65630. * @returns the resulting point along the navmesh
  65631. */
  65632. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65633. /**
  65634. * Compute the final position from a segment made of destination-position
  65635. * @param position world position
  65636. * @param destination world position
  65637. * @param result output the resulting point along the navmesh
  65638. */
  65639. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65640. /**
  65641. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65642. * @param start world position
  65643. * @param end world position
  65644. * @returns array containing world position composing the path
  65645. */
  65646. computePath(start: Vector3, end: Vector3): Vector3[];
  65647. /**
  65648. * Create a new Crowd so you can add agents
  65649. * @param maxAgents the maximum agent count in the crowd
  65650. * @param maxAgentRadius the maximum radius an agent can have
  65651. * @param scene to attach the crowd to
  65652. * @returns the crowd you can add agents to
  65653. */
  65654. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65655. /**
  65656. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65657. * The queries will try to find a solution within those bounds
  65658. * default is (1,1,1)
  65659. * @param extent x,y,z value that define the extent around the queries point of reference
  65660. */
  65661. setDefaultQueryExtent(extent: Vector3): void;
  65662. /**
  65663. * Get the Bounding box extent specified by setDefaultQueryExtent
  65664. * @returns the box extent values
  65665. */
  65666. getDefaultQueryExtent(): Vector3;
  65667. /**
  65668. * build the navmesh from a previously saved state using getNavmeshData
  65669. * @param data the Uint8Array returned by getNavmeshData
  65670. */
  65671. buildFromNavmeshData(data: Uint8Array): void;
  65672. /**
  65673. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65674. * @returns data the Uint8Array that can be saved and reused
  65675. */
  65676. getNavmeshData(): Uint8Array;
  65677. /**
  65678. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65679. * @param result output the box extent values
  65680. */
  65681. getDefaultQueryExtentToRef(result: Vector3): void;
  65682. /**
  65683. * Disposes
  65684. */
  65685. dispose(): void;
  65686. /**
  65687. * If this plugin is supported
  65688. * @returns true if plugin is supported
  65689. */
  65690. isSupported(): boolean;
  65691. }
  65692. /**
  65693. * Recast detour crowd implementation
  65694. */
  65695. export class RecastJSCrowd implements ICrowd {
  65696. /**
  65697. * Recast/detour plugin
  65698. */
  65699. bjsRECASTPlugin: RecastJSPlugin;
  65700. /**
  65701. * Link to the detour crowd
  65702. */
  65703. recastCrowd: any;
  65704. /**
  65705. * One transform per agent
  65706. */
  65707. transforms: TransformNode[];
  65708. /**
  65709. * All agents created
  65710. */
  65711. agents: number[];
  65712. /**
  65713. * Link to the scene is kept to unregister the crowd from the scene
  65714. */
  65715. private _scene;
  65716. /**
  65717. * Observer for crowd updates
  65718. */
  65719. private _onBeforeAnimationsObserver;
  65720. /**
  65721. * Constructor
  65722. * @param plugin recastJS plugin
  65723. * @param maxAgents the maximum agent count in the crowd
  65724. * @param maxAgentRadius the maximum radius an agent can have
  65725. * @param scene to attach the crowd to
  65726. * @returns the crowd you can add agents to
  65727. */
  65728. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65729. /**
  65730. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65731. * You can attach anything to that node. The node position is updated in the scene update tick.
  65732. * @param pos world position that will be constrained by the navigation mesh
  65733. * @param parameters agent parameters
  65734. * @param transform hooked to the agent that will be update by the scene
  65735. * @returns agent index
  65736. */
  65737. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65738. /**
  65739. * Returns the agent position in world space
  65740. * @param index agent index returned by addAgent
  65741. * @returns world space position
  65742. */
  65743. getAgentPosition(index: number): Vector3;
  65744. /**
  65745. * Returns the agent position result in world space
  65746. * @param index agent index returned by addAgent
  65747. * @param result output world space position
  65748. */
  65749. getAgentPositionToRef(index: number, result: Vector3): void;
  65750. /**
  65751. * Returns the agent velocity in world space
  65752. * @param index agent index returned by addAgent
  65753. * @returns world space velocity
  65754. */
  65755. getAgentVelocity(index: number): Vector3;
  65756. /**
  65757. * Returns the agent velocity result in world space
  65758. * @param index agent index returned by addAgent
  65759. * @param result output world space velocity
  65760. */
  65761. getAgentVelocityToRef(index: number, result: Vector3): void;
  65762. /**
  65763. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65764. * @param index agent index returned by addAgent
  65765. * @param destination targeted world position
  65766. */
  65767. agentGoto(index: number, destination: Vector3): void;
  65768. /**
  65769. * Teleport the agent to a new position
  65770. * @param index agent index returned by addAgent
  65771. * @param destination targeted world position
  65772. */
  65773. agentTeleport(index: number, destination: Vector3): void;
  65774. /**
  65775. * Update agent parameters
  65776. * @param index agent index returned by addAgent
  65777. * @param parameters agent parameters
  65778. */
  65779. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65780. /**
  65781. * remove a particular agent previously created
  65782. * @param index agent index returned by addAgent
  65783. */
  65784. removeAgent(index: number): void;
  65785. /**
  65786. * get the list of all agents attached to this crowd
  65787. * @returns list of agent indices
  65788. */
  65789. getAgents(): number[];
  65790. /**
  65791. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65792. * @param deltaTime in seconds
  65793. */
  65794. update(deltaTime: number): void;
  65795. /**
  65796. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65797. * The queries will try to find a solution within those bounds
  65798. * default is (1,1,1)
  65799. * @param extent x,y,z value that define the extent around the queries point of reference
  65800. */
  65801. setDefaultQueryExtent(extent: Vector3): void;
  65802. /**
  65803. * Get the Bounding box extent specified by setDefaultQueryExtent
  65804. * @returns the box extent values
  65805. */
  65806. getDefaultQueryExtent(): Vector3;
  65807. /**
  65808. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65809. * @param result output the box extent values
  65810. */
  65811. getDefaultQueryExtentToRef(result: Vector3): void;
  65812. /**
  65813. * Release all resources
  65814. */
  65815. dispose(): void;
  65816. }
  65817. }
  65818. declare module "babylonjs/Navigation/Plugins/index" {
  65819. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65820. }
  65821. declare module "babylonjs/Navigation/index" {
  65822. export * from "babylonjs/Navigation/INavigationEngine";
  65823. export * from "babylonjs/Navigation/Plugins/index";
  65824. }
  65825. declare module "babylonjs/Offline/database" {
  65826. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65827. /**
  65828. * Class used to enable access to IndexedDB
  65829. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65830. */
  65831. export class Database implements IOfflineProvider {
  65832. private _callbackManifestChecked;
  65833. private _currentSceneUrl;
  65834. private _db;
  65835. private _enableSceneOffline;
  65836. private _enableTexturesOffline;
  65837. private _manifestVersionFound;
  65838. private _mustUpdateRessources;
  65839. private _hasReachedQuota;
  65840. private _isSupported;
  65841. private _idbFactory;
  65842. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65843. private static IsUASupportingBlobStorage;
  65844. /**
  65845. * Gets a boolean indicating if Database storate is enabled (off by default)
  65846. */
  65847. static IDBStorageEnabled: boolean;
  65848. /**
  65849. * Gets a boolean indicating if scene must be saved in the database
  65850. */
  65851. get enableSceneOffline(): boolean;
  65852. /**
  65853. * Gets a boolean indicating if textures must be saved in the database
  65854. */
  65855. get enableTexturesOffline(): boolean;
  65856. /**
  65857. * Creates a new Database
  65858. * @param urlToScene defines the url to load the scene
  65859. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65860. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65861. */
  65862. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65863. private static _ParseURL;
  65864. private static _ReturnFullUrlLocation;
  65865. private _checkManifestFile;
  65866. /**
  65867. * Open the database and make it available
  65868. * @param successCallback defines the callback to call on success
  65869. * @param errorCallback defines the callback to call on error
  65870. */
  65871. open(successCallback: () => void, errorCallback: () => void): void;
  65872. /**
  65873. * Loads an image from the database
  65874. * @param url defines the url to load from
  65875. * @param image defines the target DOM image
  65876. */
  65877. loadImage(url: string, image: HTMLImageElement): void;
  65878. private _loadImageFromDBAsync;
  65879. private _saveImageIntoDBAsync;
  65880. private _checkVersionFromDB;
  65881. private _loadVersionFromDBAsync;
  65882. private _saveVersionIntoDBAsync;
  65883. /**
  65884. * Loads a file from database
  65885. * @param url defines the URL to load from
  65886. * @param sceneLoaded defines a callback to call on success
  65887. * @param progressCallBack defines a callback to call when progress changed
  65888. * @param errorCallback defines a callback to call on error
  65889. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65890. */
  65891. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65892. private _loadFileAsync;
  65893. private _saveFileAsync;
  65894. /**
  65895. * Validates if xhr data is correct
  65896. * @param xhr defines the request to validate
  65897. * @param dataType defines the expected data type
  65898. * @returns true if data is correct
  65899. */
  65900. private static _ValidateXHRData;
  65901. }
  65902. }
  65903. declare module "babylonjs/Offline/index" {
  65904. export * from "babylonjs/Offline/database";
  65905. export * from "babylonjs/Offline/IOfflineProvider";
  65906. }
  65907. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65908. /** @hidden */
  65909. export var gpuUpdateParticlesPixelShader: {
  65910. name: string;
  65911. shader: string;
  65912. };
  65913. }
  65914. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65915. /** @hidden */
  65916. export var gpuUpdateParticlesVertexShader: {
  65917. name: string;
  65918. shader: string;
  65919. };
  65920. }
  65921. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65922. /** @hidden */
  65923. export var clipPlaneFragmentDeclaration2: {
  65924. name: string;
  65925. shader: string;
  65926. };
  65927. }
  65928. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65929. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65930. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65931. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65932. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65933. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65934. /** @hidden */
  65935. export var gpuRenderParticlesPixelShader: {
  65936. name: string;
  65937. shader: string;
  65938. };
  65939. }
  65940. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65941. /** @hidden */
  65942. export var clipPlaneVertexDeclaration2: {
  65943. name: string;
  65944. shader: string;
  65945. };
  65946. }
  65947. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65948. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65949. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65950. /** @hidden */
  65951. export var gpuRenderParticlesVertexShader: {
  65952. name: string;
  65953. shader: string;
  65954. };
  65955. }
  65956. declare module "babylonjs/Particles/gpuParticleSystem" {
  65957. import { Nullable } from "babylonjs/types";
  65958. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65959. import { Observable } from "babylonjs/Misc/observable";
  65960. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65962. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65963. import { Scene, IDisposable } from "babylonjs/scene";
  65964. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65965. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65966. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65967. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65968. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65969. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65970. /**
  65971. * This represents a GPU particle system in Babylon
  65972. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65973. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65974. */
  65975. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65976. /**
  65977. * The layer mask we are rendering the particles through.
  65978. */
  65979. layerMask: number;
  65980. private _capacity;
  65981. private _activeCount;
  65982. private _currentActiveCount;
  65983. private _accumulatedCount;
  65984. private _renderEffect;
  65985. private _updateEffect;
  65986. private _buffer0;
  65987. private _buffer1;
  65988. private _spriteBuffer;
  65989. private _updateVAO;
  65990. private _renderVAO;
  65991. private _targetIndex;
  65992. private _sourceBuffer;
  65993. private _targetBuffer;
  65994. private _engine;
  65995. private _currentRenderId;
  65996. private _started;
  65997. private _stopped;
  65998. private _timeDelta;
  65999. private _randomTexture;
  66000. private _randomTexture2;
  66001. private _attributesStrideSize;
  66002. private _updateEffectOptions;
  66003. private _randomTextureSize;
  66004. private _actualFrame;
  66005. private readonly _rawTextureWidth;
  66006. /**
  66007. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66008. */
  66009. static get IsSupported(): boolean;
  66010. /**
  66011. * An event triggered when the system is disposed.
  66012. */
  66013. onDisposeObservable: Observable<GPUParticleSystem>;
  66014. /**
  66015. * Gets the maximum number of particles active at the same time.
  66016. * @returns The max number of active particles.
  66017. */
  66018. getCapacity(): number;
  66019. /**
  66020. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66021. * to override the particles.
  66022. */
  66023. forceDepthWrite: boolean;
  66024. /**
  66025. * Gets or set the number of active particles
  66026. */
  66027. get activeParticleCount(): number;
  66028. set activeParticleCount(value: number);
  66029. private _preWarmDone;
  66030. /**
  66031. * Specifies if the particles are updated in emitter local space or world space.
  66032. * This is always false for GPU particles
  66033. */
  66034. get isLocal(): boolean;
  66035. set isLocal(value: boolean);
  66036. /**
  66037. * Is this system ready to be used/rendered
  66038. * @return true if the system is ready
  66039. */
  66040. isReady(): boolean;
  66041. /**
  66042. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66043. * @returns True if it has been started, otherwise false.
  66044. */
  66045. isStarted(): boolean;
  66046. /**
  66047. * Starts the particle system and begins to emit
  66048. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66049. */
  66050. start(delay?: number): void;
  66051. /**
  66052. * Stops the particle system.
  66053. */
  66054. stop(): void;
  66055. /**
  66056. * Remove all active particles
  66057. */
  66058. reset(): void;
  66059. /**
  66060. * Returns the string "GPUParticleSystem"
  66061. * @returns a string containing the class name
  66062. */
  66063. getClassName(): string;
  66064. private _colorGradientsTexture;
  66065. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66066. /**
  66067. * Adds a new color gradient
  66068. * @param gradient defines the gradient to use (between 0 and 1)
  66069. * @param color1 defines the color to affect to the specified gradient
  66070. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66071. * @returns the current particle system
  66072. */
  66073. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66074. /**
  66075. * Remove a specific color gradient
  66076. * @param gradient defines the gradient to remove
  66077. * @returns the current particle system
  66078. */
  66079. removeColorGradient(gradient: number): GPUParticleSystem;
  66080. private _angularSpeedGradientsTexture;
  66081. private _sizeGradientsTexture;
  66082. private _velocityGradientsTexture;
  66083. private _limitVelocityGradientsTexture;
  66084. private _dragGradientsTexture;
  66085. private _addFactorGradient;
  66086. /**
  66087. * Adds a new size gradient
  66088. * @param gradient defines the gradient to use (between 0 and 1)
  66089. * @param factor defines the size factor to affect to the specified gradient
  66090. * @returns the current particle system
  66091. */
  66092. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66093. /**
  66094. * Remove a specific size gradient
  66095. * @param gradient defines the gradient to remove
  66096. * @returns the current particle system
  66097. */
  66098. removeSizeGradient(gradient: number): GPUParticleSystem;
  66099. /**
  66100. * Adds a new angular speed gradient
  66101. * @param gradient defines the gradient to use (between 0 and 1)
  66102. * @param factor defines the angular speed to affect to the specified gradient
  66103. * @returns the current particle system
  66104. */
  66105. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66106. /**
  66107. * Remove a specific angular speed gradient
  66108. * @param gradient defines the gradient to remove
  66109. * @returns the current particle system
  66110. */
  66111. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66112. /**
  66113. * Adds a new velocity gradient
  66114. * @param gradient defines the gradient to use (between 0 and 1)
  66115. * @param factor defines the velocity to affect to the specified gradient
  66116. * @returns the current particle system
  66117. */
  66118. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66119. /**
  66120. * Remove a specific velocity gradient
  66121. * @param gradient defines the gradient to remove
  66122. * @returns the current particle system
  66123. */
  66124. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66125. /**
  66126. * Adds a new limit velocity gradient
  66127. * @param gradient defines the gradient to use (between 0 and 1)
  66128. * @param factor defines the limit velocity value to affect to the specified gradient
  66129. * @returns the current particle system
  66130. */
  66131. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66132. /**
  66133. * Remove a specific limit velocity gradient
  66134. * @param gradient defines the gradient to remove
  66135. * @returns the current particle system
  66136. */
  66137. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66138. /**
  66139. * Adds a new drag gradient
  66140. * @param gradient defines the gradient to use (between 0 and 1)
  66141. * @param factor defines the drag value to affect to the specified gradient
  66142. * @returns the current particle system
  66143. */
  66144. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66145. /**
  66146. * Remove a specific drag gradient
  66147. * @param gradient defines the gradient to remove
  66148. * @returns the current particle system
  66149. */
  66150. removeDragGradient(gradient: number): GPUParticleSystem;
  66151. /**
  66152. * Not supported by GPUParticleSystem
  66153. * @param gradient defines the gradient to use (between 0 and 1)
  66154. * @param factor defines the emit rate value to affect to the specified gradient
  66155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66156. * @returns the current particle system
  66157. */
  66158. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66159. /**
  66160. * Not supported by GPUParticleSystem
  66161. * @param gradient defines the gradient to remove
  66162. * @returns the current particle system
  66163. */
  66164. removeEmitRateGradient(gradient: number): IParticleSystem;
  66165. /**
  66166. * Not supported by GPUParticleSystem
  66167. * @param gradient defines the gradient to use (between 0 and 1)
  66168. * @param factor defines the start size value to affect to the specified gradient
  66169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66170. * @returns the current particle system
  66171. */
  66172. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66173. /**
  66174. * Not supported by GPUParticleSystem
  66175. * @param gradient defines the gradient to remove
  66176. * @returns the current particle system
  66177. */
  66178. removeStartSizeGradient(gradient: number): IParticleSystem;
  66179. /**
  66180. * Not supported by GPUParticleSystem
  66181. * @param gradient defines the gradient to use (between 0 and 1)
  66182. * @param min defines the color remap minimal range
  66183. * @param max defines the color remap maximal range
  66184. * @returns the current particle system
  66185. */
  66186. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66187. /**
  66188. * Not supported by GPUParticleSystem
  66189. * @param gradient defines the gradient to remove
  66190. * @returns the current particle system
  66191. */
  66192. removeColorRemapGradient(): IParticleSystem;
  66193. /**
  66194. * Not supported by GPUParticleSystem
  66195. * @param gradient defines the gradient to use (between 0 and 1)
  66196. * @param min defines the alpha remap minimal range
  66197. * @param max defines the alpha remap maximal range
  66198. * @returns the current particle system
  66199. */
  66200. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66201. /**
  66202. * Not supported by GPUParticleSystem
  66203. * @param gradient defines the gradient to remove
  66204. * @returns the current particle system
  66205. */
  66206. removeAlphaRemapGradient(): IParticleSystem;
  66207. /**
  66208. * Not supported by GPUParticleSystem
  66209. * @param gradient defines the gradient to use (between 0 and 1)
  66210. * @param color defines the color to affect to the specified gradient
  66211. * @returns the current particle system
  66212. */
  66213. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66214. /**
  66215. * Not supported by GPUParticleSystem
  66216. * @param gradient defines the gradient to remove
  66217. * @returns the current particle system
  66218. */
  66219. removeRampGradient(): IParticleSystem;
  66220. /**
  66221. * Not supported by GPUParticleSystem
  66222. * @returns the list of ramp gradients
  66223. */
  66224. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66225. /**
  66226. * Not supported by GPUParticleSystem
  66227. * Gets or sets a boolean indicating that ramp gradients must be used
  66228. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66229. */
  66230. get useRampGradients(): boolean;
  66231. set useRampGradients(value: boolean);
  66232. /**
  66233. * Not supported by GPUParticleSystem
  66234. * @param gradient defines the gradient to use (between 0 and 1)
  66235. * @param factor defines the life time factor to affect to the specified gradient
  66236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66237. * @returns the current particle system
  66238. */
  66239. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66240. /**
  66241. * Not supported by GPUParticleSystem
  66242. * @param gradient defines the gradient to remove
  66243. * @returns the current particle system
  66244. */
  66245. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66246. /**
  66247. * Instantiates a GPU particle system.
  66248. * 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.
  66249. * @param name The name of the particle system
  66250. * @param options The options used to create the system
  66251. * @param scene The scene the particle system belongs to
  66252. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66253. */
  66254. constructor(name: string, options: Partial<{
  66255. capacity: number;
  66256. randomTextureSize: number;
  66257. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66258. protected _reset(): void;
  66259. private _createUpdateVAO;
  66260. private _createRenderVAO;
  66261. private _initialize;
  66262. /** @hidden */
  66263. _recreateUpdateEffect(): void;
  66264. /** @hidden */
  66265. _recreateRenderEffect(): void;
  66266. /**
  66267. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66268. * @param preWarm defines if we are in the pre-warmimg phase
  66269. */
  66270. animate(preWarm?: boolean): void;
  66271. private _createFactorGradientTexture;
  66272. private _createSizeGradientTexture;
  66273. private _createAngularSpeedGradientTexture;
  66274. private _createVelocityGradientTexture;
  66275. private _createLimitVelocityGradientTexture;
  66276. private _createDragGradientTexture;
  66277. private _createColorGradientTexture;
  66278. /**
  66279. * Renders the particle system in its current state
  66280. * @param preWarm defines if the system should only update the particles but not render them
  66281. * @returns the current number of particles
  66282. */
  66283. render(preWarm?: boolean): number;
  66284. /**
  66285. * Rebuilds the particle system
  66286. */
  66287. rebuild(): void;
  66288. private _releaseBuffers;
  66289. private _releaseVAOs;
  66290. /**
  66291. * Disposes the particle system and free the associated resources
  66292. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66293. */
  66294. dispose(disposeTexture?: boolean): void;
  66295. /**
  66296. * Clones the particle system.
  66297. * @param name The name of the cloned object
  66298. * @param newEmitter The new emitter to use
  66299. * @returns the cloned particle system
  66300. */
  66301. clone(name: string, newEmitter: any): GPUParticleSystem;
  66302. /**
  66303. * Serializes the particle system to a JSON object.
  66304. * @returns the JSON object
  66305. */
  66306. serialize(): any;
  66307. /**
  66308. * Parses a JSON object to create a GPU particle system.
  66309. * @param parsedParticleSystem The JSON object to parse
  66310. * @param scene The scene to create the particle system in
  66311. * @param rootUrl The root url to use to load external dependencies like texture
  66312. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66313. * @returns the parsed GPU particle system
  66314. */
  66315. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66316. }
  66317. }
  66318. declare module "babylonjs/Particles/particleSystemSet" {
  66319. import { Nullable } from "babylonjs/types";
  66320. import { Color3 } from "babylonjs/Maths/math.color";
  66321. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66323. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66324. import { Scene, IDisposable } from "babylonjs/scene";
  66325. /**
  66326. * Represents a set of particle systems working together to create a specific effect
  66327. */
  66328. export class ParticleSystemSet implements IDisposable {
  66329. /**
  66330. * Gets or sets base Assets URL
  66331. */
  66332. static BaseAssetsUrl: string;
  66333. private _emitterCreationOptions;
  66334. private _emitterNode;
  66335. /**
  66336. * Gets the particle system list
  66337. */
  66338. systems: IParticleSystem[];
  66339. /**
  66340. * Gets the emitter node used with this set
  66341. */
  66342. get emitterNode(): Nullable<TransformNode>;
  66343. /**
  66344. * Creates a new emitter mesh as a sphere
  66345. * @param options defines the options used to create the sphere
  66346. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66347. * @param scene defines the hosting scene
  66348. */
  66349. setEmitterAsSphere(options: {
  66350. diameter: number;
  66351. segments: number;
  66352. color: Color3;
  66353. }, renderingGroupId: number, scene: Scene): void;
  66354. /**
  66355. * Starts all particle systems of the set
  66356. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66357. */
  66358. start(emitter?: AbstractMesh): void;
  66359. /**
  66360. * Release all associated resources
  66361. */
  66362. dispose(): void;
  66363. /**
  66364. * Serialize the set into a JSON compatible object
  66365. * @returns a JSON compatible representation of the set
  66366. */
  66367. serialize(): any;
  66368. /**
  66369. * Parse a new ParticleSystemSet from a serialized source
  66370. * @param data defines a JSON compatible representation of the set
  66371. * @param scene defines the hosting scene
  66372. * @param gpu defines if we want GPU particles or CPU particles
  66373. * @returns a new ParticleSystemSet
  66374. */
  66375. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66376. }
  66377. }
  66378. declare module "babylonjs/Particles/particleHelper" {
  66379. import { Nullable } from "babylonjs/types";
  66380. import { Scene } from "babylonjs/scene";
  66381. import { Vector3 } from "babylonjs/Maths/math.vector";
  66382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66384. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66385. /**
  66386. * This class is made for on one-liner static method to help creating particle system set.
  66387. */
  66388. export class ParticleHelper {
  66389. /**
  66390. * Gets or sets base Assets URL
  66391. */
  66392. static BaseAssetsUrl: string;
  66393. /**
  66394. * Create a default particle system that you can tweak
  66395. * @param emitter defines the emitter to use
  66396. * @param capacity defines the system capacity (default is 500 particles)
  66397. * @param scene defines the hosting scene
  66398. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66399. * @returns the new Particle system
  66400. */
  66401. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66402. /**
  66403. * This is the main static method (one-liner) of this helper to create different particle systems
  66404. * @param type This string represents the type to the particle system to create
  66405. * @param scene The scene where the particle system should live
  66406. * @param gpu If the system will use gpu
  66407. * @returns the ParticleSystemSet created
  66408. */
  66409. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66410. /**
  66411. * Static function used to export a particle system to a ParticleSystemSet variable.
  66412. * Please note that the emitter shape is not exported
  66413. * @param systems defines the particle systems to export
  66414. * @returns the created particle system set
  66415. */
  66416. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66417. }
  66418. }
  66419. declare module "babylonjs/Particles/particleSystemComponent" {
  66420. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66421. import { Effect } from "babylonjs/Materials/effect";
  66422. import "babylonjs/Shaders/particles.vertex";
  66423. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66424. module "babylonjs/Engines/engine" {
  66425. interface Engine {
  66426. /**
  66427. * Create an effect to use with particle systems.
  66428. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66429. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66430. * @param uniformsNames defines a list of attribute names
  66431. * @param samplers defines an array of string used to represent textures
  66432. * @param defines defines the string containing the defines to use to compile the shaders
  66433. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66434. * @param onCompiled defines a function to call when the effect creation is successful
  66435. * @param onError defines a function to call when the effect creation has failed
  66436. * @returns the new Effect
  66437. */
  66438. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66439. }
  66440. }
  66441. module "babylonjs/Meshes/mesh" {
  66442. interface Mesh {
  66443. /**
  66444. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66445. * @returns an array of IParticleSystem
  66446. */
  66447. getEmittedParticleSystems(): IParticleSystem[];
  66448. /**
  66449. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66450. * @returns an array of IParticleSystem
  66451. */
  66452. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66453. }
  66454. }
  66455. /**
  66456. * @hidden
  66457. */
  66458. export var _IDoNeedToBeInTheBuild: number;
  66459. }
  66460. declare module "babylonjs/Particles/pointsCloudSystem" {
  66461. import { Color4 } from "babylonjs/Maths/math";
  66462. import { Mesh } from "babylonjs/Meshes/mesh";
  66463. import { Scene, IDisposable } from "babylonjs/scene";
  66464. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66465. /** Defines the 4 color options */
  66466. export enum PointColor {
  66467. /** color value */
  66468. Color = 2,
  66469. /** uv value */
  66470. UV = 1,
  66471. /** random value */
  66472. Random = 0,
  66473. /** stated value */
  66474. Stated = 3
  66475. }
  66476. /**
  66477. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66478. * 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.
  66479. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66480. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66481. *
  66482. * Full documentation here : TO BE ENTERED
  66483. */
  66484. export class PointsCloudSystem implements IDisposable {
  66485. /**
  66486. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66487. * Example : var p = SPS.particles[i];
  66488. */
  66489. particles: CloudPoint[];
  66490. /**
  66491. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66492. */
  66493. nbParticles: number;
  66494. /**
  66495. * This a counter for your own usage. It's not set by any SPS functions.
  66496. */
  66497. counter: number;
  66498. /**
  66499. * The PCS name. This name is also given to the underlying mesh.
  66500. */
  66501. name: string;
  66502. /**
  66503. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66504. */
  66505. mesh: Mesh;
  66506. /**
  66507. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66508. * Please read :
  66509. */
  66510. vars: any;
  66511. /**
  66512. * @hidden
  66513. */
  66514. _size: number;
  66515. private _scene;
  66516. private _promises;
  66517. private _positions;
  66518. private _indices;
  66519. private _normals;
  66520. private _colors;
  66521. private _uvs;
  66522. private _indices32;
  66523. private _positions32;
  66524. private _colors32;
  66525. private _uvs32;
  66526. private _updatable;
  66527. private _isVisibilityBoxLocked;
  66528. private _alwaysVisible;
  66529. private _groups;
  66530. private _groupCounter;
  66531. private _computeParticleColor;
  66532. private _computeParticleTexture;
  66533. private _computeParticleRotation;
  66534. private _computeBoundingBox;
  66535. private _isReady;
  66536. /**
  66537. * Creates a PCS (Points Cloud System) object
  66538. * @param name (String) is the PCS name, this will be the underlying mesh name
  66539. * @param pointSize (number) is the size for each point
  66540. * @param scene (Scene) is the scene in which the PCS is added
  66541. * @param options defines the options of the PCS e.g.
  66542. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66543. */
  66544. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66545. updatable?: boolean;
  66546. });
  66547. /**
  66548. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66549. * If no points were added to the PCS, the returned mesh is just a single point.
  66550. * @returns a promise for the created mesh
  66551. */
  66552. buildMeshAsync(): Promise<Mesh>;
  66553. /**
  66554. * @hidden
  66555. */
  66556. private _buildMesh;
  66557. private _addParticle;
  66558. private _randomUnitVector;
  66559. private _getColorIndicesForCoord;
  66560. private _setPointsColorOrUV;
  66561. private _colorFromTexture;
  66562. private _calculateDensity;
  66563. /**
  66564. * Adds points to the PCS in random positions within a unit sphere
  66565. * @param nb (positive integer) the number of particles to be created from this model
  66566. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66567. * @returns the number of groups in the system
  66568. */
  66569. addPoints(nb: number, pointFunction?: any): number;
  66570. /**
  66571. * Adds points to the PCS from the surface of the model shape
  66572. * @param mesh is any Mesh object that will be used as a surface model for the points
  66573. * @param nb (positive integer) the number of particles to be created from this model
  66574. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66575. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66576. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66577. * @returns the number of groups in the system
  66578. */
  66579. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66580. /**
  66581. * Adds points to the PCS inside the model shape
  66582. * @param mesh is any Mesh object that will be used as a surface model for the points
  66583. * @param nb (positive integer) the number of particles to be created from this model
  66584. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66585. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66586. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66587. * @returns the number of groups in the system
  66588. */
  66589. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66590. /**
  66591. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66592. * This method calls `updateParticle()` for each particle of the SPS.
  66593. * For an animated SPS, it is usually called within the render loop.
  66594. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66595. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66596. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66597. * @returns the PCS.
  66598. */
  66599. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66600. /**
  66601. * Disposes the PCS.
  66602. */
  66603. dispose(): void;
  66604. /**
  66605. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66606. * doc :
  66607. * @returns the PCS.
  66608. */
  66609. refreshVisibleSize(): PointsCloudSystem;
  66610. /**
  66611. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66612. * @param size the size (float) of the visibility box
  66613. * note : this doesn't lock the PCS mesh bounding box.
  66614. * doc :
  66615. */
  66616. setVisibilityBox(size: number): void;
  66617. /**
  66618. * Gets whether the PCS is always visible or not
  66619. * doc :
  66620. */
  66621. get isAlwaysVisible(): boolean;
  66622. /**
  66623. * Sets the PCS as always visible or not
  66624. * doc :
  66625. */
  66626. set isAlwaysVisible(val: boolean);
  66627. /**
  66628. * Tells to `setParticles()` to compute the particle rotations or not
  66629. * Default value : false. The PCS is faster when it's set to false
  66630. * Note : particle rotations are only applied to parent particles
  66631. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66632. */
  66633. set computeParticleRotation(val: boolean);
  66634. /**
  66635. * Tells to `setParticles()` to compute the particle colors or not.
  66636. * Default value : true. The PCS is faster when it's set to false.
  66637. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66638. */
  66639. set computeParticleColor(val: boolean);
  66640. set computeParticleTexture(val: boolean);
  66641. /**
  66642. * Gets if `setParticles()` computes the particle colors or not.
  66643. * Default value : false. The PCS is faster when it's set to false.
  66644. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66645. */
  66646. get computeParticleColor(): boolean;
  66647. /**
  66648. * Gets if `setParticles()` computes the particle textures or not.
  66649. * Default value : false. The PCS is faster when it's set to false.
  66650. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66651. */
  66652. get computeParticleTexture(): boolean;
  66653. /**
  66654. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66655. */
  66656. set computeBoundingBox(val: boolean);
  66657. /**
  66658. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66659. */
  66660. get computeBoundingBox(): boolean;
  66661. /**
  66662. * This function does nothing. It may be overwritten to set all the particle first values.
  66663. * The PCS doesn't call this function, you may have to call it by your own.
  66664. * doc :
  66665. */
  66666. initParticles(): void;
  66667. /**
  66668. * This function does nothing. It may be overwritten to recycle a particle
  66669. * The PCS doesn't call this function, you can to call it
  66670. * doc :
  66671. * @param particle The particle to recycle
  66672. * @returns the recycled particle
  66673. */
  66674. recycleParticle(particle: CloudPoint): CloudPoint;
  66675. /**
  66676. * Updates a particle : this function should be overwritten by the user.
  66677. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66678. * doc :
  66679. * @example : just set a particle position or velocity and recycle conditions
  66680. * @param particle The particle to update
  66681. * @returns the updated particle
  66682. */
  66683. updateParticle(particle: CloudPoint): CloudPoint;
  66684. /**
  66685. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66686. * This does nothing and may be overwritten by the user.
  66687. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66688. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66689. * @param update the boolean update value actually passed to setParticles()
  66690. */
  66691. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66692. /**
  66693. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66694. * This will be passed three parameters.
  66695. * This does nothing and may be overwritten by the user.
  66696. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66697. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66698. * @param update the boolean update value actually passed to setParticles()
  66699. */
  66700. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66701. }
  66702. }
  66703. declare module "babylonjs/Particles/cloudPoint" {
  66704. import { Nullable } from "babylonjs/types";
  66705. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66706. import { Mesh } from "babylonjs/Meshes/mesh";
  66707. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66708. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66709. /**
  66710. * Represents one particle of a points cloud system.
  66711. */
  66712. export class CloudPoint {
  66713. /**
  66714. * particle global index
  66715. */
  66716. idx: number;
  66717. /**
  66718. * The color of the particle
  66719. */
  66720. color: Nullable<Color4>;
  66721. /**
  66722. * The world space position of the particle.
  66723. */
  66724. position: Vector3;
  66725. /**
  66726. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66727. */
  66728. rotation: Vector3;
  66729. /**
  66730. * The world space rotation quaternion of the particle.
  66731. */
  66732. rotationQuaternion: Nullable<Quaternion>;
  66733. /**
  66734. * The uv of the particle.
  66735. */
  66736. uv: Nullable<Vector2>;
  66737. /**
  66738. * The current speed of the particle.
  66739. */
  66740. velocity: Vector3;
  66741. /**
  66742. * The pivot point in the particle local space.
  66743. */
  66744. pivot: Vector3;
  66745. /**
  66746. * Must the particle be translated from its pivot point in its local space ?
  66747. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66748. * Default : false
  66749. */
  66750. translateFromPivot: boolean;
  66751. /**
  66752. * Index of this particle in the global "positions" array (Internal use)
  66753. * @hidden
  66754. */
  66755. _pos: number;
  66756. /**
  66757. * @hidden Index of this particle in the global "indices" array (Internal use)
  66758. */
  66759. _ind: number;
  66760. /**
  66761. * Group this particle belongs to
  66762. */
  66763. _group: PointsGroup;
  66764. /**
  66765. * Group id of this particle
  66766. */
  66767. groupId: number;
  66768. /**
  66769. * Index of the particle in its group id (Internal use)
  66770. */
  66771. idxInGroup: number;
  66772. /**
  66773. * @hidden Particle BoundingInfo object (Internal use)
  66774. */
  66775. _boundingInfo: BoundingInfo;
  66776. /**
  66777. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66778. */
  66779. _pcs: PointsCloudSystem;
  66780. /**
  66781. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66782. */
  66783. _stillInvisible: boolean;
  66784. /**
  66785. * @hidden Last computed particle rotation matrix
  66786. */
  66787. _rotationMatrix: number[];
  66788. /**
  66789. * Parent particle Id, if any.
  66790. * Default null.
  66791. */
  66792. parentId: Nullable<number>;
  66793. /**
  66794. * @hidden Internal global position in the PCS.
  66795. */
  66796. _globalPosition: Vector3;
  66797. /**
  66798. * Creates a Point Cloud object.
  66799. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66800. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66801. * @param group (PointsGroup) is the group the particle belongs to
  66802. * @param groupId (integer) is the group identifier in the PCS.
  66803. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66804. * @param pcs defines the PCS it is associated to
  66805. */
  66806. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66807. /**
  66808. * get point size
  66809. */
  66810. get size(): Vector3;
  66811. /**
  66812. * Set point size
  66813. */
  66814. set size(scale: Vector3);
  66815. /**
  66816. * Legacy support, changed quaternion to rotationQuaternion
  66817. */
  66818. get quaternion(): Nullable<Quaternion>;
  66819. /**
  66820. * Legacy support, changed quaternion to rotationQuaternion
  66821. */
  66822. set quaternion(q: Nullable<Quaternion>);
  66823. /**
  66824. * Returns a boolean. True if the particle intersects a mesh, else false
  66825. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66826. * @param target is the object (point or mesh) what the intersection is computed against
  66827. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66828. * @returns true if it intersects
  66829. */
  66830. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66831. /**
  66832. * get the rotation matrix of the particle
  66833. * @hidden
  66834. */
  66835. getRotationMatrix(m: Matrix): void;
  66836. }
  66837. /**
  66838. * Represents a group of points in a points cloud system
  66839. * * PCS internal tool, don't use it manually.
  66840. */
  66841. export class PointsGroup {
  66842. /**
  66843. * The group id
  66844. * @hidden
  66845. */
  66846. groupID: number;
  66847. /**
  66848. * image data for group (internal use)
  66849. * @hidden
  66850. */
  66851. _groupImageData: Nullable<ArrayBufferView>;
  66852. /**
  66853. * Image Width (internal use)
  66854. * @hidden
  66855. */
  66856. _groupImgWidth: number;
  66857. /**
  66858. * Image Height (internal use)
  66859. * @hidden
  66860. */
  66861. _groupImgHeight: number;
  66862. /**
  66863. * Custom position function (internal use)
  66864. * @hidden
  66865. */
  66866. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66867. /**
  66868. * density per facet for surface points
  66869. * @hidden
  66870. */
  66871. _groupDensity: number[];
  66872. /**
  66873. * Only when points are colored by texture carries pointer to texture list array
  66874. * @hidden
  66875. */
  66876. _textureNb: number;
  66877. /**
  66878. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66879. * PCS internal tool, don't use it manually.
  66880. * @hidden
  66881. */
  66882. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66883. }
  66884. }
  66885. declare module "babylonjs/Particles/index" {
  66886. export * from "babylonjs/Particles/baseParticleSystem";
  66887. export * from "babylonjs/Particles/EmitterTypes/index";
  66888. export * from "babylonjs/Particles/gpuParticleSystem";
  66889. export * from "babylonjs/Particles/IParticleSystem";
  66890. export * from "babylonjs/Particles/particle";
  66891. export * from "babylonjs/Particles/particleHelper";
  66892. export * from "babylonjs/Particles/particleSystem";
  66893. export * from "babylonjs/Particles/particleSystemComponent";
  66894. export * from "babylonjs/Particles/particleSystemSet";
  66895. export * from "babylonjs/Particles/solidParticle";
  66896. export * from "babylonjs/Particles/solidParticleSystem";
  66897. export * from "babylonjs/Particles/cloudPoint";
  66898. export * from "babylonjs/Particles/pointsCloudSystem";
  66899. export * from "babylonjs/Particles/subEmitter";
  66900. }
  66901. declare module "babylonjs/Physics/physicsEngineComponent" {
  66902. import { Nullable } from "babylonjs/types";
  66903. import { Observable, Observer } from "babylonjs/Misc/observable";
  66904. import { Vector3 } from "babylonjs/Maths/math.vector";
  66905. import { Mesh } from "babylonjs/Meshes/mesh";
  66906. import { ISceneComponent } from "babylonjs/sceneComponent";
  66907. import { Scene } from "babylonjs/scene";
  66908. import { Node } from "babylonjs/node";
  66909. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66910. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66911. module "babylonjs/scene" {
  66912. interface Scene {
  66913. /** @hidden (Backing field) */
  66914. _physicsEngine: Nullable<IPhysicsEngine>;
  66915. /** @hidden */
  66916. _physicsTimeAccumulator: number;
  66917. /**
  66918. * Gets the current physics engine
  66919. * @returns a IPhysicsEngine or null if none attached
  66920. */
  66921. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66922. /**
  66923. * Enables physics to the current scene
  66924. * @param gravity defines the scene's gravity for the physics engine
  66925. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66926. * @return a boolean indicating if the physics engine was initialized
  66927. */
  66928. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66929. /**
  66930. * Disables and disposes the physics engine associated with the scene
  66931. */
  66932. disablePhysicsEngine(): void;
  66933. /**
  66934. * Gets a boolean indicating if there is an active physics engine
  66935. * @returns a boolean indicating if there is an active physics engine
  66936. */
  66937. isPhysicsEnabled(): boolean;
  66938. /**
  66939. * Deletes a physics compound impostor
  66940. * @param compound defines the compound to delete
  66941. */
  66942. deleteCompoundImpostor(compound: any): void;
  66943. /**
  66944. * An event triggered when physic simulation is about to be run
  66945. */
  66946. onBeforePhysicsObservable: Observable<Scene>;
  66947. /**
  66948. * An event triggered when physic simulation has been done
  66949. */
  66950. onAfterPhysicsObservable: Observable<Scene>;
  66951. }
  66952. }
  66953. module "babylonjs/Meshes/abstractMesh" {
  66954. interface AbstractMesh {
  66955. /** @hidden */
  66956. _physicsImpostor: Nullable<PhysicsImpostor>;
  66957. /**
  66958. * Gets or sets impostor used for physic simulation
  66959. * @see http://doc.babylonjs.com/features/physics_engine
  66960. */
  66961. physicsImpostor: Nullable<PhysicsImpostor>;
  66962. /**
  66963. * Gets the current physics impostor
  66964. * @see http://doc.babylonjs.com/features/physics_engine
  66965. * @returns a physics impostor or null
  66966. */
  66967. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66968. /** Apply a physic impulse to the mesh
  66969. * @param force defines the force to apply
  66970. * @param contactPoint defines where to apply the force
  66971. * @returns the current mesh
  66972. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66973. */
  66974. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66975. /**
  66976. * Creates a physic joint between two meshes
  66977. * @param otherMesh defines the other mesh to use
  66978. * @param pivot1 defines the pivot to use on this mesh
  66979. * @param pivot2 defines the pivot to use on the other mesh
  66980. * @param options defines additional options (can be plugin dependent)
  66981. * @returns the current mesh
  66982. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66983. */
  66984. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66985. /** @hidden */
  66986. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66987. }
  66988. }
  66989. /**
  66990. * Defines the physics engine scene component responsible to manage a physics engine
  66991. */
  66992. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66993. /**
  66994. * The component name helpful to identify the component in the list of scene components.
  66995. */
  66996. readonly name: string;
  66997. /**
  66998. * The scene the component belongs to.
  66999. */
  67000. scene: Scene;
  67001. /**
  67002. * Creates a new instance of the component for the given scene
  67003. * @param scene Defines the scene to register the component in
  67004. */
  67005. constructor(scene: Scene);
  67006. /**
  67007. * Registers the component in a given scene
  67008. */
  67009. register(): void;
  67010. /**
  67011. * Rebuilds the elements related to this component in case of
  67012. * context lost for instance.
  67013. */
  67014. rebuild(): void;
  67015. /**
  67016. * Disposes the component and the associated ressources
  67017. */
  67018. dispose(): void;
  67019. }
  67020. }
  67021. declare module "babylonjs/Physics/physicsHelper" {
  67022. import { Nullable } from "babylonjs/types";
  67023. import { Vector3 } from "babylonjs/Maths/math.vector";
  67024. import { Mesh } from "babylonjs/Meshes/mesh";
  67025. import { Scene } from "babylonjs/scene";
  67026. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67027. /**
  67028. * A helper for physics simulations
  67029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67030. */
  67031. export class PhysicsHelper {
  67032. private _scene;
  67033. private _physicsEngine;
  67034. /**
  67035. * Initializes the Physics helper
  67036. * @param scene Babylon.js scene
  67037. */
  67038. constructor(scene: Scene);
  67039. /**
  67040. * Applies a radial explosion impulse
  67041. * @param origin the origin of the explosion
  67042. * @param radiusOrEventOptions the radius or the options of radial explosion
  67043. * @param strength the explosion strength
  67044. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67045. * @returns A physics radial explosion event, or null
  67046. */
  67047. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67048. /**
  67049. * Applies a radial explosion force
  67050. * @param origin the origin of the explosion
  67051. * @param radiusOrEventOptions the radius or the options of radial explosion
  67052. * @param strength the explosion strength
  67053. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67054. * @returns A physics radial explosion event, or null
  67055. */
  67056. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67057. /**
  67058. * Creates a gravitational field
  67059. * @param origin the origin of the explosion
  67060. * @param radiusOrEventOptions the radius or the options of radial explosion
  67061. * @param strength the explosion strength
  67062. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67063. * @returns A physics gravitational field event, or null
  67064. */
  67065. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67066. /**
  67067. * Creates a physics updraft event
  67068. * @param origin the origin of the updraft
  67069. * @param radiusOrEventOptions the radius or the options of the updraft
  67070. * @param strength the strength of the updraft
  67071. * @param height the height of the updraft
  67072. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67073. * @returns A physics updraft event, or null
  67074. */
  67075. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67076. /**
  67077. * Creates a physics vortex event
  67078. * @param origin the of the vortex
  67079. * @param radiusOrEventOptions the radius or the options of the vortex
  67080. * @param strength the strength of the vortex
  67081. * @param height the height of the vortex
  67082. * @returns a Physics vortex event, or null
  67083. * A physics vortex event or null
  67084. */
  67085. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67086. }
  67087. /**
  67088. * Represents a physics radial explosion event
  67089. */
  67090. class PhysicsRadialExplosionEvent {
  67091. private _scene;
  67092. private _options;
  67093. private _sphere;
  67094. private _dataFetched;
  67095. /**
  67096. * Initializes a radial explosioin event
  67097. * @param _scene BabylonJS scene
  67098. * @param _options The options for the vortex event
  67099. */
  67100. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67101. /**
  67102. * Returns the data related to the radial explosion event (sphere).
  67103. * @returns The radial explosion event data
  67104. */
  67105. getData(): PhysicsRadialExplosionEventData;
  67106. /**
  67107. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67108. * @param impostor A physics imposter
  67109. * @param origin the origin of the explosion
  67110. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67111. */
  67112. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67113. /**
  67114. * Triggers affecterd impostors callbacks
  67115. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67116. */
  67117. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67118. /**
  67119. * Disposes the sphere.
  67120. * @param force Specifies if the sphere should be disposed by force
  67121. */
  67122. dispose(force?: boolean): void;
  67123. /*** Helpers ***/
  67124. private _prepareSphere;
  67125. private _intersectsWithSphere;
  67126. }
  67127. /**
  67128. * Represents a gravitational field event
  67129. */
  67130. class PhysicsGravitationalFieldEvent {
  67131. private _physicsHelper;
  67132. private _scene;
  67133. private _origin;
  67134. private _options;
  67135. private _tickCallback;
  67136. private _sphere;
  67137. private _dataFetched;
  67138. /**
  67139. * Initializes the physics gravitational field event
  67140. * @param _physicsHelper A physics helper
  67141. * @param _scene BabylonJS scene
  67142. * @param _origin The origin position of the gravitational field event
  67143. * @param _options The options for the vortex event
  67144. */
  67145. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67146. /**
  67147. * Returns the data related to the gravitational field event (sphere).
  67148. * @returns A gravitational field event
  67149. */
  67150. getData(): PhysicsGravitationalFieldEventData;
  67151. /**
  67152. * Enables the gravitational field.
  67153. */
  67154. enable(): void;
  67155. /**
  67156. * Disables the gravitational field.
  67157. */
  67158. disable(): void;
  67159. /**
  67160. * Disposes the sphere.
  67161. * @param force The force to dispose from the gravitational field event
  67162. */
  67163. dispose(force?: boolean): void;
  67164. private _tick;
  67165. }
  67166. /**
  67167. * Represents a physics updraft event
  67168. */
  67169. class PhysicsUpdraftEvent {
  67170. private _scene;
  67171. private _origin;
  67172. private _options;
  67173. private _physicsEngine;
  67174. private _originTop;
  67175. private _originDirection;
  67176. private _tickCallback;
  67177. private _cylinder;
  67178. private _cylinderPosition;
  67179. private _dataFetched;
  67180. /**
  67181. * Initializes the physics updraft event
  67182. * @param _scene BabylonJS scene
  67183. * @param _origin The origin position of the updraft
  67184. * @param _options The options for the updraft event
  67185. */
  67186. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67187. /**
  67188. * Returns the data related to the updraft event (cylinder).
  67189. * @returns A physics updraft event
  67190. */
  67191. getData(): PhysicsUpdraftEventData;
  67192. /**
  67193. * Enables the updraft.
  67194. */
  67195. enable(): void;
  67196. /**
  67197. * Disables the updraft.
  67198. */
  67199. disable(): void;
  67200. /**
  67201. * Disposes the cylinder.
  67202. * @param force Specifies if the updraft should be disposed by force
  67203. */
  67204. dispose(force?: boolean): void;
  67205. private getImpostorHitData;
  67206. private _tick;
  67207. /*** Helpers ***/
  67208. private _prepareCylinder;
  67209. private _intersectsWithCylinder;
  67210. }
  67211. /**
  67212. * Represents a physics vortex event
  67213. */
  67214. class PhysicsVortexEvent {
  67215. private _scene;
  67216. private _origin;
  67217. private _options;
  67218. private _physicsEngine;
  67219. private _originTop;
  67220. private _tickCallback;
  67221. private _cylinder;
  67222. private _cylinderPosition;
  67223. private _dataFetched;
  67224. /**
  67225. * Initializes the physics vortex event
  67226. * @param _scene The BabylonJS scene
  67227. * @param _origin The origin position of the vortex
  67228. * @param _options The options for the vortex event
  67229. */
  67230. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67231. /**
  67232. * Returns the data related to the vortex event (cylinder).
  67233. * @returns The physics vortex event data
  67234. */
  67235. getData(): PhysicsVortexEventData;
  67236. /**
  67237. * Enables the vortex.
  67238. */
  67239. enable(): void;
  67240. /**
  67241. * Disables the cortex.
  67242. */
  67243. disable(): void;
  67244. /**
  67245. * Disposes the sphere.
  67246. * @param force
  67247. */
  67248. dispose(force?: boolean): void;
  67249. private getImpostorHitData;
  67250. private _tick;
  67251. /*** Helpers ***/
  67252. private _prepareCylinder;
  67253. private _intersectsWithCylinder;
  67254. }
  67255. /**
  67256. * Options fot the radial explosion event
  67257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67258. */
  67259. export class PhysicsRadialExplosionEventOptions {
  67260. /**
  67261. * The radius of the sphere for the radial explosion.
  67262. */
  67263. radius: number;
  67264. /**
  67265. * The strenth of the explosion.
  67266. */
  67267. strength: number;
  67268. /**
  67269. * The strenght of the force in correspondence to the distance of the affected object
  67270. */
  67271. falloff: PhysicsRadialImpulseFalloff;
  67272. /**
  67273. * Sphere options for the radial explosion.
  67274. */
  67275. sphere: {
  67276. segments: number;
  67277. diameter: number;
  67278. };
  67279. /**
  67280. * Sphere options for the radial explosion.
  67281. */
  67282. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67283. }
  67284. /**
  67285. * Options fot the updraft event
  67286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67287. */
  67288. export class PhysicsUpdraftEventOptions {
  67289. /**
  67290. * The radius of the cylinder for the vortex
  67291. */
  67292. radius: number;
  67293. /**
  67294. * The strenth of the updraft.
  67295. */
  67296. strength: number;
  67297. /**
  67298. * The height of the cylinder for the updraft.
  67299. */
  67300. height: number;
  67301. /**
  67302. * The mode for the the updraft.
  67303. */
  67304. updraftMode: PhysicsUpdraftMode;
  67305. }
  67306. /**
  67307. * Options fot the vortex event
  67308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67309. */
  67310. export class PhysicsVortexEventOptions {
  67311. /**
  67312. * The radius of the cylinder for the vortex
  67313. */
  67314. radius: number;
  67315. /**
  67316. * The strenth of the vortex.
  67317. */
  67318. strength: number;
  67319. /**
  67320. * The height of the cylinder for the vortex.
  67321. */
  67322. height: number;
  67323. /**
  67324. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67325. */
  67326. centripetalForceThreshold: number;
  67327. /**
  67328. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67329. */
  67330. centripetalForceMultiplier: number;
  67331. /**
  67332. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67333. */
  67334. centrifugalForceMultiplier: number;
  67335. /**
  67336. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67337. */
  67338. updraftForceMultiplier: number;
  67339. }
  67340. /**
  67341. * The strenght of the force in correspondence to the distance of the affected object
  67342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67343. */
  67344. export enum PhysicsRadialImpulseFalloff {
  67345. /** Defines that impulse is constant in strength across it's whole radius */
  67346. Constant = 0,
  67347. /** Defines that impulse gets weaker if it's further from the origin */
  67348. Linear = 1
  67349. }
  67350. /**
  67351. * The strength of the force in correspondence to the distance of the affected object
  67352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67353. */
  67354. export enum PhysicsUpdraftMode {
  67355. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67356. Center = 0,
  67357. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67358. Perpendicular = 1
  67359. }
  67360. /**
  67361. * Interface for a physics hit data
  67362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67363. */
  67364. export interface PhysicsHitData {
  67365. /**
  67366. * The force applied at the contact point
  67367. */
  67368. force: Vector3;
  67369. /**
  67370. * The contact point
  67371. */
  67372. contactPoint: Vector3;
  67373. /**
  67374. * The distance from the origin to the contact point
  67375. */
  67376. distanceFromOrigin: number;
  67377. }
  67378. /**
  67379. * Interface for radial explosion event data
  67380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67381. */
  67382. export interface PhysicsRadialExplosionEventData {
  67383. /**
  67384. * A sphere used for the radial explosion event
  67385. */
  67386. sphere: Mesh;
  67387. }
  67388. /**
  67389. * Interface for gravitational field event data
  67390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67391. */
  67392. export interface PhysicsGravitationalFieldEventData {
  67393. /**
  67394. * A sphere mesh used for the gravitational field event
  67395. */
  67396. sphere: Mesh;
  67397. }
  67398. /**
  67399. * Interface for updraft event data
  67400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67401. */
  67402. export interface PhysicsUpdraftEventData {
  67403. /**
  67404. * A cylinder used for the updraft event
  67405. */
  67406. cylinder: Mesh;
  67407. }
  67408. /**
  67409. * Interface for vortex event data
  67410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67411. */
  67412. export interface PhysicsVortexEventData {
  67413. /**
  67414. * A cylinder used for the vortex event
  67415. */
  67416. cylinder: Mesh;
  67417. }
  67418. /**
  67419. * Interface for an affected physics impostor
  67420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67421. */
  67422. export interface PhysicsAffectedImpostorWithData {
  67423. /**
  67424. * The impostor affected by the effect
  67425. */
  67426. impostor: PhysicsImpostor;
  67427. /**
  67428. * The data about the hit/horce from the explosion
  67429. */
  67430. hitData: PhysicsHitData;
  67431. }
  67432. }
  67433. declare module "babylonjs/Physics/Plugins/index" {
  67434. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67435. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67436. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67437. }
  67438. declare module "babylonjs/Physics/index" {
  67439. export * from "babylonjs/Physics/IPhysicsEngine";
  67440. export * from "babylonjs/Physics/physicsEngine";
  67441. export * from "babylonjs/Physics/physicsEngineComponent";
  67442. export * from "babylonjs/Physics/physicsHelper";
  67443. export * from "babylonjs/Physics/physicsImpostor";
  67444. export * from "babylonjs/Physics/physicsJoint";
  67445. export * from "babylonjs/Physics/Plugins/index";
  67446. }
  67447. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67448. /** @hidden */
  67449. export var blackAndWhitePixelShader: {
  67450. name: string;
  67451. shader: string;
  67452. };
  67453. }
  67454. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67455. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67456. import { Camera } from "babylonjs/Cameras/camera";
  67457. import { Engine } from "babylonjs/Engines/engine";
  67458. import "babylonjs/Shaders/blackAndWhite.fragment";
  67459. /**
  67460. * Post process used to render in black and white
  67461. */
  67462. export class BlackAndWhitePostProcess extends PostProcess {
  67463. /**
  67464. * Linear about to convert he result to black and white (default: 1)
  67465. */
  67466. degree: number;
  67467. /**
  67468. * Creates a black and white post process
  67469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67470. * @param name The name of the effect.
  67471. * @param options The required width/height ratio to downsize to before computing the render pass.
  67472. * @param camera The camera to apply the render pass to.
  67473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67474. * @param engine The engine which the post process will be applied. (default: current engine)
  67475. * @param reusable If the post process can be reused on the same frame. (default: false)
  67476. */
  67477. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67478. }
  67479. }
  67480. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67481. import { Nullable } from "babylonjs/types";
  67482. import { Camera } from "babylonjs/Cameras/camera";
  67483. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67484. import { Engine } from "babylonjs/Engines/engine";
  67485. /**
  67486. * This represents a set of one or more post processes in Babylon.
  67487. * A post process can be used to apply a shader to a texture after it is rendered.
  67488. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67489. */
  67490. export class PostProcessRenderEffect {
  67491. private _postProcesses;
  67492. private _getPostProcesses;
  67493. private _singleInstance;
  67494. private _cameras;
  67495. private _indicesForCamera;
  67496. /**
  67497. * Name of the effect
  67498. * @hidden
  67499. */
  67500. _name: string;
  67501. /**
  67502. * Instantiates a post process render effect.
  67503. * A post process can be used to apply a shader to a texture after it is rendered.
  67504. * @param engine The engine the effect is tied to
  67505. * @param name The name of the effect
  67506. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67507. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67508. */
  67509. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67510. /**
  67511. * Checks if all the post processes in the effect are supported.
  67512. */
  67513. get isSupported(): boolean;
  67514. /**
  67515. * Updates the current state of the effect
  67516. * @hidden
  67517. */
  67518. _update(): void;
  67519. /**
  67520. * Attaches the effect on cameras
  67521. * @param cameras The camera to attach to.
  67522. * @hidden
  67523. */
  67524. _attachCameras(cameras: Camera): void;
  67525. /**
  67526. * Attaches the effect on cameras
  67527. * @param cameras The camera to attach to.
  67528. * @hidden
  67529. */
  67530. _attachCameras(cameras: Camera[]): void;
  67531. /**
  67532. * Detaches the effect on cameras
  67533. * @param cameras The camera to detatch from.
  67534. * @hidden
  67535. */
  67536. _detachCameras(cameras: Camera): void;
  67537. /**
  67538. * Detatches the effect on cameras
  67539. * @param cameras The camera to detatch from.
  67540. * @hidden
  67541. */
  67542. _detachCameras(cameras: Camera[]): void;
  67543. /**
  67544. * Enables the effect on given cameras
  67545. * @param cameras The camera to enable.
  67546. * @hidden
  67547. */
  67548. _enable(cameras: Camera): void;
  67549. /**
  67550. * Enables the effect on given cameras
  67551. * @param cameras The camera to enable.
  67552. * @hidden
  67553. */
  67554. _enable(cameras: Nullable<Camera[]>): void;
  67555. /**
  67556. * Disables the effect on the given cameras
  67557. * @param cameras The camera to disable.
  67558. * @hidden
  67559. */
  67560. _disable(cameras: Camera): void;
  67561. /**
  67562. * Disables the effect on the given cameras
  67563. * @param cameras The camera to disable.
  67564. * @hidden
  67565. */
  67566. _disable(cameras: Nullable<Camera[]>): void;
  67567. /**
  67568. * Gets a list of the post processes contained in the effect.
  67569. * @param camera The camera to get the post processes on.
  67570. * @returns The list of the post processes in the effect.
  67571. */
  67572. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67573. }
  67574. }
  67575. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67577. /** @hidden */
  67578. export var extractHighlightsPixelShader: {
  67579. name: string;
  67580. shader: string;
  67581. };
  67582. }
  67583. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67584. import { Nullable } from "babylonjs/types";
  67585. import { Camera } from "babylonjs/Cameras/camera";
  67586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67587. import { Engine } from "babylonjs/Engines/engine";
  67588. import "babylonjs/Shaders/extractHighlights.fragment";
  67589. /**
  67590. * 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.
  67591. */
  67592. export class ExtractHighlightsPostProcess extends PostProcess {
  67593. /**
  67594. * The luminance threshold, pixels below this value will be set to black.
  67595. */
  67596. threshold: number;
  67597. /** @hidden */
  67598. _exposure: number;
  67599. /**
  67600. * Post process which has the input texture to be used when performing highlight extraction
  67601. * @hidden
  67602. */
  67603. _inputPostProcess: Nullable<PostProcess>;
  67604. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67605. }
  67606. }
  67607. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67608. /** @hidden */
  67609. export var bloomMergePixelShader: {
  67610. name: string;
  67611. shader: string;
  67612. };
  67613. }
  67614. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67616. import { Nullable } from "babylonjs/types";
  67617. import { Engine } from "babylonjs/Engines/engine";
  67618. import { Camera } from "babylonjs/Cameras/camera";
  67619. import "babylonjs/Shaders/bloomMerge.fragment";
  67620. /**
  67621. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67622. */
  67623. export class BloomMergePostProcess extends PostProcess {
  67624. /** Weight of the bloom to be added to the original input. */
  67625. weight: number;
  67626. /**
  67627. * Creates a new instance of @see BloomMergePostProcess
  67628. * @param name The name of the effect.
  67629. * @param originalFromInput Post process which's input will be used for the merge.
  67630. * @param blurred Blurred highlights post process which's output will be used.
  67631. * @param weight Weight of the bloom to be added to the original input.
  67632. * @param options The required width/height ratio to downsize to before computing the render pass.
  67633. * @param camera The camera to apply the render pass to.
  67634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67635. * @param engine The engine which the post process will be applied. (default: current engine)
  67636. * @param reusable If the post process can be reused on the same frame. (default: false)
  67637. * @param textureType Type of textures used when performing the post process. (default: 0)
  67638. * @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)
  67639. */
  67640. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67641. /** Weight of the bloom to be added to the original input. */
  67642. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67643. }
  67644. }
  67645. declare module "babylonjs/PostProcesses/bloomEffect" {
  67646. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67647. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67648. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67649. import { Camera } from "babylonjs/Cameras/camera";
  67650. import { Scene } from "babylonjs/scene";
  67651. /**
  67652. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67653. */
  67654. export class BloomEffect extends PostProcessRenderEffect {
  67655. private bloomScale;
  67656. /**
  67657. * @hidden Internal
  67658. */
  67659. _effects: Array<PostProcess>;
  67660. /**
  67661. * @hidden Internal
  67662. */
  67663. _downscale: ExtractHighlightsPostProcess;
  67664. private _blurX;
  67665. private _blurY;
  67666. private _merge;
  67667. /**
  67668. * The luminance threshold to find bright areas of the image to bloom.
  67669. */
  67670. get threshold(): number;
  67671. set threshold(value: number);
  67672. /**
  67673. * The strength of the bloom.
  67674. */
  67675. get weight(): number;
  67676. set weight(value: number);
  67677. /**
  67678. * Specifies the size of the bloom blur kernel, relative to the final output size
  67679. */
  67680. get kernel(): number;
  67681. set kernel(value: number);
  67682. /**
  67683. * Creates a new instance of @see BloomEffect
  67684. * @param scene The scene the effect belongs to.
  67685. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67686. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67687. * @param bloomWeight The the strength of bloom.
  67688. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67689. * @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)
  67690. */
  67691. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67692. /**
  67693. * Disposes each of the internal effects for a given camera.
  67694. * @param camera The camera to dispose the effect on.
  67695. */
  67696. disposeEffects(camera: Camera): void;
  67697. /**
  67698. * @hidden Internal
  67699. */
  67700. _updateEffects(): void;
  67701. /**
  67702. * Internal
  67703. * @returns if all the contained post processes are ready.
  67704. * @hidden
  67705. */
  67706. _isReady(): boolean;
  67707. }
  67708. }
  67709. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67710. /** @hidden */
  67711. export var chromaticAberrationPixelShader: {
  67712. name: string;
  67713. shader: string;
  67714. };
  67715. }
  67716. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67717. import { Vector2 } from "babylonjs/Maths/math.vector";
  67718. import { Nullable } from "babylonjs/types";
  67719. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67720. import { Camera } from "babylonjs/Cameras/camera";
  67721. import { Engine } from "babylonjs/Engines/engine";
  67722. import "babylonjs/Shaders/chromaticAberration.fragment";
  67723. /**
  67724. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67725. */
  67726. export class ChromaticAberrationPostProcess extends PostProcess {
  67727. /**
  67728. * The amount of seperation of rgb channels (default: 30)
  67729. */
  67730. aberrationAmount: number;
  67731. /**
  67732. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67733. */
  67734. radialIntensity: number;
  67735. /**
  67736. * 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))
  67737. */
  67738. direction: Vector2;
  67739. /**
  67740. * 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))
  67741. */
  67742. centerPosition: Vector2;
  67743. /**
  67744. * Creates a new instance ChromaticAberrationPostProcess
  67745. * @param name The name of the effect.
  67746. * @param screenWidth The width of the screen to apply the effect on.
  67747. * @param screenHeight The height of the screen to apply the effect on.
  67748. * @param options The required width/height ratio to downsize to before computing the render pass.
  67749. * @param camera The camera to apply the render pass to.
  67750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67751. * @param engine The engine which the post process will be applied. (default: current engine)
  67752. * @param reusable If the post process can be reused on the same frame. (default: false)
  67753. * @param textureType Type of textures used when performing the post process. (default: 0)
  67754. * @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)
  67755. */
  67756. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67757. }
  67758. }
  67759. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67760. /** @hidden */
  67761. export var circleOfConfusionPixelShader: {
  67762. name: string;
  67763. shader: string;
  67764. };
  67765. }
  67766. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67767. import { Nullable } from "babylonjs/types";
  67768. import { Engine } from "babylonjs/Engines/engine";
  67769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67770. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67771. import { Camera } from "babylonjs/Cameras/camera";
  67772. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67773. /**
  67774. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67775. */
  67776. export class CircleOfConfusionPostProcess extends PostProcess {
  67777. /**
  67778. * 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.
  67779. */
  67780. lensSize: number;
  67781. /**
  67782. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67783. */
  67784. fStop: number;
  67785. /**
  67786. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67787. */
  67788. focusDistance: number;
  67789. /**
  67790. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67791. */
  67792. focalLength: number;
  67793. private _depthTexture;
  67794. /**
  67795. * Creates a new instance CircleOfConfusionPostProcess
  67796. * @param name The name of the effect.
  67797. * @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.
  67798. * @param options The required width/height ratio to downsize to before computing the render pass.
  67799. * @param camera The camera to apply the render pass to.
  67800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67801. * @param engine The engine which the post process will be applied. (default: current engine)
  67802. * @param reusable If the post process can be reused on the same frame. (default: false)
  67803. * @param textureType Type of textures used when performing the post process. (default: 0)
  67804. * @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)
  67805. */
  67806. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67807. /**
  67808. * 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.
  67809. */
  67810. set depthTexture(value: RenderTargetTexture);
  67811. }
  67812. }
  67813. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67814. /** @hidden */
  67815. export var colorCorrectionPixelShader: {
  67816. name: string;
  67817. shader: string;
  67818. };
  67819. }
  67820. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67821. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67822. import { Engine } from "babylonjs/Engines/engine";
  67823. import { Camera } from "babylonjs/Cameras/camera";
  67824. import "babylonjs/Shaders/colorCorrection.fragment";
  67825. /**
  67826. *
  67827. * This post-process allows the modification of rendered colors by using
  67828. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67829. *
  67830. * The object needs to be provided an url to a texture containing the color
  67831. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67832. * Use an image editing software to tweak the LUT to match your needs.
  67833. *
  67834. * For an example of a color LUT, see here:
  67835. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67836. * For explanations on color grading, see here:
  67837. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67838. *
  67839. */
  67840. export class ColorCorrectionPostProcess extends PostProcess {
  67841. private _colorTableTexture;
  67842. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67843. }
  67844. }
  67845. declare module "babylonjs/Shaders/convolution.fragment" {
  67846. /** @hidden */
  67847. export var convolutionPixelShader: {
  67848. name: string;
  67849. shader: string;
  67850. };
  67851. }
  67852. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67853. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67854. import { Nullable } from "babylonjs/types";
  67855. import { Camera } from "babylonjs/Cameras/camera";
  67856. import { Engine } from "babylonjs/Engines/engine";
  67857. import "babylonjs/Shaders/convolution.fragment";
  67858. /**
  67859. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67860. * input texture to perform effects such as edge detection or sharpening
  67861. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67862. */
  67863. export class ConvolutionPostProcess extends PostProcess {
  67864. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67865. kernel: number[];
  67866. /**
  67867. * Creates a new instance ConvolutionPostProcess
  67868. * @param name The name of the effect.
  67869. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67870. * @param options The required width/height ratio to downsize to before computing the render pass.
  67871. * @param camera The camera to apply the render pass to.
  67872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67873. * @param engine The engine which the post process will be applied. (default: current engine)
  67874. * @param reusable If the post process can be reused on the same frame. (default: false)
  67875. * @param textureType Type of textures used when performing the post process. (default: 0)
  67876. */
  67877. constructor(name: string,
  67878. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67879. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67880. /**
  67881. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67882. */
  67883. static EdgeDetect0Kernel: number[];
  67884. /**
  67885. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67886. */
  67887. static EdgeDetect1Kernel: number[];
  67888. /**
  67889. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67890. */
  67891. static EdgeDetect2Kernel: number[];
  67892. /**
  67893. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67894. */
  67895. static SharpenKernel: number[];
  67896. /**
  67897. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67898. */
  67899. static EmbossKernel: number[];
  67900. /**
  67901. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67902. */
  67903. static GaussianKernel: number[];
  67904. }
  67905. }
  67906. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67907. import { Nullable } from "babylonjs/types";
  67908. import { Vector2 } from "babylonjs/Maths/math.vector";
  67909. import { Camera } from "babylonjs/Cameras/camera";
  67910. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67911. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67912. import { Engine } from "babylonjs/Engines/engine";
  67913. import { Scene } from "babylonjs/scene";
  67914. /**
  67915. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67916. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67917. * based on samples that have a large difference in distance than the center pixel.
  67918. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67919. */
  67920. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67921. direction: Vector2;
  67922. /**
  67923. * Creates a new instance CircleOfConfusionPostProcess
  67924. * @param name The name of the effect.
  67925. * @param scene The scene the effect belongs to.
  67926. * @param direction The direction the blur should be applied.
  67927. * @param kernel The size of the kernel used to blur.
  67928. * @param options The required width/height ratio to downsize to before computing the render pass.
  67929. * @param camera The camera to apply the render pass to.
  67930. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67931. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67933. * @param engine The engine which the post process will be applied. (default: current engine)
  67934. * @param reusable If the post process can be reused on the same frame. (default: false)
  67935. * @param textureType Type of textures used when performing the post process. (default: 0)
  67936. * @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)
  67937. */
  67938. 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);
  67939. }
  67940. }
  67941. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67942. /** @hidden */
  67943. export var depthOfFieldMergePixelShader: {
  67944. name: string;
  67945. shader: string;
  67946. };
  67947. }
  67948. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67949. import { Nullable } from "babylonjs/types";
  67950. import { Camera } from "babylonjs/Cameras/camera";
  67951. import { Effect } from "babylonjs/Materials/effect";
  67952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67953. import { Engine } from "babylonjs/Engines/engine";
  67954. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67955. /**
  67956. * Options to be set when merging outputs from the default pipeline.
  67957. */
  67958. export class DepthOfFieldMergePostProcessOptions {
  67959. /**
  67960. * The original image to merge on top of
  67961. */
  67962. originalFromInput: PostProcess;
  67963. /**
  67964. * Parameters to perform the merge of the depth of field effect
  67965. */
  67966. depthOfField?: {
  67967. circleOfConfusion: PostProcess;
  67968. blurSteps: Array<PostProcess>;
  67969. };
  67970. /**
  67971. * Parameters to perform the merge of bloom effect
  67972. */
  67973. bloom?: {
  67974. blurred: PostProcess;
  67975. weight: number;
  67976. };
  67977. }
  67978. /**
  67979. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67980. */
  67981. export class DepthOfFieldMergePostProcess extends PostProcess {
  67982. private blurSteps;
  67983. /**
  67984. * Creates a new instance of DepthOfFieldMergePostProcess
  67985. * @param name The name of the effect.
  67986. * @param originalFromInput Post process which's input will be used for the merge.
  67987. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67988. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67989. * @param options The required width/height ratio to downsize to before computing the render pass.
  67990. * @param camera The camera to apply the render pass to.
  67991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67992. * @param engine The engine which the post process will be applied. (default: current engine)
  67993. * @param reusable If the post process can be reused on the same frame. (default: false)
  67994. * @param textureType Type of textures used when performing the post process. (default: 0)
  67995. * @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)
  67996. */
  67997. 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);
  67998. /**
  67999. * Updates the effect with the current post process compile time values and recompiles the shader.
  68000. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68001. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68002. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68003. * @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
  68004. * @param onCompiled Called when the shader has been compiled.
  68005. * @param onError Called if there is an error when compiling a shader.
  68006. */
  68007. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68008. }
  68009. }
  68010. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68011. import { Nullable } from "babylonjs/types";
  68012. import { Camera } from "babylonjs/Cameras/camera";
  68013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68014. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68015. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68016. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68017. import { Scene } from "babylonjs/scene";
  68018. /**
  68019. * Specifies the level of max blur that should be applied when using the depth of field effect
  68020. */
  68021. export enum DepthOfFieldEffectBlurLevel {
  68022. /**
  68023. * Subtle blur
  68024. */
  68025. Low = 0,
  68026. /**
  68027. * Medium blur
  68028. */
  68029. Medium = 1,
  68030. /**
  68031. * Large blur
  68032. */
  68033. High = 2
  68034. }
  68035. /**
  68036. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68037. */
  68038. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68039. private _circleOfConfusion;
  68040. /**
  68041. * @hidden Internal, blurs from high to low
  68042. */
  68043. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68044. private _depthOfFieldBlurY;
  68045. private _dofMerge;
  68046. /**
  68047. * @hidden Internal post processes in depth of field effect
  68048. */
  68049. _effects: Array<PostProcess>;
  68050. /**
  68051. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68052. */
  68053. set focalLength(value: number);
  68054. get focalLength(): number;
  68055. /**
  68056. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68057. */
  68058. set fStop(value: number);
  68059. get fStop(): number;
  68060. /**
  68061. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68062. */
  68063. set focusDistance(value: number);
  68064. get focusDistance(): number;
  68065. /**
  68066. * 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.
  68067. */
  68068. set lensSize(value: number);
  68069. get lensSize(): number;
  68070. /**
  68071. * Creates a new instance DepthOfFieldEffect
  68072. * @param scene The scene the effect belongs to.
  68073. * @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.
  68074. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68075. * @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)
  68076. */
  68077. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68078. /**
  68079. * Get the current class name of the current effet
  68080. * @returns "DepthOfFieldEffect"
  68081. */
  68082. getClassName(): string;
  68083. /**
  68084. * 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.
  68085. */
  68086. set depthTexture(value: RenderTargetTexture);
  68087. /**
  68088. * Disposes each of the internal effects for a given camera.
  68089. * @param camera The camera to dispose the effect on.
  68090. */
  68091. disposeEffects(camera: Camera): void;
  68092. /**
  68093. * @hidden Internal
  68094. */
  68095. _updateEffects(): void;
  68096. /**
  68097. * Internal
  68098. * @returns if all the contained post processes are ready.
  68099. * @hidden
  68100. */
  68101. _isReady(): boolean;
  68102. }
  68103. }
  68104. declare module "babylonjs/Shaders/displayPass.fragment" {
  68105. /** @hidden */
  68106. export var displayPassPixelShader: {
  68107. name: string;
  68108. shader: string;
  68109. };
  68110. }
  68111. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68112. import { Nullable } from "babylonjs/types";
  68113. import { Camera } from "babylonjs/Cameras/camera";
  68114. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68115. import { Engine } from "babylonjs/Engines/engine";
  68116. import "babylonjs/Shaders/displayPass.fragment";
  68117. /**
  68118. * DisplayPassPostProcess which produces an output the same as it's input
  68119. */
  68120. export class DisplayPassPostProcess extends PostProcess {
  68121. /**
  68122. * Creates the DisplayPassPostProcess
  68123. * @param name The name of the effect.
  68124. * @param options The required width/height ratio to downsize to before computing the render pass.
  68125. * @param camera The camera to apply the render pass to.
  68126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68127. * @param engine The engine which the post process will be applied. (default: current engine)
  68128. * @param reusable If the post process can be reused on the same frame. (default: false)
  68129. */
  68130. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68131. }
  68132. }
  68133. declare module "babylonjs/Shaders/filter.fragment" {
  68134. /** @hidden */
  68135. export var filterPixelShader: {
  68136. name: string;
  68137. shader: string;
  68138. };
  68139. }
  68140. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68141. import { Nullable } from "babylonjs/types";
  68142. import { Matrix } from "babylonjs/Maths/math.vector";
  68143. import { Camera } from "babylonjs/Cameras/camera";
  68144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68145. import { Engine } from "babylonjs/Engines/engine";
  68146. import "babylonjs/Shaders/filter.fragment";
  68147. /**
  68148. * Applies a kernel filter to the image
  68149. */
  68150. export class FilterPostProcess extends PostProcess {
  68151. /** The matrix to be applied to the image */
  68152. kernelMatrix: Matrix;
  68153. /**
  68154. *
  68155. * @param name The name of the effect.
  68156. * @param kernelMatrix The matrix to be applied to the image
  68157. * @param options The required width/height ratio to downsize to before computing the render pass.
  68158. * @param camera The camera to apply the render pass to.
  68159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68160. * @param engine The engine which the post process will be applied. (default: current engine)
  68161. * @param reusable If the post process can be reused on the same frame. (default: false)
  68162. */
  68163. constructor(name: string,
  68164. /** The matrix to be applied to the image */
  68165. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68166. }
  68167. }
  68168. declare module "babylonjs/Shaders/fxaa.fragment" {
  68169. /** @hidden */
  68170. export var fxaaPixelShader: {
  68171. name: string;
  68172. shader: string;
  68173. };
  68174. }
  68175. declare module "babylonjs/Shaders/fxaa.vertex" {
  68176. /** @hidden */
  68177. export var fxaaVertexShader: {
  68178. name: string;
  68179. shader: string;
  68180. };
  68181. }
  68182. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68183. import { Nullable } from "babylonjs/types";
  68184. import { Camera } from "babylonjs/Cameras/camera";
  68185. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68186. import { Engine } from "babylonjs/Engines/engine";
  68187. import "babylonjs/Shaders/fxaa.fragment";
  68188. import "babylonjs/Shaders/fxaa.vertex";
  68189. /**
  68190. * Fxaa post process
  68191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68192. */
  68193. export class FxaaPostProcess extends PostProcess {
  68194. /** @hidden */
  68195. texelWidth: number;
  68196. /** @hidden */
  68197. texelHeight: number;
  68198. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68199. private _getDefines;
  68200. }
  68201. }
  68202. declare module "babylonjs/Shaders/grain.fragment" {
  68203. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68204. /** @hidden */
  68205. export var grainPixelShader: {
  68206. name: string;
  68207. shader: string;
  68208. };
  68209. }
  68210. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68211. import { Nullable } from "babylonjs/types";
  68212. import { Camera } from "babylonjs/Cameras/camera";
  68213. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68214. import { Engine } from "babylonjs/Engines/engine";
  68215. import "babylonjs/Shaders/grain.fragment";
  68216. /**
  68217. * The GrainPostProcess adds noise to the image at mid luminance levels
  68218. */
  68219. export class GrainPostProcess extends PostProcess {
  68220. /**
  68221. * The intensity of the grain added (default: 30)
  68222. */
  68223. intensity: number;
  68224. /**
  68225. * If the grain should be randomized on every frame
  68226. */
  68227. animated: boolean;
  68228. /**
  68229. * Creates a new instance of @see GrainPostProcess
  68230. * @param name The name of the effect.
  68231. * @param options The required width/height ratio to downsize to before computing the render pass.
  68232. * @param camera The camera to apply the render pass to.
  68233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68234. * @param engine The engine which the post process will be applied. (default: current engine)
  68235. * @param reusable If the post process can be reused on the same frame. (default: false)
  68236. * @param textureType Type of textures used when performing the post process. (default: 0)
  68237. * @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)
  68238. */
  68239. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68240. }
  68241. }
  68242. declare module "babylonjs/Shaders/highlights.fragment" {
  68243. /** @hidden */
  68244. export var highlightsPixelShader: {
  68245. name: string;
  68246. shader: string;
  68247. };
  68248. }
  68249. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68250. import { Nullable } from "babylonjs/types";
  68251. import { Camera } from "babylonjs/Cameras/camera";
  68252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68253. import { Engine } from "babylonjs/Engines/engine";
  68254. import "babylonjs/Shaders/highlights.fragment";
  68255. /**
  68256. * Extracts highlights from the image
  68257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68258. */
  68259. export class HighlightsPostProcess extends PostProcess {
  68260. /**
  68261. * Extracts highlights from the image
  68262. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68263. * @param name The name of the effect.
  68264. * @param options The required width/height ratio to downsize to before computing the render pass.
  68265. * @param camera The camera to apply the render pass to.
  68266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68267. * @param engine The engine which the post process will be applied. (default: current engine)
  68268. * @param reusable If the post process can be reused on the same frame. (default: false)
  68269. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68270. */
  68271. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68272. }
  68273. }
  68274. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68275. /** @hidden */
  68276. export var mrtFragmentDeclaration: {
  68277. name: string;
  68278. shader: string;
  68279. };
  68280. }
  68281. declare module "babylonjs/Shaders/geometry.fragment" {
  68282. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68283. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68284. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68285. /** @hidden */
  68286. export var geometryPixelShader: {
  68287. name: string;
  68288. shader: string;
  68289. };
  68290. }
  68291. declare module "babylonjs/Shaders/geometry.vertex" {
  68292. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68293. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68294. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68295. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68296. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68297. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68298. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68299. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68300. /** @hidden */
  68301. export var geometryVertexShader: {
  68302. name: string;
  68303. shader: string;
  68304. };
  68305. }
  68306. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68307. import { Matrix } from "babylonjs/Maths/math.vector";
  68308. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68309. import { Mesh } from "babylonjs/Meshes/mesh";
  68310. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68311. import { Effect } from "babylonjs/Materials/effect";
  68312. import { Scene } from "babylonjs/scene";
  68313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68314. import "babylonjs/Shaders/geometry.fragment";
  68315. import "babylonjs/Shaders/geometry.vertex";
  68316. /** @hidden */
  68317. interface ISavedTransformationMatrix {
  68318. world: Matrix;
  68319. viewProjection: Matrix;
  68320. }
  68321. /**
  68322. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68323. */
  68324. export class GeometryBufferRenderer {
  68325. /**
  68326. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68327. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68328. */
  68329. static readonly POSITION_TEXTURE_TYPE: number;
  68330. /**
  68331. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68332. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68333. */
  68334. static readonly VELOCITY_TEXTURE_TYPE: number;
  68335. /**
  68336. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68337. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68338. */
  68339. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68340. /**
  68341. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68342. * in order to compute objects velocities when enableVelocity is set to "true"
  68343. * @hidden
  68344. */
  68345. _previousTransformationMatrices: {
  68346. [index: number]: ISavedTransformationMatrix;
  68347. };
  68348. /**
  68349. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68350. * in order to compute objects velocities when enableVelocity is set to "true"
  68351. * @hidden
  68352. */
  68353. _previousBonesTransformationMatrices: {
  68354. [index: number]: Float32Array;
  68355. };
  68356. /**
  68357. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68358. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68359. */
  68360. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68361. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68362. renderTransparentMeshes: boolean;
  68363. private _scene;
  68364. private _multiRenderTarget;
  68365. private _ratio;
  68366. private _enablePosition;
  68367. private _enableVelocity;
  68368. private _enableReflectivity;
  68369. private _positionIndex;
  68370. private _velocityIndex;
  68371. private _reflectivityIndex;
  68372. protected _effect: Effect;
  68373. protected _cachedDefines: string;
  68374. /**
  68375. * Set the render list (meshes to be rendered) used in the G buffer.
  68376. */
  68377. set renderList(meshes: Mesh[]);
  68378. /**
  68379. * Gets wether or not G buffer are supported by the running hardware.
  68380. * This requires draw buffer supports
  68381. */
  68382. get isSupported(): boolean;
  68383. /**
  68384. * Returns the index of the given texture type in the G-Buffer textures array
  68385. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68386. * @returns the index of the given texture type in the G-Buffer textures array
  68387. */
  68388. getTextureIndex(textureType: number): number;
  68389. /**
  68390. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68391. */
  68392. get enablePosition(): boolean;
  68393. /**
  68394. * Sets whether or not objects positions are enabled for the G buffer.
  68395. */
  68396. set enablePosition(enable: boolean);
  68397. /**
  68398. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68399. */
  68400. get enableVelocity(): boolean;
  68401. /**
  68402. * Sets wether or not objects velocities are enabled for the G buffer.
  68403. */
  68404. set enableVelocity(enable: boolean);
  68405. /**
  68406. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68407. */
  68408. get enableReflectivity(): boolean;
  68409. /**
  68410. * Sets wether or not objects roughness are enabled for the G buffer.
  68411. */
  68412. set enableReflectivity(enable: boolean);
  68413. /**
  68414. * Gets the scene associated with the buffer.
  68415. */
  68416. get scene(): Scene;
  68417. /**
  68418. * Gets the ratio used by the buffer during its creation.
  68419. * How big is the buffer related to the main canvas.
  68420. */
  68421. get ratio(): number;
  68422. /** @hidden */
  68423. static _SceneComponentInitialization: (scene: Scene) => void;
  68424. /**
  68425. * Creates a new G Buffer for the scene
  68426. * @param scene The scene the buffer belongs to
  68427. * @param ratio How big is the buffer related to the main canvas.
  68428. */
  68429. constructor(scene: Scene, ratio?: number);
  68430. /**
  68431. * Checks wether everything is ready to render a submesh to the G buffer.
  68432. * @param subMesh the submesh to check readiness for
  68433. * @param useInstances is the mesh drawn using instance or not
  68434. * @returns true if ready otherwise false
  68435. */
  68436. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68437. /**
  68438. * Gets the current underlying G Buffer.
  68439. * @returns the buffer
  68440. */
  68441. getGBuffer(): MultiRenderTarget;
  68442. /**
  68443. * Gets the number of samples used to render the buffer (anti aliasing).
  68444. */
  68445. get samples(): number;
  68446. /**
  68447. * Sets the number of samples used to render the buffer (anti aliasing).
  68448. */
  68449. set samples(value: number);
  68450. /**
  68451. * Disposes the renderer and frees up associated resources.
  68452. */
  68453. dispose(): void;
  68454. protected _createRenderTargets(): void;
  68455. private _copyBonesTransformationMatrices;
  68456. }
  68457. }
  68458. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68459. import { Nullable } from "babylonjs/types";
  68460. import { Scene } from "babylonjs/scene";
  68461. import { ISceneComponent } from "babylonjs/sceneComponent";
  68462. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68463. module "babylonjs/scene" {
  68464. interface Scene {
  68465. /** @hidden (Backing field) */
  68466. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68467. /**
  68468. * Gets or Sets the current geometry buffer associated to the scene.
  68469. */
  68470. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68471. /**
  68472. * Enables a GeometryBufferRender and associates it with the scene
  68473. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68474. * @returns the GeometryBufferRenderer
  68475. */
  68476. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68477. /**
  68478. * Disables the GeometryBufferRender associated with the scene
  68479. */
  68480. disableGeometryBufferRenderer(): void;
  68481. }
  68482. }
  68483. /**
  68484. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68485. * in several rendering techniques.
  68486. */
  68487. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68488. /**
  68489. * The component name helpful to identify the component in the list of scene components.
  68490. */
  68491. readonly name: string;
  68492. /**
  68493. * The scene the component belongs to.
  68494. */
  68495. scene: Scene;
  68496. /**
  68497. * Creates a new instance of the component for the given scene
  68498. * @param scene Defines the scene to register the component in
  68499. */
  68500. constructor(scene: Scene);
  68501. /**
  68502. * Registers the component in a given scene
  68503. */
  68504. register(): void;
  68505. /**
  68506. * Rebuilds the elements related to this component in case of
  68507. * context lost for instance.
  68508. */
  68509. rebuild(): void;
  68510. /**
  68511. * Disposes the component and the associated ressources
  68512. */
  68513. dispose(): void;
  68514. private _gatherRenderTargets;
  68515. }
  68516. }
  68517. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68518. /** @hidden */
  68519. export var motionBlurPixelShader: {
  68520. name: string;
  68521. shader: string;
  68522. };
  68523. }
  68524. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68525. import { Nullable } from "babylonjs/types";
  68526. import { Camera } from "babylonjs/Cameras/camera";
  68527. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68528. import { Scene } from "babylonjs/scene";
  68529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68530. import "babylonjs/Animations/animatable";
  68531. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68532. import "babylonjs/Shaders/motionBlur.fragment";
  68533. import { Engine } from "babylonjs/Engines/engine";
  68534. /**
  68535. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68536. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68537. * As an example, all you have to do is to create the post-process:
  68538. * var mb = new BABYLON.MotionBlurPostProcess(
  68539. * 'mb', // The name of the effect.
  68540. * scene, // The scene containing the objects to blur according to their velocity.
  68541. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68542. * camera // The camera to apply the render pass to.
  68543. * );
  68544. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68545. */
  68546. export class MotionBlurPostProcess extends PostProcess {
  68547. /**
  68548. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68549. */
  68550. motionStrength: number;
  68551. /**
  68552. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68553. */
  68554. get motionBlurSamples(): number;
  68555. /**
  68556. * Sets the number of iterations to be used for motion blur quality
  68557. */
  68558. set motionBlurSamples(samples: number);
  68559. private _motionBlurSamples;
  68560. private _geometryBufferRenderer;
  68561. /**
  68562. * Creates a new instance MotionBlurPostProcess
  68563. * @param name The name of the effect.
  68564. * @param scene The scene containing the objects to blur according to their velocity.
  68565. * @param options The required width/height ratio to downsize to before computing the render pass.
  68566. * @param camera The camera to apply the render pass to.
  68567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68568. * @param engine The engine which the post process will be applied. (default: current engine)
  68569. * @param reusable If the post process can be reused on the same frame. (default: false)
  68570. * @param textureType Type of textures used when performing the post process. (default: 0)
  68571. * @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)
  68572. */
  68573. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68574. /**
  68575. * Excludes the given skinned mesh from computing bones velocities.
  68576. * 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.
  68577. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68578. */
  68579. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68580. /**
  68581. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68582. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68583. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68584. */
  68585. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68586. /**
  68587. * Disposes the post process.
  68588. * @param camera The camera to dispose the post process on.
  68589. */
  68590. dispose(camera?: Camera): void;
  68591. }
  68592. }
  68593. declare module "babylonjs/Shaders/refraction.fragment" {
  68594. /** @hidden */
  68595. export var refractionPixelShader: {
  68596. name: string;
  68597. shader: string;
  68598. };
  68599. }
  68600. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68601. import { Color3 } from "babylonjs/Maths/math.color";
  68602. import { Camera } from "babylonjs/Cameras/camera";
  68603. import { Texture } from "babylonjs/Materials/Textures/texture";
  68604. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68605. import { Engine } from "babylonjs/Engines/engine";
  68606. import "babylonjs/Shaders/refraction.fragment";
  68607. /**
  68608. * Post process which applies a refractin texture
  68609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68610. */
  68611. export class RefractionPostProcess extends PostProcess {
  68612. /** the base color of the refraction (used to taint the rendering) */
  68613. color: Color3;
  68614. /** simulated refraction depth */
  68615. depth: number;
  68616. /** the coefficient of the base color (0 to remove base color tainting) */
  68617. colorLevel: number;
  68618. private _refTexture;
  68619. private _ownRefractionTexture;
  68620. /**
  68621. * Gets or sets the refraction texture
  68622. * Please note that you are responsible for disposing the texture if you set it manually
  68623. */
  68624. get refractionTexture(): Texture;
  68625. set refractionTexture(value: Texture);
  68626. /**
  68627. * Initializes the RefractionPostProcess
  68628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68629. * @param name The name of the effect.
  68630. * @param refractionTextureUrl Url of the refraction texture to use
  68631. * @param color the base color of the refraction (used to taint the rendering)
  68632. * @param depth simulated refraction depth
  68633. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68634. * @param camera The camera to apply the render pass to.
  68635. * @param options The required width/height ratio to downsize to before computing the render pass.
  68636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68637. * @param engine The engine which the post process will be applied. (default: current engine)
  68638. * @param reusable If the post process can be reused on the same frame. (default: false)
  68639. */
  68640. constructor(name: string, refractionTextureUrl: string,
  68641. /** the base color of the refraction (used to taint the rendering) */
  68642. color: Color3,
  68643. /** simulated refraction depth */
  68644. depth: number,
  68645. /** the coefficient of the base color (0 to remove base color tainting) */
  68646. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68647. /**
  68648. * Disposes of the post process
  68649. * @param camera Camera to dispose post process on
  68650. */
  68651. dispose(camera: Camera): void;
  68652. }
  68653. }
  68654. declare module "babylonjs/Shaders/sharpen.fragment" {
  68655. /** @hidden */
  68656. export var sharpenPixelShader: {
  68657. name: string;
  68658. shader: string;
  68659. };
  68660. }
  68661. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68662. import { Nullable } from "babylonjs/types";
  68663. import { Camera } from "babylonjs/Cameras/camera";
  68664. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68665. import "babylonjs/Shaders/sharpen.fragment";
  68666. import { Engine } from "babylonjs/Engines/engine";
  68667. /**
  68668. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68669. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68670. */
  68671. export class SharpenPostProcess extends PostProcess {
  68672. /**
  68673. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68674. */
  68675. colorAmount: number;
  68676. /**
  68677. * How much sharpness should be applied (default: 0.3)
  68678. */
  68679. edgeAmount: number;
  68680. /**
  68681. * Creates a new instance ConvolutionPostProcess
  68682. * @param name The name of the effect.
  68683. * @param options The required width/height ratio to downsize to before computing the render pass.
  68684. * @param camera The camera to apply the render pass to.
  68685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68686. * @param engine The engine which the post process will be applied. (default: current engine)
  68687. * @param reusable If the post process can be reused on the same frame. (default: false)
  68688. * @param textureType Type of textures used when performing the post process. (default: 0)
  68689. * @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)
  68690. */
  68691. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68692. }
  68693. }
  68694. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68695. import { Nullable } from "babylonjs/types";
  68696. import { Camera } from "babylonjs/Cameras/camera";
  68697. import { Engine } from "babylonjs/Engines/engine";
  68698. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68699. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68700. /**
  68701. * PostProcessRenderPipeline
  68702. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68703. */
  68704. export class PostProcessRenderPipeline {
  68705. private engine;
  68706. private _renderEffects;
  68707. private _renderEffectsForIsolatedPass;
  68708. /**
  68709. * List of inspectable custom properties (used by the Inspector)
  68710. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68711. */
  68712. inspectableCustomProperties: IInspectable[];
  68713. /**
  68714. * @hidden
  68715. */
  68716. protected _cameras: Camera[];
  68717. /** @hidden */
  68718. _name: string;
  68719. /**
  68720. * Gets pipeline name
  68721. */
  68722. get name(): string;
  68723. /** Gets the list of attached cameras */
  68724. get cameras(): Camera[];
  68725. /**
  68726. * Initializes a PostProcessRenderPipeline
  68727. * @param engine engine to add the pipeline to
  68728. * @param name name of the pipeline
  68729. */
  68730. constructor(engine: Engine, name: string);
  68731. /**
  68732. * Gets the class name
  68733. * @returns "PostProcessRenderPipeline"
  68734. */
  68735. getClassName(): string;
  68736. /**
  68737. * If all the render effects in the pipeline are supported
  68738. */
  68739. get isSupported(): boolean;
  68740. /**
  68741. * Adds an effect to the pipeline
  68742. * @param renderEffect the effect to add
  68743. */
  68744. addEffect(renderEffect: PostProcessRenderEffect): void;
  68745. /** @hidden */
  68746. _rebuild(): void;
  68747. /** @hidden */
  68748. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68749. /** @hidden */
  68750. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68751. /** @hidden */
  68752. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68753. /** @hidden */
  68754. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68755. /** @hidden */
  68756. _attachCameras(cameras: Camera, unique: boolean): void;
  68757. /** @hidden */
  68758. _attachCameras(cameras: Camera[], unique: boolean): void;
  68759. /** @hidden */
  68760. _detachCameras(cameras: Camera): void;
  68761. /** @hidden */
  68762. _detachCameras(cameras: Nullable<Camera[]>): void;
  68763. /** @hidden */
  68764. _update(): void;
  68765. /** @hidden */
  68766. _reset(): void;
  68767. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68768. /**
  68769. * Disposes of the pipeline
  68770. */
  68771. dispose(): void;
  68772. }
  68773. }
  68774. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68775. import { Camera } from "babylonjs/Cameras/camera";
  68776. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68777. /**
  68778. * PostProcessRenderPipelineManager class
  68779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68780. */
  68781. export class PostProcessRenderPipelineManager {
  68782. private _renderPipelines;
  68783. /**
  68784. * Initializes a PostProcessRenderPipelineManager
  68785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68786. */
  68787. constructor();
  68788. /**
  68789. * Gets the list of supported render pipelines
  68790. */
  68791. get supportedPipelines(): PostProcessRenderPipeline[];
  68792. /**
  68793. * Adds a pipeline to the manager
  68794. * @param renderPipeline The pipeline to add
  68795. */
  68796. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68797. /**
  68798. * Attaches a camera to the pipeline
  68799. * @param renderPipelineName The name of the pipeline to attach to
  68800. * @param cameras the camera to attach
  68801. * @param unique if the camera can be attached multiple times to the pipeline
  68802. */
  68803. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68804. /**
  68805. * Detaches a camera from the pipeline
  68806. * @param renderPipelineName The name of the pipeline to detach from
  68807. * @param cameras the camera to detach
  68808. */
  68809. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68810. /**
  68811. * Enables an effect by name on a pipeline
  68812. * @param renderPipelineName the name of the pipeline to enable the effect in
  68813. * @param renderEffectName the name of the effect to enable
  68814. * @param cameras the cameras that the effect should be enabled on
  68815. */
  68816. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68817. /**
  68818. * Disables an effect by name on a pipeline
  68819. * @param renderPipelineName the name of the pipeline to disable the effect in
  68820. * @param renderEffectName the name of the effect to disable
  68821. * @param cameras the cameras that the effect should be disabled on
  68822. */
  68823. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68824. /**
  68825. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68826. */
  68827. update(): void;
  68828. /** @hidden */
  68829. _rebuild(): void;
  68830. /**
  68831. * Disposes of the manager and pipelines
  68832. */
  68833. dispose(): void;
  68834. }
  68835. }
  68836. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68837. import { ISceneComponent } from "babylonjs/sceneComponent";
  68838. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68839. import { Scene } from "babylonjs/scene";
  68840. module "babylonjs/scene" {
  68841. interface Scene {
  68842. /** @hidden (Backing field) */
  68843. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68844. /**
  68845. * Gets the postprocess render pipeline manager
  68846. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68847. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68848. */
  68849. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68850. }
  68851. }
  68852. /**
  68853. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68854. */
  68855. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68856. /**
  68857. * The component name helpfull to identify the component in the list of scene components.
  68858. */
  68859. readonly name: string;
  68860. /**
  68861. * The scene the component belongs to.
  68862. */
  68863. scene: Scene;
  68864. /**
  68865. * Creates a new instance of the component for the given scene
  68866. * @param scene Defines the scene to register the component in
  68867. */
  68868. constructor(scene: Scene);
  68869. /**
  68870. * Registers the component in a given scene
  68871. */
  68872. register(): void;
  68873. /**
  68874. * Rebuilds the elements related to this component in case of
  68875. * context lost for instance.
  68876. */
  68877. rebuild(): void;
  68878. /**
  68879. * Disposes the component and the associated ressources
  68880. */
  68881. dispose(): void;
  68882. private _gatherRenderTargets;
  68883. }
  68884. }
  68885. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68886. import { Nullable } from "babylonjs/types";
  68887. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68888. import { Camera } from "babylonjs/Cameras/camera";
  68889. import { IDisposable } from "babylonjs/scene";
  68890. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68891. import { Scene } from "babylonjs/scene";
  68892. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68893. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68894. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68895. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68896. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68897. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68898. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68899. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68900. import { Animation } from "babylonjs/Animations/animation";
  68901. /**
  68902. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68903. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68904. */
  68905. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68906. private _scene;
  68907. private _camerasToBeAttached;
  68908. /**
  68909. * ID of the sharpen post process,
  68910. */
  68911. private readonly SharpenPostProcessId;
  68912. /**
  68913. * @ignore
  68914. * ID of the image processing post process;
  68915. */
  68916. readonly ImageProcessingPostProcessId: string;
  68917. /**
  68918. * @ignore
  68919. * ID of the Fast Approximate Anti-Aliasing post process;
  68920. */
  68921. readonly FxaaPostProcessId: string;
  68922. /**
  68923. * ID of the chromatic aberration post process,
  68924. */
  68925. private readonly ChromaticAberrationPostProcessId;
  68926. /**
  68927. * ID of the grain post process
  68928. */
  68929. private readonly GrainPostProcessId;
  68930. /**
  68931. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68932. */
  68933. sharpen: SharpenPostProcess;
  68934. private _sharpenEffect;
  68935. private bloom;
  68936. /**
  68937. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68938. */
  68939. depthOfField: DepthOfFieldEffect;
  68940. /**
  68941. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68942. */
  68943. fxaa: FxaaPostProcess;
  68944. /**
  68945. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68946. */
  68947. imageProcessing: ImageProcessingPostProcess;
  68948. /**
  68949. * Chromatic aberration post process which will shift rgb colors in the image
  68950. */
  68951. chromaticAberration: ChromaticAberrationPostProcess;
  68952. private _chromaticAberrationEffect;
  68953. /**
  68954. * Grain post process which add noise to the image
  68955. */
  68956. grain: GrainPostProcess;
  68957. private _grainEffect;
  68958. /**
  68959. * Glow post process which adds a glow to emissive areas of the image
  68960. */
  68961. private _glowLayer;
  68962. /**
  68963. * Animations which can be used to tweak settings over a period of time
  68964. */
  68965. animations: Animation[];
  68966. private _imageProcessingConfigurationObserver;
  68967. private _sharpenEnabled;
  68968. private _bloomEnabled;
  68969. private _depthOfFieldEnabled;
  68970. private _depthOfFieldBlurLevel;
  68971. private _fxaaEnabled;
  68972. private _imageProcessingEnabled;
  68973. private _defaultPipelineTextureType;
  68974. private _bloomScale;
  68975. private _chromaticAberrationEnabled;
  68976. private _grainEnabled;
  68977. private _buildAllowed;
  68978. /**
  68979. * Gets active scene
  68980. */
  68981. get scene(): Scene;
  68982. /**
  68983. * Enable or disable the sharpen process from the pipeline
  68984. */
  68985. set sharpenEnabled(enabled: boolean);
  68986. get sharpenEnabled(): boolean;
  68987. private _resizeObserver;
  68988. private _hardwareScaleLevel;
  68989. private _bloomKernel;
  68990. /**
  68991. * Specifies the size of the bloom blur kernel, relative to the final output size
  68992. */
  68993. get bloomKernel(): number;
  68994. set bloomKernel(value: number);
  68995. /**
  68996. * Specifies the weight of the bloom in the final rendering
  68997. */
  68998. private _bloomWeight;
  68999. /**
  69000. * Specifies the luma threshold for the area that will be blurred by the bloom
  69001. */
  69002. private _bloomThreshold;
  69003. private _hdr;
  69004. /**
  69005. * The strength of the bloom.
  69006. */
  69007. set bloomWeight(value: number);
  69008. get bloomWeight(): number;
  69009. /**
  69010. * The strength of the bloom.
  69011. */
  69012. set bloomThreshold(value: number);
  69013. get bloomThreshold(): number;
  69014. /**
  69015. * The scale of the bloom, lower value will provide better performance.
  69016. */
  69017. set bloomScale(value: number);
  69018. get bloomScale(): number;
  69019. /**
  69020. * Enable or disable the bloom from the pipeline
  69021. */
  69022. set bloomEnabled(enabled: boolean);
  69023. get bloomEnabled(): boolean;
  69024. private _rebuildBloom;
  69025. /**
  69026. * If the depth of field is enabled.
  69027. */
  69028. get depthOfFieldEnabled(): boolean;
  69029. set depthOfFieldEnabled(enabled: boolean);
  69030. /**
  69031. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69032. */
  69033. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69034. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69035. /**
  69036. * If the anti aliasing is enabled.
  69037. */
  69038. set fxaaEnabled(enabled: boolean);
  69039. get fxaaEnabled(): boolean;
  69040. private _samples;
  69041. /**
  69042. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69043. */
  69044. set samples(sampleCount: number);
  69045. get samples(): number;
  69046. /**
  69047. * If image processing is enabled.
  69048. */
  69049. set imageProcessingEnabled(enabled: boolean);
  69050. get imageProcessingEnabled(): boolean;
  69051. /**
  69052. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69053. */
  69054. set glowLayerEnabled(enabled: boolean);
  69055. get glowLayerEnabled(): boolean;
  69056. /**
  69057. * Gets the glow layer (or null if not defined)
  69058. */
  69059. get glowLayer(): Nullable<GlowLayer>;
  69060. /**
  69061. * Enable or disable the chromaticAberration process from the pipeline
  69062. */
  69063. set chromaticAberrationEnabled(enabled: boolean);
  69064. get chromaticAberrationEnabled(): boolean;
  69065. /**
  69066. * Enable or disable the grain process from the pipeline
  69067. */
  69068. set grainEnabled(enabled: boolean);
  69069. get grainEnabled(): boolean;
  69070. /**
  69071. * @constructor
  69072. * @param name - The rendering pipeline name (default: "")
  69073. * @param hdr - If high dynamic range textures should be used (default: true)
  69074. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69075. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69076. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69077. */
  69078. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69079. /**
  69080. * Get the class name
  69081. * @returns "DefaultRenderingPipeline"
  69082. */
  69083. getClassName(): string;
  69084. /**
  69085. * Force the compilation of the entire pipeline.
  69086. */
  69087. prepare(): void;
  69088. private _hasCleared;
  69089. private _prevPostProcess;
  69090. private _prevPrevPostProcess;
  69091. private _setAutoClearAndTextureSharing;
  69092. private _depthOfFieldSceneObserver;
  69093. private _buildPipeline;
  69094. private _disposePostProcesses;
  69095. /**
  69096. * Adds a camera to the pipeline
  69097. * @param camera the camera to be added
  69098. */
  69099. addCamera(camera: Camera): void;
  69100. /**
  69101. * Removes a camera from the pipeline
  69102. * @param camera the camera to remove
  69103. */
  69104. removeCamera(camera: Camera): void;
  69105. /**
  69106. * Dispose of the pipeline and stop all post processes
  69107. */
  69108. dispose(): void;
  69109. /**
  69110. * Serialize the rendering pipeline (Used when exporting)
  69111. * @returns the serialized object
  69112. */
  69113. serialize(): any;
  69114. /**
  69115. * Parse the serialized pipeline
  69116. * @param source Source pipeline.
  69117. * @param scene The scene to load the pipeline to.
  69118. * @param rootUrl The URL of the serialized pipeline.
  69119. * @returns An instantiated pipeline from the serialized object.
  69120. */
  69121. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69122. }
  69123. }
  69124. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69125. /** @hidden */
  69126. export var lensHighlightsPixelShader: {
  69127. name: string;
  69128. shader: string;
  69129. };
  69130. }
  69131. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69132. /** @hidden */
  69133. export var depthOfFieldPixelShader: {
  69134. name: string;
  69135. shader: string;
  69136. };
  69137. }
  69138. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69139. import { Camera } from "babylonjs/Cameras/camera";
  69140. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69141. import { Scene } from "babylonjs/scene";
  69142. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69143. import "babylonjs/Shaders/chromaticAberration.fragment";
  69144. import "babylonjs/Shaders/lensHighlights.fragment";
  69145. import "babylonjs/Shaders/depthOfField.fragment";
  69146. /**
  69147. * BABYLON.JS Chromatic Aberration GLSL Shader
  69148. * Author: Olivier Guyot
  69149. * Separates very slightly R, G and B colors on the edges of the screen
  69150. * Inspired by Francois Tarlier & Martins Upitis
  69151. */
  69152. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69153. /**
  69154. * @ignore
  69155. * The chromatic aberration PostProcess id in the pipeline
  69156. */
  69157. LensChromaticAberrationEffect: string;
  69158. /**
  69159. * @ignore
  69160. * The highlights enhancing PostProcess id in the pipeline
  69161. */
  69162. HighlightsEnhancingEffect: string;
  69163. /**
  69164. * @ignore
  69165. * The depth-of-field PostProcess id in the pipeline
  69166. */
  69167. LensDepthOfFieldEffect: string;
  69168. private _scene;
  69169. private _depthTexture;
  69170. private _grainTexture;
  69171. private _chromaticAberrationPostProcess;
  69172. private _highlightsPostProcess;
  69173. private _depthOfFieldPostProcess;
  69174. private _edgeBlur;
  69175. private _grainAmount;
  69176. private _chromaticAberration;
  69177. private _distortion;
  69178. private _highlightsGain;
  69179. private _highlightsThreshold;
  69180. private _dofDistance;
  69181. private _dofAperture;
  69182. private _dofDarken;
  69183. private _dofPentagon;
  69184. private _blurNoise;
  69185. /**
  69186. * @constructor
  69187. *
  69188. * Effect parameters are as follow:
  69189. * {
  69190. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69191. * edge_blur: number; // from 0 to x (1 for realism)
  69192. * distortion: number; // from 0 to x (1 for realism)
  69193. * grain_amount: number; // from 0 to 1
  69194. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69195. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69196. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69197. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69198. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69199. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69200. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69201. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69202. * }
  69203. * Note: if an effect parameter is unset, effect is disabled
  69204. *
  69205. * @param name The rendering pipeline name
  69206. * @param parameters - An object containing all parameters (see above)
  69207. * @param scene The scene linked to this pipeline
  69208. * @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)
  69209. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69210. */
  69211. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69212. /**
  69213. * Get the class name
  69214. * @returns "LensRenderingPipeline"
  69215. */
  69216. getClassName(): string;
  69217. /**
  69218. * Gets associated scene
  69219. */
  69220. get scene(): Scene;
  69221. /**
  69222. * Gets or sets the edge blur
  69223. */
  69224. get edgeBlur(): number;
  69225. set edgeBlur(value: number);
  69226. /**
  69227. * Gets or sets the grain amount
  69228. */
  69229. get grainAmount(): number;
  69230. set grainAmount(value: number);
  69231. /**
  69232. * Gets or sets the chromatic aberration amount
  69233. */
  69234. get chromaticAberration(): number;
  69235. set chromaticAberration(value: number);
  69236. /**
  69237. * Gets or sets the depth of field aperture
  69238. */
  69239. get dofAperture(): number;
  69240. set dofAperture(value: number);
  69241. /**
  69242. * Gets or sets the edge distortion
  69243. */
  69244. get edgeDistortion(): number;
  69245. set edgeDistortion(value: number);
  69246. /**
  69247. * Gets or sets the depth of field distortion
  69248. */
  69249. get dofDistortion(): number;
  69250. set dofDistortion(value: number);
  69251. /**
  69252. * Gets or sets the darken out of focus amount
  69253. */
  69254. get darkenOutOfFocus(): number;
  69255. set darkenOutOfFocus(value: number);
  69256. /**
  69257. * Gets or sets a boolean indicating if blur noise is enabled
  69258. */
  69259. get blurNoise(): boolean;
  69260. set blurNoise(value: boolean);
  69261. /**
  69262. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69263. */
  69264. get pentagonBokeh(): boolean;
  69265. set pentagonBokeh(value: boolean);
  69266. /**
  69267. * Gets or sets the highlight grain amount
  69268. */
  69269. get highlightsGain(): number;
  69270. set highlightsGain(value: number);
  69271. /**
  69272. * Gets or sets the highlight threshold
  69273. */
  69274. get highlightsThreshold(): number;
  69275. set highlightsThreshold(value: number);
  69276. /**
  69277. * Sets the amount of blur at the edges
  69278. * @param amount blur amount
  69279. */
  69280. setEdgeBlur(amount: number): void;
  69281. /**
  69282. * Sets edge blur to 0
  69283. */
  69284. disableEdgeBlur(): void;
  69285. /**
  69286. * Sets the amout of grain
  69287. * @param amount Amount of grain
  69288. */
  69289. setGrainAmount(amount: number): void;
  69290. /**
  69291. * Set grain amount to 0
  69292. */
  69293. disableGrain(): void;
  69294. /**
  69295. * Sets the chromatic aberration amount
  69296. * @param amount amount of chromatic aberration
  69297. */
  69298. setChromaticAberration(amount: number): void;
  69299. /**
  69300. * Sets chromatic aberration amount to 0
  69301. */
  69302. disableChromaticAberration(): void;
  69303. /**
  69304. * Sets the EdgeDistortion amount
  69305. * @param amount amount of EdgeDistortion
  69306. */
  69307. setEdgeDistortion(amount: number): void;
  69308. /**
  69309. * Sets edge distortion to 0
  69310. */
  69311. disableEdgeDistortion(): void;
  69312. /**
  69313. * Sets the FocusDistance amount
  69314. * @param amount amount of FocusDistance
  69315. */
  69316. setFocusDistance(amount: number): void;
  69317. /**
  69318. * Disables depth of field
  69319. */
  69320. disableDepthOfField(): void;
  69321. /**
  69322. * Sets the Aperture amount
  69323. * @param amount amount of Aperture
  69324. */
  69325. setAperture(amount: number): void;
  69326. /**
  69327. * Sets the DarkenOutOfFocus amount
  69328. * @param amount amount of DarkenOutOfFocus
  69329. */
  69330. setDarkenOutOfFocus(amount: number): void;
  69331. private _pentagonBokehIsEnabled;
  69332. /**
  69333. * Creates a pentagon bokeh effect
  69334. */
  69335. enablePentagonBokeh(): void;
  69336. /**
  69337. * Disables the pentagon bokeh effect
  69338. */
  69339. disablePentagonBokeh(): void;
  69340. /**
  69341. * Enables noise blur
  69342. */
  69343. enableNoiseBlur(): void;
  69344. /**
  69345. * Disables noise blur
  69346. */
  69347. disableNoiseBlur(): void;
  69348. /**
  69349. * Sets the HighlightsGain amount
  69350. * @param amount amount of HighlightsGain
  69351. */
  69352. setHighlightsGain(amount: number): void;
  69353. /**
  69354. * Sets the HighlightsThreshold amount
  69355. * @param amount amount of HighlightsThreshold
  69356. */
  69357. setHighlightsThreshold(amount: number): void;
  69358. /**
  69359. * Disables highlights
  69360. */
  69361. disableHighlights(): void;
  69362. /**
  69363. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69364. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69365. */
  69366. dispose(disableDepthRender?: boolean): void;
  69367. private _createChromaticAberrationPostProcess;
  69368. private _createHighlightsPostProcess;
  69369. private _createDepthOfFieldPostProcess;
  69370. private _createGrainTexture;
  69371. }
  69372. }
  69373. declare module "babylonjs/Shaders/ssao2.fragment" {
  69374. /** @hidden */
  69375. export var ssao2PixelShader: {
  69376. name: string;
  69377. shader: string;
  69378. };
  69379. }
  69380. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69381. /** @hidden */
  69382. export var ssaoCombinePixelShader: {
  69383. name: string;
  69384. shader: string;
  69385. };
  69386. }
  69387. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69388. import { Camera } from "babylonjs/Cameras/camera";
  69389. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69390. import { Scene } from "babylonjs/scene";
  69391. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69392. import "babylonjs/Shaders/ssao2.fragment";
  69393. import "babylonjs/Shaders/ssaoCombine.fragment";
  69394. /**
  69395. * Render pipeline to produce ssao effect
  69396. */
  69397. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69398. /**
  69399. * @ignore
  69400. * The PassPostProcess id in the pipeline that contains the original scene color
  69401. */
  69402. SSAOOriginalSceneColorEffect: string;
  69403. /**
  69404. * @ignore
  69405. * The SSAO PostProcess id in the pipeline
  69406. */
  69407. SSAORenderEffect: string;
  69408. /**
  69409. * @ignore
  69410. * The horizontal blur PostProcess id in the pipeline
  69411. */
  69412. SSAOBlurHRenderEffect: string;
  69413. /**
  69414. * @ignore
  69415. * The vertical blur PostProcess id in the pipeline
  69416. */
  69417. SSAOBlurVRenderEffect: string;
  69418. /**
  69419. * @ignore
  69420. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69421. */
  69422. SSAOCombineRenderEffect: string;
  69423. /**
  69424. * The output strength of the SSAO post-process. Default value is 1.0.
  69425. */
  69426. totalStrength: number;
  69427. /**
  69428. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69429. */
  69430. maxZ: number;
  69431. /**
  69432. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69433. */
  69434. minZAspect: number;
  69435. private _samples;
  69436. /**
  69437. * Number of samples used for the SSAO calculations. Default value is 8
  69438. */
  69439. set samples(n: number);
  69440. get samples(): number;
  69441. private _textureSamples;
  69442. /**
  69443. * Number of samples to use for antialiasing
  69444. */
  69445. set textureSamples(n: number);
  69446. get textureSamples(): number;
  69447. /**
  69448. * Ratio object used for SSAO ratio and blur ratio
  69449. */
  69450. private _ratio;
  69451. /**
  69452. * Dynamically generated sphere sampler.
  69453. */
  69454. private _sampleSphere;
  69455. /**
  69456. * Blur filter offsets
  69457. */
  69458. private _samplerOffsets;
  69459. private _expensiveBlur;
  69460. /**
  69461. * If bilateral blur should be used
  69462. */
  69463. set expensiveBlur(b: boolean);
  69464. get expensiveBlur(): boolean;
  69465. /**
  69466. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69467. */
  69468. radius: number;
  69469. /**
  69470. * The base color of the SSAO post-process
  69471. * The final result is "base + ssao" between [0, 1]
  69472. */
  69473. base: number;
  69474. /**
  69475. * Support test.
  69476. */
  69477. static get IsSupported(): boolean;
  69478. private _scene;
  69479. private _depthTexture;
  69480. private _normalTexture;
  69481. private _randomTexture;
  69482. private _originalColorPostProcess;
  69483. private _ssaoPostProcess;
  69484. private _blurHPostProcess;
  69485. private _blurVPostProcess;
  69486. private _ssaoCombinePostProcess;
  69487. /**
  69488. * Gets active scene
  69489. */
  69490. get scene(): Scene;
  69491. /**
  69492. * @constructor
  69493. * @param name The rendering pipeline name
  69494. * @param scene The scene linked to this pipeline
  69495. * @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 }
  69496. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69497. */
  69498. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69499. /**
  69500. * Get the class name
  69501. * @returns "SSAO2RenderingPipeline"
  69502. */
  69503. getClassName(): string;
  69504. /**
  69505. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69506. */
  69507. dispose(disableGeometryBufferRenderer?: boolean): void;
  69508. private _createBlurPostProcess;
  69509. /** @hidden */
  69510. _rebuild(): void;
  69511. private _bits;
  69512. private _radicalInverse_VdC;
  69513. private _hammersley;
  69514. private _hemisphereSample_uniform;
  69515. private _generateHemisphere;
  69516. private _createSSAOPostProcess;
  69517. private _createSSAOCombinePostProcess;
  69518. private _createRandomTexture;
  69519. /**
  69520. * Serialize the rendering pipeline (Used when exporting)
  69521. * @returns the serialized object
  69522. */
  69523. serialize(): any;
  69524. /**
  69525. * Parse the serialized pipeline
  69526. * @param source Source pipeline.
  69527. * @param scene The scene to load the pipeline to.
  69528. * @param rootUrl The URL of the serialized pipeline.
  69529. * @returns An instantiated pipeline from the serialized object.
  69530. */
  69531. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69532. }
  69533. }
  69534. declare module "babylonjs/Shaders/ssao.fragment" {
  69535. /** @hidden */
  69536. export var ssaoPixelShader: {
  69537. name: string;
  69538. shader: string;
  69539. };
  69540. }
  69541. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69542. import { Camera } from "babylonjs/Cameras/camera";
  69543. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69544. import { Scene } from "babylonjs/scene";
  69545. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69546. import "babylonjs/Shaders/ssao.fragment";
  69547. import "babylonjs/Shaders/ssaoCombine.fragment";
  69548. /**
  69549. * Render pipeline to produce ssao effect
  69550. */
  69551. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69552. /**
  69553. * @ignore
  69554. * The PassPostProcess id in the pipeline that contains the original scene color
  69555. */
  69556. SSAOOriginalSceneColorEffect: string;
  69557. /**
  69558. * @ignore
  69559. * The SSAO PostProcess id in the pipeline
  69560. */
  69561. SSAORenderEffect: string;
  69562. /**
  69563. * @ignore
  69564. * The horizontal blur PostProcess id in the pipeline
  69565. */
  69566. SSAOBlurHRenderEffect: string;
  69567. /**
  69568. * @ignore
  69569. * The vertical blur PostProcess id in the pipeline
  69570. */
  69571. SSAOBlurVRenderEffect: string;
  69572. /**
  69573. * @ignore
  69574. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69575. */
  69576. SSAOCombineRenderEffect: string;
  69577. /**
  69578. * The output strength of the SSAO post-process. Default value is 1.0.
  69579. */
  69580. totalStrength: number;
  69581. /**
  69582. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69583. */
  69584. radius: number;
  69585. /**
  69586. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69587. * Must not be equal to fallOff and superior to fallOff.
  69588. * Default value is 0.0075
  69589. */
  69590. area: number;
  69591. /**
  69592. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69593. * Must not be equal to area and inferior to area.
  69594. * Default value is 0.000001
  69595. */
  69596. fallOff: number;
  69597. /**
  69598. * The base color of the SSAO post-process
  69599. * The final result is "base + ssao" between [0, 1]
  69600. */
  69601. base: number;
  69602. private _scene;
  69603. private _depthTexture;
  69604. private _randomTexture;
  69605. private _originalColorPostProcess;
  69606. private _ssaoPostProcess;
  69607. private _blurHPostProcess;
  69608. private _blurVPostProcess;
  69609. private _ssaoCombinePostProcess;
  69610. private _firstUpdate;
  69611. /**
  69612. * Gets active scene
  69613. */
  69614. get scene(): Scene;
  69615. /**
  69616. * @constructor
  69617. * @param name - The rendering pipeline name
  69618. * @param scene - The scene linked to this pipeline
  69619. * @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 }
  69620. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69621. */
  69622. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69623. /**
  69624. * Get the class name
  69625. * @returns "SSAORenderingPipeline"
  69626. */
  69627. getClassName(): string;
  69628. /**
  69629. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69630. */
  69631. dispose(disableDepthRender?: boolean): void;
  69632. private _createBlurPostProcess;
  69633. /** @hidden */
  69634. _rebuild(): void;
  69635. private _createSSAOPostProcess;
  69636. private _createSSAOCombinePostProcess;
  69637. private _createRandomTexture;
  69638. }
  69639. }
  69640. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69641. /** @hidden */
  69642. export var screenSpaceReflectionPixelShader: {
  69643. name: string;
  69644. shader: string;
  69645. };
  69646. }
  69647. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69648. import { Nullable } from "babylonjs/types";
  69649. import { Camera } from "babylonjs/Cameras/camera";
  69650. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69651. import { Scene } from "babylonjs/scene";
  69652. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69653. import { Engine } from "babylonjs/Engines/engine";
  69654. /**
  69655. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69656. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69657. */
  69658. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69659. /**
  69660. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69661. */
  69662. threshold: number;
  69663. /**
  69664. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69665. */
  69666. strength: number;
  69667. /**
  69668. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69669. */
  69670. reflectionSpecularFalloffExponent: number;
  69671. /**
  69672. * 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]
  69673. */
  69674. step: number;
  69675. /**
  69676. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69677. */
  69678. roughnessFactor: number;
  69679. private _geometryBufferRenderer;
  69680. private _enableSmoothReflections;
  69681. private _reflectionSamples;
  69682. private _smoothSteps;
  69683. /**
  69684. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69685. * @param name The name of the effect.
  69686. * @param scene The scene containing the objects to calculate reflections.
  69687. * @param options The required width/height ratio to downsize to before computing the render pass.
  69688. * @param camera The camera to apply the render pass to.
  69689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69690. * @param engine The engine which the post process will be applied. (default: current engine)
  69691. * @param reusable If the post process can be reused on the same frame. (default: false)
  69692. * @param textureType Type of textures used when performing the post process. (default: 0)
  69693. * @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)
  69694. */
  69695. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69696. /**
  69697. * Gets wether or not smoothing reflections is enabled.
  69698. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69699. */
  69700. get enableSmoothReflections(): boolean;
  69701. /**
  69702. * Sets wether or not smoothing reflections is enabled.
  69703. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69704. */
  69705. set enableSmoothReflections(enabled: boolean);
  69706. /**
  69707. * Gets the number of samples taken while computing reflections. More samples count is high,
  69708. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69709. */
  69710. get reflectionSamples(): number;
  69711. /**
  69712. * Sets the number of samples taken while computing reflections. More samples count is high,
  69713. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69714. */
  69715. set reflectionSamples(samples: number);
  69716. /**
  69717. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69718. * more the post-process will require GPU power and can generate a drop in FPS.
  69719. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69720. */
  69721. get smoothSteps(): number;
  69722. set smoothSteps(steps: number);
  69723. private _updateEffectDefines;
  69724. }
  69725. }
  69726. declare module "babylonjs/Shaders/standard.fragment" {
  69727. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69728. /** @hidden */
  69729. export var standardPixelShader: {
  69730. name: string;
  69731. shader: string;
  69732. };
  69733. }
  69734. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69735. import { Nullable } from "babylonjs/types";
  69736. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69737. import { Camera } from "babylonjs/Cameras/camera";
  69738. import { Texture } from "babylonjs/Materials/Textures/texture";
  69739. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69740. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69741. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69742. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69743. import { IDisposable } from "babylonjs/scene";
  69744. import { SpotLight } from "babylonjs/Lights/spotLight";
  69745. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69746. import { Scene } from "babylonjs/scene";
  69747. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69748. import { Animation } from "babylonjs/Animations/animation";
  69749. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69750. import "babylonjs/Shaders/standard.fragment";
  69751. /**
  69752. * Standard rendering pipeline
  69753. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69754. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69755. */
  69756. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69757. /**
  69758. * Public members
  69759. */
  69760. /**
  69761. * Post-process which contains the original scene color before the pipeline applies all the effects
  69762. */
  69763. originalPostProcess: Nullable<PostProcess>;
  69764. /**
  69765. * Post-process used to down scale an image x4
  69766. */
  69767. downSampleX4PostProcess: Nullable<PostProcess>;
  69768. /**
  69769. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69770. */
  69771. brightPassPostProcess: Nullable<PostProcess>;
  69772. /**
  69773. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69774. */
  69775. blurHPostProcesses: PostProcess[];
  69776. /**
  69777. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69778. */
  69779. blurVPostProcesses: PostProcess[];
  69780. /**
  69781. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69782. */
  69783. textureAdderPostProcess: Nullable<PostProcess>;
  69784. /**
  69785. * Post-process used to create volumetric lighting effect
  69786. */
  69787. volumetricLightPostProcess: Nullable<PostProcess>;
  69788. /**
  69789. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69790. */
  69791. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69792. /**
  69793. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69794. */
  69795. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69796. /**
  69797. * Post-process used to merge the volumetric light effect and the real scene color
  69798. */
  69799. volumetricLightMergePostProces: Nullable<PostProcess>;
  69800. /**
  69801. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69802. */
  69803. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69804. /**
  69805. * Base post-process used to calculate the average luminance of the final image for HDR
  69806. */
  69807. luminancePostProcess: Nullable<PostProcess>;
  69808. /**
  69809. * Post-processes used to create down sample post-processes in order to get
  69810. * the average luminance of the final image for HDR
  69811. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69812. */
  69813. luminanceDownSamplePostProcesses: PostProcess[];
  69814. /**
  69815. * Post-process used to create a HDR effect (light adaptation)
  69816. */
  69817. hdrPostProcess: Nullable<PostProcess>;
  69818. /**
  69819. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69820. */
  69821. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69822. /**
  69823. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69824. */
  69825. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69826. /**
  69827. * Post-process used to merge the final HDR post-process and the real scene color
  69828. */
  69829. hdrFinalPostProcess: Nullable<PostProcess>;
  69830. /**
  69831. * Post-process used to create a lens flare effect
  69832. */
  69833. lensFlarePostProcess: Nullable<PostProcess>;
  69834. /**
  69835. * Post-process that merges the result of the lens flare post-process and the real scene color
  69836. */
  69837. lensFlareComposePostProcess: Nullable<PostProcess>;
  69838. /**
  69839. * Post-process used to create a motion blur effect
  69840. */
  69841. motionBlurPostProcess: Nullable<PostProcess>;
  69842. /**
  69843. * Post-process used to create a depth of field effect
  69844. */
  69845. depthOfFieldPostProcess: Nullable<PostProcess>;
  69846. /**
  69847. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69848. */
  69849. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69850. /**
  69851. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69852. */
  69853. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69854. /**
  69855. * Represents the brightness threshold in order to configure the illuminated surfaces
  69856. */
  69857. brightThreshold: number;
  69858. /**
  69859. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69860. */
  69861. blurWidth: number;
  69862. /**
  69863. * Sets if the blur for highlighted surfaces must be only horizontal
  69864. */
  69865. horizontalBlur: boolean;
  69866. /**
  69867. * Gets the overall exposure used by the pipeline
  69868. */
  69869. get exposure(): number;
  69870. /**
  69871. * Sets the overall exposure used by the pipeline
  69872. */
  69873. set exposure(value: number);
  69874. /**
  69875. * Texture used typically to simulate "dirty" on camera lens
  69876. */
  69877. lensTexture: Nullable<Texture>;
  69878. /**
  69879. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69880. */
  69881. volumetricLightCoefficient: number;
  69882. /**
  69883. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69884. */
  69885. volumetricLightPower: number;
  69886. /**
  69887. * Used the set the blur intensity to smooth the volumetric lights
  69888. */
  69889. volumetricLightBlurScale: number;
  69890. /**
  69891. * Light (spot or directional) used to generate the volumetric lights rays
  69892. * The source light must have a shadow generate so the pipeline can get its
  69893. * depth map
  69894. */
  69895. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69896. /**
  69897. * For eye adaptation, represents the minimum luminance the eye can see
  69898. */
  69899. hdrMinimumLuminance: number;
  69900. /**
  69901. * For eye adaptation, represents the decrease luminance speed
  69902. */
  69903. hdrDecreaseRate: number;
  69904. /**
  69905. * For eye adaptation, represents the increase luminance speed
  69906. */
  69907. hdrIncreaseRate: number;
  69908. /**
  69909. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69910. */
  69911. get hdrAutoExposure(): boolean;
  69912. /**
  69913. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69914. */
  69915. set hdrAutoExposure(value: boolean);
  69916. /**
  69917. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69918. */
  69919. lensColorTexture: Nullable<Texture>;
  69920. /**
  69921. * The overall strengh for the lens flare effect
  69922. */
  69923. lensFlareStrength: number;
  69924. /**
  69925. * Dispersion coefficient for lens flare ghosts
  69926. */
  69927. lensFlareGhostDispersal: number;
  69928. /**
  69929. * Main lens flare halo width
  69930. */
  69931. lensFlareHaloWidth: number;
  69932. /**
  69933. * Based on the lens distortion effect, defines how much the lens flare result
  69934. * is distorted
  69935. */
  69936. lensFlareDistortionStrength: number;
  69937. /**
  69938. * Configures the blur intensity used for for lens flare (halo)
  69939. */
  69940. lensFlareBlurWidth: number;
  69941. /**
  69942. * Lens star texture must be used to simulate rays on the flares and is available
  69943. * in the documentation
  69944. */
  69945. lensStarTexture: Nullable<Texture>;
  69946. /**
  69947. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69948. * flare effect by taking account of the dirt texture
  69949. */
  69950. lensFlareDirtTexture: Nullable<Texture>;
  69951. /**
  69952. * Represents the focal length for the depth of field effect
  69953. */
  69954. depthOfFieldDistance: number;
  69955. /**
  69956. * Represents the blur intensity for the blurred part of the depth of field effect
  69957. */
  69958. depthOfFieldBlurWidth: number;
  69959. /**
  69960. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69961. */
  69962. get motionStrength(): number;
  69963. /**
  69964. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69965. */
  69966. set motionStrength(strength: number);
  69967. /**
  69968. * Gets wether or not the motion blur post-process is object based or screen based.
  69969. */
  69970. get objectBasedMotionBlur(): boolean;
  69971. /**
  69972. * Sets wether or not the motion blur post-process should be object based or screen based
  69973. */
  69974. set objectBasedMotionBlur(value: boolean);
  69975. /**
  69976. * List of animations for the pipeline (IAnimatable implementation)
  69977. */
  69978. animations: Animation[];
  69979. /**
  69980. * Private members
  69981. */
  69982. private _scene;
  69983. private _currentDepthOfFieldSource;
  69984. private _basePostProcess;
  69985. private _fixedExposure;
  69986. private _currentExposure;
  69987. private _hdrAutoExposure;
  69988. private _hdrCurrentLuminance;
  69989. private _motionStrength;
  69990. private _isObjectBasedMotionBlur;
  69991. private _floatTextureType;
  69992. private _camerasToBeAttached;
  69993. private _ratio;
  69994. private _bloomEnabled;
  69995. private _depthOfFieldEnabled;
  69996. private _vlsEnabled;
  69997. private _lensFlareEnabled;
  69998. private _hdrEnabled;
  69999. private _motionBlurEnabled;
  70000. private _fxaaEnabled;
  70001. private _screenSpaceReflectionsEnabled;
  70002. private _motionBlurSamples;
  70003. private _volumetricLightStepsCount;
  70004. private _samples;
  70005. /**
  70006. * @ignore
  70007. * Specifies if the bloom pipeline is enabled
  70008. */
  70009. get BloomEnabled(): boolean;
  70010. set BloomEnabled(enabled: boolean);
  70011. /**
  70012. * @ignore
  70013. * Specifies if the depth of field pipeline is enabed
  70014. */
  70015. get DepthOfFieldEnabled(): boolean;
  70016. set DepthOfFieldEnabled(enabled: boolean);
  70017. /**
  70018. * @ignore
  70019. * Specifies if the lens flare pipeline is enabed
  70020. */
  70021. get LensFlareEnabled(): boolean;
  70022. set LensFlareEnabled(enabled: boolean);
  70023. /**
  70024. * @ignore
  70025. * Specifies if the HDR pipeline is enabled
  70026. */
  70027. get HDREnabled(): boolean;
  70028. set HDREnabled(enabled: boolean);
  70029. /**
  70030. * @ignore
  70031. * Specifies if the volumetric lights scattering effect is enabled
  70032. */
  70033. get VLSEnabled(): boolean;
  70034. set VLSEnabled(enabled: boolean);
  70035. /**
  70036. * @ignore
  70037. * Specifies if the motion blur effect is enabled
  70038. */
  70039. get MotionBlurEnabled(): boolean;
  70040. set MotionBlurEnabled(enabled: boolean);
  70041. /**
  70042. * Specifies if anti-aliasing is enabled
  70043. */
  70044. get fxaaEnabled(): boolean;
  70045. set fxaaEnabled(enabled: boolean);
  70046. /**
  70047. * Specifies if screen space reflections are enabled.
  70048. */
  70049. get screenSpaceReflectionsEnabled(): boolean;
  70050. set screenSpaceReflectionsEnabled(enabled: boolean);
  70051. /**
  70052. * Specifies the number of steps used to calculate the volumetric lights
  70053. * Typically in interval [50, 200]
  70054. */
  70055. get volumetricLightStepsCount(): number;
  70056. set volumetricLightStepsCount(count: number);
  70057. /**
  70058. * Specifies the number of samples used for the motion blur effect
  70059. * Typically in interval [16, 64]
  70060. */
  70061. get motionBlurSamples(): number;
  70062. set motionBlurSamples(samples: number);
  70063. /**
  70064. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70065. */
  70066. get samples(): number;
  70067. set samples(sampleCount: number);
  70068. /**
  70069. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70070. * @constructor
  70071. * @param name The rendering pipeline name
  70072. * @param scene The scene linked to this pipeline
  70073. * @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)
  70074. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70075. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70076. */
  70077. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70078. private _buildPipeline;
  70079. private _createDownSampleX4PostProcess;
  70080. private _createBrightPassPostProcess;
  70081. private _createBlurPostProcesses;
  70082. private _createTextureAdderPostProcess;
  70083. private _createVolumetricLightPostProcess;
  70084. private _createLuminancePostProcesses;
  70085. private _createHdrPostProcess;
  70086. private _createLensFlarePostProcess;
  70087. private _createDepthOfFieldPostProcess;
  70088. private _createMotionBlurPostProcess;
  70089. private _getDepthTexture;
  70090. private _disposePostProcesses;
  70091. /**
  70092. * Dispose of the pipeline and stop all post processes
  70093. */
  70094. dispose(): void;
  70095. /**
  70096. * Serialize the rendering pipeline (Used when exporting)
  70097. * @returns the serialized object
  70098. */
  70099. serialize(): any;
  70100. /**
  70101. * Parse the serialized pipeline
  70102. * @param source Source pipeline.
  70103. * @param scene The scene to load the pipeline to.
  70104. * @param rootUrl The URL of the serialized pipeline.
  70105. * @returns An instantiated pipeline from the serialized object.
  70106. */
  70107. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70108. /**
  70109. * Luminance steps
  70110. */
  70111. static LuminanceSteps: number;
  70112. }
  70113. }
  70114. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70115. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70116. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70117. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70118. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70119. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70120. }
  70121. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70122. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70123. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70124. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70125. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70126. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70127. }
  70128. declare module "babylonjs/Shaders/tonemap.fragment" {
  70129. /** @hidden */
  70130. export var tonemapPixelShader: {
  70131. name: string;
  70132. shader: string;
  70133. };
  70134. }
  70135. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70136. import { Camera } from "babylonjs/Cameras/camera";
  70137. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70138. import "babylonjs/Shaders/tonemap.fragment";
  70139. import { Engine } from "babylonjs/Engines/engine";
  70140. /** Defines operator used for tonemapping */
  70141. export enum TonemappingOperator {
  70142. /** Hable */
  70143. Hable = 0,
  70144. /** Reinhard */
  70145. Reinhard = 1,
  70146. /** HejiDawson */
  70147. HejiDawson = 2,
  70148. /** Photographic */
  70149. Photographic = 3
  70150. }
  70151. /**
  70152. * Defines a post process to apply tone mapping
  70153. */
  70154. export class TonemapPostProcess extends PostProcess {
  70155. private _operator;
  70156. /** Defines the required exposure adjustement */
  70157. exposureAdjustment: number;
  70158. /**
  70159. * Creates a new TonemapPostProcess
  70160. * @param name defines the name of the postprocess
  70161. * @param _operator defines the operator to use
  70162. * @param exposureAdjustment defines the required exposure adjustement
  70163. * @param camera defines the camera to use (can be null)
  70164. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70165. * @param engine defines the hosting engine (can be ignore if camera is set)
  70166. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70167. */
  70168. constructor(name: string, _operator: TonemappingOperator,
  70169. /** Defines the required exposure adjustement */
  70170. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70171. }
  70172. }
  70173. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70174. /** @hidden */
  70175. export var volumetricLightScatteringPixelShader: {
  70176. name: string;
  70177. shader: string;
  70178. };
  70179. }
  70180. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70181. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70182. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70183. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70184. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70185. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70186. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70187. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70188. /** @hidden */
  70189. export var volumetricLightScatteringPassVertexShader: {
  70190. name: string;
  70191. shader: string;
  70192. };
  70193. }
  70194. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70195. /** @hidden */
  70196. export var volumetricLightScatteringPassPixelShader: {
  70197. name: string;
  70198. shader: string;
  70199. };
  70200. }
  70201. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70202. import { Vector3 } from "babylonjs/Maths/math.vector";
  70203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70204. import { Mesh } from "babylonjs/Meshes/mesh";
  70205. import { Camera } from "babylonjs/Cameras/camera";
  70206. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70207. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70208. import { Scene } from "babylonjs/scene";
  70209. import "babylonjs/Meshes/Builders/planeBuilder";
  70210. import "babylonjs/Shaders/depth.vertex";
  70211. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70212. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70213. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70214. import { Engine } from "babylonjs/Engines/engine";
  70215. /**
  70216. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70217. */
  70218. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70219. private _volumetricLightScatteringPass;
  70220. private _volumetricLightScatteringRTT;
  70221. private _viewPort;
  70222. private _screenCoordinates;
  70223. private _cachedDefines;
  70224. /**
  70225. * If not undefined, the mesh position is computed from the attached node position
  70226. */
  70227. attachedNode: {
  70228. position: Vector3;
  70229. };
  70230. /**
  70231. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70232. */
  70233. customMeshPosition: Vector3;
  70234. /**
  70235. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70236. */
  70237. useCustomMeshPosition: boolean;
  70238. /**
  70239. * If the post-process should inverse the light scattering direction
  70240. */
  70241. invert: boolean;
  70242. /**
  70243. * The internal mesh used by the post-process
  70244. */
  70245. mesh: Mesh;
  70246. /**
  70247. * @hidden
  70248. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70249. */
  70250. get useDiffuseColor(): boolean;
  70251. set useDiffuseColor(useDiffuseColor: boolean);
  70252. /**
  70253. * Array containing the excluded meshes not rendered in the internal pass
  70254. */
  70255. excludedMeshes: AbstractMesh[];
  70256. /**
  70257. * Controls the overall intensity of the post-process
  70258. */
  70259. exposure: number;
  70260. /**
  70261. * Dissipates each sample's contribution in range [0, 1]
  70262. */
  70263. decay: number;
  70264. /**
  70265. * Controls the overall intensity of each sample
  70266. */
  70267. weight: number;
  70268. /**
  70269. * Controls the density of each sample
  70270. */
  70271. density: number;
  70272. /**
  70273. * @constructor
  70274. * @param name The post-process name
  70275. * @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)
  70276. * @param camera The camera that the post-process will be attached to
  70277. * @param mesh The mesh used to create the light scattering
  70278. * @param samples The post-process quality, default 100
  70279. * @param samplingModeThe post-process filtering mode
  70280. * @param engine The babylon engine
  70281. * @param reusable If the post-process is reusable
  70282. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70283. */
  70284. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70285. /**
  70286. * Returns the string "VolumetricLightScatteringPostProcess"
  70287. * @returns "VolumetricLightScatteringPostProcess"
  70288. */
  70289. getClassName(): string;
  70290. private _isReady;
  70291. /**
  70292. * Sets the new light position for light scattering effect
  70293. * @param position The new custom light position
  70294. */
  70295. setCustomMeshPosition(position: Vector3): void;
  70296. /**
  70297. * Returns the light position for light scattering effect
  70298. * @return Vector3 The custom light position
  70299. */
  70300. getCustomMeshPosition(): Vector3;
  70301. /**
  70302. * Disposes the internal assets and detaches the post-process from the camera
  70303. */
  70304. dispose(camera: Camera): void;
  70305. /**
  70306. * Returns the render target texture used by the post-process
  70307. * @return the render target texture used by the post-process
  70308. */
  70309. getPass(): RenderTargetTexture;
  70310. private _meshExcluded;
  70311. private _createPass;
  70312. private _updateMeshScreenCoordinates;
  70313. /**
  70314. * Creates a default mesh for the Volumeric Light Scattering post-process
  70315. * @param name The mesh name
  70316. * @param scene The scene where to create the mesh
  70317. * @return the default mesh
  70318. */
  70319. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70320. }
  70321. }
  70322. declare module "babylonjs/PostProcesses/index" {
  70323. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70324. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70325. export * from "babylonjs/PostProcesses/bloomEffect";
  70326. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70327. export * from "babylonjs/PostProcesses/blurPostProcess";
  70328. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70329. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70330. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70331. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70332. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70333. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70334. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70335. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70336. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70337. export * from "babylonjs/PostProcesses/filterPostProcess";
  70338. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70339. export * from "babylonjs/PostProcesses/grainPostProcess";
  70340. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70341. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70342. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70343. export * from "babylonjs/PostProcesses/passPostProcess";
  70344. export * from "babylonjs/PostProcesses/postProcess";
  70345. export * from "babylonjs/PostProcesses/postProcessManager";
  70346. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70347. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70348. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70349. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70350. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70351. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70352. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70353. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70354. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70355. }
  70356. declare module "babylonjs/Probes/index" {
  70357. export * from "babylonjs/Probes/reflectionProbe";
  70358. }
  70359. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70360. import { Scene } from "babylonjs/scene";
  70361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70362. import { SmartArray } from "babylonjs/Misc/smartArray";
  70363. import { ISceneComponent } from "babylonjs/sceneComponent";
  70364. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70365. import "babylonjs/Meshes/Builders/boxBuilder";
  70366. import "babylonjs/Shaders/color.fragment";
  70367. import "babylonjs/Shaders/color.vertex";
  70368. import { Color3 } from "babylonjs/Maths/math.color";
  70369. module "babylonjs/scene" {
  70370. interface Scene {
  70371. /** @hidden (Backing field) */
  70372. _boundingBoxRenderer: BoundingBoxRenderer;
  70373. /** @hidden (Backing field) */
  70374. _forceShowBoundingBoxes: boolean;
  70375. /**
  70376. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70377. */
  70378. forceShowBoundingBoxes: boolean;
  70379. /**
  70380. * Gets the bounding box renderer associated with the scene
  70381. * @returns a BoundingBoxRenderer
  70382. */
  70383. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70384. }
  70385. }
  70386. module "babylonjs/Meshes/abstractMesh" {
  70387. interface AbstractMesh {
  70388. /** @hidden (Backing field) */
  70389. _showBoundingBox: boolean;
  70390. /**
  70391. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70392. */
  70393. showBoundingBox: boolean;
  70394. }
  70395. }
  70396. /**
  70397. * Component responsible of rendering the bounding box of the meshes in a scene.
  70398. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70399. */
  70400. export class BoundingBoxRenderer implements ISceneComponent {
  70401. /**
  70402. * The component name helpfull to identify the component in the list of scene components.
  70403. */
  70404. readonly name: string;
  70405. /**
  70406. * The scene the component belongs to.
  70407. */
  70408. scene: Scene;
  70409. /**
  70410. * Color of the bounding box lines placed in front of an object
  70411. */
  70412. frontColor: Color3;
  70413. /**
  70414. * Color of the bounding box lines placed behind an object
  70415. */
  70416. backColor: Color3;
  70417. /**
  70418. * Defines if the renderer should show the back lines or not
  70419. */
  70420. showBackLines: boolean;
  70421. /**
  70422. * @hidden
  70423. */
  70424. renderList: SmartArray<BoundingBox>;
  70425. private _colorShader;
  70426. private _vertexBuffers;
  70427. private _indexBuffer;
  70428. private _fillIndexBuffer;
  70429. private _fillIndexData;
  70430. /**
  70431. * Instantiates a new bounding box renderer in a scene.
  70432. * @param scene the scene the renderer renders in
  70433. */
  70434. constructor(scene: Scene);
  70435. /**
  70436. * Registers the component in a given scene
  70437. */
  70438. register(): void;
  70439. private _evaluateSubMesh;
  70440. private _activeMesh;
  70441. private _prepareRessources;
  70442. private _createIndexBuffer;
  70443. /**
  70444. * Rebuilds the elements related to this component in case of
  70445. * context lost for instance.
  70446. */
  70447. rebuild(): void;
  70448. /**
  70449. * @hidden
  70450. */
  70451. reset(): void;
  70452. /**
  70453. * Render the bounding boxes of a specific rendering group
  70454. * @param renderingGroupId defines the rendering group to render
  70455. */
  70456. render(renderingGroupId: number): void;
  70457. /**
  70458. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70459. * @param mesh Define the mesh to render the occlusion bounding box for
  70460. */
  70461. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70462. /**
  70463. * Dispose and release the resources attached to this renderer.
  70464. */
  70465. dispose(): void;
  70466. }
  70467. }
  70468. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70469. import { Nullable } from "babylonjs/types";
  70470. import { Scene } from "babylonjs/scene";
  70471. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70472. import { Camera } from "babylonjs/Cameras/camera";
  70473. import { ISceneComponent } from "babylonjs/sceneComponent";
  70474. module "babylonjs/scene" {
  70475. interface Scene {
  70476. /** @hidden (Backing field) */
  70477. _depthRenderer: {
  70478. [id: string]: DepthRenderer;
  70479. };
  70480. /**
  70481. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70482. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70483. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70484. * @returns the created depth renderer
  70485. */
  70486. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70487. /**
  70488. * Disables a depth renderer for a given camera
  70489. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70490. */
  70491. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70492. }
  70493. }
  70494. /**
  70495. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70496. * in several rendering techniques.
  70497. */
  70498. export class DepthRendererSceneComponent implements ISceneComponent {
  70499. /**
  70500. * The component name helpfull to identify the component in the list of scene components.
  70501. */
  70502. readonly name: string;
  70503. /**
  70504. * The scene the component belongs to.
  70505. */
  70506. scene: Scene;
  70507. /**
  70508. * Creates a new instance of the component for the given scene
  70509. * @param scene Defines the scene to register the component in
  70510. */
  70511. constructor(scene: Scene);
  70512. /**
  70513. * Registers the component in a given scene
  70514. */
  70515. register(): void;
  70516. /**
  70517. * Rebuilds the elements related to this component in case of
  70518. * context lost for instance.
  70519. */
  70520. rebuild(): void;
  70521. /**
  70522. * Disposes the component and the associated ressources
  70523. */
  70524. dispose(): void;
  70525. private _gatherRenderTargets;
  70526. private _gatherActiveCameraRenderTargets;
  70527. }
  70528. }
  70529. declare module "babylonjs/Shaders/outline.fragment" {
  70530. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70531. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70532. /** @hidden */
  70533. export var outlinePixelShader: {
  70534. name: string;
  70535. shader: string;
  70536. };
  70537. }
  70538. declare module "babylonjs/Shaders/outline.vertex" {
  70539. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70541. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70542. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70543. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70545. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70546. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70547. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70548. /** @hidden */
  70549. export var outlineVertexShader: {
  70550. name: string;
  70551. shader: string;
  70552. };
  70553. }
  70554. declare module "babylonjs/Rendering/outlineRenderer" {
  70555. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70556. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70557. import { Scene } from "babylonjs/scene";
  70558. import { ISceneComponent } from "babylonjs/sceneComponent";
  70559. import "babylonjs/Shaders/outline.fragment";
  70560. import "babylonjs/Shaders/outline.vertex";
  70561. module "babylonjs/scene" {
  70562. interface Scene {
  70563. /** @hidden */
  70564. _outlineRenderer: OutlineRenderer;
  70565. /**
  70566. * Gets the outline renderer associated with the scene
  70567. * @returns a OutlineRenderer
  70568. */
  70569. getOutlineRenderer(): OutlineRenderer;
  70570. }
  70571. }
  70572. module "babylonjs/Meshes/abstractMesh" {
  70573. interface AbstractMesh {
  70574. /** @hidden (Backing field) */
  70575. _renderOutline: boolean;
  70576. /**
  70577. * Gets or sets a boolean indicating if the outline must be rendered as well
  70578. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70579. */
  70580. renderOutline: boolean;
  70581. /** @hidden (Backing field) */
  70582. _renderOverlay: boolean;
  70583. /**
  70584. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70585. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70586. */
  70587. renderOverlay: boolean;
  70588. }
  70589. }
  70590. /**
  70591. * This class is responsible to draw bothe outline/overlay of meshes.
  70592. * It should not be used directly but through the available method on mesh.
  70593. */
  70594. export class OutlineRenderer implements ISceneComponent {
  70595. /**
  70596. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70597. */
  70598. private static _StencilReference;
  70599. /**
  70600. * The name of the component. Each component must have a unique name.
  70601. */
  70602. name: string;
  70603. /**
  70604. * The scene the component belongs to.
  70605. */
  70606. scene: Scene;
  70607. /**
  70608. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70609. */
  70610. zOffset: number;
  70611. private _engine;
  70612. private _effect;
  70613. private _cachedDefines;
  70614. private _savedDepthWrite;
  70615. /**
  70616. * Instantiates a new outline renderer. (There could be only one per scene).
  70617. * @param scene Defines the scene it belongs to
  70618. */
  70619. constructor(scene: Scene);
  70620. /**
  70621. * Register the component to one instance of a scene.
  70622. */
  70623. register(): void;
  70624. /**
  70625. * Rebuilds the elements related to this component in case of
  70626. * context lost for instance.
  70627. */
  70628. rebuild(): void;
  70629. /**
  70630. * Disposes the component and the associated ressources.
  70631. */
  70632. dispose(): void;
  70633. /**
  70634. * Renders the outline in the canvas.
  70635. * @param subMesh Defines the sumesh to render
  70636. * @param batch Defines the batch of meshes in case of instances
  70637. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70638. */
  70639. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70640. /**
  70641. * Returns whether or not the outline renderer is ready for a given submesh.
  70642. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70643. * @param subMesh Defines the submesh to check readyness for
  70644. * @param useInstances Defines wheter wee are trying to render instances or not
  70645. * @returns true if ready otherwise false
  70646. */
  70647. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70648. private _beforeRenderingMesh;
  70649. private _afterRenderingMesh;
  70650. }
  70651. }
  70652. declare module "babylonjs/Rendering/index" {
  70653. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70654. export * from "babylonjs/Rendering/depthRenderer";
  70655. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70656. export * from "babylonjs/Rendering/edgesRenderer";
  70657. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70658. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70659. export * from "babylonjs/Rendering/outlineRenderer";
  70660. export * from "babylonjs/Rendering/renderingGroup";
  70661. export * from "babylonjs/Rendering/renderingManager";
  70662. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70663. }
  70664. declare module "babylonjs/Sprites/ISprites" {
  70665. /**
  70666. * Defines the basic options interface of a Sprite Frame Source Size.
  70667. */
  70668. export interface ISpriteJSONSpriteSourceSize {
  70669. /**
  70670. * number of the original width of the Frame
  70671. */
  70672. w: number;
  70673. /**
  70674. * number of the original height of the Frame
  70675. */
  70676. h: number;
  70677. }
  70678. /**
  70679. * Defines the basic options interface of a Sprite Frame Data.
  70680. */
  70681. export interface ISpriteJSONSpriteFrameData {
  70682. /**
  70683. * number of the x offset of the Frame
  70684. */
  70685. x: number;
  70686. /**
  70687. * number of the y offset of the Frame
  70688. */
  70689. y: number;
  70690. /**
  70691. * number of the width of the Frame
  70692. */
  70693. w: number;
  70694. /**
  70695. * number of the height of the Frame
  70696. */
  70697. h: number;
  70698. }
  70699. /**
  70700. * Defines the basic options interface of a JSON Sprite.
  70701. */
  70702. export interface ISpriteJSONSprite {
  70703. /**
  70704. * string name of the Frame
  70705. */
  70706. filename: string;
  70707. /**
  70708. * ISpriteJSONSpriteFrame basic object of the frame data
  70709. */
  70710. frame: ISpriteJSONSpriteFrameData;
  70711. /**
  70712. * boolean to flag is the frame was rotated.
  70713. */
  70714. rotated: boolean;
  70715. /**
  70716. * boolean to flag is the frame was trimmed.
  70717. */
  70718. trimmed: boolean;
  70719. /**
  70720. * ISpriteJSONSpriteFrame basic object of the source data
  70721. */
  70722. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70723. /**
  70724. * ISpriteJSONSpriteFrame basic object of the source data
  70725. */
  70726. sourceSize: ISpriteJSONSpriteSourceSize;
  70727. }
  70728. /**
  70729. * Defines the basic options interface of a JSON atlas.
  70730. */
  70731. export interface ISpriteJSONAtlas {
  70732. /**
  70733. * Array of objects that contain the frame data.
  70734. */
  70735. frames: Array<ISpriteJSONSprite>;
  70736. /**
  70737. * object basic object containing the sprite meta data.
  70738. */
  70739. meta?: object;
  70740. }
  70741. }
  70742. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70743. /** @hidden */
  70744. export var spriteMapPixelShader: {
  70745. name: string;
  70746. shader: string;
  70747. };
  70748. }
  70749. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70750. /** @hidden */
  70751. export var spriteMapVertexShader: {
  70752. name: string;
  70753. shader: string;
  70754. };
  70755. }
  70756. declare module "babylonjs/Sprites/spriteMap" {
  70757. import { IDisposable, Scene } from "babylonjs/scene";
  70758. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70759. import { Texture } from "babylonjs/Materials/Textures/texture";
  70760. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70761. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70762. import "babylonjs/Meshes/Builders/planeBuilder";
  70763. import "babylonjs/Shaders/spriteMap.fragment";
  70764. import "babylonjs/Shaders/spriteMap.vertex";
  70765. /**
  70766. * Defines the basic options interface of a SpriteMap
  70767. */
  70768. export interface ISpriteMapOptions {
  70769. /**
  70770. * Vector2 of the number of cells in the grid.
  70771. */
  70772. stageSize?: Vector2;
  70773. /**
  70774. * Vector2 of the size of the output plane in World Units.
  70775. */
  70776. outputSize?: Vector2;
  70777. /**
  70778. * Vector3 of the position of the output plane in World Units.
  70779. */
  70780. outputPosition?: Vector3;
  70781. /**
  70782. * Vector3 of the rotation of the output plane.
  70783. */
  70784. outputRotation?: Vector3;
  70785. /**
  70786. * number of layers that the system will reserve in resources.
  70787. */
  70788. layerCount?: number;
  70789. /**
  70790. * number of max animation frames a single cell will reserve in resources.
  70791. */
  70792. maxAnimationFrames?: number;
  70793. /**
  70794. * number cell index of the base tile when the system compiles.
  70795. */
  70796. baseTile?: number;
  70797. /**
  70798. * boolean flip the sprite after its been repositioned by the framing data.
  70799. */
  70800. flipU?: boolean;
  70801. /**
  70802. * Vector3 scalar of the global RGB values of the SpriteMap.
  70803. */
  70804. colorMultiply?: Vector3;
  70805. }
  70806. /**
  70807. * Defines the IDisposable interface in order to be cleanable from resources.
  70808. */
  70809. export interface ISpriteMap extends IDisposable {
  70810. /**
  70811. * String name of the SpriteMap.
  70812. */
  70813. name: string;
  70814. /**
  70815. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70816. */
  70817. atlasJSON: ISpriteJSONAtlas;
  70818. /**
  70819. * Texture of the SpriteMap.
  70820. */
  70821. spriteSheet: Texture;
  70822. /**
  70823. * The parameters to initialize the SpriteMap with.
  70824. */
  70825. options: ISpriteMapOptions;
  70826. }
  70827. /**
  70828. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70829. */
  70830. export class SpriteMap implements ISpriteMap {
  70831. /** The Name of the spriteMap */
  70832. name: string;
  70833. /** The JSON file with the frame and meta data */
  70834. atlasJSON: ISpriteJSONAtlas;
  70835. /** The systems Sprite Sheet Texture */
  70836. spriteSheet: Texture;
  70837. /** Arguments passed with the Constructor */
  70838. options: ISpriteMapOptions;
  70839. /** Public Sprite Storage array, parsed from atlasJSON */
  70840. sprites: Array<ISpriteJSONSprite>;
  70841. /** Returns the Number of Sprites in the System */
  70842. get spriteCount(): number;
  70843. /** Returns the Position of Output Plane*/
  70844. get position(): Vector3;
  70845. /** Returns the Position of Output Plane*/
  70846. set position(v: Vector3);
  70847. /** Returns the Rotation of Output Plane*/
  70848. get rotation(): Vector3;
  70849. /** Returns the Rotation of Output Plane*/
  70850. set rotation(v: Vector3);
  70851. /** Sets the AnimationMap*/
  70852. get animationMap(): RawTexture;
  70853. /** Sets the AnimationMap*/
  70854. set animationMap(v: RawTexture);
  70855. /** Scene that the SpriteMap was created in */
  70856. private _scene;
  70857. /** Texture Buffer of Float32 that holds tile frame data*/
  70858. private _frameMap;
  70859. /** Texture Buffers of Float32 that holds tileMap data*/
  70860. private _tileMaps;
  70861. /** Texture Buffer of Float32 that holds Animation Data*/
  70862. private _animationMap;
  70863. /** Custom ShaderMaterial Central to the System*/
  70864. private _material;
  70865. /** Custom ShaderMaterial Central to the System*/
  70866. private _output;
  70867. /** Systems Time Ticker*/
  70868. private _time;
  70869. /**
  70870. * Creates a new SpriteMap
  70871. * @param name defines the SpriteMaps Name
  70872. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70873. * @param spriteSheet is the Texture that the Sprites are on.
  70874. * @param options a basic deployment configuration
  70875. * @param scene The Scene that the map is deployed on
  70876. */
  70877. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70878. /**
  70879. * Returns tileID location
  70880. * @returns Vector2 the cell position ID
  70881. */
  70882. getTileID(): Vector2;
  70883. /**
  70884. * Gets the UV location of the mouse over the SpriteMap.
  70885. * @returns Vector2 the UV position of the mouse interaction
  70886. */
  70887. getMousePosition(): Vector2;
  70888. /**
  70889. * Creates the "frame" texture Buffer
  70890. * -------------------------------------
  70891. * Structure of frames
  70892. * "filename": "Falling-Water-2.png",
  70893. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70894. * "rotated": true,
  70895. * "trimmed": true,
  70896. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70897. * "sourceSize": {"w":32,"h":32}
  70898. * @returns RawTexture of the frameMap
  70899. */
  70900. private _createFrameBuffer;
  70901. /**
  70902. * Creates the tileMap texture Buffer
  70903. * @param buffer normally and array of numbers, or a false to generate from scratch
  70904. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70905. * @returns RawTexture of the tileMap
  70906. */
  70907. private _createTileBuffer;
  70908. /**
  70909. * Modifies the data of the tileMaps
  70910. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70911. * @param pos is the iVector2 Coordinates of the Tile
  70912. * @param tile The SpriteIndex of the new Tile
  70913. */
  70914. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70915. /**
  70916. * Creates the animationMap texture Buffer
  70917. * @param buffer normally and array of numbers, or a false to generate from scratch
  70918. * @returns RawTexture of the animationMap
  70919. */
  70920. private _createTileAnimationBuffer;
  70921. /**
  70922. * Modifies the data of the animationMap
  70923. * @param cellID is the Index of the Sprite
  70924. * @param _frame is the target Animation frame
  70925. * @param toCell is the Target Index of the next frame of the animation
  70926. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70927. * @param speed is a global scalar of the time variable on the map.
  70928. */
  70929. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70930. /**
  70931. * Exports the .tilemaps file
  70932. */
  70933. saveTileMaps(): void;
  70934. /**
  70935. * Imports the .tilemaps file
  70936. * @param url of the .tilemaps file
  70937. */
  70938. loadTileMaps(url: string): void;
  70939. /**
  70940. * Release associated resources
  70941. */
  70942. dispose(): void;
  70943. }
  70944. }
  70945. declare module "babylonjs/Sprites/spritePackedManager" {
  70946. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70947. import { Scene } from "babylonjs/scene";
  70948. /**
  70949. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70950. * @see http://doc.babylonjs.com/babylon101/sprites
  70951. */
  70952. export class SpritePackedManager extends SpriteManager {
  70953. /** defines the packed manager's name */
  70954. name: string;
  70955. /**
  70956. * Creates a new sprite manager from a packed sprite sheet
  70957. * @param name defines the manager's name
  70958. * @param imgUrl defines the sprite sheet url
  70959. * @param capacity defines the maximum allowed number of sprites
  70960. * @param scene defines the hosting scene
  70961. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70962. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70963. * @param samplingMode defines the smapling mode to use with spritesheet
  70964. * @param fromPacked set to true; do not alter
  70965. */
  70966. constructor(
  70967. /** defines the packed manager's name */
  70968. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70969. }
  70970. }
  70971. declare module "babylonjs/Sprites/index" {
  70972. export * from "babylonjs/Sprites/sprite";
  70973. export * from "babylonjs/Sprites/ISprites";
  70974. export * from "babylonjs/Sprites/spriteManager";
  70975. export * from "babylonjs/Sprites/spriteMap";
  70976. export * from "babylonjs/Sprites/spritePackedManager";
  70977. export * from "babylonjs/Sprites/spriteSceneComponent";
  70978. }
  70979. declare module "babylonjs/States/index" {
  70980. export * from "babylonjs/States/alphaCullingState";
  70981. export * from "babylonjs/States/depthCullingState";
  70982. export * from "babylonjs/States/stencilState";
  70983. }
  70984. declare module "babylonjs/Misc/assetsManager" {
  70985. import { Scene } from "babylonjs/scene";
  70986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70987. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70988. import { Skeleton } from "babylonjs/Bones/skeleton";
  70989. import { Observable } from "babylonjs/Misc/observable";
  70990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70991. import { Texture } from "babylonjs/Materials/Textures/texture";
  70992. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70993. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70994. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70995. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70996. /**
  70997. * Defines the list of states available for a task inside a AssetsManager
  70998. */
  70999. export enum AssetTaskState {
  71000. /**
  71001. * Initialization
  71002. */
  71003. INIT = 0,
  71004. /**
  71005. * Running
  71006. */
  71007. RUNNING = 1,
  71008. /**
  71009. * Done
  71010. */
  71011. DONE = 2,
  71012. /**
  71013. * Error
  71014. */
  71015. ERROR = 3
  71016. }
  71017. /**
  71018. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71019. */
  71020. export abstract class AbstractAssetTask {
  71021. /**
  71022. * Task name
  71023. */ name: string;
  71024. /**
  71025. * Callback called when the task is successful
  71026. */
  71027. onSuccess: (task: any) => void;
  71028. /**
  71029. * Callback called when the task is not successful
  71030. */
  71031. onError: (task: any, message?: string, exception?: any) => void;
  71032. /**
  71033. * Creates a new AssetsManager
  71034. * @param name defines the name of the task
  71035. */
  71036. constructor(
  71037. /**
  71038. * Task name
  71039. */ name: string);
  71040. private _isCompleted;
  71041. private _taskState;
  71042. private _errorObject;
  71043. /**
  71044. * Get if the task is completed
  71045. */
  71046. get isCompleted(): boolean;
  71047. /**
  71048. * Gets the current state of the task
  71049. */
  71050. get taskState(): AssetTaskState;
  71051. /**
  71052. * Gets the current error object (if task is in error)
  71053. */
  71054. get errorObject(): {
  71055. message?: string;
  71056. exception?: any;
  71057. };
  71058. /**
  71059. * Internal only
  71060. * @hidden
  71061. */
  71062. _setErrorObject(message?: string, exception?: any): void;
  71063. /**
  71064. * Execute the current task
  71065. * @param scene defines the scene where you want your assets to be loaded
  71066. * @param onSuccess is a callback called when the task is successfully executed
  71067. * @param onError is a callback called if an error occurs
  71068. */
  71069. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71070. /**
  71071. * Execute the current task
  71072. * @param scene defines the scene where you want your assets to be loaded
  71073. * @param onSuccess is a callback called when the task is successfully executed
  71074. * @param onError is a callback called if an error occurs
  71075. */
  71076. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71077. /**
  71078. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71079. * This can be used with failed tasks that have the reason for failure fixed.
  71080. */
  71081. reset(): void;
  71082. private onErrorCallback;
  71083. private onDoneCallback;
  71084. }
  71085. /**
  71086. * Define the interface used by progress events raised during assets loading
  71087. */
  71088. export interface IAssetsProgressEvent {
  71089. /**
  71090. * Defines the number of remaining tasks to process
  71091. */
  71092. remainingCount: number;
  71093. /**
  71094. * Defines the total number of tasks
  71095. */
  71096. totalCount: number;
  71097. /**
  71098. * Defines the task that was just processed
  71099. */
  71100. task: AbstractAssetTask;
  71101. }
  71102. /**
  71103. * Class used to share progress information about assets loading
  71104. */
  71105. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71106. /**
  71107. * Defines the number of remaining tasks to process
  71108. */
  71109. remainingCount: number;
  71110. /**
  71111. * Defines the total number of tasks
  71112. */
  71113. totalCount: number;
  71114. /**
  71115. * Defines the task that was just processed
  71116. */
  71117. task: AbstractAssetTask;
  71118. /**
  71119. * Creates a AssetsProgressEvent
  71120. * @param remainingCount defines the number of remaining tasks to process
  71121. * @param totalCount defines the total number of tasks
  71122. * @param task defines the task that was just processed
  71123. */
  71124. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71125. }
  71126. /**
  71127. * Define a task used by AssetsManager to load meshes
  71128. */
  71129. export class MeshAssetTask extends AbstractAssetTask {
  71130. /**
  71131. * Defines the name of the task
  71132. */
  71133. name: string;
  71134. /**
  71135. * Defines the list of mesh's names you want to load
  71136. */
  71137. meshesNames: any;
  71138. /**
  71139. * Defines the root url to use as a base to load your meshes and associated resources
  71140. */
  71141. rootUrl: string;
  71142. /**
  71143. * Defines the filename of the scene to load from
  71144. */
  71145. sceneFilename: string;
  71146. /**
  71147. * Gets the list of loaded meshes
  71148. */
  71149. loadedMeshes: Array<AbstractMesh>;
  71150. /**
  71151. * Gets the list of loaded particle systems
  71152. */
  71153. loadedParticleSystems: Array<IParticleSystem>;
  71154. /**
  71155. * Gets the list of loaded skeletons
  71156. */
  71157. loadedSkeletons: Array<Skeleton>;
  71158. /**
  71159. * Gets the list of loaded animation groups
  71160. */
  71161. loadedAnimationGroups: Array<AnimationGroup>;
  71162. /**
  71163. * Callback called when the task is successful
  71164. */
  71165. onSuccess: (task: MeshAssetTask) => void;
  71166. /**
  71167. * Callback called when the task is successful
  71168. */
  71169. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71170. /**
  71171. * Creates a new MeshAssetTask
  71172. * @param name defines the name of the task
  71173. * @param meshesNames defines the list of mesh's names you want to load
  71174. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71175. * @param sceneFilename defines the filename of the scene to load from
  71176. */
  71177. constructor(
  71178. /**
  71179. * Defines the name of the task
  71180. */
  71181. name: string,
  71182. /**
  71183. * Defines the list of mesh's names you want to load
  71184. */
  71185. meshesNames: any,
  71186. /**
  71187. * Defines the root url to use as a base to load your meshes and associated resources
  71188. */
  71189. rootUrl: string,
  71190. /**
  71191. * Defines the filename of the scene to load from
  71192. */
  71193. sceneFilename: string);
  71194. /**
  71195. * Execute the current task
  71196. * @param scene defines the scene where you want your assets to be loaded
  71197. * @param onSuccess is a callback called when the task is successfully executed
  71198. * @param onError is a callback called if an error occurs
  71199. */
  71200. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71201. }
  71202. /**
  71203. * Define a task used by AssetsManager to load text content
  71204. */
  71205. export class TextFileAssetTask extends AbstractAssetTask {
  71206. /**
  71207. * Defines the name of the task
  71208. */
  71209. name: string;
  71210. /**
  71211. * Defines the location of the file to load
  71212. */
  71213. url: string;
  71214. /**
  71215. * Gets the loaded text string
  71216. */
  71217. text: string;
  71218. /**
  71219. * Callback called when the task is successful
  71220. */
  71221. onSuccess: (task: TextFileAssetTask) => void;
  71222. /**
  71223. * Callback called when the task is successful
  71224. */
  71225. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71226. /**
  71227. * Creates a new TextFileAssetTask object
  71228. * @param name defines the name of the task
  71229. * @param url defines the location of the file to load
  71230. */
  71231. constructor(
  71232. /**
  71233. * Defines the name of the task
  71234. */
  71235. name: string,
  71236. /**
  71237. * Defines the location of the file to load
  71238. */
  71239. url: string);
  71240. /**
  71241. * Execute the current task
  71242. * @param scene defines the scene where you want your assets to be loaded
  71243. * @param onSuccess is a callback called when the task is successfully executed
  71244. * @param onError is a callback called if an error occurs
  71245. */
  71246. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71247. }
  71248. /**
  71249. * Define a task used by AssetsManager to load binary data
  71250. */
  71251. export class BinaryFileAssetTask extends AbstractAssetTask {
  71252. /**
  71253. * Defines the name of the task
  71254. */
  71255. name: string;
  71256. /**
  71257. * Defines the location of the file to load
  71258. */
  71259. url: string;
  71260. /**
  71261. * Gets the lodaded data (as an array buffer)
  71262. */
  71263. data: ArrayBuffer;
  71264. /**
  71265. * Callback called when the task is successful
  71266. */
  71267. onSuccess: (task: BinaryFileAssetTask) => void;
  71268. /**
  71269. * Callback called when the task is successful
  71270. */
  71271. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71272. /**
  71273. * Creates a new BinaryFileAssetTask object
  71274. * @param name defines the name of the new task
  71275. * @param url defines the location of the file to load
  71276. */
  71277. constructor(
  71278. /**
  71279. * Defines the name of the task
  71280. */
  71281. name: string,
  71282. /**
  71283. * Defines the location of the file to load
  71284. */
  71285. url: string);
  71286. /**
  71287. * Execute the current task
  71288. * @param scene defines the scene where you want your assets to be loaded
  71289. * @param onSuccess is a callback called when the task is successfully executed
  71290. * @param onError is a callback called if an error occurs
  71291. */
  71292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71293. }
  71294. /**
  71295. * Define a task used by AssetsManager to load images
  71296. */
  71297. export class ImageAssetTask extends AbstractAssetTask {
  71298. /**
  71299. * Defines the name of the task
  71300. */
  71301. name: string;
  71302. /**
  71303. * Defines the location of the image to load
  71304. */
  71305. url: string;
  71306. /**
  71307. * Gets the loaded images
  71308. */
  71309. image: HTMLImageElement;
  71310. /**
  71311. * Callback called when the task is successful
  71312. */
  71313. onSuccess: (task: ImageAssetTask) => void;
  71314. /**
  71315. * Callback called when the task is successful
  71316. */
  71317. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71318. /**
  71319. * Creates a new ImageAssetTask
  71320. * @param name defines the name of the task
  71321. * @param url defines the location of the image to load
  71322. */
  71323. constructor(
  71324. /**
  71325. * Defines the name of the task
  71326. */
  71327. name: string,
  71328. /**
  71329. * Defines the location of the image to load
  71330. */
  71331. url: string);
  71332. /**
  71333. * Execute the current task
  71334. * @param scene defines the scene where you want your assets to be loaded
  71335. * @param onSuccess is a callback called when the task is successfully executed
  71336. * @param onError is a callback called if an error occurs
  71337. */
  71338. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71339. }
  71340. /**
  71341. * Defines the interface used by texture loading tasks
  71342. */
  71343. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71344. /**
  71345. * Gets the loaded texture
  71346. */
  71347. texture: TEX;
  71348. }
  71349. /**
  71350. * Define a task used by AssetsManager to load 2D textures
  71351. */
  71352. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71353. /**
  71354. * Defines the name of the task
  71355. */
  71356. name: string;
  71357. /**
  71358. * Defines the location of the file to load
  71359. */
  71360. url: string;
  71361. /**
  71362. * Defines if mipmap should not be generated (default is false)
  71363. */
  71364. noMipmap?: boolean | undefined;
  71365. /**
  71366. * Defines if texture must be inverted on Y axis (default is false)
  71367. */
  71368. invertY?: boolean | undefined;
  71369. /**
  71370. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71371. */
  71372. samplingMode: number;
  71373. /**
  71374. * Gets the loaded texture
  71375. */
  71376. texture: Texture;
  71377. /**
  71378. * Callback called when the task is successful
  71379. */
  71380. onSuccess: (task: TextureAssetTask) => void;
  71381. /**
  71382. * Callback called when the task is successful
  71383. */
  71384. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71385. /**
  71386. * Creates a new TextureAssetTask object
  71387. * @param name defines the name of the task
  71388. * @param url defines the location of the file to load
  71389. * @param noMipmap defines if mipmap should not be generated (default is false)
  71390. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71391. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71392. */
  71393. constructor(
  71394. /**
  71395. * Defines the name of the task
  71396. */
  71397. name: string,
  71398. /**
  71399. * Defines the location of the file to load
  71400. */
  71401. url: string,
  71402. /**
  71403. * Defines if mipmap should not be generated (default is false)
  71404. */
  71405. noMipmap?: boolean | undefined,
  71406. /**
  71407. * Defines if texture must be inverted on Y axis (default is false)
  71408. */
  71409. invertY?: boolean | undefined,
  71410. /**
  71411. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71412. */
  71413. samplingMode?: number);
  71414. /**
  71415. * Execute the current task
  71416. * @param scene defines the scene where you want your assets to be loaded
  71417. * @param onSuccess is a callback called when the task is successfully executed
  71418. * @param onError is a callback called if an error occurs
  71419. */
  71420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71421. }
  71422. /**
  71423. * Define a task used by AssetsManager to load cube textures
  71424. */
  71425. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71426. /**
  71427. * Defines the name of the task
  71428. */
  71429. name: string;
  71430. /**
  71431. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71432. */
  71433. url: string;
  71434. /**
  71435. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71436. */
  71437. extensions?: string[] | undefined;
  71438. /**
  71439. * Defines if mipmaps should not be generated (default is false)
  71440. */
  71441. noMipmap?: boolean | undefined;
  71442. /**
  71443. * Defines the explicit list of files (undefined by default)
  71444. */
  71445. files?: string[] | undefined;
  71446. /**
  71447. * Gets the loaded texture
  71448. */
  71449. texture: CubeTexture;
  71450. /**
  71451. * Callback called when the task is successful
  71452. */
  71453. onSuccess: (task: CubeTextureAssetTask) => void;
  71454. /**
  71455. * Callback called when the task is successful
  71456. */
  71457. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71458. /**
  71459. * Creates a new CubeTextureAssetTask
  71460. * @param name defines the name of the task
  71461. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71462. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71463. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71464. * @param files defines the explicit list of files (undefined by default)
  71465. */
  71466. constructor(
  71467. /**
  71468. * Defines the name of the task
  71469. */
  71470. name: string,
  71471. /**
  71472. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71473. */
  71474. url: string,
  71475. /**
  71476. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71477. */
  71478. extensions?: string[] | undefined,
  71479. /**
  71480. * Defines if mipmaps should not be generated (default is false)
  71481. */
  71482. noMipmap?: boolean | undefined,
  71483. /**
  71484. * Defines the explicit list of files (undefined by default)
  71485. */
  71486. files?: string[] | undefined);
  71487. /**
  71488. * Execute the current task
  71489. * @param scene defines the scene where you want your assets to be loaded
  71490. * @param onSuccess is a callback called when the task is successfully executed
  71491. * @param onError is a callback called if an error occurs
  71492. */
  71493. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71494. }
  71495. /**
  71496. * Define a task used by AssetsManager to load HDR cube textures
  71497. */
  71498. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71499. /**
  71500. * Defines the name of the task
  71501. */
  71502. name: string;
  71503. /**
  71504. * Defines the location of the file to load
  71505. */
  71506. url: string;
  71507. /**
  71508. * Defines the desired size (the more it increases the longer the generation will be)
  71509. */
  71510. size: number;
  71511. /**
  71512. * Defines if mipmaps should not be generated (default is false)
  71513. */
  71514. noMipmap: boolean;
  71515. /**
  71516. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71517. */
  71518. generateHarmonics: boolean;
  71519. /**
  71520. * 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)
  71521. */
  71522. gammaSpace: boolean;
  71523. /**
  71524. * Internal Use Only
  71525. */
  71526. reserved: boolean;
  71527. /**
  71528. * Gets the loaded texture
  71529. */
  71530. texture: HDRCubeTexture;
  71531. /**
  71532. * Callback called when the task is successful
  71533. */
  71534. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71535. /**
  71536. * Callback called when the task is successful
  71537. */
  71538. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71539. /**
  71540. * Creates a new HDRCubeTextureAssetTask object
  71541. * @param name defines the name of the task
  71542. * @param url defines the location of the file to load
  71543. * @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.
  71544. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71545. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71546. * @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)
  71547. * @param reserved Internal use only
  71548. */
  71549. constructor(
  71550. /**
  71551. * Defines the name of the task
  71552. */
  71553. name: string,
  71554. /**
  71555. * Defines the location of the file to load
  71556. */
  71557. url: string,
  71558. /**
  71559. * Defines the desired size (the more it increases the longer the generation will be)
  71560. */
  71561. size: number,
  71562. /**
  71563. * Defines if mipmaps should not be generated (default is false)
  71564. */
  71565. noMipmap?: boolean,
  71566. /**
  71567. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71568. */
  71569. generateHarmonics?: boolean,
  71570. /**
  71571. * 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)
  71572. */
  71573. gammaSpace?: boolean,
  71574. /**
  71575. * Internal Use Only
  71576. */
  71577. reserved?: boolean);
  71578. /**
  71579. * Execute the current task
  71580. * @param scene defines the scene where you want your assets to be loaded
  71581. * @param onSuccess is a callback called when the task is successfully executed
  71582. * @param onError is a callback called if an error occurs
  71583. */
  71584. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71585. }
  71586. /**
  71587. * Define a task used by AssetsManager to load Equirectangular cube textures
  71588. */
  71589. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71590. /**
  71591. * Defines the name of the task
  71592. */
  71593. name: string;
  71594. /**
  71595. * Defines the location of the file to load
  71596. */
  71597. url: string;
  71598. /**
  71599. * Defines the desired size (the more it increases the longer the generation will be)
  71600. */
  71601. size: number;
  71602. /**
  71603. * Defines if mipmaps should not be generated (default is false)
  71604. */
  71605. noMipmap: boolean;
  71606. /**
  71607. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71608. * but the standard material would require them in Gamma space) (default is true)
  71609. */
  71610. gammaSpace: boolean;
  71611. /**
  71612. * Gets the loaded texture
  71613. */
  71614. texture: EquiRectangularCubeTexture;
  71615. /**
  71616. * Callback called when the task is successful
  71617. */
  71618. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71619. /**
  71620. * Callback called when the task is successful
  71621. */
  71622. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71623. /**
  71624. * Creates a new EquiRectangularCubeTextureAssetTask object
  71625. * @param name defines the name of the task
  71626. * @param url defines the location of the file to load
  71627. * @param size defines the desired size (the more it increases the longer the generation will be)
  71628. * If the size is omitted this implies you are using a preprocessed cubemap.
  71629. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71630. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71631. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71632. * (default is true)
  71633. */
  71634. constructor(
  71635. /**
  71636. * Defines the name of the task
  71637. */
  71638. name: string,
  71639. /**
  71640. * Defines the location of the file to load
  71641. */
  71642. url: string,
  71643. /**
  71644. * Defines the desired size (the more it increases the longer the generation will be)
  71645. */
  71646. size: number,
  71647. /**
  71648. * Defines if mipmaps should not be generated (default is false)
  71649. */
  71650. noMipmap?: boolean,
  71651. /**
  71652. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71653. * but the standard material would require them in Gamma space) (default is true)
  71654. */
  71655. gammaSpace?: boolean);
  71656. /**
  71657. * Execute the current task
  71658. * @param scene defines the scene where you want your assets to be loaded
  71659. * @param onSuccess is a callback called when the task is successfully executed
  71660. * @param onError is a callback called if an error occurs
  71661. */
  71662. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71663. }
  71664. /**
  71665. * This class can be used to easily import assets into a scene
  71666. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71667. */
  71668. export class AssetsManager {
  71669. private _scene;
  71670. private _isLoading;
  71671. protected _tasks: AbstractAssetTask[];
  71672. protected _waitingTasksCount: number;
  71673. protected _totalTasksCount: number;
  71674. /**
  71675. * Callback called when all tasks are processed
  71676. */
  71677. onFinish: (tasks: AbstractAssetTask[]) => void;
  71678. /**
  71679. * Callback called when a task is successful
  71680. */
  71681. onTaskSuccess: (task: AbstractAssetTask) => void;
  71682. /**
  71683. * Callback called when a task had an error
  71684. */
  71685. onTaskError: (task: AbstractAssetTask) => void;
  71686. /**
  71687. * Callback called when a task is done (whatever the result is)
  71688. */
  71689. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71690. /**
  71691. * Observable called when all tasks are processed
  71692. */
  71693. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71694. /**
  71695. * Observable called when a task had an error
  71696. */
  71697. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71698. /**
  71699. * Observable called when all tasks were executed
  71700. */
  71701. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71702. /**
  71703. * Observable called when a task is done (whatever the result is)
  71704. */
  71705. onProgressObservable: Observable<IAssetsProgressEvent>;
  71706. /**
  71707. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71708. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71709. */
  71710. useDefaultLoadingScreen: boolean;
  71711. /**
  71712. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71713. * when all assets have been downloaded.
  71714. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71715. */
  71716. autoHideLoadingUI: boolean;
  71717. /**
  71718. * Creates a new AssetsManager
  71719. * @param scene defines the scene to work on
  71720. */
  71721. constructor(scene: Scene);
  71722. /**
  71723. * Add a MeshAssetTask to the list of active tasks
  71724. * @param taskName defines the name of the new task
  71725. * @param meshesNames defines the name of meshes to load
  71726. * @param rootUrl defines the root url to use to locate files
  71727. * @param sceneFilename defines the filename of the scene file
  71728. * @returns a new MeshAssetTask object
  71729. */
  71730. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71731. /**
  71732. * Add a TextFileAssetTask to the list of active tasks
  71733. * @param taskName defines the name of the new task
  71734. * @param url defines the url of the file to load
  71735. * @returns a new TextFileAssetTask object
  71736. */
  71737. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71738. /**
  71739. * Add a BinaryFileAssetTask to the list of active tasks
  71740. * @param taskName defines the name of the new task
  71741. * @param url defines the url of the file to load
  71742. * @returns a new BinaryFileAssetTask object
  71743. */
  71744. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71745. /**
  71746. * Add a ImageAssetTask to the list of active tasks
  71747. * @param taskName defines the name of the new task
  71748. * @param url defines the url of the file to load
  71749. * @returns a new ImageAssetTask object
  71750. */
  71751. addImageTask(taskName: string, url: string): ImageAssetTask;
  71752. /**
  71753. * Add a TextureAssetTask to the list of active tasks
  71754. * @param taskName defines the name of the new task
  71755. * @param url defines the url of the file to load
  71756. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71757. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71758. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71759. * @returns a new TextureAssetTask object
  71760. */
  71761. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71762. /**
  71763. * Add a CubeTextureAssetTask to the list of active tasks
  71764. * @param taskName defines the name of the new task
  71765. * @param url defines the url of the file to load
  71766. * @param extensions defines the extension to use to load the cube map (can be null)
  71767. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71768. * @param files defines the list of files to load (can be null)
  71769. * @returns a new CubeTextureAssetTask object
  71770. */
  71771. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71772. /**
  71773. *
  71774. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71775. * @param taskName defines the name of the new task
  71776. * @param url defines the url of the file to load
  71777. * @param size defines the size you want for the cubemap (can be null)
  71778. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71779. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71780. * @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)
  71781. * @param reserved Internal use only
  71782. * @returns a new HDRCubeTextureAssetTask object
  71783. */
  71784. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71785. /**
  71786. *
  71787. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71788. * @param taskName defines the name of the new task
  71789. * @param url defines the url of the file to load
  71790. * @param size defines the size you want for the cubemap (can be null)
  71791. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71792. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71793. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71794. * @returns a new EquiRectangularCubeTextureAssetTask object
  71795. */
  71796. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71797. /**
  71798. * Remove a task from the assets manager.
  71799. * @param task the task to remove
  71800. */
  71801. removeTask(task: AbstractAssetTask): void;
  71802. private _decreaseWaitingTasksCount;
  71803. private _runTask;
  71804. /**
  71805. * Reset the AssetsManager and remove all tasks
  71806. * @return the current instance of the AssetsManager
  71807. */
  71808. reset(): AssetsManager;
  71809. /**
  71810. * Start the loading process
  71811. * @return the current instance of the AssetsManager
  71812. */
  71813. load(): AssetsManager;
  71814. /**
  71815. * Start the loading process as an async operation
  71816. * @return a promise returning the list of failed tasks
  71817. */
  71818. loadAsync(): Promise<void>;
  71819. }
  71820. }
  71821. declare module "babylonjs/Misc/deferred" {
  71822. /**
  71823. * Wrapper class for promise with external resolve and reject.
  71824. */
  71825. export class Deferred<T> {
  71826. /**
  71827. * The promise associated with this deferred object.
  71828. */
  71829. readonly promise: Promise<T>;
  71830. private _resolve;
  71831. private _reject;
  71832. /**
  71833. * The resolve method of the promise associated with this deferred object.
  71834. */
  71835. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71836. /**
  71837. * The reject method of the promise associated with this deferred object.
  71838. */
  71839. get reject(): (reason?: any) => void;
  71840. /**
  71841. * Constructor for this deferred object.
  71842. */
  71843. constructor();
  71844. }
  71845. }
  71846. declare module "babylonjs/Misc/meshExploder" {
  71847. import { Mesh } from "babylonjs/Meshes/mesh";
  71848. /**
  71849. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71850. */
  71851. export class MeshExploder {
  71852. private _centerMesh;
  71853. private _meshes;
  71854. private _meshesOrigins;
  71855. private _toCenterVectors;
  71856. private _scaledDirection;
  71857. private _newPosition;
  71858. private _centerPosition;
  71859. /**
  71860. * Explodes meshes from a center mesh.
  71861. * @param meshes The meshes to explode.
  71862. * @param centerMesh The mesh to be center of explosion.
  71863. */
  71864. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71865. private _setCenterMesh;
  71866. /**
  71867. * Get class name
  71868. * @returns "MeshExploder"
  71869. */
  71870. getClassName(): string;
  71871. /**
  71872. * "Exploded meshes"
  71873. * @returns Array of meshes with the centerMesh at index 0.
  71874. */
  71875. getMeshes(): Array<Mesh>;
  71876. /**
  71877. * Explodes meshes giving a specific direction
  71878. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71879. */
  71880. explode(direction?: number): void;
  71881. }
  71882. }
  71883. declare module "babylonjs/Misc/filesInput" {
  71884. import { Engine } from "babylonjs/Engines/engine";
  71885. import { Scene } from "babylonjs/scene";
  71886. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71887. /**
  71888. * Class used to help managing file picking and drag'n'drop
  71889. */
  71890. export class FilesInput {
  71891. /**
  71892. * List of files ready to be loaded
  71893. */
  71894. static get FilesToLoad(): {
  71895. [key: string]: File;
  71896. };
  71897. /**
  71898. * Callback called when a file is processed
  71899. */
  71900. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71901. private _engine;
  71902. private _currentScene;
  71903. private _sceneLoadedCallback;
  71904. private _progressCallback;
  71905. private _additionalRenderLoopLogicCallback;
  71906. private _textureLoadingCallback;
  71907. private _startingProcessingFilesCallback;
  71908. private _onReloadCallback;
  71909. private _errorCallback;
  71910. private _elementToMonitor;
  71911. private _sceneFileToLoad;
  71912. private _filesToLoad;
  71913. /**
  71914. * Creates a new FilesInput
  71915. * @param engine defines the rendering engine
  71916. * @param scene defines the hosting scene
  71917. * @param sceneLoadedCallback callback called when scene is loaded
  71918. * @param progressCallback callback called to track progress
  71919. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71920. * @param textureLoadingCallback callback called when a texture is loading
  71921. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71922. * @param onReloadCallback callback called when a reload is requested
  71923. * @param errorCallback callback call if an error occurs
  71924. */
  71925. 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);
  71926. private _dragEnterHandler;
  71927. private _dragOverHandler;
  71928. private _dropHandler;
  71929. /**
  71930. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71931. * @param elementToMonitor defines the DOM element to track
  71932. */
  71933. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71934. /**
  71935. * Release all associated resources
  71936. */
  71937. dispose(): void;
  71938. private renderFunction;
  71939. private drag;
  71940. private drop;
  71941. private _traverseFolder;
  71942. private _processFiles;
  71943. /**
  71944. * Load files from a drop event
  71945. * @param event defines the drop event to use as source
  71946. */
  71947. loadFiles(event: any): void;
  71948. private _processReload;
  71949. /**
  71950. * Reload the current scene from the loaded files
  71951. */
  71952. reload(): void;
  71953. }
  71954. }
  71955. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71956. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71957. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71958. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71959. }
  71960. declare module "babylonjs/Misc/sceneOptimizer" {
  71961. import { Scene, IDisposable } from "babylonjs/scene";
  71962. import { Observable } from "babylonjs/Misc/observable";
  71963. /**
  71964. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71966. */
  71967. export class SceneOptimization {
  71968. /**
  71969. * Defines the priority of this optimization (0 by default which means first in the list)
  71970. */
  71971. priority: number;
  71972. /**
  71973. * Gets a string describing the action executed by the current optimization
  71974. * @returns description string
  71975. */
  71976. getDescription(): string;
  71977. /**
  71978. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71979. * @param scene defines the current scene where to apply this optimization
  71980. * @param optimizer defines the current optimizer
  71981. * @returns true if everything that can be done was applied
  71982. */
  71983. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71984. /**
  71985. * Creates the SceneOptimization object
  71986. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71987. * @param desc defines the description associated with the optimization
  71988. */
  71989. constructor(
  71990. /**
  71991. * Defines the priority of this optimization (0 by default which means first in the list)
  71992. */
  71993. priority?: number);
  71994. }
  71995. /**
  71996. * Defines an optimization used to reduce the size of render target textures
  71997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71998. */
  71999. export class TextureOptimization extends SceneOptimization {
  72000. /**
  72001. * Defines the priority of this optimization (0 by default which means first in the list)
  72002. */
  72003. priority: number;
  72004. /**
  72005. * 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
  72006. */
  72007. maximumSize: number;
  72008. /**
  72009. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72010. */
  72011. step: number;
  72012. /**
  72013. * Gets a string describing the action executed by the current optimization
  72014. * @returns description string
  72015. */
  72016. getDescription(): string;
  72017. /**
  72018. * Creates the TextureOptimization object
  72019. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72020. * @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
  72021. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72022. */
  72023. constructor(
  72024. /**
  72025. * Defines the priority of this optimization (0 by default which means first in the list)
  72026. */
  72027. priority?: number,
  72028. /**
  72029. * 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
  72030. */
  72031. maximumSize?: number,
  72032. /**
  72033. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72034. */
  72035. step?: number);
  72036. /**
  72037. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72038. * @param scene defines the current scene where to apply this optimization
  72039. * @param optimizer defines the current optimizer
  72040. * @returns true if everything that can be done was applied
  72041. */
  72042. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72043. }
  72044. /**
  72045. * Defines an optimization used to increase or decrease the rendering resolution
  72046. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72047. */
  72048. export class HardwareScalingOptimization extends SceneOptimization {
  72049. /**
  72050. * Defines the priority of this optimization (0 by default which means first in the list)
  72051. */
  72052. priority: number;
  72053. /**
  72054. * Defines the maximum scale to use (2 by default)
  72055. */
  72056. maximumScale: number;
  72057. /**
  72058. * Defines the step to use between two passes (0.5 by default)
  72059. */
  72060. step: number;
  72061. private _currentScale;
  72062. private _directionOffset;
  72063. /**
  72064. * Gets a string describing the action executed by the current optimization
  72065. * @return description string
  72066. */
  72067. getDescription(): string;
  72068. /**
  72069. * Creates the HardwareScalingOptimization object
  72070. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72071. * @param maximumScale defines the maximum scale to use (2 by default)
  72072. * @param step defines the step to use between two passes (0.5 by default)
  72073. */
  72074. constructor(
  72075. /**
  72076. * Defines the priority of this optimization (0 by default which means first in the list)
  72077. */
  72078. priority?: number,
  72079. /**
  72080. * Defines the maximum scale to use (2 by default)
  72081. */
  72082. maximumScale?: number,
  72083. /**
  72084. * Defines the step to use between two passes (0.5 by default)
  72085. */
  72086. step?: number);
  72087. /**
  72088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72089. * @param scene defines the current scene where to apply this optimization
  72090. * @param optimizer defines the current optimizer
  72091. * @returns true if everything that can be done was applied
  72092. */
  72093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72094. }
  72095. /**
  72096. * Defines an optimization used to remove shadows
  72097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72098. */
  72099. export class ShadowsOptimization extends SceneOptimization {
  72100. /**
  72101. * Gets a string describing the action executed by the current optimization
  72102. * @return description string
  72103. */
  72104. getDescription(): string;
  72105. /**
  72106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72107. * @param scene defines the current scene where to apply this optimization
  72108. * @param optimizer defines the current optimizer
  72109. * @returns true if everything that can be done was applied
  72110. */
  72111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72112. }
  72113. /**
  72114. * Defines an optimization used to turn post-processes off
  72115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72116. */
  72117. export class PostProcessesOptimization extends SceneOptimization {
  72118. /**
  72119. * Gets a string describing the action executed by the current optimization
  72120. * @return description string
  72121. */
  72122. getDescription(): string;
  72123. /**
  72124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72125. * @param scene defines the current scene where to apply this optimization
  72126. * @param optimizer defines the current optimizer
  72127. * @returns true if everything that can be done was applied
  72128. */
  72129. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72130. }
  72131. /**
  72132. * Defines an optimization used to turn lens flares off
  72133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72134. */
  72135. export class LensFlaresOptimization extends SceneOptimization {
  72136. /**
  72137. * Gets a string describing the action executed by the current optimization
  72138. * @return description string
  72139. */
  72140. getDescription(): string;
  72141. /**
  72142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72143. * @param scene defines the current scene where to apply this optimization
  72144. * @param optimizer defines the current optimizer
  72145. * @returns true if everything that can be done was applied
  72146. */
  72147. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72148. }
  72149. /**
  72150. * Defines an optimization based on user defined callback.
  72151. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72152. */
  72153. export class CustomOptimization extends SceneOptimization {
  72154. /**
  72155. * Callback called to apply the custom optimization.
  72156. */
  72157. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72158. /**
  72159. * Callback called to get custom description
  72160. */
  72161. onGetDescription: () => string;
  72162. /**
  72163. * Gets a string describing the action executed by the current optimization
  72164. * @returns description string
  72165. */
  72166. getDescription(): string;
  72167. /**
  72168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72169. * @param scene defines the current scene where to apply this optimization
  72170. * @param optimizer defines the current optimizer
  72171. * @returns true if everything that can be done was applied
  72172. */
  72173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72174. }
  72175. /**
  72176. * Defines an optimization used to turn particles off
  72177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72178. */
  72179. export class ParticlesOptimization extends SceneOptimization {
  72180. /**
  72181. * Gets a string describing the action executed by the current optimization
  72182. * @return description string
  72183. */
  72184. getDescription(): string;
  72185. /**
  72186. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72187. * @param scene defines the current scene where to apply this optimization
  72188. * @param optimizer defines the current optimizer
  72189. * @returns true if everything that can be done was applied
  72190. */
  72191. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72192. }
  72193. /**
  72194. * Defines an optimization used to turn render targets off
  72195. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72196. */
  72197. export class RenderTargetsOptimization extends SceneOptimization {
  72198. /**
  72199. * Gets a string describing the action executed by the current optimization
  72200. * @return description string
  72201. */
  72202. getDescription(): string;
  72203. /**
  72204. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72205. * @param scene defines the current scene where to apply this optimization
  72206. * @param optimizer defines the current optimizer
  72207. * @returns true if everything that can be done was applied
  72208. */
  72209. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72210. }
  72211. /**
  72212. * Defines an optimization used to merge meshes with compatible materials
  72213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72214. */
  72215. export class MergeMeshesOptimization extends SceneOptimization {
  72216. private static _UpdateSelectionTree;
  72217. /**
  72218. * Gets or sets a boolean which defines if optimization octree has to be updated
  72219. */
  72220. static get UpdateSelectionTree(): boolean;
  72221. /**
  72222. * Gets or sets a boolean which defines if optimization octree has to be updated
  72223. */
  72224. static set UpdateSelectionTree(value: boolean);
  72225. /**
  72226. * Gets a string describing the action executed by the current optimization
  72227. * @return description string
  72228. */
  72229. getDescription(): string;
  72230. private _canBeMerged;
  72231. /**
  72232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72233. * @param scene defines the current scene where to apply this optimization
  72234. * @param optimizer defines the current optimizer
  72235. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72236. * @returns true if everything that can be done was applied
  72237. */
  72238. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72239. }
  72240. /**
  72241. * Defines a list of options used by SceneOptimizer
  72242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72243. */
  72244. export class SceneOptimizerOptions {
  72245. /**
  72246. * Defines the target frame rate to reach (60 by default)
  72247. */
  72248. targetFrameRate: number;
  72249. /**
  72250. * Defines the interval between two checkes (2000ms by default)
  72251. */
  72252. trackerDuration: number;
  72253. /**
  72254. * Gets the list of optimizations to apply
  72255. */
  72256. optimizations: SceneOptimization[];
  72257. /**
  72258. * Creates a new list of options used by SceneOptimizer
  72259. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72260. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72261. */
  72262. constructor(
  72263. /**
  72264. * Defines the target frame rate to reach (60 by default)
  72265. */
  72266. targetFrameRate?: number,
  72267. /**
  72268. * Defines the interval between two checkes (2000ms by default)
  72269. */
  72270. trackerDuration?: number);
  72271. /**
  72272. * Add a new optimization
  72273. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72274. * @returns the current SceneOptimizerOptions
  72275. */
  72276. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72277. /**
  72278. * Add a new custom optimization
  72279. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72280. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72281. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72282. * @returns the current SceneOptimizerOptions
  72283. */
  72284. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72285. /**
  72286. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72287. * @param targetFrameRate defines the target frame rate (60 by default)
  72288. * @returns a SceneOptimizerOptions object
  72289. */
  72290. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72291. /**
  72292. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72293. * @param targetFrameRate defines the target frame rate (60 by default)
  72294. * @returns a SceneOptimizerOptions object
  72295. */
  72296. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72297. /**
  72298. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72299. * @param targetFrameRate defines the target frame rate (60 by default)
  72300. * @returns a SceneOptimizerOptions object
  72301. */
  72302. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72303. }
  72304. /**
  72305. * Class used to run optimizations in order to reach a target frame rate
  72306. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72307. */
  72308. export class SceneOptimizer implements IDisposable {
  72309. private _isRunning;
  72310. private _options;
  72311. private _scene;
  72312. private _currentPriorityLevel;
  72313. private _targetFrameRate;
  72314. private _trackerDuration;
  72315. private _currentFrameRate;
  72316. private _sceneDisposeObserver;
  72317. private _improvementMode;
  72318. /**
  72319. * Defines an observable called when the optimizer reaches the target frame rate
  72320. */
  72321. onSuccessObservable: Observable<SceneOptimizer>;
  72322. /**
  72323. * Defines an observable called when the optimizer enables an optimization
  72324. */
  72325. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72326. /**
  72327. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72328. */
  72329. onFailureObservable: Observable<SceneOptimizer>;
  72330. /**
  72331. * Gets a boolean indicating if the optimizer is in improvement mode
  72332. */
  72333. get isInImprovementMode(): boolean;
  72334. /**
  72335. * Gets the current priority level (0 at start)
  72336. */
  72337. get currentPriorityLevel(): number;
  72338. /**
  72339. * Gets the current frame rate checked by the SceneOptimizer
  72340. */
  72341. get currentFrameRate(): number;
  72342. /**
  72343. * Gets or sets the current target frame rate (60 by default)
  72344. */
  72345. get targetFrameRate(): number;
  72346. /**
  72347. * Gets or sets the current target frame rate (60 by default)
  72348. */
  72349. set targetFrameRate(value: number);
  72350. /**
  72351. * Gets or sets the current interval between two checks (every 2000ms by default)
  72352. */
  72353. get trackerDuration(): number;
  72354. /**
  72355. * Gets or sets the current interval between two checks (every 2000ms by default)
  72356. */
  72357. set trackerDuration(value: number);
  72358. /**
  72359. * Gets the list of active optimizations
  72360. */
  72361. get optimizations(): SceneOptimization[];
  72362. /**
  72363. * Creates a new SceneOptimizer
  72364. * @param scene defines the scene to work on
  72365. * @param options defines the options to use with the SceneOptimizer
  72366. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72367. * @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)
  72368. */
  72369. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72370. /**
  72371. * Stops the current optimizer
  72372. */
  72373. stop(): void;
  72374. /**
  72375. * Reset the optimizer to initial step (current priority level = 0)
  72376. */
  72377. reset(): void;
  72378. /**
  72379. * Start the optimizer. By default it will try to reach a specific framerate
  72380. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72381. */
  72382. start(): void;
  72383. private _checkCurrentState;
  72384. /**
  72385. * Release all resources
  72386. */
  72387. dispose(): void;
  72388. /**
  72389. * Helper function to create a SceneOptimizer with one single line of code
  72390. * @param scene defines the scene to work on
  72391. * @param options defines the options to use with the SceneOptimizer
  72392. * @param onSuccess defines a callback to call on success
  72393. * @param onFailure defines a callback to call on failure
  72394. * @returns the new SceneOptimizer object
  72395. */
  72396. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72397. }
  72398. }
  72399. declare module "babylonjs/Misc/sceneSerializer" {
  72400. import { Scene } from "babylonjs/scene";
  72401. /**
  72402. * Class used to serialize a scene into a string
  72403. */
  72404. export class SceneSerializer {
  72405. /**
  72406. * Clear cache used by a previous serialization
  72407. */
  72408. static ClearCache(): void;
  72409. /**
  72410. * Serialize a scene into a JSON compatible object
  72411. * @param scene defines the scene to serialize
  72412. * @returns a JSON compatible object
  72413. */
  72414. static Serialize(scene: Scene): any;
  72415. /**
  72416. * Serialize a mesh into a JSON compatible object
  72417. * @param toSerialize defines the mesh to serialize
  72418. * @param withParents defines if parents must be serialized as well
  72419. * @param withChildren defines if children must be serialized as well
  72420. * @returns a JSON compatible object
  72421. */
  72422. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72423. }
  72424. }
  72425. declare module "babylonjs/Misc/textureTools" {
  72426. import { Texture } from "babylonjs/Materials/Textures/texture";
  72427. /**
  72428. * Class used to host texture specific utilities
  72429. */
  72430. export class TextureTools {
  72431. /**
  72432. * Uses the GPU to create a copy texture rescaled at a given size
  72433. * @param texture Texture to copy from
  72434. * @param width defines the desired width
  72435. * @param height defines the desired height
  72436. * @param useBilinearMode defines if bilinear mode has to be used
  72437. * @return the generated texture
  72438. */
  72439. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72440. }
  72441. }
  72442. declare module "babylonjs/Misc/videoRecorder" {
  72443. import { Nullable } from "babylonjs/types";
  72444. import { Engine } from "babylonjs/Engines/engine";
  72445. /**
  72446. * This represents the different options available for the video capture.
  72447. */
  72448. export interface VideoRecorderOptions {
  72449. /** Defines the mime type of the video. */
  72450. mimeType: string;
  72451. /** Defines the FPS the video should be recorded at. */
  72452. fps: number;
  72453. /** Defines the chunk size for the recording data. */
  72454. recordChunckSize: number;
  72455. /** The audio tracks to attach to the recording. */
  72456. audioTracks?: MediaStreamTrack[];
  72457. }
  72458. /**
  72459. * This can help with recording videos from BabylonJS.
  72460. * This is based on the available WebRTC functionalities of the browser.
  72461. *
  72462. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72463. */
  72464. export class VideoRecorder {
  72465. private static readonly _defaultOptions;
  72466. /**
  72467. * Returns whether or not the VideoRecorder is available in your browser.
  72468. * @param engine Defines the Babylon Engine.
  72469. * @returns true if supported otherwise false.
  72470. */
  72471. static IsSupported(engine: Engine): boolean;
  72472. private readonly _options;
  72473. private _canvas;
  72474. private _mediaRecorder;
  72475. private _recordedChunks;
  72476. private _fileName;
  72477. private _resolve;
  72478. private _reject;
  72479. /**
  72480. * True when a recording is already in progress.
  72481. */
  72482. get isRecording(): boolean;
  72483. /**
  72484. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72485. * @param engine Defines the BabylonJS Engine you wish to record.
  72486. * @param options Defines options that can be used to customize the capture.
  72487. */
  72488. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72489. /**
  72490. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72491. */
  72492. stopRecording(): void;
  72493. /**
  72494. * Starts recording the canvas for a max duration specified in parameters.
  72495. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72496. * If null no automatic download will start and you can rely on the promise to get the data back.
  72497. * @param maxDuration Defines the maximum recording time in seconds.
  72498. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72499. * @return A promise callback at the end of the recording with the video data in Blob.
  72500. */
  72501. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72502. /**
  72503. * Releases internal resources used during the recording.
  72504. */
  72505. dispose(): void;
  72506. private _handleDataAvailable;
  72507. private _handleError;
  72508. private _handleStop;
  72509. }
  72510. }
  72511. declare module "babylonjs/Misc/screenshotTools" {
  72512. import { Camera } from "babylonjs/Cameras/camera";
  72513. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72514. import { Engine } from "babylonjs/Engines/engine";
  72515. /**
  72516. * Class containing a set of static utilities functions for screenshots
  72517. */
  72518. export class ScreenshotTools {
  72519. /**
  72520. * Captures a screenshot of the current rendering
  72521. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72522. * @param engine defines the rendering engine
  72523. * @param camera defines the source camera
  72524. * @param size This parameter can be set to a single number or to an object with the
  72525. * following (optional) properties: precision, width, height. If a single number is passed,
  72526. * it will be used for both width and height. If an object is passed, the screenshot size
  72527. * will be derived from the parameters. The precision property is a multiplier allowing
  72528. * rendering at a higher or lower resolution
  72529. * @param successCallback defines the callback receives a single parameter which contains the
  72530. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72531. * src parameter of an <img> to display it
  72532. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72533. * Check your browser for supported MIME types
  72534. */
  72535. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72536. /**
  72537. * Captures a screenshot of the current rendering
  72538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72539. * @param engine defines the rendering engine
  72540. * @param camera defines the source camera
  72541. * @param size This parameter can be set to a single number or to an object with the
  72542. * following (optional) properties: precision, width, height. If a single number is passed,
  72543. * it will be used for both width and height. If an object is passed, the screenshot size
  72544. * will be derived from the parameters. The precision property is a multiplier allowing
  72545. * rendering at a higher or lower resolution
  72546. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72547. * Check your browser for supported MIME types
  72548. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72549. * to the src parameter of an <img> to display it
  72550. */
  72551. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72552. /**
  72553. * Generates an image screenshot from the specified camera.
  72554. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72555. * @param engine The engine to use for rendering
  72556. * @param camera The camera to use for rendering
  72557. * @param size This parameter can be set to a single number or to an object with the
  72558. * following (optional) properties: precision, width, height. If a single number is passed,
  72559. * it will be used for both width and height. If an object is passed, the screenshot size
  72560. * will be derived from the parameters. The precision property is a multiplier allowing
  72561. * rendering at a higher or lower resolution
  72562. * @param successCallback The callback receives a single parameter which contains the
  72563. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72564. * src parameter of an <img> to display it
  72565. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72566. * Check your browser for supported MIME types
  72567. * @param samples Texture samples (default: 1)
  72568. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72569. * @param fileName A name for for the downloaded file.
  72570. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72571. */
  72572. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72573. /**
  72574. * Generates an image screenshot from the specified camera.
  72575. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72576. * @param engine The engine to use for rendering
  72577. * @param camera The camera to use for rendering
  72578. * @param size This parameter can be set to a single number or to an object with the
  72579. * following (optional) properties: precision, width, height. If a single number is passed,
  72580. * it will be used for both width and height. If an object is passed, the screenshot size
  72581. * will be derived from the parameters. The precision property is a multiplier allowing
  72582. * rendering at a higher or lower resolution
  72583. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72584. * Check your browser for supported MIME types
  72585. * @param samples Texture samples (default: 1)
  72586. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72587. * @param fileName A name for for the downloaded file.
  72588. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72590. * to the src parameter of an <img> to display it
  72591. */
  72592. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72593. /**
  72594. * Gets height and width for screenshot size
  72595. * @private
  72596. */
  72597. private static _getScreenshotSize;
  72598. }
  72599. }
  72600. declare module "babylonjs/Misc/dataReader" {
  72601. /**
  72602. * Interface for a data buffer
  72603. */
  72604. export interface IDataBuffer {
  72605. /**
  72606. * Reads bytes from the data buffer.
  72607. * @param byteOffset The byte offset to read
  72608. * @param byteLength The byte length to read
  72609. * @returns A promise that resolves when the bytes are read
  72610. */
  72611. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72612. /**
  72613. * The byte length of the buffer.
  72614. */
  72615. readonly byteLength: number;
  72616. }
  72617. /**
  72618. * Utility class for reading from a data buffer
  72619. */
  72620. export class DataReader {
  72621. /**
  72622. * The data buffer associated with this data reader.
  72623. */
  72624. readonly buffer: IDataBuffer;
  72625. /**
  72626. * The current byte offset from the beginning of the data buffer.
  72627. */
  72628. byteOffset: number;
  72629. private _dataView;
  72630. private _dataByteOffset;
  72631. /**
  72632. * Constructor
  72633. * @param buffer The buffer to read
  72634. */
  72635. constructor(buffer: IDataBuffer);
  72636. /**
  72637. * Loads the given byte length.
  72638. * @param byteLength The byte length to load
  72639. * @returns A promise that resolves when the load is complete
  72640. */
  72641. loadAsync(byteLength: number): Promise<void>;
  72642. /**
  72643. * Read a unsigned 32-bit integer from the currently loaded data range.
  72644. * @returns The 32-bit integer read
  72645. */
  72646. readUint32(): number;
  72647. /**
  72648. * Read a byte array from the currently loaded data range.
  72649. * @param byteLength The byte length to read
  72650. * @returns The byte array read
  72651. */
  72652. readUint8Array(byteLength: number): Uint8Array;
  72653. /**
  72654. * Read a string from the currently loaded data range.
  72655. * @param byteLength The byte length to read
  72656. * @returns The string read
  72657. */
  72658. readString(byteLength: number): string;
  72659. /**
  72660. * Skips the given byte length the currently loaded data range.
  72661. * @param byteLength The byte length to skip
  72662. */
  72663. skipBytes(byteLength: number): void;
  72664. }
  72665. }
  72666. declare module "babylonjs/Misc/dataStorage" {
  72667. /**
  72668. * Class for storing data to local storage if available or in-memory storage otherwise
  72669. */
  72670. export class DataStorage {
  72671. private static _Storage;
  72672. private static _GetStorage;
  72673. /**
  72674. * Reads a string from the data storage
  72675. * @param key The key to read
  72676. * @param defaultValue The value if the key doesn't exist
  72677. * @returns The string value
  72678. */
  72679. static ReadString(key: string, defaultValue: string): string;
  72680. /**
  72681. * Writes a string to the data storage
  72682. * @param key The key to write
  72683. * @param value The value to write
  72684. */
  72685. static WriteString(key: string, value: string): void;
  72686. /**
  72687. * Reads a boolean from the data storage
  72688. * @param key The key to read
  72689. * @param defaultValue The value if the key doesn't exist
  72690. * @returns The boolean value
  72691. */
  72692. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72693. /**
  72694. * Writes a boolean to the data storage
  72695. * @param key The key to write
  72696. * @param value The value to write
  72697. */
  72698. static WriteBoolean(key: string, value: boolean): void;
  72699. /**
  72700. * Reads a number from the data storage
  72701. * @param key The key to read
  72702. * @param defaultValue The value if the key doesn't exist
  72703. * @returns The number value
  72704. */
  72705. static ReadNumber(key: string, defaultValue: number): number;
  72706. /**
  72707. * Writes a number to the data storage
  72708. * @param key The key to write
  72709. * @param value The value to write
  72710. */
  72711. static WriteNumber(key: string, value: number): void;
  72712. }
  72713. }
  72714. declare module "babylonjs/Misc/index" {
  72715. export * from "babylonjs/Misc/andOrNotEvaluator";
  72716. export * from "babylonjs/Misc/assetsManager";
  72717. export * from "babylonjs/Misc/basis";
  72718. export * from "babylonjs/Misc/dds";
  72719. export * from "babylonjs/Misc/decorators";
  72720. export * from "babylonjs/Misc/deferred";
  72721. export * from "babylonjs/Misc/environmentTextureTools";
  72722. export * from "babylonjs/Misc/meshExploder";
  72723. export * from "babylonjs/Misc/filesInput";
  72724. export * from "babylonjs/Misc/HighDynamicRange/index";
  72725. export * from "babylonjs/Misc/khronosTextureContainer";
  72726. export * from "babylonjs/Misc/observable";
  72727. export * from "babylonjs/Misc/performanceMonitor";
  72728. export * from "babylonjs/Misc/promise";
  72729. export * from "babylonjs/Misc/sceneOptimizer";
  72730. export * from "babylonjs/Misc/sceneSerializer";
  72731. export * from "babylonjs/Misc/smartArray";
  72732. export * from "babylonjs/Misc/stringDictionary";
  72733. export * from "babylonjs/Misc/tags";
  72734. export * from "babylonjs/Misc/textureTools";
  72735. export * from "babylonjs/Misc/tga";
  72736. export * from "babylonjs/Misc/tools";
  72737. export * from "babylonjs/Misc/videoRecorder";
  72738. export * from "babylonjs/Misc/virtualJoystick";
  72739. export * from "babylonjs/Misc/workerPool";
  72740. export * from "babylonjs/Misc/logger";
  72741. export * from "babylonjs/Misc/typeStore";
  72742. export * from "babylonjs/Misc/filesInputStore";
  72743. export * from "babylonjs/Misc/deepCopier";
  72744. export * from "babylonjs/Misc/pivotTools";
  72745. export * from "babylonjs/Misc/precisionDate";
  72746. export * from "babylonjs/Misc/screenshotTools";
  72747. export * from "babylonjs/Misc/typeStore";
  72748. export * from "babylonjs/Misc/webRequest";
  72749. export * from "babylonjs/Misc/iInspectable";
  72750. export * from "babylonjs/Misc/brdfTextureTools";
  72751. export * from "babylonjs/Misc/rgbdTextureTools";
  72752. export * from "babylonjs/Misc/gradients";
  72753. export * from "babylonjs/Misc/perfCounter";
  72754. export * from "babylonjs/Misc/fileRequest";
  72755. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72756. export * from "babylonjs/Misc/retryStrategy";
  72757. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72758. export * from "babylonjs/Misc/canvasGenerator";
  72759. export * from "babylonjs/Misc/fileTools";
  72760. export * from "babylonjs/Misc/stringTools";
  72761. export * from "babylonjs/Misc/dataReader";
  72762. export * from "babylonjs/Misc/minMaxReducer";
  72763. export * from "babylonjs/Misc/depthReducer";
  72764. export * from "babylonjs/Misc/dataStorage";
  72765. }
  72766. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72767. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72768. import { Observable } from "babylonjs/Misc/observable";
  72769. import { Matrix } from "babylonjs/Maths/math.vector";
  72770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72771. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72772. /**
  72773. * Options used for hit testing
  72774. */
  72775. export interface IWebXRHitTestOptions {
  72776. /**
  72777. * Only test when user interacted with the scene. Default - hit test every frame
  72778. */
  72779. testOnPointerDownOnly?: boolean;
  72780. /**
  72781. * The node to use to transform the local results to world coordinates
  72782. */
  72783. worldParentNode?: TransformNode;
  72784. }
  72785. /**
  72786. * Interface defining the babylon result of raycasting/hit-test
  72787. */
  72788. export interface IWebXRHitResult {
  72789. /**
  72790. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72791. */
  72792. transformationMatrix: Matrix;
  72793. /**
  72794. * The native hit test result
  72795. */
  72796. xrHitResult: XRHitResult;
  72797. }
  72798. /**
  72799. * The currently-working hit-test module.
  72800. * Hit test (or Ray-casting) is used to interact with the real world.
  72801. * For further information read here - https://github.com/immersive-web/hit-test
  72802. */
  72803. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72804. /**
  72805. * options to use when constructing this feature
  72806. */
  72807. readonly options: IWebXRHitTestOptions;
  72808. private _direction;
  72809. private _mat;
  72810. private _onSelectEnabled;
  72811. private _origin;
  72812. /**
  72813. * The module's name
  72814. */
  72815. static readonly Name: string;
  72816. /**
  72817. * The (Babylon) version of this module.
  72818. * This is an integer representing the implementation version.
  72819. * This number does not correspond to the WebXR specs version
  72820. */
  72821. static readonly Version: number;
  72822. /**
  72823. * Populated with the last native XR Hit Results
  72824. */
  72825. lastNativeXRHitResults: XRHitResult[];
  72826. /**
  72827. * Triggered when new babylon (transformed) hit test results are available
  72828. */
  72829. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72830. /**
  72831. * Creates a new instance of the (legacy version) hit test feature
  72832. * @param _xrSessionManager an instance of WebXRSessionManager
  72833. * @param options options to use when constructing this feature
  72834. */
  72835. constructor(_xrSessionManager: WebXRSessionManager,
  72836. /**
  72837. * options to use when constructing this feature
  72838. */
  72839. options?: IWebXRHitTestOptions);
  72840. /**
  72841. * execute a hit test with an XR Ray
  72842. *
  72843. * @param xrSession a native xrSession that will execute this hit test
  72844. * @param xrRay the ray (position and direction) to use for ray-casting
  72845. * @param referenceSpace native XR reference space to use for the hit-test
  72846. * @param filter filter function that will filter the results
  72847. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72848. */
  72849. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72850. /**
  72851. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72852. * @param event the (select) event to use to select with
  72853. * @param referenceSpace the reference space to use for this hit test
  72854. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72855. */
  72856. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72857. /**
  72858. * attach this feature
  72859. * Will usually be called by the features manager
  72860. *
  72861. * @returns true if successful.
  72862. */
  72863. attach(): boolean;
  72864. /**
  72865. * detach this feature.
  72866. * Will usually be called by the features manager
  72867. *
  72868. * @returns true if successful.
  72869. */
  72870. detach(): boolean;
  72871. /**
  72872. * Dispose this feature and all of the resources attached
  72873. */
  72874. dispose(): void;
  72875. protected _onXRFrame(frame: XRFrame): void;
  72876. private _onHitTestResults;
  72877. private _onSelect;
  72878. }
  72879. }
  72880. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72881. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72882. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72883. import { Observable } from "babylonjs/Misc/observable";
  72884. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72885. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72886. /**
  72887. * Options used in the plane detector module
  72888. */
  72889. export interface IWebXRPlaneDetectorOptions {
  72890. /**
  72891. * The node to use to transform the local results to world coordinates
  72892. */
  72893. worldParentNode?: TransformNode;
  72894. }
  72895. /**
  72896. * A babylon interface for a WebXR plane.
  72897. * A Plane is actually a polygon, built from N points in space
  72898. *
  72899. * Supported in chrome 79, not supported in canary 81 ATM
  72900. */
  72901. export interface IWebXRPlane {
  72902. /**
  72903. * a babylon-assigned ID for this polygon
  72904. */
  72905. id: number;
  72906. /**
  72907. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72908. */
  72909. polygonDefinition: Array<Vector3>;
  72910. /**
  72911. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72912. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72913. */
  72914. transformationMatrix: Matrix;
  72915. /**
  72916. * the native xr-plane object
  72917. */
  72918. xrPlane: XRPlane;
  72919. }
  72920. /**
  72921. * The plane detector is used to detect planes in the real world when in AR
  72922. * For more information see https://github.com/immersive-web/real-world-geometry/
  72923. */
  72924. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72925. private _options;
  72926. private _detectedPlanes;
  72927. private _enabled;
  72928. private _lastFrameDetected;
  72929. /**
  72930. * The module's name
  72931. */
  72932. static readonly Name: string;
  72933. /**
  72934. * The (Babylon) version of this module.
  72935. * This is an integer representing the implementation version.
  72936. * This number does not correspond to the WebXR specs version
  72937. */
  72938. static readonly Version: number;
  72939. /**
  72940. * Observers registered here will be executed when a new plane was added to the session
  72941. */
  72942. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72943. /**
  72944. * Observers registered here will be executed when a plane is no longer detected in the session
  72945. */
  72946. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72947. /**
  72948. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72949. * This can execute N times every frame
  72950. */
  72951. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72952. /**
  72953. * construct a new Plane Detector
  72954. * @param _xrSessionManager an instance of xr Session manager
  72955. * @param _options configuration to use when constructing this feature
  72956. */
  72957. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72958. /**
  72959. * Dispose this feature and all of the resources attached
  72960. */
  72961. dispose(): void;
  72962. protected _onXRFrame(frame: XRFrame): void;
  72963. private _init;
  72964. private _updatePlaneWithXRPlane;
  72965. /**
  72966. * avoiding using Array.find for global support.
  72967. * @param xrPlane the plane to find in the array
  72968. */
  72969. private findIndexInPlaneArray;
  72970. }
  72971. }
  72972. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72973. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72974. import { Observable } from "babylonjs/Misc/observable";
  72975. import { Matrix } from "babylonjs/Maths/math.vector";
  72976. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72977. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72978. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72979. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72980. /**
  72981. * Configuration options of the anchor system
  72982. */
  72983. export interface IWebXRAnchorSystemOptions {
  72984. /**
  72985. * Should a new anchor be added every time a select event is triggered
  72986. */
  72987. addAnchorOnSelect?: boolean;
  72988. /**
  72989. * should the anchor system use plane detection.
  72990. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72991. */
  72992. usePlaneDetection?: boolean;
  72993. /**
  72994. * a node that will be used to convert local to world coordinates
  72995. */
  72996. worldParentNode?: TransformNode;
  72997. }
  72998. /**
  72999. * A babylon container for an XR Anchor
  73000. */
  73001. export interface IWebXRAnchor {
  73002. /**
  73003. * A babylon-assigned ID for this anchor
  73004. */
  73005. id: number;
  73006. /**
  73007. * Transformation matrix to apply to an object attached to this anchor
  73008. */
  73009. transformationMatrix: Matrix;
  73010. /**
  73011. * The native anchor object
  73012. */
  73013. xrAnchor: XRAnchor;
  73014. }
  73015. /**
  73016. * An implementation of the anchor system of WebXR.
  73017. * Note that the current documented implementation is not available in any browser. Future implementations
  73018. * will use the frame to create an anchor and not the session or a detected plane
  73019. * For further information see https://github.com/immersive-web/anchors/
  73020. */
  73021. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73022. private _options;
  73023. private _enabled;
  73024. private _hitTestModule;
  73025. private _lastFrameDetected;
  73026. private _onSelect;
  73027. private _planeDetector;
  73028. private _trackedAnchors;
  73029. /**
  73030. * The module's name
  73031. */
  73032. static readonly Name: string;
  73033. /**
  73034. * The (Babylon) version of this module.
  73035. * This is an integer representing the implementation version.
  73036. * This number does not correspond to the WebXR specs version
  73037. */
  73038. static readonly Version: number;
  73039. /**
  73040. * Observers registered here will be executed when a new anchor was added to the session
  73041. */
  73042. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73043. /**
  73044. * Observers registered here will be executed when an anchor was removed from the session
  73045. */
  73046. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73047. /**
  73048. * Observers registered here will be executed when an existing anchor updates
  73049. * This can execute N times every frame
  73050. */
  73051. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73052. /**
  73053. * constructs a new anchor system
  73054. * @param _xrSessionManager an instance of WebXRSessionManager
  73055. * @param _options configuration object for this feature
  73056. */
  73057. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73058. /**
  73059. * Add anchor at a specific XR point.
  73060. *
  73061. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73062. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73063. * @returns a promise the fulfills when the anchor was created
  73064. */
  73065. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73066. /**
  73067. * attach this feature
  73068. * Will usually be called by the features manager
  73069. *
  73070. * @returns true if successful.
  73071. */
  73072. attach(): boolean;
  73073. /**
  73074. * detach this feature.
  73075. * Will usually be called by the features manager
  73076. *
  73077. * @returns true if successful.
  73078. */
  73079. detach(): boolean;
  73080. /**
  73081. * Dispose this feature and all of the resources attached
  73082. */
  73083. dispose(): void;
  73084. /**
  73085. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73086. * @param hitTestModule the hit-test module to use.
  73087. */
  73088. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73089. /**
  73090. * set the plane detector to use in order to create anchors from frames
  73091. * @param planeDetector the plane-detector module to use
  73092. * @param enable enable plane-anchors. default is true
  73093. */
  73094. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73095. protected _onXRFrame(frame: XRFrame): void;
  73096. /**
  73097. * avoiding using Array.find for global support.
  73098. * @param xrAnchor the plane to find in the array
  73099. */
  73100. private _findIndexInAnchorArray;
  73101. private _updateAnchorWithXRFrame;
  73102. }
  73103. }
  73104. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73105. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73107. import { Observable } from "babylonjs/Misc/observable";
  73108. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73109. /**
  73110. * Options interface for the background remover plugin
  73111. */
  73112. export interface IWebXRBackgroundRemoverOptions {
  73113. /**
  73114. * Further background meshes to disable when entering AR
  73115. */
  73116. backgroundMeshes?: AbstractMesh[];
  73117. /**
  73118. * flags to configure the removal of the environment helper.
  73119. * If not set, the entire background will be removed. If set, flags should be set as well.
  73120. */
  73121. environmentHelperRemovalFlags?: {
  73122. /**
  73123. * Should the skybox be removed (default false)
  73124. */
  73125. skyBox?: boolean;
  73126. /**
  73127. * Should the ground be removed (default false)
  73128. */
  73129. ground?: boolean;
  73130. };
  73131. /**
  73132. * don't disable the environment helper
  73133. */
  73134. ignoreEnvironmentHelper?: boolean;
  73135. }
  73136. /**
  73137. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73138. */
  73139. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73140. /**
  73141. * read-only options to be used in this module
  73142. */
  73143. readonly options: IWebXRBackgroundRemoverOptions;
  73144. /**
  73145. * The module's name
  73146. */
  73147. static readonly Name: string;
  73148. /**
  73149. * The (Babylon) version of this module.
  73150. * This is an integer representing the implementation version.
  73151. * This number does not correspond to the WebXR specs version
  73152. */
  73153. static readonly Version: number;
  73154. /**
  73155. * registered observers will be triggered when the background state changes
  73156. */
  73157. onBackgroundStateChangedObservable: Observable<boolean>;
  73158. /**
  73159. * constructs a new background remover module
  73160. * @param _xrSessionManager the session manager for this module
  73161. * @param options read-only options to be used in this module
  73162. */
  73163. constructor(_xrSessionManager: WebXRSessionManager,
  73164. /**
  73165. * read-only options to be used in this module
  73166. */
  73167. options?: IWebXRBackgroundRemoverOptions);
  73168. /**
  73169. * attach this feature
  73170. * Will usually be called by the features manager
  73171. *
  73172. * @returns true if successful.
  73173. */
  73174. attach(): boolean;
  73175. /**
  73176. * detach this feature.
  73177. * Will usually be called by the features manager
  73178. *
  73179. * @returns true if successful.
  73180. */
  73181. detach(): boolean;
  73182. /**
  73183. * Dispose this feature and all of the resources attached
  73184. */
  73185. dispose(): void;
  73186. protected _onXRFrame(_xrFrame: XRFrame): void;
  73187. private _setBackgroundState;
  73188. }
  73189. }
  73190. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73191. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73192. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73193. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73194. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73195. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73196. import { Nullable } from "babylonjs/types";
  73197. /**
  73198. * Options for the controller physics feature
  73199. */
  73200. export class IWebXRControllerPhysicsOptions {
  73201. /**
  73202. * Should the headset get its own impostor
  73203. */
  73204. enableHeadsetImpostor?: boolean;
  73205. /**
  73206. * Optional parameters for the headset impostor
  73207. */
  73208. headsetImpostorParams?: {
  73209. /**
  73210. * The type of impostor to create. Default is sphere
  73211. */
  73212. impostorType: number;
  73213. /**
  73214. * the size of the impostor. Defaults to 10cm
  73215. */
  73216. impostorSize?: number | {
  73217. width: number;
  73218. height: number;
  73219. depth: number;
  73220. };
  73221. /**
  73222. * Friction definitions
  73223. */
  73224. friction?: number;
  73225. /**
  73226. * Restitution
  73227. */
  73228. restitution?: number;
  73229. };
  73230. /**
  73231. * The physics properties of the future impostors
  73232. */
  73233. physicsProperties?: {
  73234. /**
  73235. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73236. * Note that this requires a physics engine that supports mesh impostors!
  73237. */
  73238. useControllerMesh?: boolean;
  73239. /**
  73240. * The type of impostor to create. Default is sphere
  73241. */
  73242. impostorType?: number;
  73243. /**
  73244. * the size of the impostor. Defaults to 10cm
  73245. */
  73246. impostorSize?: number | {
  73247. width: number;
  73248. height: number;
  73249. depth: number;
  73250. };
  73251. /**
  73252. * Friction definitions
  73253. */
  73254. friction?: number;
  73255. /**
  73256. * Restitution
  73257. */
  73258. restitution?: number;
  73259. };
  73260. /**
  73261. * the xr input to use with this pointer selection
  73262. */
  73263. xrInput: WebXRInput;
  73264. }
  73265. /**
  73266. * Add physics impostor to your webxr controllers,
  73267. * including naive calculation of their linear and angular velocity
  73268. */
  73269. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73270. private readonly _options;
  73271. private _attachController;
  73272. private _controllers;
  73273. private _debugMode;
  73274. private _delta;
  73275. private _headsetImpostor?;
  73276. private _headsetMesh?;
  73277. private _lastTimestamp;
  73278. private _tmpQuaternion;
  73279. private _tmpVector;
  73280. /**
  73281. * The module's name
  73282. */
  73283. static readonly Name: string;
  73284. /**
  73285. * The (Babylon) version of this module.
  73286. * This is an integer representing the implementation version.
  73287. * This number does not correspond to the webxr specs version
  73288. */
  73289. static readonly Version: number;
  73290. /**
  73291. * Construct a new Controller Physics Feature
  73292. * @param _xrSessionManager the corresponding xr session manager
  73293. * @param _options options to create this feature with
  73294. */
  73295. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73296. /**
  73297. * @hidden
  73298. * enable debugging - will show console outputs and the impostor mesh
  73299. */
  73300. _enablePhysicsDebug(): void;
  73301. /**
  73302. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73303. * @param xrController the controller to add
  73304. */
  73305. addController(xrController: WebXRInputSource): void;
  73306. /**
  73307. * attach this feature
  73308. * Will usually be called by the features manager
  73309. *
  73310. * @returns true if successful.
  73311. */
  73312. attach(): boolean;
  73313. /**
  73314. * detach this feature.
  73315. * Will usually be called by the features manager
  73316. *
  73317. * @returns true if successful.
  73318. */
  73319. detach(): boolean;
  73320. /**
  73321. * Get the headset impostor, if enabled
  73322. * @returns the impostor
  73323. */
  73324. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73325. /**
  73326. * Get the physics impostor of a specific controller.
  73327. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73328. * @param controller the controller or the controller id of which to get the impostor
  73329. * @returns the impostor or null
  73330. */
  73331. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73332. /**
  73333. * Update the physics properties provided in the constructor
  73334. * @param newProperties the new properties object
  73335. */
  73336. setPhysicsProperties(newProperties: {
  73337. impostorType?: number;
  73338. impostorSize?: number | {
  73339. width: number;
  73340. height: number;
  73341. depth: number;
  73342. };
  73343. friction?: number;
  73344. restitution?: number;
  73345. }): void;
  73346. protected _onXRFrame(_xrFrame: any): void;
  73347. private _detachController;
  73348. }
  73349. }
  73350. declare module "babylonjs/XR/features/index" {
  73351. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73352. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73353. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73354. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73355. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73356. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73357. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73358. }
  73359. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73360. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73362. import { Scene } from "babylonjs/scene";
  73363. /**
  73364. * The motion controller class for all microsoft mixed reality controllers
  73365. */
  73366. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73367. protected readonly _mapping: {
  73368. defaultButton: {
  73369. "valueNodeName": string;
  73370. "unpressedNodeName": string;
  73371. "pressedNodeName": string;
  73372. };
  73373. defaultAxis: {
  73374. "valueNodeName": string;
  73375. "minNodeName": string;
  73376. "maxNodeName": string;
  73377. };
  73378. buttons: {
  73379. "xr-standard-trigger": {
  73380. "rootNodeName": string;
  73381. "componentProperty": string;
  73382. "states": string[];
  73383. };
  73384. "xr-standard-squeeze": {
  73385. "rootNodeName": string;
  73386. "componentProperty": string;
  73387. "states": string[];
  73388. };
  73389. "xr-standard-touchpad": {
  73390. "rootNodeName": string;
  73391. "labelAnchorNodeName": string;
  73392. "touchPointNodeName": string;
  73393. };
  73394. "xr-standard-thumbstick": {
  73395. "rootNodeName": string;
  73396. "componentProperty": string;
  73397. "states": string[];
  73398. };
  73399. };
  73400. axes: {
  73401. "xr-standard-touchpad": {
  73402. "x-axis": {
  73403. "rootNodeName": string;
  73404. };
  73405. "y-axis": {
  73406. "rootNodeName": string;
  73407. };
  73408. };
  73409. "xr-standard-thumbstick": {
  73410. "x-axis": {
  73411. "rootNodeName": string;
  73412. };
  73413. "y-axis": {
  73414. "rootNodeName": string;
  73415. };
  73416. };
  73417. };
  73418. };
  73419. /**
  73420. * The base url used to load the left and right controller models
  73421. */
  73422. static MODEL_BASE_URL: string;
  73423. /**
  73424. * The name of the left controller model file
  73425. */
  73426. static MODEL_LEFT_FILENAME: string;
  73427. /**
  73428. * The name of the right controller model file
  73429. */
  73430. static MODEL_RIGHT_FILENAME: string;
  73431. profileId: string;
  73432. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73433. protected _getFilenameAndPath(): {
  73434. filename: string;
  73435. path: string;
  73436. };
  73437. protected _getModelLoadingConstraints(): boolean;
  73438. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73439. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73440. protected _updateModel(): void;
  73441. }
  73442. }
  73443. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73444. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73446. import { Scene } from "babylonjs/scene";
  73447. /**
  73448. * The motion controller class for oculus touch (quest, rift).
  73449. * This class supports legacy mapping as well the standard xr mapping
  73450. */
  73451. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73452. private _forceLegacyControllers;
  73453. private _modelRootNode;
  73454. /**
  73455. * The base url used to load the left and right controller models
  73456. */
  73457. static MODEL_BASE_URL: string;
  73458. /**
  73459. * The name of the left controller model file
  73460. */
  73461. static MODEL_LEFT_FILENAME: string;
  73462. /**
  73463. * The name of the right controller model file
  73464. */
  73465. static MODEL_RIGHT_FILENAME: string;
  73466. /**
  73467. * Base Url for the Quest controller model.
  73468. */
  73469. static QUEST_MODEL_BASE_URL: string;
  73470. profileId: string;
  73471. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73472. protected _getFilenameAndPath(): {
  73473. filename: string;
  73474. path: string;
  73475. };
  73476. protected _getModelLoadingConstraints(): boolean;
  73477. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73478. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73479. protected _updateModel(): void;
  73480. /**
  73481. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73482. * between the touch and touch 2.
  73483. */
  73484. private _isQuest;
  73485. }
  73486. }
  73487. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73488. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73489. import { Scene } from "babylonjs/scene";
  73490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73491. /**
  73492. * The motion controller class for the standard HTC-Vive controllers
  73493. */
  73494. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73495. private _modelRootNode;
  73496. /**
  73497. * The base url used to load the left and right controller models
  73498. */
  73499. static MODEL_BASE_URL: string;
  73500. /**
  73501. * File name for the controller model.
  73502. */
  73503. static MODEL_FILENAME: string;
  73504. profileId: string;
  73505. /**
  73506. * Create a new Vive motion controller object
  73507. * @param scene the scene to use to create this controller
  73508. * @param gamepadObject the corresponding gamepad object
  73509. * @param handness the handness of the controller
  73510. */
  73511. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73512. protected _getFilenameAndPath(): {
  73513. filename: string;
  73514. path: string;
  73515. };
  73516. protected _getModelLoadingConstraints(): boolean;
  73517. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73518. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73519. protected _updateModel(): void;
  73520. }
  73521. }
  73522. declare module "babylonjs/XR/motionController/index" {
  73523. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73524. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73525. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73526. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73527. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73528. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73529. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73530. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73531. }
  73532. declare module "babylonjs/XR/index" {
  73533. export * from "babylonjs/XR/webXRCamera";
  73534. export * from "babylonjs/XR/webXREnterExitUI";
  73535. export * from "babylonjs/XR/webXRExperienceHelper";
  73536. export * from "babylonjs/XR/webXRInput";
  73537. export * from "babylonjs/XR/webXRInputSource";
  73538. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73539. export * from "babylonjs/XR/webXRTypes";
  73540. export * from "babylonjs/XR/webXRSessionManager";
  73541. export * from "babylonjs/XR/webXRDefaultExperience";
  73542. export * from "babylonjs/XR/webXRFeaturesManager";
  73543. export * from "babylonjs/XR/features/index";
  73544. export * from "babylonjs/XR/motionController/index";
  73545. }
  73546. declare module "babylonjs/index" {
  73547. export * from "babylonjs/abstractScene";
  73548. export * from "babylonjs/Actions/index";
  73549. export * from "babylonjs/Animations/index";
  73550. export * from "babylonjs/assetContainer";
  73551. export * from "babylonjs/Audio/index";
  73552. export * from "babylonjs/Behaviors/index";
  73553. export * from "babylonjs/Bones/index";
  73554. export * from "babylonjs/Cameras/index";
  73555. export * from "babylonjs/Collisions/index";
  73556. export * from "babylonjs/Culling/index";
  73557. export * from "babylonjs/Debug/index";
  73558. export * from "babylonjs/Engines/index";
  73559. export * from "babylonjs/Events/index";
  73560. export * from "babylonjs/Gamepads/index";
  73561. export * from "babylonjs/Gizmos/index";
  73562. export * from "babylonjs/Helpers/index";
  73563. export * from "babylonjs/Instrumentation/index";
  73564. export * from "babylonjs/Layers/index";
  73565. export * from "babylonjs/LensFlares/index";
  73566. export * from "babylonjs/Lights/index";
  73567. export * from "babylonjs/Loading/index";
  73568. export * from "babylonjs/Materials/index";
  73569. export * from "babylonjs/Maths/index";
  73570. export * from "babylonjs/Meshes/index";
  73571. export * from "babylonjs/Morph/index";
  73572. export * from "babylonjs/Navigation/index";
  73573. export * from "babylonjs/node";
  73574. export * from "babylonjs/Offline/index";
  73575. export * from "babylonjs/Particles/index";
  73576. export * from "babylonjs/Physics/index";
  73577. export * from "babylonjs/PostProcesses/index";
  73578. export * from "babylonjs/Probes/index";
  73579. export * from "babylonjs/Rendering/index";
  73580. export * from "babylonjs/scene";
  73581. export * from "babylonjs/sceneComponent";
  73582. export * from "babylonjs/Sprites/index";
  73583. export * from "babylonjs/States/index";
  73584. export * from "babylonjs/Misc/index";
  73585. export * from "babylonjs/XR/index";
  73586. export * from "babylonjs/types";
  73587. }
  73588. declare module "babylonjs/Animations/pathCursor" {
  73589. import { Vector3 } from "babylonjs/Maths/math.vector";
  73590. import { Path2 } from "babylonjs/Maths/math.path";
  73591. /**
  73592. * A cursor which tracks a point on a path
  73593. */
  73594. export class PathCursor {
  73595. private path;
  73596. /**
  73597. * Stores path cursor callbacks for when an onchange event is triggered
  73598. */
  73599. private _onchange;
  73600. /**
  73601. * The value of the path cursor
  73602. */
  73603. value: number;
  73604. /**
  73605. * The animation array of the path cursor
  73606. */
  73607. animations: Animation[];
  73608. /**
  73609. * Initializes the path cursor
  73610. * @param path The path to track
  73611. */
  73612. constructor(path: Path2);
  73613. /**
  73614. * Gets the cursor point on the path
  73615. * @returns A point on the path cursor at the cursor location
  73616. */
  73617. getPoint(): Vector3;
  73618. /**
  73619. * Moves the cursor ahead by the step amount
  73620. * @param step The amount to move the cursor forward
  73621. * @returns This path cursor
  73622. */
  73623. moveAhead(step?: number): PathCursor;
  73624. /**
  73625. * Moves the cursor behind by the step amount
  73626. * @param step The amount to move the cursor back
  73627. * @returns This path cursor
  73628. */
  73629. moveBack(step?: number): PathCursor;
  73630. /**
  73631. * Moves the cursor by the step amount
  73632. * If the step amount is greater than one, an exception is thrown
  73633. * @param step The amount to move the cursor
  73634. * @returns This path cursor
  73635. */
  73636. move(step: number): PathCursor;
  73637. /**
  73638. * Ensures that the value is limited between zero and one
  73639. * @returns This path cursor
  73640. */
  73641. private ensureLimits;
  73642. /**
  73643. * Runs onchange callbacks on change (used by the animation engine)
  73644. * @returns This path cursor
  73645. */
  73646. private raiseOnChange;
  73647. /**
  73648. * Executes a function on change
  73649. * @param f A path cursor onchange callback
  73650. * @returns This path cursor
  73651. */
  73652. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73653. }
  73654. }
  73655. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73656. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73657. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73658. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73659. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73660. }
  73661. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73662. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73663. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73664. }
  73665. declare module "babylonjs/Engines/Processors/index" {
  73666. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73667. export * from "babylonjs/Engines/Processors/Expressions/index";
  73668. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73669. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73670. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73671. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73672. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73673. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73674. }
  73675. declare module "babylonjs/Legacy/legacy" {
  73676. import * as Babylon from "babylonjs/index";
  73677. export * from "babylonjs/index";
  73678. }
  73679. declare module "babylonjs/Shaders/blur.fragment" {
  73680. /** @hidden */
  73681. export var blurPixelShader: {
  73682. name: string;
  73683. shader: string;
  73684. };
  73685. }
  73686. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73687. /** @hidden */
  73688. export var pointCloudVertexDeclaration: {
  73689. name: string;
  73690. shader: string;
  73691. };
  73692. }
  73693. declare module "babylonjs" {
  73694. export * from "babylonjs/Legacy/legacy";
  73695. }
  73696. declare module BABYLON {
  73697. /** Alias type for value that can be null */
  73698. export type Nullable<T> = T | null;
  73699. /**
  73700. * Alias type for number that are floats
  73701. * @ignorenaming
  73702. */
  73703. export type float = number;
  73704. /**
  73705. * Alias type for number that are doubles.
  73706. * @ignorenaming
  73707. */
  73708. export type double = number;
  73709. /**
  73710. * Alias type for number that are integer
  73711. * @ignorenaming
  73712. */
  73713. export type int = number;
  73714. /** Alias type for number array or Float32Array */
  73715. export type FloatArray = number[] | Float32Array;
  73716. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73717. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73718. /**
  73719. * Alias for types that can be used by a Buffer or VertexBuffer.
  73720. */
  73721. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73722. /**
  73723. * Alias type for primitive types
  73724. * @ignorenaming
  73725. */
  73726. type Primitive = undefined | null | boolean | string | number | Function;
  73727. /**
  73728. * Type modifier to make all the properties of an object Readonly
  73729. */
  73730. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73731. /**
  73732. * Type modifier to make all the properties of an object Readonly recursively
  73733. */
  73734. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73735. /**
  73736. * Type modifier to make object properties readonly.
  73737. */
  73738. export type DeepImmutableObject<T> = {
  73739. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73740. };
  73741. /** @hidden */
  73742. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73743. }
  73744. }
  73745. declare module BABYLON {
  73746. /**
  73747. * A class serves as a medium between the observable and its observers
  73748. */
  73749. export class EventState {
  73750. /**
  73751. * Create a new EventState
  73752. * @param mask defines the mask associated with this state
  73753. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73754. * @param target defines the original target of the state
  73755. * @param currentTarget defines the current target of the state
  73756. */
  73757. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73758. /**
  73759. * Initialize the current event state
  73760. * @param mask defines the mask associated with this state
  73761. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73762. * @param target defines the original target of the state
  73763. * @param currentTarget defines the current target of the state
  73764. * @returns the current event state
  73765. */
  73766. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73767. /**
  73768. * An Observer can set this property to true to prevent subsequent observers of being notified
  73769. */
  73770. skipNextObservers: boolean;
  73771. /**
  73772. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73773. */
  73774. mask: number;
  73775. /**
  73776. * The object that originally notified the event
  73777. */
  73778. target?: any;
  73779. /**
  73780. * The current object in the bubbling phase
  73781. */
  73782. currentTarget?: any;
  73783. /**
  73784. * This will be populated with the return value of the last function that was executed.
  73785. * If it is the first function in the callback chain it will be the event data.
  73786. */
  73787. lastReturnValue?: any;
  73788. }
  73789. /**
  73790. * Represent an Observer registered to a given Observable object.
  73791. */
  73792. export class Observer<T> {
  73793. /**
  73794. * Defines the callback to call when the observer is notified
  73795. */
  73796. callback: (eventData: T, eventState: EventState) => void;
  73797. /**
  73798. * Defines the mask of the observer (used to filter notifications)
  73799. */
  73800. mask: number;
  73801. /**
  73802. * Defines the current scope used to restore the JS context
  73803. */
  73804. scope: any;
  73805. /** @hidden */
  73806. _willBeUnregistered: boolean;
  73807. /**
  73808. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73809. */
  73810. unregisterOnNextCall: boolean;
  73811. /**
  73812. * Creates a new observer
  73813. * @param callback defines the callback to call when the observer is notified
  73814. * @param mask defines the mask of the observer (used to filter notifications)
  73815. * @param scope defines the current scope used to restore the JS context
  73816. */
  73817. constructor(
  73818. /**
  73819. * Defines the callback to call when the observer is notified
  73820. */
  73821. callback: (eventData: T, eventState: EventState) => void,
  73822. /**
  73823. * Defines the mask of the observer (used to filter notifications)
  73824. */
  73825. mask: number,
  73826. /**
  73827. * Defines the current scope used to restore the JS context
  73828. */
  73829. scope?: any);
  73830. }
  73831. /**
  73832. * Represent a list of observers registered to multiple Observables object.
  73833. */
  73834. export class MultiObserver<T> {
  73835. private _observers;
  73836. private _observables;
  73837. /**
  73838. * Release associated resources
  73839. */
  73840. dispose(): void;
  73841. /**
  73842. * Raise a callback when one of the observable will notify
  73843. * @param observables defines a list of observables to watch
  73844. * @param callback defines the callback to call on notification
  73845. * @param mask defines the mask used to filter notifications
  73846. * @param scope defines the current scope used to restore the JS context
  73847. * @returns the new MultiObserver
  73848. */
  73849. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73850. }
  73851. /**
  73852. * The Observable class is a simple implementation of the Observable pattern.
  73853. *
  73854. * 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.
  73855. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73856. * 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).
  73857. * 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.
  73858. */
  73859. export class Observable<T> {
  73860. private _observers;
  73861. private _eventState;
  73862. private _onObserverAdded;
  73863. /**
  73864. * Gets the list of observers
  73865. */
  73866. get observers(): Array<Observer<T>>;
  73867. /**
  73868. * Creates a new observable
  73869. * @param onObserverAdded defines a callback to call when a new observer is added
  73870. */
  73871. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73872. /**
  73873. * Create a new Observer with the specified callback
  73874. * @param callback the callback that will be executed for that Observer
  73875. * @param mask the mask used to filter observers
  73876. * @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.
  73877. * @param scope optional scope for the callback to be called from
  73878. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73879. * @returns the new observer created for the callback
  73880. */
  73881. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73882. /**
  73883. * Create a new Observer with the specified callback and unregisters after the next notification
  73884. * @param callback the callback that will be executed for that Observer
  73885. * @returns the new observer created for the callback
  73886. */
  73887. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73888. /**
  73889. * Remove an Observer from the Observable object
  73890. * @param observer the instance of the Observer to remove
  73891. * @returns false if it doesn't belong to this Observable
  73892. */
  73893. remove(observer: Nullable<Observer<T>>): boolean;
  73894. /**
  73895. * Remove a callback from the Observable object
  73896. * @param callback the callback to remove
  73897. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73898. * @returns false if it doesn't belong to this Observable
  73899. */
  73900. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73901. private _deferUnregister;
  73902. private _remove;
  73903. /**
  73904. * Moves the observable to the top of the observer list making it get called first when notified
  73905. * @param observer the observer to move
  73906. */
  73907. makeObserverTopPriority(observer: Observer<T>): void;
  73908. /**
  73909. * Moves the observable to the bottom of the observer list making it get called last when notified
  73910. * @param observer the observer to move
  73911. */
  73912. makeObserverBottomPriority(observer: Observer<T>): void;
  73913. /**
  73914. * Notify all Observers by calling their respective callback with the given data
  73915. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73916. * @param eventData defines the data to send to all observers
  73917. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73918. * @param target defines the original target of the state
  73919. * @param currentTarget defines the current target of the state
  73920. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73921. */
  73922. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73923. /**
  73924. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73925. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73926. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73927. * and it is crucial that all callbacks will be executed.
  73928. * The order of the callbacks is kept, callbacks are not executed parallel.
  73929. *
  73930. * @param eventData The data to be sent to each callback
  73931. * @param mask is used to filter observers defaults to -1
  73932. * @param target defines the callback target (see EventState)
  73933. * @param currentTarget defines he current object in the bubbling phase
  73934. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73935. */
  73936. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73937. /**
  73938. * Notify a specific observer
  73939. * @param observer defines the observer to notify
  73940. * @param eventData defines the data to be sent to each callback
  73941. * @param mask is used to filter observers defaults to -1
  73942. */
  73943. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73944. /**
  73945. * Gets a boolean indicating if the observable has at least one observer
  73946. * @returns true is the Observable has at least one Observer registered
  73947. */
  73948. hasObservers(): boolean;
  73949. /**
  73950. * Clear the list of observers
  73951. */
  73952. clear(): void;
  73953. /**
  73954. * Clone the current observable
  73955. * @returns a new observable
  73956. */
  73957. clone(): Observable<T>;
  73958. /**
  73959. * Does this observable handles observer registered with a given mask
  73960. * @param mask defines the mask to be tested
  73961. * @return whether or not one observer registered with the given mask is handeled
  73962. **/
  73963. hasSpecificMask(mask?: number): boolean;
  73964. }
  73965. }
  73966. declare module BABYLON {
  73967. /**
  73968. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73969. * Babylon.js
  73970. */
  73971. export class DomManagement {
  73972. /**
  73973. * Checks if the window object exists
  73974. * @returns true if the window object exists
  73975. */
  73976. static IsWindowObjectExist(): boolean;
  73977. /**
  73978. * Checks if the navigator object exists
  73979. * @returns true if the navigator object exists
  73980. */
  73981. static IsNavigatorAvailable(): boolean;
  73982. /**
  73983. * Extracts text content from a DOM element hierarchy
  73984. * @param element defines the root element
  73985. * @returns a string
  73986. */
  73987. static GetDOMTextContent(element: HTMLElement): string;
  73988. }
  73989. }
  73990. declare module BABYLON {
  73991. /**
  73992. * Logger used througouht the application to allow configuration of
  73993. * the log level required for the messages.
  73994. */
  73995. export class Logger {
  73996. /**
  73997. * No log
  73998. */
  73999. static readonly NoneLogLevel: number;
  74000. /**
  74001. * Only message logs
  74002. */
  74003. static readonly MessageLogLevel: number;
  74004. /**
  74005. * Only warning logs
  74006. */
  74007. static readonly WarningLogLevel: number;
  74008. /**
  74009. * Only error logs
  74010. */
  74011. static readonly ErrorLogLevel: number;
  74012. /**
  74013. * All logs
  74014. */
  74015. static readonly AllLogLevel: number;
  74016. private static _LogCache;
  74017. /**
  74018. * Gets a value indicating the number of loading errors
  74019. * @ignorenaming
  74020. */
  74021. static errorsCount: number;
  74022. /**
  74023. * Callback called when a new log is added
  74024. */
  74025. static OnNewCacheEntry: (entry: string) => void;
  74026. private static _AddLogEntry;
  74027. private static _FormatMessage;
  74028. private static _LogDisabled;
  74029. private static _LogEnabled;
  74030. private static _WarnDisabled;
  74031. private static _WarnEnabled;
  74032. private static _ErrorDisabled;
  74033. private static _ErrorEnabled;
  74034. /**
  74035. * Log a message to the console
  74036. */
  74037. static Log: (message: string) => void;
  74038. /**
  74039. * Write a warning message to the console
  74040. */
  74041. static Warn: (message: string) => void;
  74042. /**
  74043. * Write an error message to the console
  74044. */
  74045. static Error: (message: string) => void;
  74046. /**
  74047. * Gets current log cache (list of logs)
  74048. */
  74049. static get LogCache(): string;
  74050. /**
  74051. * Clears the log cache
  74052. */
  74053. static ClearLogCache(): void;
  74054. /**
  74055. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74056. */
  74057. static set LogLevels(level: number);
  74058. }
  74059. }
  74060. declare module BABYLON {
  74061. /** @hidden */
  74062. export class _TypeStore {
  74063. /** @hidden */
  74064. static RegisteredTypes: {
  74065. [key: string]: Object;
  74066. };
  74067. /** @hidden */
  74068. static GetClass(fqdn: string): any;
  74069. }
  74070. }
  74071. declare module BABYLON {
  74072. /**
  74073. * Helper to manipulate strings
  74074. */
  74075. export class StringTools {
  74076. /**
  74077. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74078. * @param str Source string
  74079. * @param suffix Suffix to search for in the source string
  74080. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74081. */
  74082. static EndsWith(str: string, suffix: string): boolean;
  74083. /**
  74084. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74085. * @param str Source string
  74086. * @param suffix Suffix to search for in the source string
  74087. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74088. */
  74089. static StartsWith(str: string, suffix: string): boolean;
  74090. /**
  74091. * Decodes a buffer into a string
  74092. * @param buffer The buffer to decode
  74093. * @returns The decoded string
  74094. */
  74095. static Decode(buffer: Uint8Array | Uint16Array): string;
  74096. /**
  74097. * Encode a buffer to a base64 string
  74098. * @param buffer defines the buffer to encode
  74099. * @returns the encoded string
  74100. */
  74101. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74102. /**
  74103. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74104. * @param num the number to convert and pad
  74105. * @param length the expected length of the string
  74106. * @returns the padded string
  74107. */
  74108. static PadNumber(num: number, length: number): string;
  74109. }
  74110. }
  74111. declare module BABYLON {
  74112. /**
  74113. * Class containing a set of static utilities functions for deep copy.
  74114. */
  74115. export class DeepCopier {
  74116. /**
  74117. * Tries to copy an object by duplicating every property
  74118. * @param source defines the source object
  74119. * @param destination defines the target object
  74120. * @param doNotCopyList defines a list of properties to avoid
  74121. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74122. */
  74123. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74124. }
  74125. }
  74126. declare module BABYLON {
  74127. /**
  74128. * Class containing a set of static utilities functions for precision date
  74129. */
  74130. export class PrecisionDate {
  74131. /**
  74132. * Gets either window.performance.now() if supported or Date.now() else
  74133. */
  74134. static get Now(): number;
  74135. }
  74136. }
  74137. declare module BABYLON {
  74138. /** @hidden */
  74139. export class _DevTools {
  74140. static WarnImport(name: string): string;
  74141. }
  74142. }
  74143. declare module BABYLON {
  74144. /**
  74145. * Interface used to define the mechanism to get data from the network
  74146. */
  74147. export interface IWebRequest {
  74148. /**
  74149. * Returns client's response url
  74150. */
  74151. responseURL: string;
  74152. /**
  74153. * Returns client's status
  74154. */
  74155. status: number;
  74156. /**
  74157. * Returns client's status as a text
  74158. */
  74159. statusText: string;
  74160. }
  74161. }
  74162. declare module BABYLON {
  74163. /**
  74164. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74165. */
  74166. export class WebRequest implements IWebRequest {
  74167. private _xhr;
  74168. /**
  74169. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74170. * i.e. when loading files, where the server/service expects an Authorization header
  74171. */
  74172. static CustomRequestHeaders: {
  74173. [key: string]: string;
  74174. };
  74175. /**
  74176. * Add callback functions in this array to update all the requests before they get sent to the network
  74177. */
  74178. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74179. private _injectCustomRequestHeaders;
  74180. /**
  74181. * Gets or sets a function to be called when loading progress changes
  74182. */
  74183. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74184. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74185. /**
  74186. * Returns client's state
  74187. */
  74188. get readyState(): number;
  74189. /**
  74190. * Returns client's status
  74191. */
  74192. get status(): number;
  74193. /**
  74194. * Returns client's status as a text
  74195. */
  74196. get statusText(): string;
  74197. /**
  74198. * Returns client's response
  74199. */
  74200. get response(): any;
  74201. /**
  74202. * Returns client's response url
  74203. */
  74204. get responseURL(): string;
  74205. /**
  74206. * Returns client's response as text
  74207. */
  74208. get responseText(): string;
  74209. /**
  74210. * Gets or sets the expected response type
  74211. */
  74212. get responseType(): XMLHttpRequestResponseType;
  74213. set responseType(value: XMLHttpRequestResponseType);
  74214. /** @hidden */
  74215. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74216. /** @hidden */
  74217. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74218. /**
  74219. * Cancels any network activity
  74220. */
  74221. abort(): void;
  74222. /**
  74223. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74224. * @param body defines an optional request body
  74225. */
  74226. send(body?: Document | BodyInit | null): void;
  74227. /**
  74228. * Sets the request method, request URL
  74229. * @param method defines the method to use (GET, POST, etc..)
  74230. * @param url defines the url to connect with
  74231. */
  74232. open(method: string, url: string): void;
  74233. /**
  74234. * Sets the value of a request header.
  74235. * @param name The name of the header whose value is to be set
  74236. * @param value The value to set as the body of the header
  74237. */
  74238. setRequestHeader(name: string, value: string): void;
  74239. /**
  74240. * Get the string containing the text of a particular header's value.
  74241. * @param name The name of the header
  74242. * @returns The string containing the text of the given header name
  74243. */
  74244. getResponseHeader(name: string): Nullable<string>;
  74245. }
  74246. }
  74247. declare module BABYLON {
  74248. /**
  74249. * File request interface
  74250. */
  74251. export interface IFileRequest {
  74252. /**
  74253. * Raised when the request is complete (success or error).
  74254. */
  74255. onCompleteObservable: Observable<IFileRequest>;
  74256. /**
  74257. * Aborts the request for a file.
  74258. */
  74259. abort: () => void;
  74260. }
  74261. }
  74262. declare module BABYLON {
  74263. /**
  74264. * Define options used to create a render target texture
  74265. */
  74266. export class RenderTargetCreationOptions {
  74267. /**
  74268. * Specifies is mipmaps must be generated
  74269. */
  74270. generateMipMaps?: boolean;
  74271. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74272. generateDepthBuffer?: boolean;
  74273. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74274. generateStencilBuffer?: boolean;
  74275. /** Defines texture type (int by default) */
  74276. type?: number;
  74277. /** Defines sampling mode (trilinear by default) */
  74278. samplingMode?: number;
  74279. /** Defines format (RGBA by default) */
  74280. format?: number;
  74281. }
  74282. }
  74283. declare module BABYLON {
  74284. /** Defines the cross module used constants to avoid circular dependncies */
  74285. export class Constants {
  74286. /** Defines that alpha blending is disabled */
  74287. static readonly ALPHA_DISABLE: number;
  74288. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74289. static readonly ALPHA_ADD: number;
  74290. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74291. static readonly ALPHA_COMBINE: number;
  74292. /** Defines that alpha blending is DEST - SRC * DEST */
  74293. static readonly ALPHA_SUBTRACT: number;
  74294. /** Defines that alpha blending is SRC * DEST */
  74295. static readonly ALPHA_MULTIPLY: number;
  74296. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74297. static readonly ALPHA_MAXIMIZED: number;
  74298. /** Defines that alpha blending is SRC + DEST */
  74299. static readonly ALPHA_ONEONE: number;
  74300. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74301. static readonly ALPHA_PREMULTIPLIED: number;
  74302. /**
  74303. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74304. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74305. */
  74306. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74307. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74308. static readonly ALPHA_INTERPOLATE: number;
  74309. /**
  74310. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74311. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74312. */
  74313. static readonly ALPHA_SCREENMODE: number;
  74314. /**
  74315. * Defines that alpha blending is SRC + DST
  74316. * Alpha will be set to SRC ALPHA + DST ALPHA
  74317. */
  74318. static readonly ALPHA_ONEONE_ONEONE: number;
  74319. /**
  74320. * Defines that alpha blending is SRC * DST ALPHA + DST
  74321. * Alpha will be set to 0
  74322. */
  74323. static readonly ALPHA_ALPHATOCOLOR: number;
  74324. /**
  74325. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74326. */
  74327. static readonly ALPHA_REVERSEONEMINUS: number;
  74328. /**
  74329. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74330. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74331. */
  74332. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74333. /**
  74334. * Defines that alpha blending is SRC + DST
  74335. * Alpha will be set to SRC ALPHA
  74336. */
  74337. static readonly ALPHA_ONEONE_ONEZERO: number;
  74338. /**
  74339. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74340. * Alpha will be set to DST ALPHA
  74341. */
  74342. static readonly ALPHA_EXCLUSION: number;
  74343. /** Defines that alpha blending equation a SUM */
  74344. static readonly ALPHA_EQUATION_ADD: number;
  74345. /** Defines that alpha blending equation a SUBSTRACTION */
  74346. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74347. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74348. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74349. /** Defines that alpha blending equation a MAX operation */
  74350. static readonly ALPHA_EQUATION_MAX: number;
  74351. /** Defines that alpha blending equation a MIN operation */
  74352. static readonly ALPHA_EQUATION_MIN: number;
  74353. /**
  74354. * Defines that alpha blending equation a DARKEN operation:
  74355. * It takes the min of the src and sums the alpha channels.
  74356. */
  74357. static readonly ALPHA_EQUATION_DARKEN: number;
  74358. /** Defines that the ressource is not delayed*/
  74359. static readonly DELAYLOADSTATE_NONE: number;
  74360. /** Defines that the ressource was successfully delay loaded */
  74361. static readonly DELAYLOADSTATE_LOADED: number;
  74362. /** Defines that the ressource is currently delay loading */
  74363. static readonly DELAYLOADSTATE_LOADING: number;
  74364. /** Defines that the ressource is delayed and has not started loading */
  74365. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74366. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74367. static readonly NEVER: number;
  74368. /** 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 */
  74369. static readonly ALWAYS: number;
  74370. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74371. static readonly LESS: number;
  74372. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74373. static readonly EQUAL: number;
  74374. /** 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 */
  74375. static readonly LEQUAL: number;
  74376. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74377. static readonly GREATER: number;
  74378. /** 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 */
  74379. static readonly GEQUAL: number;
  74380. /** 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 */
  74381. static readonly NOTEQUAL: number;
  74382. /** Passed to stencilOperation to specify that stencil value must be kept */
  74383. static readonly KEEP: number;
  74384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74385. static readonly REPLACE: number;
  74386. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74387. static readonly INCR: number;
  74388. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74389. static readonly DECR: number;
  74390. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74391. static readonly INVERT: number;
  74392. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74393. static readonly INCR_WRAP: number;
  74394. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74395. static readonly DECR_WRAP: number;
  74396. /** Texture is not repeating outside of 0..1 UVs */
  74397. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74398. /** Texture is repeating outside of 0..1 UVs */
  74399. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74400. /** Texture is repeating and mirrored */
  74401. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74402. /** ALPHA */
  74403. static readonly TEXTUREFORMAT_ALPHA: number;
  74404. /** LUMINANCE */
  74405. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74406. /** LUMINANCE_ALPHA */
  74407. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74408. /** RGB */
  74409. static readonly TEXTUREFORMAT_RGB: number;
  74410. /** RGBA */
  74411. static readonly TEXTUREFORMAT_RGBA: number;
  74412. /** RED */
  74413. static readonly TEXTUREFORMAT_RED: number;
  74414. /** RED (2nd reference) */
  74415. static readonly TEXTUREFORMAT_R: number;
  74416. /** RG */
  74417. static readonly TEXTUREFORMAT_RG: number;
  74418. /** RED_INTEGER */
  74419. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74420. /** RED_INTEGER (2nd reference) */
  74421. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74422. /** RG_INTEGER */
  74423. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74424. /** RGB_INTEGER */
  74425. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74426. /** RGBA_INTEGER */
  74427. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74428. /** UNSIGNED_BYTE */
  74429. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74430. /** UNSIGNED_BYTE (2nd reference) */
  74431. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74432. /** FLOAT */
  74433. static readonly TEXTURETYPE_FLOAT: number;
  74434. /** HALF_FLOAT */
  74435. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74436. /** BYTE */
  74437. static readonly TEXTURETYPE_BYTE: number;
  74438. /** SHORT */
  74439. static readonly TEXTURETYPE_SHORT: number;
  74440. /** UNSIGNED_SHORT */
  74441. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74442. /** INT */
  74443. static readonly TEXTURETYPE_INT: number;
  74444. /** UNSIGNED_INT */
  74445. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74446. /** UNSIGNED_SHORT_4_4_4_4 */
  74447. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74448. /** UNSIGNED_SHORT_5_5_5_1 */
  74449. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74450. /** UNSIGNED_SHORT_5_6_5 */
  74451. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74452. /** UNSIGNED_INT_2_10_10_10_REV */
  74453. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74454. /** UNSIGNED_INT_24_8 */
  74455. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74456. /** UNSIGNED_INT_10F_11F_11F_REV */
  74457. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74458. /** UNSIGNED_INT_5_9_9_9_REV */
  74459. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74460. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74461. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74462. /** nearest is mag = nearest and min = nearest and no mip */
  74463. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74464. /** mag = nearest and min = nearest and mip = none */
  74465. static readonly TEXTURE_NEAREST_NEAREST: number;
  74466. /** Bilinear is mag = linear and min = linear and no mip */
  74467. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74468. /** mag = linear and min = linear and mip = none */
  74469. static readonly TEXTURE_LINEAR_LINEAR: number;
  74470. /** Trilinear is mag = linear and min = linear and mip = linear */
  74471. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74472. /** Trilinear is mag = linear and min = linear and mip = linear */
  74473. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74474. /** mag = nearest and min = nearest and mip = nearest */
  74475. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74476. /** mag = nearest and min = linear and mip = nearest */
  74477. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74478. /** mag = nearest and min = linear and mip = linear */
  74479. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74480. /** mag = nearest and min = linear and mip = none */
  74481. static readonly TEXTURE_NEAREST_LINEAR: number;
  74482. /** nearest is mag = nearest and min = nearest and mip = linear */
  74483. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74484. /** mag = linear and min = nearest and mip = nearest */
  74485. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74486. /** mag = linear and min = nearest and mip = linear */
  74487. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74488. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74489. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74490. /** mag = linear and min = nearest and mip = none */
  74491. static readonly TEXTURE_LINEAR_NEAREST: number;
  74492. /** Explicit coordinates mode */
  74493. static readonly TEXTURE_EXPLICIT_MODE: number;
  74494. /** Spherical coordinates mode */
  74495. static readonly TEXTURE_SPHERICAL_MODE: number;
  74496. /** Planar coordinates mode */
  74497. static readonly TEXTURE_PLANAR_MODE: number;
  74498. /** Cubic coordinates mode */
  74499. static readonly TEXTURE_CUBIC_MODE: number;
  74500. /** Projection coordinates mode */
  74501. static readonly TEXTURE_PROJECTION_MODE: number;
  74502. /** Skybox coordinates mode */
  74503. static readonly TEXTURE_SKYBOX_MODE: number;
  74504. /** Inverse Cubic coordinates mode */
  74505. static readonly TEXTURE_INVCUBIC_MODE: number;
  74506. /** Equirectangular coordinates mode */
  74507. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74508. /** Equirectangular Fixed coordinates mode */
  74509. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74510. /** Equirectangular Fixed Mirrored coordinates mode */
  74511. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74512. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74513. static readonly SCALEMODE_FLOOR: number;
  74514. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74515. static readonly SCALEMODE_NEAREST: number;
  74516. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74517. static readonly SCALEMODE_CEILING: number;
  74518. /**
  74519. * The dirty texture flag value
  74520. */
  74521. static readonly MATERIAL_TextureDirtyFlag: number;
  74522. /**
  74523. * The dirty light flag value
  74524. */
  74525. static readonly MATERIAL_LightDirtyFlag: number;
  74526. /**
  74527. * The dirty fresnel flag value
  74528. */
  74529. static readonly MATERIAL_FresnelDirtyFlag: number;
  74530. /**
  74531. * The dirty attribute flag value
  74532. */
  74533. static readonly MATERIAL_AttributesDirtyFlag: number;
  74534. /**
  74535. * The dirty misc flag value
  74536. */
  74537. static readonly MATERIAL_MiscDirtyFlag: number;
  74538. /**
  74539. * The all dirty flag value
  74540. */
  74541. static readonly MATERIAL_AllDirtyFlag: number;
  74542. /**
  74543. * Returns the triangle fill mode
  74544. */
  74545. static readonly MATERIAL_TriangleFillMode: number;
  74546. /**
  74547. * Returns the wireframe mode
  74548. */
  74549. static readonly MATERIAL_WireFrameFillMode: number;
  74550. /**
  74551. * Returns the point fill mode
  74552. */
  74553. static readonly MATERIAL_PointFillMode: number;
  74554. /**
  74555. * Returns the point list draw mode
  74556. */
  74557. static readonly MATERIAL_PointListDrawMode: number;
  74558. /**
  74559. * Returns the line list draw mode
  74560. */
  74561. static readonly MATERIAL_LineListDrawMode: number;
  74562. /**
  74563. * Returns the line loop draw mode
  74564. */
  74565. static readonly MATERIAL_LineLoopDrawMode: number;
  74566. /**
  74567. * Returns the line strip draw mode
  74568. */
  74569. static readonly MATERIAL_LineStripDrawMode: number;
  74570. /**
  74571. * Returns the triangle strip draw mode
  74572. */
  74573. static readonly MATERIAL_TriangleStripDrawMode: number;
  74574. /**
  74575. * Returns the triangle fan draw mode
  74576. */
  74577. static readonly MATERIAL_TriangleFanDrawMode: number;
  74578. /**
  74579. * Stores the clock-wise side orientation
  74580. */
  74581. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74582. /**
  74583. * Stores the counter clock-wise side orientation
  74584. */
  74585. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74586. /**
  74587. * Nothing
  74588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74589. */
  74590. static readonly ACTION_NothingTrigger: number;
  74591. /**
  74592. * On pick
  74593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74594. */
  74595. static readonly ACTION_OnPickTrigger: number;
  74596. /**
  74597. * On left pick
  74598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74599. */
  74600. static readonly ACTION_OnLeftPickTrigger: number;
  74601. /**
  74602. * On right pick
  74603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74604. */
  74605. static readonly ACTION_OnRightPickTrigger: number;
  74606. /**
  74607. * On center pick
  74608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74609. */
  74610. static readonly ACTION_OnCenterPickTrigger: number;
  74611. /**
  74612. * On pick down
  74613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74614. */
  74615. static readonly ACTION_OnPickDownTrigger: number;
  74616. /**
  74617. * On double pick
  74618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74619. */
  74620. static readonly ACTION_OnDoublePickTrigger: number;
  74621. /**
  74622. * On pick up
  74623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74624. */
  74625. static readonly ACTION_OnPickUpTrigger: number;
  74626. /**
  74627. * On pick out.
  74628. * This trigger will only be raised if you also declared a OnPickDown
  74629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74630. */
  74631. static readonly ACTION_OnPickOutTrigger: number;
  74632. /**
  74633. * On long press
  74634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74635. */
  74636. static readonly ACTION_OnLongPressTrigger: number;
  74637. /**
  74638. * On pointer over
  74639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74640. */
  74641. static readonly ACTION_OnPointerOverTrigger: number;
  74642. /**
  74643. * On pointer out
  74644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74645. */
  74646. static readonly ACTION_OnPointerOutTrigger: number;
  74647. /**
  74648. * On every frame
  74649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74650. */
  74651. static readonly ACTION_OnEveryFrameTrigger: number;
  74652. /**
  74653. * On intersection enter
  74654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74655. */
  74656. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74657. /**
  74658. * On intersection exit
  74659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74660. */
  74661. static readonly ACTION_OnIntersectionExitTrigger: number;
  74662. /**
  74663. * On key down
  74664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74665. */
  74666. static readonly ACTION_OnKeyDownTrigger: number;
  74667. /**
  74668. * On key up
  74669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74670. */
  74671. static readonly ACTION_OnKeyUpTrigger: number;
  74672. /**
  74673. * Billboard mode will only apply to Y axis
  74674. */
  74675. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74676. /**
  74677. * Billboard mode will apply to all axes
  74678. */
  74679. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74680. /**
  74681. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74682. */
  74683. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74684. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74685. * Test order :
  74686. * Is the bounding sphere outside the frustum ?
  74687. * If not, are the bounding box vertices outside the frustum ?
  74688. * It not, then the cullable object is in the frustum.
  74689. */
  74690. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74691. /** Culling strategy : Bounding Sphere Only.
  74692. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74693. * It's also less accurate than the standard because some not visible objects can still be selected.
  74694. * Test : is the bounding sphere outside the frustum ?
  74695. * If not, then the cullable object is in the frustum.
  74696. */
  74697. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74698. /** Culling strategy : Optimistic Inclusion.
  74699. * This in an inclusion test first, then the standard exclusion test.
  74700. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74701. * 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.
  74702. * Anyway, it's as accurate as the standard strategy.
  74703. * Test :
  74704. * Is the cullable object bounding sphere center in the frustum ?
  74705. * If not, apply the default culling strategy.
  74706. */
  74707. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74708. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74709. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74710. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74711. * 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.
  74712. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74713. * Test :
  74714. * Is the cullable object bounding sphere center in the frustum ?
  74715. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74716. */
  74717. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74718. /**
  74719. * No logging while loading
  74720. */
  74721. static readonly SCENELOADER_NO_LOGGING: number;
  74722. /**
  74723. * Minimal logging while loading
  74724. */
  74725. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74726. /**
  74727. * Summary logging while loading
  74728. */
  74729. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74730. /**
  74731. * Detailled logging while loading
  74732. */
  74733. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74734. }
  74735. }
  74736. declare module BABYLON {
  74737. /**
  74738. * This represents the required contract to create a new type of texture loader.
  74739. */
  74740. export interface IInternalTextureLoader {
  74741. /**
  74742. * Defines wether the loader supports cascade loading the different faces.
  74743. */
  74744. supportCascades: boolean;
  74745. /**
  74746. * This returns if the loader support the current file information.
  74747. * @param extension defines the file extension of the file being loaded
  74748. * @returns true if the loader can load the specified file
  74749. */
  74750. canLoad(extension: string): boolean;
  74751. /**
  74752. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74753. * @param data contains the texture data
  74754. * @param texture defines the BabylonJS internal texture
  74755. * @param createPolynomials will be true if polynomials have been requested
  74756. * @param onLoad defines the callback to trigger once the texture is ready
  74757. * @param onError defines the callback to trigger in case of error
  74758. */
  74759. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74760. /**
  74761. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74762. * @param data contains the texture data
  74763. * @param texture defines the BabylonJS internal texture
  74764. * @param callback defines the method to call once ready to upload
  74765. */
  74766. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74767. }
  74768. }
  74769. declare module BABYLON {
  74770. /**
  74771. * Class used to store and describe the pipeline context associated with an effect
  74772. */
  74773. export interface IPipelineContext {
  74774. /**
  74775. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74776. */
  74777. isAsync: boolean;
  74778. /**
  74779. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74780. */
  74781. isReady: boolean;
  74782. /** @hidden */
  74783. _getVertexShaderCode(): string | null;
  74784. /** @hidden */
  74785. _getFragmentShaderCode(): string | null;
  74786. /** @hidden */
  74787. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74788. }
  74789. }
  74790. declare module BABYLON {
  74791. /**
  74792. * Class used to store gfx data (like WebGLBuffer)
  74793. */
  74794. export class DataBuffer {
  74795. /**
  74796. * Gets or sets the number of objects referencing this buffer
  74797. */
  74798. references: number;
  74799. /** Gets or sets the size of the underlying buffer */
  74800. capacity: number;
  74801. /**
  74802. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74803. */
  74804. is32Bits: boolean;
  74805. /**
  74806. * Gets the underlying buffer
  74807. */
  74808. get underlyingResource(): any;
  74809. }
  74810. }
  74811. declare module BABYLON {
  74812. /** @hidden */
  74813. export interface IShaderProcessor {
  74814. attributeProcessor?: (attribute: string) => string;
  74815. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74816. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74817. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74818. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74819. lineProcessor?: (line: string, isFragment: boolean) => string;
  74820. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74821. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74822. }
  74823. }
  74824. declare module BABYLON {
  74825. /** @hidden */
  74826. export interface ProcessingOptions {
  74827. defines: string[];
  74828. indexParameters: any;
  74829. isFragment: boolean;
  74830. shouldUseHighPrecisionShader: boolean;
  74831. supportsUniformBuffers: boolean;
  74832. shadersRepository: string;
  74833. includesShadersStore: {
  74834. [key: string]: string;
  74835. };
  74836. processor?: IShaderProcessor;
  74837. version: string;
  74838. platformName: string;
  74839. lookForClosingBracketForUniformBuffer?: boolean;
  74840. }
  74841. }
  74842. declare module BABYLON {
  74843. /** @hidden */
  74844. export class ShaderCodeNode {
  74845. line: string;
  74846. children: ShaderCodeNode[];
  74847. additionalDefineKey?: string;
  74848. additionalDefineValue?: string;
  74849. isValid(preprocessors: {
  74850. [key: string]: string;
  74851. }): boolean;
  74852. process(preprocessors: {
  74853. [key: string]: string;
  74854. }, options: ProcessingOptions): string;
  74855. }
  74856. }
  74857. declare module BABYLON {
  74858. /** @hidden */
  74859. export class ShaderCodeCursor {
  74860. private _lines;
  74861. lineIndex: number;
  74862. get currentLine(): string;
  74863. get canRead(): boolean;
  74864. set lines(value: string[]);
  74865. }
  74866. }
  74867. declare module BABYLON {
  74868. /** @hidden */
  74869. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74870. process(preprocessors: {
  74871. [key: string]: string;
  74872. }, options: ProcessingOptions): string;
  74873. }
  74874. }
  74875. declare module BABYLON {
  74876. /** @hidden */
  74877. export class ShaderDefineExpression {
  74878. isTrue(preprocessors: {
  74879. [key: string]: string;
  74880. }): boolean;
  74881. }
  74882. }
  74883. declare module BABYLON {
  74884. /** @hidden */
  74885. export class ShaderCodeTestNode extends ShaderCodeNode {
  74886. testExpression: ShaderDefineExpression;
  74887. isValid(preprocessors: {
  74888. [key: string]: string;
  74889. }): boolean;
  74890. }
  74891. }
  74892. declare module BABYLON {
  74893. /** @hidden */
  74894. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74895. define: string;
  74896. not: boolean;
  74897. constructor(define: string, not?: boolean);
  74898. isTrue(preprocessors: {
  74899. [key: string]: string;
  74900. }): boolean;
  74901. }
  74902. }
  74903. declare module BABYLON {
  74904. /** @hidden */
  74905. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74906. leftOperand: ShaderDefineExpression;
  74907. rightOperand: ShaderDefineExpression;
  74908. isTrue(preprocessors: {
  74909. [key: string]: string;
  74910. }): boolean;
  74911. }
  74912. }
  74913. declare module BABYLON {
  74914. /** @hidden */
  74915. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74916. leftOperand: ShaderDefineExpression;
  74917. rightOperand: ShaderDefineExpression;
  74918. isTrue(preprocessors: {
  74919. [key: string]: string;
  74920. }): boolean;
  74921. }
  74922. }
  74923. declare module BABYLON {
  74924. /** @hidden */
  74925. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74926. define: string;
  74927. operand: string;
  74928. testValue: string;
  74929. constructor(define: string, operand: string, testValue: string);
  74930. isTrue(preprocessors: {
  74931. [key: string]: string;
  74932. }): boolean;
  74933. }
  74934. }
  74935. declare module BABYLON {
  74936. /**
  74937. * Class used to enable access to offline support
  74938. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74939. */
  74940. export interface IOfflineProvider {
  74941. /**
  74942. * Gets a boolean indicating if scene must be saved in the database
  74943. */
  74944. enableSceneOffline: boolean;
  74945. /**
  74946. * Gets a boolean indicating if textures must be saved in the database
  74947. */
  74948. enableTexturesOffline: boolean;
  74949. /**
  74950. * Open the offline support and make it available
  74951. * @param successCallback defines the callback to call on success
  74952. * @param errorCallback defines the callback to call on error
  74953. */
  74954. open(successCallback: () => void, errorCallback: () => void): void;
  74955. /**
  74956. * Loads an image from the offline support
  74957. * @param url defines the url to load from
  74958. * @param image defines the target DOM image
  74959. */
  74960. loadImage(url: string, image: HTMLImageElement): void;
  74961. /**
  74962. * Loads a file from offline support
  74963. * @param url defines the URL to load from
  74964. * @param sceneLoaded defines a callback to call on success
  74965. * @param progressCallBack defines a callback to call when progress changed
  74966. * @param errorCallback defines a callback to call on error
  74967. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74968. */
  74969. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74970. }
  74971. }
  74972. declare module BABYLON {
  74973. /**
  74974. * Class used to help managing file picking and drag'n'drop
  74975. * File Storage
  74976. */
  74977. export class FilesInputStore {
  74978. /**
  74979. * List of files ready to be loaded
  74980. */
  74981. static FilesToLoad: {
  74982. [key: string]: File;
  74983. };
  74984. }
  74985. }
  74986. declare module BABYLON {
  74987. /**
  74988. * Class used to define a retry strategy when error happens while loading assets
  74989. */
  74990. export class RetryStrategy {
  74991. /**
  74992. * Function used to defines an exponential back off strategy
  74993. * @param maxRetries defines the maximum number of retries (3 by default)
  74994. * @param baseInterval defines the interval between retries
  74995. * @returns the strategy function to use
  74996. */
  74997. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74998. }
  74999. }
  75000. declare module BABYLON {
  75001. /**
  75002. * @ignore
  75003. * Application error to support additional information when loading a file
  75004. */
  75005. export abstract class BaseError extends Error {
  75006. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75007. }
  75008. }
  75009. declare module BABYLON {
  75010. /** @ignore */
  75011. export class LoadFileError extends BaseError {
  75012. request?: WebRequest;
  75013. file?: File;
  75014. /**
  75015. * Creates a new LoadFileError
  75016. * @param message defines the message of the error
  75017. * @param request defines the optional web request
  75018. * @param file defines the optional file
  75019. */
  75020. constructor(message: string, object?: WebRequest | File);
  75021. }
  75022. /** @ignore */
  75023. export class RequestFileError extends BaseError {
  75024. request: WebRequest;
  75025. /**
  75026. * Creates a new LoadFileError
  75027. * @param message defines the message of the error
  75028. * @param request defines the optional web request
  75029. */
  75030. constructor(message: string, request: WebRequest);
  75031. }
  75032. /** @ignore */
  75033. export class ReadFileError extends BaseError {
  75034. file: File;
  75035. /**
  75036. * Creates a new ReadFileError
  75037. * @param message defines the message of the error
  75038. * @param file defines the optional file
  75039. */
  75040. constructor(message: string, file: File);
  75041. }
  75042. /**
  75043. * @hidden
  75044. */
  75045. export class FileTools {
  75046. /**
  75047. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75048. */
  75049. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75050. /**
  75051. * Gets or sets the base URL to use to load assets
  75052. */
  75053. static BaseUrl: string;
  75054. /**
  75055. * Default behaviour for cors in the application.
  75056. * It can be a string if the expected behavior is identical in the entire app.
  75057. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75058. */
  75059. static CorsBehavior: string | ((url: string | string[]) => string);
  75060. /**
  75061. * Gets or sets a function used to pre-process url before using them to load assets
  75062. */
  75063. static PreprocessUrl: (url: string) => string;
  75064. /**
  75065. * Removes unwanted characters from an url
  75066. * @param url defines the url to clean
  75067. * @returns the cleaned url
  75068. */
  75069. private static _CleanUrl;
  75070. /**
  75071. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75072. * @param url define the url we are trying
  75073. * @param element define the dom element where to configure the cors policy
  75074. */
  75075. static SetCorsBehavior(url: string | string[], element: {
  75076. crossOrigin: string | null;
  75077. }): void;
  75078. /**
  75079. * Loads an image as an HTMLImageElement.
  75080. * @param input url string, ArrayBuffer, or Blob to load
  75081. * @param onLoad callback called when the image successfully loads
  75082. * @param onError callback called when the image fails to load
  75083. * @param offlineProvider offline provider for caching
  75084. * @param mimeType optional mime type
  75085. * @returns the HTMLImageElement of the loaded image
  75086. */
  75087. 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>;
  75088. /**
  75089. * Reads a file from a File object
  75090. * @param file defines the file to load
  75091. * @param onSuccess defines the callback to call when data is loaded
  75092. * @param onProgress defines the callback to call during loading process
  75093. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75094. * @param onError defines the callback to call when an error occurs
  75095. * @returns a file request object
  75096. */
  75097. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75098. /**
  75099. * Loads a file from a url
  75100. * @param url url to load
  75101. * @param onSuccess callback called when the file successfully loads
  75102. * @param onProgress callback called while file is loading (if the server supports this mode)
  75103. * @param offlineProvider defines the offline provider for caching
  75104. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75105. * @param onError callback called when the file fails to load
  75106. * @returns a file request object
  75107. */
  75108. 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;
  75109. /**
  75110. * Loads a file
  75111. * @param url url to load
  75112. * @param onSuccess callback called when the file successfully loads
  75113. * @param onProgress callback called while file is loading (if the server supports this mode)
  75114. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75115. * @param onError callback called when the file fails to load
  75116. * @param onOpened callback called when the web request is opened
  75117. * @returns a file request object
  75118. */
  75119. 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;
  75120. /**
  75121. * Checks if the loaded document was accessed via `file:`-Protocol.
  75122. * @returns boolean
  75123. */
  75124. static IsFileURL(): boolean;
  75125. }
  75126. }
  75127. declare module BABYLON {
  75128. /** @hidden */
  75129. export class ShaderProcessor {
  75130. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75131. private static _ProcessPrecision;
  75132. private static _ExtractOperation;
  75133. private static _BuildSubExpression;
  75134. private static _BuildExpression;
  75135. private static _MoveCursorWithinIf;
  75136. private static _MoveCursor;
  75137. private static _EvaluatePreProcessors;
  75138. private static _PreparePreProcessors;
  75139. private static _ProcessShaderConversion;
  75140. private static _ProcessIncludes;
  75141. /**
  75142. * Loads a file from a url
  75143. * @param url url to load
  75144. * @param onSuccess callback called when the file successfully loads
  75145. * @param onProgress callback called while file is loading (if the server supports this mode)
  75146. * @param offlineProvider defines the offline provider for caching
  75147. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75148. * @param onError callback called when the file fails to load
  75149. * @returns a file request object
  75150. * @hidden
  75151. */
  75152. 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;
  75153. }
  75154. }
  75155. declare module BABYLON {
  75156. /**
  75157. * @hidden
  75158. */
  75159. export interface IColor4Like {
  75160. r: float;
  75161. g: float;
  75162. b: float;
  75163. a: float;
  75164. }
  75165. /**
  75166. * @hidden
  75167. */
  75168. export interface IColor3Like {
  75169. r: float;
  75170. g: float;
  75171. b: float;
  75172. }
  75173. /**
  75174. * @hidden
  75175. */
  75176. export interface IVector4Like {
  75177. x: float;
  75178. y: float;
  75179. z: float;
  75180. w: float;
  75181. }
  75182. /**
  75183. * @hidden
  75184. */
  75185. export interface IVector3Like {
  75186. x: float;
  75187. y: float;
  75188. z: float;
  75189. }
  75190. /**
  75191. * @hidden
  75192. */
  75193. export interface IVector2Like {
  75194. x: float;
  75195. y: float;
  75196. }
  75197. /**
  75198. * @hidden
  75199. */
  75200. export interface IMatrixLike {
  75201. toArray(): DeepImmutable<Float32Array>;
  75202. updateFlag: int;
  75203. }
  75204. /**
  75205. * @hidden
  75206. */
  75207. export interface IViewportLike {
  75208. x: float;
  75209. y: float;
  75210. width: float;
  75211. height: float;
  75212. }
  75213. /**
  75214. * @hidden
  75215. */
  75216. export interface IPlaneLike {
  75217. normal: IVector3Like;
  75218. d: float;
  75219. normalize(): void;
  75220. }
  75221. }
  75222. declare module BABYLON {
  75223. /**
  75224. * Interface used to define common properties for effect fallbacks
  75225. */
  75226. export interface IEffectFallbacks {
  75227. /**
  75228. * Removes the defines that should be removed when falling back.
  75229. * @param currentDefines defines the current define statements for the shader.
  75230. * @param effect defines the current effect we try to compile
  75231. * @returns The resulting defines with defines of the current rank removed.
  75232. */
  75233. reduce(currentDefines: string, effect: Effect): string;
  75234. /**
  75235. * Removes the fallback from the bound mesh.
  75236. */
  75237. unBindMesh(): void;
  75238. /**
  75239. * Checks to see if more fallbacks are still availible.
  75240. */
  75241. hasMoreFallbacks: boolean;
  75242. }
  75243. }
  75244. declare module BABYLON {
  75245. /**
  75246. * Class used to evalaute queries containing `and` and `or` operators
  75247. */
  75248. export class AndOrNotEvaluator {
  75249. /**
  75250. * Evaluate a query
  75251. * @param query defines the query to evaluate
  75252. * @param evaluateCallback defines the callback used to filter result
  75253. * @returns true if the query matches
  75254. */
  75255. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75256. private static _HandleParenthesisContent;
  75257. private static _SimplifyNegation;
  75258. }
  75259. }
  75260. declare module BABYLON {
  75261. /**
  75262. * Class used to store custom tags
  75263. */
  75264. export class Tags {
  75265. /**
  75266. * Adds support for tags on the given object
  75267. * @param obj defines the object to use
  75268. */
  75269. static EnableFor(obj: any): void;
  75270. /**
  75271. * Removes tags support
  75272. * @param obj defines the object to use
  75273. */
  75274. static DisableFor(obj: any): void;
  75275. /**
  75276. * Gets a boolean indicating if the given object has tags
  75277. * @param obj defines the object to use
  75278. * @returns a boolean
  75279. */
  75280. static HasTags(obj: any): boolean;
  75281. /**
  75282. * Gets the tags available on a given object
  75283. * @param obj defines the object to use
  75284. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75285. * @returns the tags
  75286. */
  75287. static GetTags(obj: any, asString?: boolean): any;
  75288. /**
  75289. * Adds tags to an object
  75290. * @param obj defines the object to use
  75291. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75292. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75293. */
  75294. static AddTagsTo(obj: any, tagsString: string): void;
  75295. /**
  75296. * @hidden
  75297. */
  75298. static _AddTagTo(obj: any, tag: string): void;
  75299. /**
  75300. * Removes specific tags from a specific object
  75301. * @param obj defines the object to use
  75302. * @param tagsString defines the tags to remove
  75303. */
  75304. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75305. /**
  75306. * @hidden
  75307. */
  75308. static _RemoveTagFrom(obj: any, tag: string): void;
  75309. /**
  75310. * Defines if tags hosted on an object match a given query
  75311. * @param obj defines the object to use
  75312. * @param tagsQuery defines the tag query
  75313. * @returns a boolean
  75314. */
  75315. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75316. }
  75317. }
  75318. declare module BABYLON {
  75319. /**
  75320. * Scalar computation library
  75321. */
  75322. export class Scalar {
  75323. /**
  75324. * Two pi constants convenient for computation.
  75325. */
  75326. static TwoPi: number;
  75327. /**
  75328. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75329. * @param a number
  75330. * @param b number
  75331. * @param epsilon (default = 1.401298E-45)
  75332. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75333. */
  75334. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75335. /**
  75336. * Returns a string : the upper case translation of the number i to hexadecimal.
  75337. * @param i number
  75338. * @returns the upper case translation of the number i to hexadecimal.
  75339. */
  75340. static ToHex(i: number): string;
  75341. /**
  75342. * Returns -1 if value is negative and +1 is value is positive.
  75343. * @param value the value
  75344. * @returns the value itself if it's equal to zero.
  75345. */
  75346. static Sign(value: number): number;
  75347. /**
  75348. * Returns the value itself if it's between min and max.
  75349. * Returns min if the value is lower than min.
  75350. * Returns max if the value is greater than max.
  75351. * @param value the value to clmap
  75352. * @param min the min value to clamp to (default: 0)
  75353. * @param max the max value to clamp to (default: 1)
  75354. * @returns the clamped value
  75355. */
  75356. static Clamp(value: number, min?: number, max?: number): number;
  75357. /**
  75358. * the log2 of value.
  75359. * @param value the value to compute log2 of
  75360. * @returns the log2 of value.
  75361. */
  75362. static Log2(value: number): number;
  75363. /**
  75364. * Loops the value, so that it is never larger than length and never smaller than 0.
  75365. *
  75366. * This is similar to the modulo operator but it works with floating point numbers.
  75367. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75368. * With t = 5 and length = 2.5, the result would be 0.0.
  75369. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75370. * @param value the value
  75371. * @param length the length
  75372. * @returns the looped value
  75373. */
  75374. static Repeat(value: number, length: number): number;
  75375. /**
  75376. * Normalize the value between 0.0 and 1.0 using min and max values
  75377. * @param value value to normalize
  75378. * @param min max to normalize between
  75379. * @param max min to normalize between
  75380. * @returns the normalized value
  75381. */
  75382. static Normalize(value: number, min: number, max: number): number;
  75383. /**
  75384. * Denormalize the value from 0.0 and 1.0 using min and max values
  75385. * @param normalized value to denormalize
  75386. * @param min max to denormalize between
  75387. * @param max min to denormalize between
  75388. * @returns the denormalized value
  75389. */
  75390. static Denormalize(normalized: number, min: number, max: number): number;
  75391. /**
  75392. * Calculates the shortest difference between two given angles given in degrees.
  75393. * @param current current angle in degrees
  75394. * @param target target angle in degrees
  75395. * @returns the delta
  75396. */
  75397. static DeltaAngle(current: number, target: number): number;
  75398. /**
  75399. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75400. * @param tx value
  75401. * @param length length
  75402. * @returns The returned value will move back and forth between 0 and length
  75403. */
  75404. static PingPong(tx: number, length: number): number;
  75405. /**
  75406. * Interpolates between min and max with smoothing at the limits.
  75407. *
  75408. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75409. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75410. * @param from from
  75411. * @param to to
  75412. * @param tx value
  75413. * @returns the smooth stepped value
  75414. */
  75415. static SmoothStep(from: number, to: number, tx: number): number;
  75416. /**
  75417. * Moves a value current towards target.
  75418. *
  75419. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75420. * Negative values of maxDelta pushes the value away from target.
  75421. * @param current current value
  75422. * @param target target value
  75423. * @param maxDelta max distance to move
  75424. * @returns resulting value
  75425. */
  75426. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75427. /**
  75428. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75429. *
  75430. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75431. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75432. * @param current current value
  75433. * @param target target value
  75434. * @param maxDelta max distance to move
  75435. * @returns resulting angle
  75436. */
  75437. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75438. /**
  75439. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75440. * @param start start value
  75441. * @param end target value
  75442. * @param amount amount to lerp between
  75443. * @returns the lerped value
  75444. */
  75445. static Lerp(start: number, end: number, amount: number): number;
  75446. /**
  75447. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75448. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75449. * @param start start value
  75450. * @param end target value
  75451. * @param amount amount to lerp between
  75452. * @returns the lerped value
  75453. */
  75454. static LerpAngle(start: number, end: number, amount: number): number;
  75455. /**
  75456. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75457. * @param a start value
  75458. * @param b target value
  75459. * @param value value between a and b
  75460. * @returns the inverseLerp value
  75461. */
  75462. static InverseLerp(a: number, b: number, value: number): number;
  75463. /**
  75464. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75465. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75466. * @param value1 spline value
  75467. * @param tangent1 spline value
  75468. * @param value2 spline value
  75469. * @param tangent2 spline value
  75470. * @param amount input value
  75471. * @returns hermite result
  75472. */
  75473. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75474. /**
  75475. * Returns a random float number between and min and max values
  75476. * @param min min value of random
  75477. * @param max max value of random
  75478. * @returns random value
  75479. */
  75480. static RandomRange(min: number, max: number): number;
  75481. /**
  75482. * This function returns percentage of a number in a given range.
  75483. *
  75484. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75485. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75486. * @param number to convert to percentage
  75487. * @param min min range
  75488. * @param max max range
  75489. * @returns the percentage
  75490. */
  75491. static RangeToPercent(number: number, min: number, max: number): number;
  75492. /**
  75493. * This function returns number that corresponds to the percentage in a given range.
  75494. *
  75495. * PercentToRange(0.34,0,100) will return 34.
  75496. * @param percent to convert to number
  75497. * @param min min range
  75498. * @param max max range
  75499. * @returns the number
  75500. */
  75501. static PercentToRange(percent: number, min: number, max: number): number;
  75502. /**
  75503. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75504. * @param angle The angle to normalize in radian.
  75505. * @return The converted angle.
  75506. */
  75507. static NormalizeRadians(angle: number): number;
  75508. }
  75509. }
  75510. declare module BABYLON {
  75511. /**
  75512. * Constant used to convert a value to gamma space
  75513. * @ignorenaming
  75514. */
  75515. export const ToGammaSpace: number;
  75516. /**
  75517. * Constant used to convert a value to linear space
  75518. * @ignorenaming
  75519. */
  75520. export const ToLinearSpace = 2.2;
  75521. /**
  75522. * Constant used to define the minimal number value in Babylon.js
  75523. * @ignorenaming
  75524. */
  75525. let Epsilon: number;
  75526. }
  75527. declare module BABYLON {
  75528. /**
  75529. * Class used to represent a viewport on screen
  75530. */
  75531. export class Viewport {
  75532. /** viewport left coordinate */
  75533. x: number;
  75534. /** viewport top coordinate */
  75535. y: number;
  75536. /**viewport width */
  75537. width: number;
  75538. /** viewport height */
  75539. height: number;
  75540. /**
  75541. * Creates a Viewport object located at (x, y) and sized (width, height)
  75542. * @param x defines viewport left coordinate
  75543. * @param y defines viewport top coordinate
  75544. * @param width defines the viewport width
  75545. * @param height defines the viewport height
  75546. */
  75547. constructor(
  75548. /** viewport left coordinate */
  75549. x: number,
  75550. /** viewport top coordinate */
  75551. y: number,
  75552. /**viewport width */
  75553. width: number,
  75554. /** viewport height */
  75555. height: number);
  75556. /**
  75557. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75558. * @param renderWidth defines the rendering width
  75559. * @param renderHeight defines the rendering height
  75560. * @returns a new Viewport
  75561. */
  75562. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75563. /**
  75564. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75565. * @param renderWidth defines the rendering width
  75566. * @param renderHeight defines the rendering height
  75567. * @param ref defines the target viewport
  75568. * @returns the current viewport
  75569. */
  75570. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75571. /**
  75572. * Returns a new Viewport copied from the current one
  75573. * @returns a new Viewport
  75574. */
  75575. clone(): Viewport;
  75576. }
  75577. }
  75578. declare module BABYLON {
  75579. /**
  75580. * Class containing a set of static utilities functions for arrays.
  75581. */
  75582. export class ArrayTools {
  75583. /**
  75584. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75585. * @param size the number of element to construct and put in the array
  75586. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75587. * @returns a new array filled with new objects
  75588. */
  75589. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75590. }
  75591. }
  75592. declare module BABYLON {
  75593. /**
  75594. * Class representing a vector containing 2 coordinates
  75595. */
  75596. export class Vector2 {
  75597. /** defines the first coordinate */
  75598. x: number;
  75599. /** defines the second coordinate */
  75600. y: number;
  75601. /**
  75602. * Creates a new Vector2 from the given x and y coordinates
  75603. * @param x defines the first coordinate
  75604. * @param y defines the second coordinate
  75605. */
  75606. constructor(
  75607. /** defines the first coordinate */
  75608. x?: number,
  75609. /** defines the second coordinate */
  75610. y?: number);
  75611. /**
  75612. * Gets a string with the Vector2 coordinates
  75613. * @returns a string with the Vector2 coordinates
  75614. */
  75615. toString(): string;
  75616. /**
  75617. * Gets class name
  75618. * @returns the string "Vector2"
  75619. */
  75620. getClassName(): string;
  75621. /**
  75622. * Gets current vector hash code
  75623. * @returns the Vector2 hash code as a number
  75624. */
  75625. getHashCode(): number;
  75626. /**
  75627. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75628. * @param array defines the source array
  75629. * @param index defines the offset in source array
  75630. * @returns the current Vector2
  75631. */
  75632. toArray(array: FloatArray, index?: number): Vector2;
  75633. /**
  75634. * Copy the current vector to an array
  75635. * @returns a new array with 2 elements: the Vector2 coordinates.
  75636. */
  75637. asArray(): number[];
  75638. /**
  75639. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75640. * @param source defines the source Vector2
  75641. * @returns the current updated Vector2
  75642. */
  75643. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75644. /**
  75645. * Sets the Vector2 coordinates with the given floats
  75646. * @param x defines the first coordinate
  75647. * @param y defines the second coordinate
  75648. * @returns the current updated Vector2
  75649. */
  75650. copyFromFloats(x: number, y: number): Vector2;
  75651. /**
  75652. * Sets the Vector2 coordinates with the given floats
  75653. * @param x defines the first coordinate
  75654. * @param y defines the second coordinate
  75655. * @returns the current updated Vector2
  75656. */
  75657. set(x: number, y: number): Vector2;
  75658. /**
  75659. * Add another vector with the current one
  75660. * @param otherVector defines the other vector
  75661. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75662. */
  75663. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75664. /**
  75665. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75666. * @param otherVector defines the other vector
  75667. * @param result defines the target vector
  75668. * @returns the unmodified current Vector2
  75669. */
  75670. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75671. /**
  75672. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75673. * @param otherVector defines the other vector
  75674. * @returns the current updated Vector2
  75675. */
  75676. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75677. /**
  75678. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75679. * @param otherVector defines the other vector
  75680. * @returns a new Vector2
  75681. */
  75682. addVector3(otherVector: Vector3): Vector2;
  75683. /**
  75684. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75685. * @param otherVector defines the other vector
  75686. * @returns a new Vector2
  75687. */
  75688. subtract(otherVector: Vector2): Vector2;
  75689. /**
  75690. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75691. * @param otherVector defines the other vector
  75692. * @param result defines the target vector
  75693. * @returns the unmodified current Vector2
  75694. */
  75695. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75696. /**
  75697. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75698. * @param otherVector defines the other vector
  75699. * @returns the current updated Vector2
  75700. */
  75701. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75702. /**
  75703. * Multiplies in place the current Vector2 coordinates by the given ones
  75704. * @param otherVector defines the other vector
  75705. * @returns the current updated Vector2
  75706. */
  75707. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75708. /**
  75709. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75710. * @param otherVector defines the other vector
  75711. * @returns a new Vector2
  75712. */
  75713. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75714. /**
  75715. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75716. * @param otherVector defines the other vector
  75717. * @param result defines the target vector
  75718. * @returns the unmodified current Vector2
  75719. */
  75720. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75721. /**
  75722. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75723. * @param x defines the first coordinate
  75724. * @param y defines the second coordinate
  75725. * @returns a new Vector2
  75726. */
  75727. multiplyByFloats(x: number, y: number): Vector2;
  75728. /**
  75729. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75730. * @param otherVector defines the other vector
  75731. * @returns a new Vector2
  75732. */
  75733. divide(otherVector: Vector2): Vector2;
  75734. /**
  75735. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75736. * @param otherVector defines the other vector
  75737. * @param result defines the target vector
  75738. * @returns the unmodified current Vector2
  75739. */
  75740. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75741. /**
  75742. * Divides the current Vector2 coordinates by the given ones
  75743. * @param otherVector defines the other vector
  75744. * @returns the current updated Vector2
  75745. */
  75746. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75747. /**
  75748. * Gets a new Vector2 with current Vector2 negated coordinates
  75749. * @returns a new Vector2
  75750. */
  75751. negate(): Vector2;
  75752. /**
  75753. * Negate this vector in place
  75754. * @returns this
  75755. */
  75756. negateInPlace(): Vector2;
  75757. /**
  75758. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75759. * @param result defines the Vector3 object where to store the result
  75760. * @returns the current Vector2
  75761. */
  75762. negateToRef(result: Vector2): Vector2;
  75763. /**
  75764. * Multiply the Vector2 coordinates by scale
  75765. * @param scale defines the scaling factor
  75766. * @returns the current updated Vector2
  75767. */
  75768. scaleInPlace(scale: number): Vector2;
  75769. /**
  75770. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75771. * @param scale defines the scaling factor
  75772. * @returns a new Vector2
  75773. */
  75774. scale(scale: number): Vector2;
  75775. /**
  75776. * Scale the current Vector2 values by a factor to a given Vector2
  75777. * @param scale defines the scale factor
  75778. * @param result defines the Vector2 object where to store the result
  75779. * @returns the unmodified current Vector2
  75780. */
  75781. scaleToRef(scale: number, result: Vector2): Vector2;
  75782. /**
  75783. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75784. * @param scale defines the scale factor
  75785. * @param result defines the Vector2 object where to store the result
  75786. * @returns the unmodified current Vector2
  75787. */
  75788. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75789. /**
  75790. * Gets a boolean if two vectors are equals
  75791. * @param otherVector defines the other vector
  75792. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75793. */
  75794. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75795. /**
  75796. * Gets a boolean if two vectors are equals (using an epsilon value)
  75797. * @param otherVector defines the other vector
  75798. * @param epsilon defines the minimal distance to consider equality
  75799. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75800. */
  75801. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75802. /**
  75803. * Gets a new Vector2 from current Vector2 floored values
  75804. * @returns a new Vector2
  75805. */
  75806. floor(): Vector2;
  75807. /**
  75808. * Gets a new Vector2 from current Vector2 floored values
  75809. * @returns a new Vector2
  75810. */
  75811. fract(): Vector2;
  75812. /**
  75813. * Gets the length of the vector
  75814. * @returns the vector length (float)
  75815. */
  75816. length(): number;
  75817. /**
  75818. * Gets the vector squared length
  75819. * @returns the vector squared length (float)
  75820. */
  75821. lengthSquared(): number;
  75822. /**
  75823. * Normalize the vector
  75824. * @returns the current updated Vector2
  75825. */
  75826. normalize(): Vector2;
  75827. /**
  75828. * Gets a new Vector2 copied from the Vector2
  75829. * @returns a new Vector2
  75830. */
  75831. clone(): Vector2;
  75832. /**
  75833. * Gets a new Vector2(0, 0)
  75834. * @returns a new Vector2
  75835. */
  75836. static Zero(): Vector2;
  75837. /**
  75838. * Gets a new Vector2(1, 1)
  75839. * @returns a new Vector2
  75840. */
  75841. static One(): Vector2;
  75842. /**
  75843. * Gets a new Vector2 set from the given index element of the given array
  75844. * @param array defines the data source
  75845. * @param offset defines the offset in the data source
  75846. * @returns a new Vector2
  75847. */
  75848. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75849. /**
  75850. * Sets "result" from the given index element of the given array
  75851. * @param array defines the data source
  75852. * @param offset defines the offset in the data source
  75853. * @param result defines the target vector
  75854. */
  75855. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75856. /**
  75857. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75858. * @param value1 defines 1st point of control
  75859. * @param value2 defines 2nd point of control
  75860. * @param value3 defines 3rd point of control
  75861. * @param value4 defines 4th point of control
  75862. * @param amount defines the interpolation factor
  75863. * @returns a new Vector2
  75864. */
  75865. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75866. /**
  75867. * 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".
  75868. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75869. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75870. * @param value defines the value to clamp
  75871. * @param min defines the lower limit
  75872. * @param max defines the upper limit
  75873. * @returns a new Vector2
  75874. */
  75875. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75876. /**
  75877. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75878. * @param value1 defines the 1st control point
  75879. * @param tangent1 defines the outgoing tangent
  75880. * @param value2 defines the 2nd control point
  75881. * @param tangent2 defines the incoming tangent
  75882. * @param amount defines the interpolation factor
  75883. * @returns a new Vector2
  75884. */
  75885. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75886. /**
  75887. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75888. * @param start defines the start vector
  75889. * @param end defines the end vector
  75890. * @param amount defines the interpolation factor
  75891. * @returns a new Vector2
  75892. */
  75893. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75894. /**
  75895. * Gets the dot product of the vector "left" and the vector "right"
  75896. * @param left defines first vector
  75897. * @param right defines second vector
  75898. * @returns the dot product (float)
  75899. */
  75900. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75901. /**
  75902. * Returns a new Vector2 equal to the normalized given vector
  75903. * @param vector defines the vector to normalize
  75904. * @returns a new Vector2
  75905. */
  75906. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75907. /**
  75908. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75909. * @param left defines 1st vector
  75910. * @param right defines 2nd vector
  75911. * @returns a new Vector2
  75912. */
  75913. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75914. /**
  75915. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75916. * @param left defines 1st vector
  75917. * @param right defines 2nd vector
  75918. * @returns a new Vector2
  75919. */
  75920. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75921. /**
  75922. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75923. * @param vector defines the vector to transform
  75924. * @param transformation defines the matrix to apply
  75925. * @returns a new Vector2
  75926. */
  75927. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75928. /**
  75929. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75930. * @param vector defines the vector to transform
  75931. * @param transformation defines the matrix to apply
  75932. * @param result defines the target vector
  75933. */
  75934. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75935. /**
  75936. * Determines if a given vector is included in a triangle
  75937. * @param p defines the vector to test
  75938. * @param p0 defines 1st triangle point
  75939. * @param p1 defines 2nd triangle point
  75940. * @param p2 defines 3rd triangle point
  75941. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75942. */
  75943. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75944. /**
  75945. * Gets the distance between the vectors "value1" and "value2"
  75946. * @param value1 defines first vector
  75947. * @param value2 defines second vector
  75948. * @returns the distance between vectors
  75949. */
  75950. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75951. /**
  75952. * Returns the squared distance between the vectors "value1" and "value2"
  75953. * @param value1 defines first vector
  75954. * @param value2 defines second vector
  75955. * @returns the squared distance between vectors
  75956. */
  75957. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75958. /**
  75959. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75960. * @param value1 defines first vector
  75961. * @param value2 defines second vector
  75962. * @returns a new Vector2
  75963. */
  75964. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75965. /**
  75966. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75967. * @param p defines the middle point
  75968. * @param segA defines one point of the segment
  75969. * @param segB defines the other point of the segment
  75970. * @returns the shortest distance
  75971. */
  75972. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75973. }
  75974. /**
  75975. * Class used to store (x,y,z) vector representation
  75976. * A Vector3 is the main object used in 3D geometry
  75977. * It can represent etiher the coordinates of a point the space, either a direction
  75978. * Reminder: js uses a left handed forward facing system
  75979. */
  75980. export class Vector3 {
  75981. /**
  75982. * Defines the first coordinates (on X axis)
  75983. */
  75984. x: number;
  75985. /**
  75986. * Defines the second coordinates (on Y axis)
  75987. */
  75988. y: number;
  75989. /**
  75990. * Defines the third coordinates (on Z axis)
  75991. */
  75992. z: number;
  75993. private static _UpReadOnly;
  75994. private static _ZeroReadOnly;
  75995. /**
  75996. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75997. * @param x defines the first coordinates (on X axis)
  75998. * @param y defines the second coordinates (on Y axis)
  75999. * @param z defines the third coordinates (on Z axis)
  76000. */
  76001. constructor(
  76002. /**
  76003. * Defines the first coordinates (on X axis)
  76004. */
  76005. x?: number,
  76006. /**
  76007. * Defines the second coordinates (on Y axis)
  76008. */
  76009. y?: number,
  76010. /**
  76011. * Defines the third coordinates (on Z axis)
  76012. */
  76013. z?: number);
  76014. /**
  76015. * Creates a string representation of the Vector3
  76016. * @returns a string with the Vector3 coordinates.
  76017. */
  76018. toString(): string;
  76019. /**
  76020. * Gets the class name
  76021. * @returns the string "Vector3"
  76022. */
  76023. getClassName(): string;
  76024. /**
  76025. * Creates the Vector3 hash code
  76026. * @returns a number which tends to be unique between Vector3 instances
  76027. */
  76028. getHashCode(): number;
  76029. /**
  76030. * Creates an array containing three elements : the coordinates of the Vector3
  76031. * @returns a new array of numbers
  76032. */
  76033. asArray(): number[];
  76034. /**
  76035. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76036. * @param array defines the destination array
  76037. * @param index defines the offset in the destination array
  76038. * @returns the current Vector3
  76039. */
  76040. toArray(array: FloatArray, index?: number): Vector3;
  76041. /**
  76042. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76043. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76044. */
  76045. toQuaternion(): Quaternion;
  76046. /**
  76047. * Adds the given vector to the current Vector3
  76048. * @param otherVector defines the second operand
  76049. * @returns the current updated Vector3
  76050. */
  76051. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76052. /**
  76053. * Adds the given coordinates to the current Vector3
  76054. * @param x defines the x coordinate of the operand
  76055. * @param y defines the y coordinate of the operand
  76056. * @param z defines the z coordinate of the operand
  76057. * @returns the current updated Vector3
  76058. */
  76059. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76060. /**
  76061. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76062. * @param otherVector defines the second operand
  76063. * @returns the resulting Vector3
  76064. */
  76065. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76066. /**
  76067. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76068. * @param otherVector defines the second operand
  76069. * @param result defines the Vector3 object where to store the result
  76070. * @returns the current Vector3
  76071. */
  76072. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76073. /**
  76074. * Subtract the given vector from the current Vector3
  76075. * @param otherVector defines the second operand
  76076. * @returns the current updated Vector3
  76077. */
  76078. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76079. /**
  76080. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76081. * @param otherVector defines the second operand
  76082. * @returns the resulting Vector3
  76083. */
  76084. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76085. /**
  76086. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76087. * @param otherVector defines the second operand
  76088. * @param result defines the Vector3 object where to store the result
  76089. * @returns the current Vector3
  76090. */
  76091. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76092. /**
  76093. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76094. * @param x defines the x coordinate of the operand
  76095. * @param y defines the y coordinate of the operand
  76096. * @param z defines the z coordinate of the operand
  76097. * @returns the resulting Vector3
  76098. */
  76099. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76100. /**
  76101. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76102. * @param x defines the x coordinate of the operand
  76103. * @param y defines the y coordinate of the operand
  76104. * @param z defines the z coordinate of the operand
  76105. * @param result defines the Vector3 object where to store the result
  76106. * @returns the current Vector3
  76107. */
  76108. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76109. /**
  76110. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76111. * @returns a new Vector3
  76112. */
  76113. negate(): Vector3;
  76114. /**
  76115. * Negate this vector in place
  76116. * @returns this
  76117. */
  76118. negateInPlace(): Vector3;
  76119. /**
  76120. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76121. * @param result defines the Vector3 object where to store the result
  76122. * @returns the current Vector3
  76123. */
  76124. negateToRef(result: Vector3): Vector3;
  76125. /**
  76126. * Multiplies the Vector3 coordinates by the float "scale"
  76127. * @param scale defines the multiplier factor
  76128. * @returns the current updated Vector3
  76129. */
  76130. scaleInPlace(scale: number): Vector3;
  76131. /**
  76132. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76133. * @param scale defines the multiplier factor
  76134. * @returns a new Vector3
  76135. */
  76136. scale(scale: number): Vector3;
  76137. /**
  76138. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76139. * @param scale defines the multiplier factor
  76140. * @param result defines the Vector3 object where to store the result
  76141. * @returns the current Vector3
  76142. */
  76143. scaleToRef(scale: number, result: Vector3): Vector3;
  76144. /**
  76145. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76146. * @param scale defines the scale factor
  76147. * @param result defines the Vector3 object where to store the result
  76148. * @returns the unmodified current Vector3
  76149. */
  76150. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76151. /**
  76152. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76153. * @param otherVector defines the second operand
  76154. * @returns true if both vectors are equals
  76155. */
  76156. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76157. /**
  76158. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76159. * @param otherVector defines the second operand
  76160. * @param epsilon defines the minimal distance to define values as equals
  76161. * @returns true if both vectors are distant less than epsilon
  76162. */
  76163. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76164. /**
  76165. * Returns true if the current Vector3 coordinates equals the given floats
  76166. * @param x defines the x coordinate of the operand
  76167. * @param y defines the y coordinate of the operand
  76168. * @param z defines the z coordinate of the operand
  76169. * @returns true if both vectors are equals
  76170. */
  76171. equalsToFloats(x: number, y: number, z: number): boolean;
  76172. /**
  76173. * Multiplies the current Vector3 coordinates by the given ones
  76174. * @param otherVector defines the second operand
  76175. * @returns the current updated Vector3
  76176. */
  76177. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76178. /**
  76179. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76180. * @param otherVector defines the second operand
  76181. * @returns the new Vector3
  76182. */
  76183. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76184. /**
  76185. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76186. * @param otherVector defines the second operand
  76187. * @param result defines the Vector3 object where to store the result
  76188. * @returns the current Vector3
  76189. */
  76190. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76191. /**
  76192. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76193. * @param x defines the x coordinate of the operand
  76194. * @param y defines the y coordinate of the operand
  76195. * @param z defines the z coordinate of the operand
  76196. * @returns the new Vector3
  76197. */
  76198. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76199. /**
  76200. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76201. * @param otherVector defines the second operand
  76202. * @returns the new Vector3
  76203. */
  76204. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76205. /**
  76206. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76207. * @param otherVector defines the second operand
  76208. * @param result defines the Vector3 object where to store the result
  76209. * @returns the current Vector3
  76210. */
  76211. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76212. /**
  76213. * Divides the current Vector3 coordinates by the given ones.
  76214. * @param otherVector defines the second operand
  76215. * @returns the current updated Vector3
  76216. */
  76217. divideInPlace(otherVector: Vector3): Vector3;
  76218. /**
  76219. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76220. * @param other defines the second operand
  76221. * @returns the current updated Vector3
  76222. */
  76223. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76224. /**
  76225. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76226. * @param other defines the second operand
  76227. * @returns the current updated Vector3
  76228. */
  76229. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76230. /**
  76231. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76232. * @param x defines the x coordinate of the operand
  76233. * @param y defines the y coordinate of the operand
  76234. * @param z defines the z coordinate of the operand
  76235. * @returns the current updated Vector3
  76236. */
  76237. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76238. /**
  76239. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76240. * @param x defines the x coordinate of the operand
  76241. * @param y defines the y coordinate of the operand
  76242. * @param z defines the z coordinate of the operand
  76243. * @returns the current updated Vector3
  76244. */
  76245. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76246. /**
  76247. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76248. * Check if is non uniform within a certain amount of decimal places to account for this
  76249. * @param epsilon the amount the values can differ
  76250. * @returns if the the vector is non uniform to a certain number of decimal places
  76251. */
  76252. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76253. /**
  76254. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76255. */
  76256. get isNonUniform(): boolean;
  76257. /**
  76258. * Gets a new Vector3 from current Vector3 floored values
  76259. * @returns a new Vector3
  76260. */
  76261. floor(): Vector3;
  76262. /**
  76263. * Gets a new Vector3 from current Vector3 floored values
  76264. * @returns a new Vector3
  76265. */
  76266. fract(): Vector3;
  76267. /**
  76268. * Gets the length of the Vector3
  76269. * @returns the length of the Vector3
  76270. */
  76271. length(): number;
  76272. /**
  76273. * Gets the squared length of the Vector3
  76274. * @returns squared length of the Vector3
  76275. */
  76276. lengthSquared(): number;
  76277. /**
  76278. * Normalize the current Vector3.
  76279. * Please note that this is an in place operation.
  76280. * @returns the current updated Vector3
  76281. */
  76282. normalize(): Vector3;
  76283. /**
  76284. * Reorders the x y z properties of the vector in place
  76285. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76286. * @returns the current updated vector
  76287. */
  76288. reorderInPlace(order: string): this;
  76289. /**
  76290. * Rotates the vector around 0,0,0 by a quaternion
  76291. * @param quaternion the rotation quaternion
  76292. * @param result vector to store the result
  76293. * @returns the resulting vector
  76294. */
  76295. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76296. /**
  76297. * Rotates a vector around a given point
  76298. * @param quaternion the rotation quaternion
  76299. * @param point the point to rotate around
  76300. * @param result vector to store the result
  76301. * @returns the resulting vector
  76302. */
  76303. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76304. /**
  76305. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76306. * The cross product is then orthogonal to both current and "other"
  76307. * @param other defines the right operand
  76308. * @returns the cross product
  76309. */
  76310. cross(other: Vector3): Vector3;
  76311. /**
  76312. * Normalize the current Vector3 with the given input length.
  76313. * Please note that this is an in place operation.
  76314. * @param len the length of the vector
  76315. * @returns the current updated Vector3
  76316. */
  76317. normalizeFromLength(len: number): Vector3;
  76318. /**
  76319. * Normalize the current Vector3 to a new vector
  76320. * @returns the new Vector3
  76321. */
  76322. normalizeToNew(): Vector3;
  76323. /**
  76324. * Normalize the current Vector3 to the reference
  76325. * @param reference define the Vector3 to update
  76326. * @returns the updated Vector3
  76327. */
  76328. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76329. /**
  76330. * Creates a new Vector3 copied from the current Vector3
  76331. * @returns the new Vector3
  76332. */
  76333. clone(): Vector3;
  76334. /**
  76335. * Copies the given vector coordinates to the current Vector3 ones
  76336. * @param source defines the source Vector3
  76337. * @returns the current updated Vector3
  76338. */
  76339. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76340. /**
  76341. * Copies the given floats to the current Vector3 coordinates
  76342. * @param x defines the x coordinate of the operand
  76343. * @param y defines the y coordinate of the operand
  76344. * @param z defines the z coordinate of the operand
  76345. * @returns the current updated Vector3
  76346. */
  76347. copyFromFloats(x: number, y: number, z: number): Vector3;
  76348. /**
  76349. * Copies the given floats to the current Vector3 coordinates
  76350. * @param x defines the x coordinate of the operand
  76351. * @param y defines the y coordinate of the operand
  76352. * @param z defines the z coordinate of the operand
  76353. * @returns the current updated Vector3
  76354. */
  76355. set(x: number, y: number, z: number): Vector3;
  76356. /**
  76357. * Copies the given float to the current Vector3 coordinates
  76358. * @param v defines the x, y and z coordinates of the operand
  76359. * @returns the current updated Vector3
  76360. */
  76361. setAll(v: number): Vector3;
  76362. /**
  76363. * Get the clip factor between two vectors
  76364. * @param vector0 defines the first operand
  76365. * @param vector1 defines the second operand
  76366. * @param axis defines the axis to use
  76367. * @param size defines the size along the axis
  76368. * @returns the clip factor
  76369. */
  76370. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76371. /**
  76372. * Get angle between two vectors
  76373. * @param vector0 angle between vector0 and vector1
  76374. * @param vector1 angle between vector0 and vector1
  76375. * @param normal direction of the normal
  76376. * @return the angle between vector0 and vector1
  76377. */
  76378. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76379. /**
  76380. * Returns a new Vector3 set from the index "offset" of the given array
  76381. * @param array defines the source array
  76382. * @param offset defines the offset in the source array
  76383. * @returns the new Vector3
  76384. */
  76385. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76386. /**
  76387. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76388. * @param array defines the source array
  76389. * @param offset defines the offset in the source array
  76390. * @returns the new Vector3
  76391. * @deprecated Please use FromArray instead.
  76392. */
  76393. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76394. /**
  76395. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76396. * @param array defines the source array
  76397. * @param offset defines the offset in the source array
  76398. * @param result defines the Vector3 where to store the result
  76399. */
  76400. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76401. /**
  76402. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76403. * @param array defines the source array
  76404. * @param offset defines the offset in the source array
  76405. * @param result defines the Vector3 where to store the result
  76406. * @deprecated Please use FromArrayToRef instead.
  76407. */
  76408. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76409. /**
  76410. * Sets the given vector "result" with the given floats.
  76411. * @param x defines the x coordinate of the source
  76412. * @param y defines the y coordinate of the source
  76413. * @param z defines the z coordinate of the source
  76414. * @param result defines the Vector3 where to store the result
  76415. */
  76416. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76417. /**
  76418. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76419. * @returns a new empty Vector3
  76420. */
  76421. static Zero(): Vector3;
  76422. /**
  76423. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76424. * @returns a new unit Vector3
  76425. */
  76426. static One(): Vector3;
  76427. /**
  76428. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76429. * @returns a new up Vector3
  76430. */
  76431. static Up(): Vector3;
  76432. /**
  76433. * Gets a up Vector3 that must not be updated
  76434. */
  76435. static get UpReadOnly(): DeepImmutable<Vector3>;
  76436. /**
  76437. * Gets a zero Vector3 that must not be updated
  76438. */
  76439. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76440. /**
  76441. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76442. * @returns a new down Vector3
  76443. */
  76444. static Down(): Vector3;
  76445. /**
  76446. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76447. * @returns a new forward Vector3
  76448. */
  76449. static Forward(): Vector3;
  76450. /**
  76451. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76452. * @returns a new forward Vector3
  76453. */
  76454. static Backward(): Vector3;
  76455. /**
  76456. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76457. * @returns a new right Vector3
  76458. */
  76459. static Right(): Vector3;
  76460. /**
  76461. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76462. * @returns a new left Vector3
  76463. */
  76464. static Left(): Vector3;
  76465. /**
  76466. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76467. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76468. * @param vector defines the Vector3 to transform
  76469. * @param transformation defines the transformation matrix
  76470. * @returns the transformed Vector3
  76471. */
  76472. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76473. /**
  76474. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76475. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76476. * @param vector defines the Vector3 to transform
  76477. * @param transformation defines the transformation matrix
  76478. * @param result defines the Vector3 where to store the result
  76479. */
  76480. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76481. /**
  76482. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76483. * This method computes tranformed coordinates only, not transformed direction vectors
  76484. * @param x define the x coordinate of the source vector
  76485. * @param y define the y coordinate of the source vector
  76486. * @param z define the z coordinate of the source vector
  76487. * @param transformation defines the transformation matrix
  76488. * @param result defines the Vector3 where to store the result
  76489. */
  76490. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76491. /**
  76492. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76493. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76494. * @param vector defines the Vector3 to transform
  76495. * @param transformation defines the transformation matrix
  76496. * @returns the new Vector3
  76497. */
  76498. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76499. /**
  76500. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76501. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76502. * @param vector defines the Vector3 to transform
  76503. * @param transformation defines the transformation matrix
  76504. * @param result defines the Vector3 where to store the result
  76505. */
  76506. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76507. /**
  76508. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76509. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76510. * @param x define the x coordinate of the source vector
  76511. * @param y define the y coordinate of the source vector
  76512. * @param z define the z coordinate of the source vector
  76513. * @param transformation defines the transformation matrix
  76514. * @param result defines the Vector3 where to store the result
  76515. */
  76516. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76517. /**
  76518. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76519. * @param value1 defines the first control point
  76520. * @param value2 defines the second control point
  76521. * @param value3 defines the third control point
  76522. * @param value4 defines the fourth control point
  76523. * @param amount defines the amount on the spline to use
  76524. * @returns the new Vector3
  76525. */
  76526. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76527. /**
  76528. * 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"
  76529. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76530. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76531. * @param value defines the current value
  76532. * @param min defines the lower range value
  76533. * @param max defines the upper range value
  76534. * @returns the new Vector3
  76535. */
  76536. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76537. /**
  76538. * 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"
  76539. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76540. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76541. * @param value defines the current value
  76542. * @param min defines the lower range value
  76543. * @param max defines the upper range value
  76544. * @param result defines the Vector3 where to store the result
  76545. */
  76546. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76547. /**
  76548. * Checks if a given vector is inside a specific range
  76549. * @param v defines the vector to test
  76550. * @param min defines the minimum range
  76551. * @param max defines the maximum range
  76552. */
  76553. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76554. /**
  76555. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76556. * @param value1 defines the first control point
  76557. * @param tangent1 defines the first tangent vector
  76558. * @param value2 defines the second control point
  76559. * @param tangent2 defines the second tangent vector
  76560. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76561. * @returns the new Vector3
  76562. */
  76563. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76564. /**
  76565. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76566. * @param start defines the start value
  76567. * @param end defines the end value
  76568. * @param amount max defines amount between both (between 0 and 1)
  76569. * @returns the new Vector3
  76570. */
  76571. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76572. /**
  76573. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76574. * @param start defines the start value
  76575. * @param end defines the end value
  76576. * @param amount max defines amount between both (between 0 and 1)
  76577. * @param result defines the Vector3 where to store the result
  76578. */
  76579. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76580. /**
  76581. * Returns the dot product (float) between the vectors "left" and "right"
  76582. * @param left defines the left operand
  76583. * @param right defines the right operand
  76584. * @returns the dot product
  76585. */
  76586. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76587. /**
  76588. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76589. * The cross product is then orthogonal to both "left" and "right"
  76590. * @param left defines the left operand
  76591. * @param right defines the right operand
  76592. * @returns the cross product
  76593. */
  76594. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76595. /**
  76596. * Sets the given vector "result" with the cross product of "left" and "right"
  76597. * The cross product is then orthogonal to both "left" and "right"
  76598. * @param left defines the left operand
  76599. * @param right defines the right operand
  76600. * @param result defines the Vector3 where to store the result
  76601. */
  76602. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76603. /**
  76604. * Returns a new Vector3 as the normalization of the given vector
  76605. * @param vector defines the Vector3 to normalize
  76606. * @returns the new Vector3
  76607. */
  76608. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76609. /**
  76610. * Sets the given vector "result" with the normalization of the given first vector
  76611. * @param vector defines the Vector3 to normalize
  76612. * @param result defines the Vector3 where to store the result
  76613. */
  76614. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76615. /**
  76616. * Project a Vector3 onto screen space
  76617. * @param vector defines the Vector3 to project
  76618. * @param world defines the world matrix to use
  76619. * @param transform defines the transform (view x projection) matrix to use
  76620. * @param viewport defines the screen viewport to use
  76621. * @returns the new Vector3
  76622. */
  76623. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76624. /** @hidden */
  76625. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76626. /**
  76627. * Unproject from screen space to object space
  76628. * @param source defines the screen space Vector3 to use
  76629. * @param viewportWidth defines the current width of the viewport
  76630. * @param viewportHeight defines the current height of the viewport
  76631. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76632. * @param transform defines the transform (view x projection) matrix to use
  76633. * @returns the new Vector3
  76634. */
  76635. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76636. /**
  76637. * Unproject from screen space to object space
  76638. * @param source defines the screen space Vector3 to use
  76639. * @param viewportWidth defines the current width of the viewport
  76640. * @param viewportHeight defines the current height of the viewport
  76641. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76642. * @param view defines the view matrix to use
  76643. * @param projection defines the projection matrix to use
  76644. * @returns the new Vector3
  76645. */
  76646. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76647. /**
  76648. * Unproject from screen space to object space
  76649. * @param source defines the screen space Vector3 to use
  76650. * @param viewportWidth defines the current width of the viewport
  76651. * @param viewportHeight defines the current height of the viewport
  76652. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76653. * @param view defines the view matrix to use
  76654. * @param projection defines the projection matrix to use
  76655. * @param result defines the Vector3 where to store the result
  76656. */
  76657. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76658. /**
  76659. * Unproject from screen space to object space
  76660. * @param sourceX defines the screen space x coordinate to use
  76661. * @param sourceY defines the screen space y coordinate to use
  76662. * @param sourceZ defines the screen space z coordinate to use
  76663. * @param viewportWidth defines the current width of the viewport
  76664. * @param viewportHeight defines the current height of the viewport
  76665. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76666. * @param view defines the view matrix to use
  76667. * @param projection defines the projection matrix to use
  76668. * @param result defines the Vector3 where to store the result
  76669. */
  76670. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76671. /**
  76672. * Gets the minimal coordinate values between two Vector3
  76673. * @param left defines the first operand
  76674. * @param right defines the second operand
  76675. * @returns the new Vector3
  76676. */
  76677. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76678. /**
  76679. * Gets the maximal coordinate values between two Vector3
  76680. * @param left defines the first operand
  76681. * @param right defines the second operand
  76682. * @returns the new Vector3
  76683. */
  76684. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76685. /**
  76686. * Returns the distance between the vectors "value1" and "value2"
  76687. * @param value1 defines the first operand
  76688. * @param value2 defines the second operand
  76689. * @returns the distance
  76690. */
  76691. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76692. /**
  76693. * Returns the squared distance between the vectors "value1" and "value2"
  76694. * @param value1 defines the first operand
  76695. * @param value2 defines the second operand
  76696. * @returns the squared distance
  76697. */
  76698. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76699. /**
  76700. * Returns a new Vector3 located at the center between "value1" and "value2"
  76701. * @param value1 defines the first operand
  76702. * @param value2 defines the second operand
  76703. * @returns the new Vector3
  76704. */
  76705. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76706. /**
  76707. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76708. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76709. * to something in order to rotate it from its local system to the given target system
  76710. * Note: axis1, axis2 and axis3 are normalized during this operation
  76711. * @param axis1 defines the first axis
  76712. * @param axis2 defines the second axis
  76713. * @param axis3 defines the third axis
  76714. * @returns a new Vector3
  76715. */
  76716. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76717. /**
  76718. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76719. * @param axis1 defines the first axis
  76720. * @param axis2 defines the second axis
  76721. * @param axis3 defines the third axis
  76722. * @param ref defines the Vector3 where to store the result
  76723. */
  76724. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76725. }
  76726. /**
  76727. * Vector4 class created for EulerAngle class conversion to Quaternion
  76728. */
  76729. export class Vector4 {
  76730. /** x value of the vector */
  76731. x: number;
  76732. /** y value of the vector */
  76733. y: number;
  76734. /** z value of the vector */
  76735. z: number;
  76736. /** w value of the vector */
  76737. w: number;
  76738. /**
  76739. * Creates a Vector4 object from the given floats.
  76740. * @param x x value of the vector
  76741. * @param y y value of the vector
  76742. * @param z z value of the vector
  76743. * @param w w value of the vector
  76744. */
  76745. constructor(
  76746. /** x value of the vector */
  76747. x: number,
  76748. /** y value of the vector */
  76749. y: number,
  76750. /** z value of the vector */
  76751. z: number,
  76752. /** w value of the vector */
  76753. w: number);
  76754. /**
  76755. * Returns the string with the Vector4 coordinates.
  76756. * @returns a string containing all the vector values
  76757. */
  76758. toString(): string;
  76759. /**
  76760. * Returns the string "Vector4".
  76761. * @returns "Vector4"
  76762. */
  76763. getClassName(): string;
  76764. /**
  76765. * Returns the Vector4 hash code.
  76766. * @returns a unique hash code
  76767. */
  76768. getHashCode(): number;
  76769. /**
  76770. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76771. * @returns the resulting array
  76772. */
  76773. asArray(): number[];
  76774. /**
  76775. * Populates the given array from the given index with the Vector4 coordinates.
  76776. * @param array array to populate
  76777. * @param index index of the array to start at (default: 0)
  76778. * @returns the Vector4.
  76779. */
  76780. toArray(array: FloatArray, index?: number): Vector4;
  76781. /**
  76782. * Adds the given vector to the current Vector4.
  76783. * @param otherVector the vector to add
  76784. * @returns the updated Vector4.
  76785. */
  76786. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76787. /**
  76788. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76789. * @param otherVector the vector to add
  76790. * @returns the resulting vector
  76791. */
  76792. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76793. /**
  76794. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76795. * @param otherVector the vector to add
  76796. * @param result the vector to store the result
  76797. * @returns the current Vector4.
  76798. */
  76799. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76800. /**
  76801. * Subtract in place the given vector from the current Vector4.
  76802. * @param otherVector the vector to subtract
  76803. * @returns the updated Vector4.
  76804. */
  76805. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76806. /**
  76807. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76808. * @param otherVector the vector to add
  76809. * @returns the new vector with the result
  76810. */
  76811. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76812. /**
  76813. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76814. * @param otherVector the vector to subtract
  76815. * @param result the vector to store the result
  76816. * @returns the current Vector4.
  76817. */
  76818. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76819. /**
  76820. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76821. */
  76822. /**
  76823. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76824. * @param x value to subtract
  76825. * @param y value to subtract
  76826. * @param z value to subtract
  76827. * @param w value to subtract
  76828. * @returns new vector containing the result
  76829. */
  76830. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76831. /**
  76832. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76833. * @param x value to subtract
  76834. * @param y value to subtract
  76835. * @param z value to subtract
  76836. * @param w value to subtract
  76837. * @param result the vector to store the result in
  76838. * @returns the current Vector4.
  76839. */
  76840. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76841. /**
  76842. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76843. * @returns a new vector with the negated values
  76844. */
  76845. negate(): Vector4;
  76846. /**
  76847. * Negate this vector in place
  76848. * @returns this
  76849. */
  76850. negateInPlace(): Vector4;
  76851. /**
  76852. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76853. * @param result defines the Vector3 object where to store the result
  76854. * @returns the current Vector4
  76855. */
  76856. negateToRef(result: Vector4): Vector4;
  76857. /**
  76858. * Multiplies the current Vector4 coordinates by scale (float).
  76859. * @param scale the number to scale with
  76860. * @returns the updated Vector4.
  76861. */
  76862. scaleInPlace(scale: number): Vector4;
  76863. /**
  76864. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76865. * @param scale the number to scale with
  76866. * @returns a new vector with the result
  76867. */
  76868. scale(scale: number): Vector4;
  76869. /**
  76870. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76871. * @param scale the number to scale with
  76872. * @param result a vector to store the result in
  76873. * @returns the current Vector4.
  76874. */
  76875. scaleToRef(scale: number, result: Vector4): Vector4;
  76876. /**
  76877. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76878. * @param scale defines the scale factor
  76879. * @param result defines the Vector4 object where to store the result
  76880. * @returns the unmodified current Vector4
  76881. */
  76882. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76883. /**
  76884. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76885. * @param otherVector the vector to compare against
  76886. * @returns true if they are equal
  76887. */
  76888. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76889. /**
  76890. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76891. * @param otherVector vector to compare against
  76892. * @param epsilon (Default: very small number)
  76893. * @returns true if they are equal
  76894. */
  76895. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76896. /**
  76897. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76898. * @param x x value to compare against
  76899. * @param y y value to compare against
  76900. * @param z z value to compare against
  76901. * @param w w value to compare against
  76902. * @returns true if equal
  76903. */
  76904. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76905. /**
  76906. * Multiplies in place the current Vector4 by the given one.
  76907. * @param otherVector vector to multiple with
  76908. * @returns the updated Vector4.
  76909. */
  76910. multiplyInPlace(otherVector: Vector4): Vector4;
  76911. /**
  76912. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76913. * @param otherVector vector to multiple with
  76914. * @returns resulting new vector
  76915. */
  76916. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76917. /**
  76918. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76919. * @param otherVector vector to multiple with
  76920. * @param result vector to store the result
  76921. * @returns the current Vector4.
  76922. */
  76923. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76924. /**
  76925. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76926. * @param x x value multiply with
  76927. * @param y y value multiply with
  76928. * @param z z value multiply with
  76929. * @param w w value multiply with
  76930. * @returns resulting new vector
  76931. */
  76932. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76933. /**
  76934. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76935. * @param otherVector vector to devide with
  76936. * @returns resulting new vector
  76937. */
  76938. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76939. /**
  76940. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76941. * @param otherVector vector to devide with
  76942. * @param result vector to store the result
  76943. * @returns the current Vector4.
  76944. */
  76945. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76946. /**
  76947. * Divides the current Vector3 coordinates by the given ones.
  76948. * @param otherVector vector to devide with
  76949. * @returns the updated Vector3.
  76950. */
  76951. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76952. /**
  76953. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76954. * @param other defines the second operand
  76955. * @returns the current updated Vector4
  76956. */
  76957. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76958. /**
  76959. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76960. * @param other defines the second operand
  76961. * @returns the current updated Vector4
  76962. */
  76963. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76964. /**
  76965. * Gets a new Vector4 from current Vector4 floored values
  76966. * @returns a new Vector4
  76967. */
  76968. floor(): Vector4;
  76969. /**
  76970. * Gets a new Vector4 from current Vector3 floored values
  76971. * @returns a new Vector4
  76972. */
  76973. fract(): Vector4;
  76974. /**
  76975. * Returns the Vector4 length (float).
  76976. * @returns the length
  76977. */
  76978. length(): number;
  76979. /**
  76980. * Returns the Vector4 squared length (float).
  76981. * @returns the length squared
  76982. */
  76983. lengthSquared(): number;
  76984. /**
  76985. * Normalizes in place the Vector4.
  76986. * @returns the updated Vector4.
  76987. */
  76988. normalize(): Vector4;
  76989. /**
  76990. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76991. * @returns this converted to a new vector3
  76992. */
  76993. toVector3(): Vector3;
  76994. /**
  76995. * Returns a new Vector4 copied from the current one.
  76996. * @returns the new cloned vector
  76997. */
  76998. clone(): Vector4;
  76999. /**
  77000. * Updates the current Vector4 with the given one coordinates.
  77001. * @param source the source vector to copy from
  77002. * @returns the updated Vector4.
  77003. */
  77004. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77005. /**
  77006. * Updates the current Vector4 coordinates with the given floats.
  77007. * @param x float to copy from
  77008. * @param y float to copy from
  77009. * @param z float to copy from
  77010. * @param w float to copy from
  77011. * @returns the updated Vector4.
  77012. */
  77013. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77014. /**
  77015. * Updates the current Vector4 coordinates with the given floats.
  77016. * @param x float to set from
  77017. * @param y float to set from
  77018. * @param z float to set from
  77019. * @param w float to set from
  77020. * @returns the updated Vector4.
  77021. */
  77022. set(x: number, y: number, z: number, w: number): Vector4;
  77023. /**
  77024. * Copies the given float to the current Vector3 coordinates
  77025. * @param v defines the x, y, z and w coordinates of the operand
  77026. * @returns the current updated Vector3
  77027. */
  77028. setAll(v: number): Vector4;
  77029. /**
  77030. * Returns a new Vector4 set from the starting index of the given array.
  77031. * @param array the array to pull values from
  77032. * @param offset the offset into the array to start at
  77033. * @returns the new vector
  77034. */
  77035. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77036. /**
  77037. * Updates the given vector "result" from the starting index of the given array.
  77038. * @param array the array to pull values from
  77039. * @param offset the offset into the array to start at
  77040. * @param result the vector to store the result in
  77041. */
  77042. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77043. /**
  77044. * Updates the given vector "result" from the starting index of the given Float32Array.
  77045. * @param array the array to pull values from
  77046. * @param offset the offset into the array to start at
  77047. * @param result the vector to store the result in
  77048. */
  77049. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77050. /**
  77051. * Updates the given vector "result" coordinates from the given floats.
  77052. * @param x float to set from
  77053. * @param y float to set from
  77054. * @param z float to set from
  77055. * @param w float to set from
  77056. * @param result the vector to the floats in
  77057. */
  77058. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77059. /**
  77060. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77061. * @returns the new vector
  77062. */
  77063. static Zero(): Vector4;
  77064. /**
  77065. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77066. * @returns the new vector
  77067. */
  77068. static One(): Vector4;
  77069. /**
  77070. * Returns a new normalized Vector4 from the given one.
  77071. * @param vector the vector to normalize
  77072. * @returns the vector
  77073. */
  77074. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77075. /**
  77076. * Updates the given vector "result" from the normalization of the given one.
  77077. * @param vector the vector to normalize
  77078. * @param result the vector to store the result in
  77079. */
  77080. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77081. /**
  77082. * Returns a vector with the minimum values from the left and right vectors
  77083. * @param left left vector to minimize
  77084. * @param right right vector to minimize
  77085. * @returns a new vector with the minimum of the left and right vector values
  77086. */
  77087. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77088. /**
  77089. * Returns a vector with the maximum values from the left and right vectors
  77090. * @param left left vector to maximize
  77091. * @param right right vector to maximize
  77092. * @returns a new vector with the maximum of the left and right vector values
  77093. */
  77094. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77095. /**
  77096. * Returns the distance (float) between the vectors "value1" and "value2".
  77097. * @param value1 value to calulate the distance between
  77098. * @param value2 value to calulate the distance between
  77099. * @return the distance between the two vectors
  77100. */
  77101. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77102. /**
  77103. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77104. * @param value1 value to calulate the distance between
  77105. * @param value2 value to calulate the distance between
  77106. * @return the distance between the two vectors squared
  77107. */
  77108. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77109. /**
  77110. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77111. * @param value1 value to calulate the center between
  77112. * @param value2 value to calulate the center between
  77113. * @return the center between the two vectors
  77114. */
  77115. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77116. /**
  77117. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77118. * This methods computes transformed normalized direction vectors only.
  77119. * @param vector the vector to transform
  77120. * @param transformation the transformation matrix to apply
  77121. * @returns the new vector
  77122. */
  77123. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77124. /**
  77125. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77126. * This methods computes transformed normalized direction vectors only.
  77127. * @param vector the vector to transform
  77128. * @param transformation the transformation matrix to apply
  77129. * @param result the vector to store the result in
  77130. */
  77131. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77132. /**
  77133. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77134. * This methods computes transformed normalized direction vectors only.
  77135. * @param x value to transform
  77136. * @param y value to transform
  77137. * @param z value to transform
  77138. * @param w value to transform
  77139. * @param transformation the transformation matrix to apply
  77140. * @param result the vector to store the results in
  77141. */
  77142. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77143. /**
  77144. * Creates a new Vector4 from a Vector3
  77145. * @param source defines the source data
  77146. * @param w defines the 4th component (default is 0)
  77147. * @returns a new Vector4
  77148. */
  77149. static FromVector3(source: Vector3, w?: number): Vector4;
  77150. }
  77151. /**
  77152. * Class used to store quaternion data
  77153. * @see https://en.wikipedia.org/wiki/Quaternion
  77154. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77155. */
  77156. export class Quaternion {
  77157. /** defines the first component (0 by default) */
  77158. x: number;
  77159. /** defines the second component (0 by default) */
  77160. y: number;
  77161. /** defines the third component (0 by default) */
  77162. z: number;
  77163. /** defines the fourth component (1.0 by default) */
  77164. w: number;
  77165. /**
  77166. * Creates a new Quaternion from the given floats
  77167. * @param x defines the first component (0 by default)
  77168. * @param y defines the second component (0 by default)
  77169. * @param z defines the third component (0 by default)
  77170. * @param w defines the fourth component (1.0 by default)
  77171. */
  77172. constructor(
  77173. /** defines the first component (0 by default) */
  77174. x?: number,
  77175. /** defines the second component (0 by default) */
  77176. y?: number,
  77177. /** defines the third component (0 by default) */
  77178. z?: number,
  77179. /** defines the fourth component (1.0 by default) */
  77180. w?: number);
  77181. /**
  77182. * Gets a string representation for the current quaternion
  77183. * @returns a string with the Quaternion coordinates
  77184. */
  77185. toString(): string;
  77186. /**
  77187. * Gets the class name of the quaternion
  77188. * @returns the string "Quaternion"
  77189. */
  77190. getClassName(): string;
  77191. /**
  77192. * Gets a hash code for this quaternion
  77193. * @returns the quaternion hash code
  77194. */
  77195. getHashCode(): number;
  77196. /**
  77197. * Copy the quaternion to an array
  77198. * @returns a new array populated with 4 elements from the quaternion coordinates
  77199. */
  77200. asArray(): number[];
  77201. /**
  77202. * Check if two quaternions are equals
  77203. * @param otherQuaternion defines the second operand
  77204. * @return true if the current quaternion and the given one coordinates are strictly equals
  77205. */
  77206. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77207. /**
  77208. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77209. * @param otherQuaternion defines the other quaternion
  77210. * @param epsilon defines the minimal distance to consider equality
  77211. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77212. */
  77213. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77214. /**
  77215. * Clone the current quaternion
  77216. * @returns a new quaternion copied from the current one
  77217. */
  77218. clone(): Quaternion;
  77219. /**
  77220. * Copy a quaternion to the current one
  77221. * @param other defines the other quaternion
  77222. * @returns the updated current quaternion
  77223. */
  77224. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77225. /**
  77226. * Updates the current quaternion with the given float coordinates
  77227. * @param x defines the x coordinate
  77228. * @param y defines the y coordinate
  77229. * @param z defines the z coordinate
  77230. * @param w defines the w coordinate
  77231. * @returns the updated current quaternion
  77232. */
  77233. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77234. /**
  77235. * Updates the current quaternion from the given float coordinates
  77236. * @param x defines the x coordinate
  77237. * @param y defines the y coordinate
  77238. * @param z defines the z coordinate
  77239. * @param w defines the w coordinate
  77240. * @returns the updated current quaternion
  77241. */
  77242. set(x: number, y: number, z: number, w: number): Quaternion;
  77243. /**
  77244. * Adds two quaternions
  77245. * @param other defines the second operand
  77246. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77247. */
  77248. add(other: DeepImmutable<Quaternion>): Quaternion;
  77249. /**
  77250. * Add a quaternion to the current one
  77251. * @param other defines the quaternion to add
  77252. * @returns the current quaternion
  77253. */
  77254. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77255. /**
  77256. * Subtract two quaternions
  77257. * @param other defines the second operand
  77258. * @returns a new quaternion as the subtraction result of the given one from the current one
  77259. */
  77260. subtract(other: Quaternion): Quaternion;
  77261. /**
  77262. * Multiplies the current quaternion by a scale factor
  77263. * @param value defines the scale factor
  77264. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77265. */
  77266. scale(value: number): Quaternion;
  77267. /**
  77268. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77269. * @param scale defines the scale factor
  77270. * @param result defines the Quaternion object where to store the result
  77271. * @returns the unmodified current quaternion
  77272. */
  77273. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77274. /**
  77275. * Multiplies in place the current quaternion by a scale factor
  77276. * @param value defines the scale factor
  77277. * @returns the current modified quaternion
  77278. */
  77279. scaleInPlace(value: number): Quaternion;
  77280. /**
  77281. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77282. * @param scale defines the scale factor
  77283. * @param result defines the Quaternion object where to store the result
  77284. * @returns the unmodified current quaternion
  77285. */
  77286. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77287. /**
  77288. * Multiplies two quaternions
  77289. * @param q1 defines the second operand
  77290. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77291. */
  77292. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77293. /**
  77294. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77295. * @param q1 defines the second operand
  77296. * @param result defines the target quaternion
  77297. * @returns the current quaternion
  77298. */
  77299. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77300. /**
  77301. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77302. * @param q1 defines the second operand
  77303. * @returns the currentupdated quaternion
  77304. */
  77305. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77306. /**
  77307. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77308. * @param ref defines the target quaternion
  77309. * @returns the current quaternion
  77310. */
  77311. conjugateToRef(ref: Quaternion): Quaternion;
  77312. /**
  77313. * Conjugates in place (1-q) the current quaternion
  77314. * @returns the current updated quaternion
  77315. */
  77316. conjugateInPlace(): Quaternion;
  77317. /**
  77318. * Conjugates in place (1-q) the current quaternion
  77319. * @returns a new quaternion
  77320. */
  77321. conjugate(): Quaternion;
  77322. /**
  77323. * Gets length of current quaternion
  77324. * @returns the quaternion length (float)
  77325. */
  77326. length(): number;
  77327. /**
  77328. * Normalize in place the current quaternion
  77329. * @returns the current updated quaternion
  77330. */
  77331. normalize(): Quaternion;
  77332. /**
  77333. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77334. * @param order is a reserved parameter and is ignore for now
  77335. * @returns a new Vector3 containing the Euler angles
  77336. */
  77337. toEulerAngles(order?: string): Vector3;
  77338. /**
  77339. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77340. * @param result defines the vector which will be filled with the Euler angles
  77341. * @param order is a reserved parameter and is ignore for now
  77342. * @returns the current unchanged quaternion
  77343. */
  77344. toEulerAnglesToRef(result: Vector3): Quaternion;
  77345. /**
  77346. * Updates the given rotation matrix with the current quaternion values
  77347. * @param result defines the target matrix
  77348. * @returns the current unchanged quaternion
  77349. */
  77350. toRotationMatrix(result: Matrix): Quaternion;
  77351. /**
  77352. * Updates the current quaternion from the given rotation matrix values
  77353. * @param matrix defines the source matrix
  77354. * @returns the current updated quaternion
  77355. */
  77356. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77357. /**
  77358. * Creates a new quaternion from a rotation matrix
  77359. * @param matrix defines the source matrix
  77360. * @returns a new quaternion created from the given rotation matrix values
  77361. */
  77362. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77363. /**
  77364. * Updates the given quaternion with the given rotation matrix values
  77365. * @param matrix defines the source matrix
  77366. * @param result defines the target quaternion
  77367. */
  77368. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77369. /**
  77370. * Returns the dot product (float) between the quaternions "left" and "right"
  77371. * @param left defines the left operand
  77372. * @param right defines the right operand
  77373. * @returns the dot product
  77374. */
  77375. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77376. /**
  77377. * Checks if the two quaternions are close to each other
  77378. * @param quat0 defines the first quaternion to check
  77379. * @param quat1 defines the second quaternion to check
  77380. * @returns true if the two quaternions are close to each other
  77381. */
  77382. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77383. /**
  77384. * Creates an empty quaternion
  77385. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77386. */
  77387. static Zero(): Quaternion;
  77388. /**
  77389. * Inverse a given quaternion
  77390. * @param q defines the source quaternion
  77391. * @returns a new quaternion as the inverted current quaternion
  77392. */
  77393. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77394. /**
  77395. * Inverse a given quaternion
  77396. * @param q defines the source quaternion
  77397. * @param result the quaternion the result will be stored in
  77398. * @returns the result quaternion
  77399. */
  77400. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77401. /**
  77402. * Creates an identity quaternion
  77403. * @returns the identity quaternion
  77404. */
  77405. static Identity(): Quaternion;
  77406. /**
  77407. * Gets a boolean indicating if the given quaternion is identity
  77408. * @param quaternion defines the quaternion to check
  77409. * @returns true if the quaternion is identity
  77410. */
  77411. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77412. /**
  77413. * Creates a quaternion from a rotation around an axis
  77414. * @param axis defines the axis to use
  77415. * @param angle defines the angle to use
  77416. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77417. */
  77418. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77419. /**
  77420. * Creates a rotation around an axis and stores it into the given quaternion
  77421. * @param axis defines the axis to use
  77422. * @param angle defines the angle to use
  77423. * @param result defines the target quaternion
  77424. * @returns the target quaternion
  77425. */
  77426. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77427. /**
  77428. * Creates a new quaternion from data stored into an array
  77429. * @param array defines the data source
  77430. * @param offset defines the offset in the source array where the data starts
  77431. * @returns a new quaternion
  77432. */
  77433. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77434. /**
  77435. * Updates the given quaternion "result" from the starting index of the given array.
  77436. * @param array the array to pull values from
  77437. * @param offset the offset into the array to start at
  77438. * @param result the quaternion to store the result in
  77439. */
  77440. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  77441. /**
  77442. * Create a quaternion from Euler rotation angles
  77443. * @param x Pitch
  77444. * @param y Yaw
  77445. * @param z Roll
  77446. * @returns the new Quaternion
  77447. */
  77448. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77449. /**
  77450. * Updates a quaternion from Euler rotation angles
  77451. * @param x Pitch
  77452. * @param y Yaw
  77453. * @param z Roll
  77454. * @param result the quaternion to store the result
  77455. * @returns the updated quaternion
  77456. */
  77457. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77458. /**
  77459. * Create a quaternion from Euler rotation vector
  77460. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77461. * @returns the new Quaternion
  77462. */
  77463. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77464. /**
  77465. * Updates a quaternion from Euler rotation vector
  77466. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77467. * @param result the quaternion to store the result
  77468. * @returns the updated quaternion
  77469. */
  77470. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77471. /**
  77472. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77473. * @param yaw defines the rotation around Y axis
  77474. * @param pitch defines the rotation around X axis
  77475. * @param roll defines the rotation around Z axis
  77476. * @returns the new quaternion
  77477. */
  77478. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77479. /**
  77480. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77481. * @param yaw defines the rotation around Y axis
  77482. * @param pitch defines the rotation around X axis
  77483. * @param roll defines the rotation around Z axis
  77484. * @param result defines the target quaternion
  77485. */
  77486. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77487. /**
  77488. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77489. * @param alpha defines the rotation around first axis
  77490. * @param beta defines the rotation around second axis
  77491. * @param gamma defines the rotation around third axis
  77492. * @returns the new quaternion
  77493. */
  77494. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77495. /**
  77496. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77497. * @param alpha defines the rotation around first axis
  77498. * @param beta defines the rotation around second axis
  77499. * @param gamma defines the rotation around third axis
  77500. * @param result defines the target quaternion
  77501. */
  77502. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77503. /**
  77504. * 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)
  77505. * @param axis1 defines the first axis
  77506. * @param axis2 defines the second axis
  77507. * @param axis3 defines the third axis
  77508. * @returns the new quaternion
  77509. */
  77510. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77511. /**
  77512. * 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
  77513. * @param axis1 defines the first axis
  77514. * @param axis2 defines the second axis
  77515. * @param axis3 defines the third axis
  77516. * @param ref defines the target quaternion
  77517. */
  77518. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77519. /**
  77520. * Interpolates between two quaternions
  77521. * @param left defines first quaternion
  77522. * @param right defines second quaternion
  77523. * @param amount defines the gradient to use
  77524. * @returns the new interpolated quaternion
  77525. */
  77526. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77527. /**
  77528. * Interpolates between two quaternions and stores it into a target quaternion
  77529. * @param left defines first quaternion
  77530. * @param right defines second quaternion
  77531. * @param amount defines the gradient to use
  77532. * @param result defines the target quaternion
  77533. */
  77534. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77535. /**
  77536. * Interpolate between two quaternions using Hermite interpolation
  77537. * @param value1 defines first quaternion
  77538. * @param tangent1 defines the incoming tangent
  77539. * @param value2 defines second quaternion
  77540. * @param tangent2 defines the outgoing tangent
  77541. * @param amount defines the target quaternion
  77542. * @returns the new interpolated quaternion
  77543. */
  77544. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77545. }
  77546. /**
  77547. * Class used to store matrix data (4x4)
  77548. */
  77549. export class Matrix {
  77550. private static _updateFlagSeed;
  77551. private static _identityReadOnly;
  77552. private _isIdentity;
  77553. private _isIdentityDirty;
  77554. private _isIdentity3x2;
  77555. private _isIdentity3x2Dirty;
  77556. /**
  77557. * Gets the update flag of the matrix which is an unique number for the matrix.
  77558. * It will be incremented every time the matrix data change.
  77559. * You can use it to speed the comparison between two versions of the same matrix.
  77560. */
  77561. updateFlag: number;
  77562. private readonly _m;
  77563. /**
  77564. * Gets the internal data of the matrix
  77565. */
  77566. get m(): DeepImmutable<Float32Array>;
  77567. /** @hidden */
  77568. _markAsUpdated(): void;
  77569. /** @hidden */
  77570. private _updateIdentityStatus;
  77571. /**
  77572. * Creates an empty matrix (filled with zeros)
  77573. */
  77574. constructor();
  77575. /**
  77576. * Check if the current matrix is identity
  77577. * @returns true is the matrix is the identity matrix
  77578. */
  77579. isIdentity(): boolean;
  77580. /**
  77581. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77582. * @returns true is the matrix is the identity matrix
  77583. */
  77584. isIdentityAs3x2(): boolean;
  77585. /**
  77586. * Gets the determinant of the matrix
  77587. * @returns the matrix determinant
  77588. */
  77589. determinant(): number;
  77590. /**
  77591. * Returns the matrix as a Float32Array
  77592. * @returns the matrix underlying array
  77593. */
  77594. toArray(): DeepImmutable<Float32Array>;
  77595. /**
  77596. * Returns the matrix as a Float32Array
  77597. * @returns the matrix underlying array.
  77598. */
  77599. asArray(): DeepImmutable<Float32Array>;
  77600. /**
  77601. * Inverts the current matrix in place
  77602. * @returns the current inverted matrix
  77603. */
  77604. invert(): Matrix;
  77605. /**
  77606. * Sets all the matrix elements to zero
  77607. * @returns the current matrix
  77608. */
  77609. reset(): Matrix;
  77610. /**
  77611. * Adds the current matrix with a second one
  77612. * @param other defines the matrix to add
  77613. * @returns a new matrix as the addition of the current matrix and the given one
  77614. */
  77615. add(other: DeepImmutable<Matrix>): Matrix;
  77616. /**
  77617. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77618. * @param other defines the matrix to add
  77619. * @param result defines the target matrix
  77620. * @returns the current matrix
  77621. */
  77622. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77623. /**
  77624. * Adds in place the given matrix to the current matrix
  77625. * @param other defines the second operand
  77626. * @returns the current updated matrix
  77627. */
  77628. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77629. /**
  77630. * Sets the given matrix to the current inverted Matrix
  77631. * @param other defines the target matrix
  77632. * @returns the unmodified current matrix
  77633. */
  77634. invertToRef(other: Matrix): Matrix;
  77635. /**
  77636. * add a value at the specified position in the current Matrix
  77637. * @param index the index of the value within the matrix. between 0 and 15.
  77638. * @param value the value to be added
  77639. * @returns the current updated matrix
  77640. */
  77641. addAtIndex(index: number, value: number): Matrix;
  77642. /**
  77643. * mutiply the specified position in the current Matrix by a value
  77644. * @param index the index of the value within the matrix. between 0 and 15.
  77645. * @param value the value to be added
  77646. * @returns the current updated matrix
  77647. */
  77648. multiplyAtIndex(index: number, value: number): Matrix;
  77649. /**
  77650. * Inserts the translation vector (using 3 floats) in the current matrix
  77651. * @param x defines the 1st component of the translation
  77652. * @param y defines the 2nd component of the translation
  77653. * @param z defines the 3rd component of the translation
  77654. * @returns the current updated matrix
  77655. */
  77656. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77657. /**
  77658. * Adds the translation vector (using 3 floats) in the current matrix
  77659. * @param x defines the 1st component of the translation
  77660. * @param y defines the 2nd component of the translation
  77661. * @param z defines the 3rd component of the translation
  77662. * @returns the current updated matrix
  77663. */
  77664. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77665. /**
  77666. * Inserts the translation vector in the current matrix
  77667. * @param vector3 defines the translation to insert
  77668. * @returns the current updated matrix
  77669. */
  77670. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77671. /**
  77672. * Gets the translation value of the current matrix
  77673. * @returns a new Vector3 as the extracted translation from the matrix
  77674. */
  77675. getTranslation(): Vector3;
  77676. /**
  77677. * Fill a Vector3 with the extracted translation from the matrix
  77678. * @param result defines the Vector3 where to store the translation
  77679. * @returns the current matrix
  77680. */
  77681. getTranslationToRef(result: Vector3): Matrix;
  77682. /**
  77683. * Remove rotation and scaling part from the matrix
  77684. * @returns the updated matrix
  77685. */
  77686. removeRotationAndScaling(): Matrix;
  77687. /**
  77688. * Multiply two matrices
  77689. * @param other defines the second operand
  77690. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77691. */
  77692. multiply(other: DeepImmutable<Matrix>): Matrix;
  77693. /**
  77694. * Copy the current matrix from the given one
  77695. * @param other defines the source matrix
  77696. * @returns the current updated matrix
  77697. */
  77698. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77699. /**
  77700. * Populates the given array from the starting index with the current matrix values
  77701. * @param array defines the target array
  77702. * @param offset defines the offset in the target array where to start storing values
  77703. * @returns the current matrix
  77704. */
  77705. copyToArray(array: Float32Array, offset?: number): Matrix;
  77706. /**
  77707. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77708. * @param other defines the second operand
  77709. * @param result defines the matrix where to store the multiplication
  77710. * @returns the current matrix
  77711. */
  77712. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77713. /**
  77714. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77715. * @param other defines the second operand
  77716. * @param result defines the array where to store the multiplication
  77717. * @param offset defines the offset in the target array where to start storing values
  77718. * @returns the current matrix
  77719. */
  77720. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77721. /**
  77722. * Check equality between this matrix and a second one
  77723. * @param value defines the second matrix to compare
  77724. * @returns true is the current matrix and the given one values are strictly equal
  77725. */
  77726. equals(value: DeepImmutable<Matrix>): boolean;
  77727. /**
  77728. * Clone the current matrix
  77729. * @returns a new matrix from the current matrix
  77730. */
  77731. clone(): Matrix;
  77732. /**
  77733. * Returns the name of the current matrix class
  77734. * @returns the string "Matrix"
  77735. */
  77736. getClassName(): string;
  77737. /**
  77738. * Gets the hash code of the current matrix
  77739. * @returns the hash code
  77740. */
  77741. getHashCode(): number;
  77742. /**
  77743. * Decomposes the current Matrix into a translation, rotation and scaling components
  77744. * @param scale defines the scale vector3 given as a reference to update
  77745. * @param rotation defines the rotation quaternion given as a reference to update
  77746. * @param translation defines the translation vector3 given as a reference to update
  77747. * @returns true if operation was successful
  77748. */
  77749. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77750. /**
  77751. * Gets specific row of the matrix
  77752. * @param index defines the number of the row to get
  77753. * @returns the index-th row of the current matrix as a new Vector4
  77754. */
  77755. getRow(index: number): Nullable<Vector4>;
  77756. /**
  77757. * Sets the index-th row of the current matrix to the vector4 values
  77758. * @param index defines the number of the row to set
  77759. * @param row defines the target vector4
  77760. * @returns the updated current matrix
  77761. */
  77762. setRow(index: number, row: Vector4): Matrix;
  77763. /**
  77764. * Compute the transpose of the matrix
  77765. * @returns the new transposed matrix
  77766. */
  77767. transpose(): Matrix;
  77768. /**
  77769. * Compute the transpose of the matrix and store it in a given matrix
  77770. * @param result defines the target matrix
  77771. * @returns the current matrix
  77772. */
  77773. transposeToRef(result: Matrix): Matrix;
  77774. /**
  77775. * Sets the index-th row of the current matrix with the given 4 x float values
  77776. * @param index defines the row index
  77777. * @param x defines the x component to set
  77778. * @param y defines the y component to set
  77779. * @param z defines the z component to set
  77780. * @param w defines the w component to set
  77781. * @returns the updated current matrix
  77782. */
  77783. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77784. /**
  77785. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77786. * @param scale defines the scale factor
  77787. * @returns a new matrix
  77788. */
  77789. scale(scale: number): Matrix;
  77790. /**
  77791. * Scale the current matrix values by a factor to a given result matrix
  77792. * @param scale defines the scale factor
  77793. * @param result defines the matrix to store the result
  77794. * @returns the current matrix
  77795. */
  77796. scaleToRef(scale: number, result: Matrix): Matrix;
  77797. /**
  77798. * Scale the current matrix values by a factor and add the result to a given matrix
  77799. * @param scale defines the scale factor
  77800. * @param result defines the Matrix to store the result
  77801. * @returns the current matrix
  77802. */
  77803. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77804. /**
  77805. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77806. * @param ref matrix to store the result
  77807. */
  77808. toNormalMatrix(ref: Matrix): void;
  77809. /**
  77810. * Gets only rotation part of the current matrix
  77811. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77812. */
  77813. getRotationMatrix(): Matrix;
  77814. /**
  77815. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77816. * @param result defines the target matrix to store data to
  77817. * @returns the current matrix
  77818. */
  77819. getRotationMatrixToRef(result: Matrix): Matrix;
  77820. /**
  77821. * Toggles model matrix from being right handed to left handed in place and vice versa
  77822. */
  77823. toggleModelMatrixHandInPlace(): void;
  77824. /**
  77825. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77826. */
  77827. toggleProjectionMatrixHandInPlace(): void;
  77828. /**
  77829. * Creates a matrix from an array
  77830. * @param array defines the source array
  77831. * @param offset defines an offset in the source array
  77832. * @returns a new Matrix set from the starting index of the given array
  77833. */
  77834. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77835. /**
  77836. * Copy the content of an array into a given matrix
  77837. * @param array defines the source array
  77838. * @param offset defines an offset in the source array
  77839. * @param result defines the target matrix
  77840. */
  77841. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77842. /**
  77843. * Stores an array into a matrix after having multiplied each component by a given factor
  77844. * @param array defines the source array
  77845. * @param offset defines the offset in the source array
  77846. * @param scale defines the scaling factor
  77847. * @param result defines the target matrix
  77848. */
  77849. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77850. /**
  77851. * Gets an identity matrix that must not be updated
  77852. */
  77853. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77854. /**
  77855. * Stores a list of values (16) inside a given matrix
  77856. * @param initialM11 defines 1st value of 1st row
  77857. * @param initialM12 defines 2nd value of 1st row
  77858. * @param initialM13 defines 3rd value of 1st row
  77859. * @param initialM14 defines 4th value of 1st row
  77860. * @param initialM21 defines 1st value of 2nd row
  77861. * @param initialM22 defines 2nd value of 2nd row
  77862. * @param initialM23 defines 3rd value of 2nd row
  77863. * @param initialM24 defines 4th value of 2nd row
  77864. * @param initialM31 defines 1st value of 3rd row
  77865. * @param initialM32 defines 2nd value of 3rd row
  77866. * @param initialM33 defines 3rd value of 3rd row
  77867. * @param initialM34 defines 4th value of 3rd row
  77868. * @param initialM41 defines 1st value of 4th row
  77869. * @param initialM42 defines 2nd value of 4th row
  77870. * @param initialM43 defines 3rd value of 4th row
  77871. * @param initialM44 defines 4th value of 4th row
  77872. * @param result defines the target matrix
  77873. */
  77874. 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;
  77875. /**
  77876. * Creates new matrix from a list of values (16)
  77877. * @param initialM11 defines 1st value of 1st row
  77878. * @param initialM12 defines 2nd value of 1st row
  77879. * @param initialM13 defines 3rd value of 1st row
  77880. * @param initialM14 defines 4th value of 1st row
  77881. * @param initialM21 defines 1st value of 2nd row
  77882. * @param initialM22 defines 2nd value of 2nd row
  77883. * @param initialM23 defines 3rd value of 2nd row
  77884. * @param initialM24 defines 4th value of 2nd row
  77885. * @param initialM31 defines 1st value of 3rd row
  77886. * @param initialM32 defines 2nd value of 3rd row
  77887. * @param initialM33 defines 3rd value of 3rd row
  77888. * @param initialM34 defines 4th value of 3rd row
  77889. * @param initialM41 defines 1st value of 4th row
  77890. * @param initialM42 defines 2nd value of 4th row
  77891. * @param initialM43 defines 3rd value of 4th row
  77892. * @param initialM44 defines 4th value of 4th row
  77893. * @returns the new matrix
  77894. */
  77895. 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;
  77896. /**
  77897. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77898. * @param scale defines the scale vector3
  77899. * @param rotation defines the rotation quaternion
  77900. * @param translation defines the translation vector3
  77901. * @returns a new matrix
  77902. */
  77903. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77904. /**
  77905. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77906. * @param scale defines the scale vector3
  77907. * @param rotation defines the rotation quaternion
  77908. * @param translation defines the translation vector3
  77909. * @param result defines the target matrix
  77910. */
  77911. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77912. /**
  77913. * Creates a new identity matrix
  77914. * @returns a new identity matrix
  77915. */
  77916. static Identity(): Matrix;
  77917. /**
  77918. * Creates a new identity matrix and stores the result in a given matrix
  77919. * @param result defines the target matrix
  77920. */
  77921. static IdentityToRef(result: Matrix): void;
  77922. /**
  77923. * Creates a new zero matrix
  77924. * @returns a new zero matrix
  77925. */
  77926. static Zero(): Matrix;
  77927. /**
  77928. * Creates a new rotation matrix for "angle" radians around the X axis
  77929. * @param angle defines the angle (in radians) to use
  77930. * @return the new matrix
  77931. */
  77932. static RotationX(angle: number): Matrix;
  77933. /**
  77934. * Creates a new matrix as the invert of a given matrix
  77935. * @param source defines the source matrix
  77936. * @returns the new matrix
  77937. */
  77938. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77939. /**
  77940. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77941. * @param angle defines the angle (in radians) to use
  77942. * @param result defines the target matrix
  77943. */
  77944. static RotationXToRef(angle: number, result: Matrix): void;
  77945. /**
  77946. * Creates a new rotation matrix for "angle" radians around the Y axis
  77947. * @param angle defines the angle (in radians) to use
  77948. * @return the new matrix
  77949. */
  77950. static RotationY(angle: number): Matrix;
  77951. /**
  77952. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77953. * @param angle defines the angle (in radians) to use
  77954. * @param result defines the target matrix
  77955. */
  77956. static RotationYToRef(angle: number, result: Matrix): void;
  77957. /**
  77958. * Creates a new rotation matrix for "angle" radians around the Z axis
  77959. * @param angle defines the angle (in radians) to use
  77960. * @return the new matrix
  77961. */
  77962. static RotationZ(angle: number): Matrix;
  77963. /**
  77964. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77965. * @param angle defines the angle (in radians) to use
  77966. * @param result defines the target matrix
  77967. */
  77968. static RotationZToRef(angle: number, result: Matrix): void;
  77969. /**
  77970. * Creates a new rotation matrix for "angle" radians around the given axis
  77971. * @param axis defines the axis to use
  77972. * @param angle defines the angle (in radians) to use
  77973. * @return the new matrix
  77974. */
  77975. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77976. /**
  77977. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77978. * @param axis defines the axis to use
  77979. * @param angle defines the angle (in radians) to use
  77980. * @param result defines the target matrix
  77981. */
  77982. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77983. /**
  77984. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77985. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77986. * @param from defines the vector to align
  77987. * @param to defines the vector to align to
  77988. * @param result defines the target matrix
  77989. */
  77990. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77991. /**
  77992. * Creates a rotation matrix
  77993. * @param yaw defines the yaw angle in radians (Y axis)
  77994. * @param pitch defines the pitch angle in radians (X axis)
  77995. * @param roll defines the roll angle in radians (X axis)
  77996. * @returns the new rotation matrix
  77997. */
  77998. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77999. /**
  78000. * Creates a rotation matrix and stores it in a given matrix
  78001. * @param yaw defines the yaw angle in radians (Y axis)
  78002. * @param pitch defines the pitch angle in radians (X axis)
  78003. * @param roll defines the roll angle in radians (X axis)
  78004. * @param result defines the target matrix
  78005. */
  78006. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78007. /**
  78008. * Creates a scaling matrix
  78009. * @param x defines the scale factor on X axis
  78010. * @param y defines the scale factor on Y axis
  78011. * @param z defines the scale factor on Z axis
  78012. * @returns the new matrix
  78013. */
  78014. static Scaling(x: number, y: number, z: number): Matrix;
  78015. /**
  78016. * Creates a scaling matrix and stores it in a given matrix
  78017. * @param x defines the scale factor on X axis
  78018. * @param y defines the scale factor on Y axis
  78019. * @param z defines the scale factor on Z axis
  78020. * @param result defines the target matrix
  78021. */
  78022. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78023. /**
  78024. * Creates a translation matrix
  78025. * @param x defines the translation on X axis
  78026. * @param y defines the translation on Y axis
  78027. * @param z defines the translationon Z axis
  78028. * @returns the new matrix
  78029. */
  78030. static Translation(x: number, y: number, z: number): Matrix;
  78031. /**
  78032. * Creates a translation matrix and stores it in a given matrix
  78033. * @param x defines the translation on X axis
  78034. * @param y defines the translation on Y axis
  78035. * @param z defines the translationon Z axis
  78036. * @param result defines the target matrix
  78037. */
  78038. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78039. /**
  78040. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78041. * @param startValue defines the start value
  78042. * @param endValue defines the end value
  78043. * @param gradient defines the gradient factor
  78044. * @returns the new matrix
  78045. */
  78046. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78047. /**
  78048. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78049. * @param startValue defines the start value
  78050. * @param endValue defines the end value
  78051. * @param gradient defines the gradient factor
  78052. * @param result defines the Matrix object where to store data
  78053. */
  78054. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78055. /**
  78056. * Builds a new matrix whose values are computed by:
  78057. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78058. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78059. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78060. * @param startValue defines the first matrix
  78061. * @param endValue defines the second matrix
  78062. * @param gradient defines the gradient between the two matrices
  78063. * @returns the new matrix
  78064. */
  78065. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78066. /**
  78067. * Update a matrix to values which are computed by:
  78068. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78069. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78070. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78071. * @param startValue defines the first matrix
  78072. * @param endValue defines the second matrix
  78073. * @param gradient defines the gradient between the two matrices
  78074. * @param result defines the target matrix
  78075. */
  78076. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78077. /**
  78078. * 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"
  78079. * This function works in left handed mode
  78080. * @param eye defines the final position of the entity
  78081. * @param target defines where the entity should look at
  78082. * @param up defines the up vector for the entity
  78083. * @returns the new matrix
  78084. */
  78085. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78086. /**
  78087. * 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".
  78088. * This function works in left handed mode
  78089. * @param eye defines the final position of the entity
  78090. * @param target defines where the entity should look at
  78091. * @param up defines the up vector for the entity
  78092. * @param result defines the target matrix
  78093. */
  78094. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78095. /**
  78096. * 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"
  78097. * This function works in right handed mode
  78098. * @param eye defines the final position of the entity
  78099. * @param target defines where the entity should look at
  78100. * @param up defines the up vector for the entity
  78101. * @returns the new matrix
  78102. */
  78103. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78104. /**
  78105. * 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".
  78106. * This function works in right handed mode
  78107. * @param eye defines the final position of the entity
  78108. * @param target defines where the entity should look at
  78109. * @param up defines the up vector for the entity
  78110. * @param result defines the target matrix
  78111. */
  78112. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78113. /**
  78114. * Create a left-handed orthographic projection matrix
  78115. * @param width defines the viewport width
  78116. * @param height defines the viewport height
  78117. * @param znear defines the near clip plane
  78118. * @param zfar defines the far clip plane
  78119. * @returns a new matrix as a left-handed orthographic projection matrix
  78120. */
  78121. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78122. /**
  78123. * Store a left-handed orthographic projection to a given matrix
  78124. * @param width defines the viewport width
  78125. * @param height defines the viewport height
  78126. * @param znear defines the near clip plane
  78127. * @param zfar defines the far clip plane
  78128. * @param result defines the target matrix
  78129. */
  78130. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78131. /**
  78132. * Create a left-handed orthographic projection matrix
  78133. * @param left defines the viewport left coordinate
  78134. * @param right defines the viewport right coordinate
  78135. * @param bottom defines the viewport bottom coordinate
  78136. * @param top defines the viewport top coordinate
  78137. * @param znear defines the near clip plane
  78138. * @param zfar defines the far clip plane
  78139. * @returns a new matrix as a left-handed orthographic projection matrix
  78140. */
  78141. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78142. /**
  78143. * Stores a left-handed orthographic projection into a given matrix
  78144. * @param left defines the viewport left coordinate
  78145. * @param right defines the viewport right coordinate
  78146. * @param bottom defines the viewport bottom coordinate
  78147. * @param top defines the viewport top coordinate
  78148. * @param znear defines the near clip plane
  78149. * @param zfar defines the far clip plane
  78150. * @param result defines the target matrix
  78151. */
  78152. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78153. /**
  78154. * Creates a right-handed orthographic projection matrix
  78155. * @param left defines the viewport left coordinate
  78156. * @param right defines the viewport right coordinate
  78157. * @param bottom defines the viewport bottom coordinate
  78158. * @param top defines the viewport top coordinate
  78159. * @param znear defines the near clip plane
  78160. * @param zfar defines the far clip plane
  78161. * @returns a new matrix as a right-handed orthographic projection matrix
  78162. */
  78163. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78164. /**
  78165. * Stores a right-handed orthographic projection into a given matrix
  78166. * @param left defines the viewport left coordinate
  78167. * @param right defines the viewport right coordinate
  78168. * @param bottom defines the viewport bottom coordinate
  78169. * @param top defines the viewport top coordinate
  78170. * @param znear defines the near clip plane
  78171. * @param zfar defines the far clip plane
  78172. * @param result defines the target matrix
  78173. */
  78174. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78175. /**
  78176. * Creates a left-handed perspective projection matrix
  78177. * @param width defines the viewport width
  78178. * @param height defines the viewport height
  78179. * @param znear defines the near clip plane
  78180. * @param zfar defines the far clip plane
  78181. * @returns a new matrix as a left-handed perspective projection matrix
  78182. */
  78183. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78184. /**
  78185. * Creates a left-handed perspective projection matrix
  78186. * @param fov defines the horizontal field of view
  78187. * @param aspect defines the aspect ratio
  78188. * @param znear defines the near clip plane
  78189. * @param zfar defines the far clip plane
  78190. * @returns a new matrix as a left-handed perspective projection matrix
  78191. */
  78192. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78193. /**
  78194. * Stores a left-handed perspective projection into a given matrix
  78195. * @param fov defines the horizontal field of view
  78196. * @param aspect defines the aspect ratio
  78197. * @param znear defines the near clip plane
  78198. * @param zfar defines the far clip plane
  78199. * @param result defines the target matrix
  78200. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78201. */
  78202. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78203. /**
  78204. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78205. * @param fov defines the horizontal field of view
  78206. * @param aspect defines the aspect ratio
  78207. * @param znear defines the near clip plane
  78208. * @param zfar not used as infinity is used as far clip
  78209. * @param result defines the target matrix
  78210. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78211. */
  78212. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78213. /**
  78214. * Creates a right-handed perspective projection matrix
  78215. * @param fov defines the horizontal field of view
  78216. * @param aspect defines the aspect ratio
  78217. * @param znear defines the near clip plane
  78218. * @param zfar defines the far clip plane
  78219. * @returns a new matrix as a right-handed perspective projection matrix
  78220. */
  78221. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78222. /**
  78223. * Stores a right-handed perspective projection into a given matrix
  78224. * @param fov defines the horizontal field of view
  78225. * @param aspect defines the aspect ratio
  78226. * @param znear defines the near clip plane
  78227. * @param zfar defines the far clip plane
  78228. * @param result defines the target matrix
  78229. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78230. */
  78231. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78232. /**
  78233. * Stores a right-handed perspective projection into a given matrix
  78234. * @param fov defines the horizontal field of view
  78235. * @param aspect defines the aspect ratio
  78236. * @param znear defines the near clip plane
  78237. * @param zfar not used as infinity is used as far clip
  78238. * @param result defines the target matrix
  78239. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78240. */
  78241. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78242. /**
  78243. * Stores a perspective projection for WebVR info a given matrix
  78244. * @param fov defines the field of view
  78245. * @param znear defines the near clip plane
  78246. * @param zfar defines the far clip plane
  78247. * @param result defines the target matrix
  78248. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78249. */
  78250. static PerspectiveFovWebVRToRef(fov: {
  78251. upDegrees: number;
  78252. downDegrees: number;
  78253. leftDegrees: number;
  78254. rightDegrees: number;
  78255. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78256. /**
  78257. * Computes a complete transformation matrix
  78258. * @param viewport defines the viewport to use
  78259. * @param world defines the world matrix
  78260. * @param view defines the view matrix
  78261. * @param projection defines the projection matrix
  78262. * @param zmin defines the near clip plane
  78263. * @param zmax defines the far clip plane
  78264. * @returns the transformation matrix
  78265. */
  78266. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78267. /**
  78268. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78269. * @param matrix defines the matrix to use
  78270. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78271. */
  78272. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78273. /**
  78274. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78275. * @param matrix defines the matrix to use
  78276. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78277. */
  78278. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78279. /**
  78280. * Compute the transpose of a given matrix
  78281. * @param matrix defines the matrix to transpose
  78282. * @returns the new matrix
  78283. */
  78284. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78285. /**
  78286. * Compute the transpose of a matrix and store it in a target matrix
  78287. * @param matrix defines the matrix to transpose
  78288. * @param result defines the target matrix
  78289. */
  78290. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78291. /**
  78292. * Computes a reflection matrix from a plane
  78293. * @param plane defines the reflection plane
  78294. * @returns a new matrix
  78295. */
  78296. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78297. /**
  78298. * Computes a reflection matrix from a plane
  78299. * @param plane defines the reflection plane
  78300. * @param result defines the target matrix
  78301. */
  78302. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78303. /**
  78304. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78305. * @param xaxis defines the value of the 1st axis
  78306. * @param yaxis defines the value of the 2nd axis
  78307. * @param zaxis defines the value of the 3rd axis
  78308. * @param result defines the target matrix
  78309. */
  78310. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78311. /**
  78312. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78313. * @param quat defines the quaternion to use
  78314. * @param result defines the target matrix
  78315. */
  78316. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78317. }
  78318. /**
  78319. * @hidden
  78320. */
  78321. export class TmpVectors {
  78322. static Vector2: Vector2[];
  78323. static Vector3: Vector3[];
  78324. static Vector4: Vector4[];
  78325. static Quaternion: Quaternion[];
  78326. static Matrix: Matrix[];
  78327. }
  78328. }
  78329. declare module BABYLON {
  78330. /**
  78331. * Defines potential orientation for back face culling
  78332. */
  78333. export enum Orientation {
  78334. /**
  78335. * Clockwise
  78336. */
  78337. CW = 0,
  78338. /** Counter clockwise */
  78339. CCW = 1
  78340. }
  78341. /** Class used to represent a Bezier curve */
  78342. export class BezierCurve {
  78343. /**
  78344. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78345. * @param t defines the time
  78346. * @param x1 defines the left coordinate on X axis
  78347. * @param y1 defines the left coordinate on Y axis
  78348. * @param x2 defines the right coordinate on X axis
  78349. * @param y2 defines the right coordinate on Y axis
  78350. * @returns the interpolated value
  78351. */
  78352. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78353. }
  78354. /**
  78355. * Defines angle representation
  78356. */
  78357. export class Angle {
  78358. private _radians;
  78359. /**
  78360. * Creates an Angle object of "radians" radians (float).
  78361. * @param radians the angle in radians
  78362. */
  78363. constructor(radians: number);
  78364. /**
  78365. * Get value in degrees
  78366. * @returns the Angle value in degrees (float)
  78367. */
  78368. degrees(): number;
  78369. /**
  78370. * Get value in radians
  78371. * @returns the Angle value in radians (float)
  78372. */
  78373. radians(): number;
  78374. /**
  78375. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78376. * @param a defines first vector
  78377. * @param b defines second vector
  78378. * @returns a new Angle
  78379. */
  78380. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78381. /**
  78382. * Gets a new Angle object from the given float in radians
  78383. * @param radians defines the angle value in radians
  78384. * @returns a new Angle
  78385. */
  78386. static FromRadians(radians: number): Angle;
  78387. /**
  78388. * Gets a new Angle object from the given float in degrees
  78389. * @param degrees defines the angle value in degrees
  78390. * @returns a new Angle
  78391. */
  78392. static FromDegrees(degrees: number): Angle;
  78393. }
  78394. /**
  78395. * This represents an arc in a 2d space.
  78396. */
  78397. export class Arc2 {
  78398. /** Defines the start point of the arc */
  78399. startPoint: Vector2;
  78400. /** Defines the mid point of the arc */
  78401. midPoint: Vector2;
  78402. /** Defines the end point of the arc */
  78403. endPoint: Vector2;
  78404. /**
  78405. * Defines the center point of the arc.
  78406. */
  78407. centerPoint: Vector2;
  78408. /**
  78409. * Defines the radius of the arc.
  78410. */
  78411. radius: number;
  78412. /**
  78413. * Defines the angle of the arc (from mid point to end point).
  78414. */
  78415. angle: Angle;
  78416. /**
  78417. * Defines the start angle of the arc (from start point to middle point).
  78418. */
  78419. startAngle: Angle;
  78420. /**
  78421. * Defines the orientation of the arc (clock wise/counter clock wise).
  78422. */
  78423. orientation: Orientation;
  78424. /**
  78425. * Creates an Arc object from the three given points : start, middle and end.
  78426. * @param startPoint Defines the start point of the arc
  78427. * @param midPoint Defines the midlle point of the arc
  78428. * @param endPoint Defines the end point of the arc
  78429. */
  78430. constructor(
  78431. /** Defines the start point of the arc */
  78432. startPoint: Vector2,
  78433. /** Defines the mid point of the arc */
  78434. midPoint: Vector2,
  78435. /** Defines the end point of the arc */
  78436. endPoint: Vector2);
  78437. }
  78438. /**
  78439. * Represents a 2D path made up of multiple 2D points
  78440. */
  78441. export class Path2 {
  78442. private _points;
  78443. private _length;
  78444. /**
  78445. * If the path start and end point are the same
  78446. */
  78447. closed: boolean;
  78448. /**
  78449. * Creates a Path2 object from the starting 2D coordinates x and y.
  78450. * @param x the starting points x value
  78451. * @param y the starting points y value
  78452. */
  78453. constructor(x: number, y: number);
  78454. /**
  78455. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78456. * @param x the added points x value
  78457. * @param y the added points y value
  78458. * @returns the updated Path2.
  78459. */
  78460. addLineTo(x: number, y: number): Path2;
  78461. /**
  78462. * 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.
  78463. * @param midX middle point x value
  78464. * @param midY middle point y value
  78465. * @param endX end point x value
  78466. * @param endY end point y value
  78467. * @param numberOfSegments (default: 36)
  78468. * @returns the updated Path2.
  78469. */
  78470. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78471. /**
  78472. * Closes the Path2.
  78473. * @returns the Path2.
  78474. */
  78475. close(): Path2;
  78476. /**
  78477. * Gets the sum of the distance between each sequential point in the path
  78478. * @returns the Path2 total length (float).
  78479. */
  78480. length(): number;
  78481. /**
  78482. * Gets the points which construct the path
  78483. * @returns the Path2 internal array of points.
  78484. */
  78485. getPoints(): Vector2[];
  78486. /**
  78487. * Retreives the point at the distance aways from the starting point
  78488. * @param normalizedLengthPosition the length along the path to retreive the point from
  78489. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78490. */
  78491. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78492. /**
  78493. * Creates a new path starting from an x and y position
  78494. * @param x starting x value
  78495. * @param y starting y value
  78496. * @returns a new Path2 starting at the coordinates (x, y).
  78497. */
  78498. static StartingAt(x: number, y: number): Path2;
  78499. }
  78500. /**
  78501. * Represents a 3D path made up of multiple 3D points
  78502. */
  78503. export class Path3D {
  78504. /**
  78505. * an array of Vector3, the curve axis of the Path3D
  78506. */
  78507. path: Vector3[];
  78508. private _curve;
  78509. private _distances;
  78510. private _tangents;
  78511. private _normals;
  78512. private _binormals;
  78513. private _raw;
  78514. private _alignTangentsWithPath;
  78515. private readonly _pointAtData;
  78516. /**
  78517. * new Path3D(path, normal, raw)
  78518. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78519. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78520. * @param path an array of Vector3, the curve axis of the Path3D
  78521. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78522. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78523. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78524. */
  78525. constructor(
  78526. /**
  78527. * an array of Vector3, the curve axis of the Path3D
  78528. */
  78529. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78530. /**
  78531. * Returns the Path3D array of successive Vector3 designing its curve.
  78532. * @returns the Path3D array of successive Vector3 designing its curve.
  78533. */
  78534. getCurve(): Vector3[];
  78535. /**
  78536. * Returns the Path3D array of successive Vector3 designing its curve.
  78537. * @returns the Path3D array of successive Vector3 designing its curve.
  78538. */
  78539. getPoints(): Vector3[];
  78540. /**
  78541. * @returns the computed length (float) of the path.
  78542. */
  78543. length(): number;
  78544. /**
  78545. * Returns an array populated with tangent vectors on each Path3D curve point.
  78546. * @returns an array populated with tangent vectors on each Path3D curve point.
  78547. */
  78548. getTangents(): Vector3[];
  78549. /**
  78550. * Returns an array populated with normal vectors on each Path3D curve point.
  78551. * @returns an array populated with normal vectors on each Path3D curve point.
  78552. */
  78553. getNormals(): Vector3[];
  78554. /**
  78555. * Returns an array populated with binormal vectors on each Path3D curve point.
  78556. * @returns an array populated with binormal vectors on each Path3D curve point.
  78557. */
  78558. getBinormals(): Vector3[];
  78559. /**
  78560. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78561. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78562. */
  78563. getDistances(): number[];
  78564. /**
  78565. * Returns an interpolated point along this path
  78566. * @param position the position of the point along this path, from 0.0 to 1.0
  78567. * @returns a new Vector3 as the point
  78568. */
  78569. getPointAt(position: number): Vector3;
  78570. /**
  78571. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78572. * @param position the position of the point along this path, from 0.0 to 1.0
  78573. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78574. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78575. */
  78576. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78577. /**
  78578. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78579. * @param position the position of the point along this path, from 0.0 to 1.0
  78580. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78581. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78582. */
  78583. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78584. /**
  78585. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78586. * @param position the position of the point along this path, from 0.0 to 1.0
  78587. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78588. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78589. */
  78590. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78591. /**
  78592. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78593. * @param position the position of the point along this path, from 0.0 to 1.0
  78594. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78595. */
  78596. getDistanceAt(position: number): number;
  78597. /**
  78598. * Returns the array index of the previous point of an interpolated point along this path
  78599. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78600. * @returns the array index
  78601. */
  78602. getPreviousPointIndexAt(position: number): number;
  78603. /**
  78604. * 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)
  78605. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78606. * @returns the sub position
  78607. */
  78608. getSubPositionAt(position: number): number;
  78609. /**
  78610. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78611. * @param target the vector of which to get the closest position to
  78612. * @returns the position of the closest virtual point on this path to the target vector
  78613. */
  78614. getClosestPositionTo(target: Vector3): number;
  78615. /**
  78616. * Returns a sub path (slice) of this path
  78617. * @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
  78618. * @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
  78619. * @returns a sub path (slice) of this path
  78620. */
  78621. slice(start?: number, end?: number): Path3D;
  78622. /**
  78623. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78624. * @param path path which all values are copied into the curves points
  78625. * @param firstNormal which should be projected onto the curve
  78626. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78627. * @returns the same object updated.
  78628. */
  78629. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78630. private _compute;
  78631. private _getFirstNonNullVector;
  78632. private _getLastNonNullVector;
  78633. private _normalVector;
  78634. /**
  78635. * Updates the point at data for an interpolated point along this curve
  78636. * @param position the position of the point along this curve, from 0.0 to 1.0
  78637. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78638. * @returns the (updated) point at data
  78639. */
  78640. private _updatePointAtData;
  78641. /**
  78642. * Updates the point at data from the specified parameters
  78643. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78644. * @param point the interpolated point
  78645. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78646. */
  78647. private _setPointAtData;
  78648. /**
  78649. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78650. */
  78651. private _updateInterpolationMatrix;
  78652. }
  78653. /**
  78654. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78655. * A Curve3 is designed from a series of successive Vector3.
  78656. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78657. */
  78658. export class Curve3 {
  78659. private _points;
  78660. private _length;
  78661. /**
  78662. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78663. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78664. * @param v1 (Vector3) the control point
  78665. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78666. * @param nbPoints (integer) the wanted number of points in the curve
  78667. * @returns the created Curve3
  78668. */
  78669. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78670. /**
  78671. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78672. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78673. * @param v1 (Vector3) the first control point
  78674. * @param v2 (Vector3) the second control point
  78675. * @param v3 (Vector3) the end point of the Cubic Bezier
  78676. * @param nbPoints (integer) the wanted number of points in the curve
  78677. * @returns the created Curve3
  78678. */
  78679. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78680. /**
  78681. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78682. * @param p1 (Vector3) the origin point of the Hermite Spline
  78683. * @param t1 (Vector3) the tangent vector at the origin point
  78684. * @param p2 (Vector3) the end point of the Hermite Spline
  78685. * @param t2 (Vector3) the tangent vector at the end point
  78686. * @param nbPoints (integer) the wanted number of points in the curve
  78687. * @returns the created Curve3
  78688. */
  78689. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78690. /**
  78691. * Returns a Curve3 object along a CatmullRom Spline curve :
  78692. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78693. * @param nbPoints (integer) the wanted number of points between each curve control points
  78694. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78695. * @returns the created Curve3
  78696. */
  78697. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78698. /**
  78699. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78700. * A Curve3 is designed from a series of successive Vector3.
  78701. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78702. * @param points points which make up the curve
  78703. */
  78704. constructor(points: Vector3[]);
  78705. /**
  78706. * @returns the Curve3 stored array of successive Vector3
  78707. */
  78708. getPoints(): Vector3[];
  78709. /**
  78710. * @returns the computed length (float) of the curve.
  78711. */
  78712. length(): number;
  78713. /**
  78714. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78715. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78716. * curveA and curveB keep unchanged.
  78717. * @param curve the curve to continue from this curve
  78718. * @returns the newly constructed curve
  78719. */
  78720. continue(curve: DeepImmutable<Curve3>): Curve3;
  78721. private _computeLength;
  78722. }
  78723. }
  78724. declare module BABYLON {
  78725. /**
  78726. * This represents the main contract an easing function should follow.
  78727. * Easing functions are used throughout the animation system.
  78728. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78729. */
  78730. export interface IEasingFunction {
  78731. /**
  78732. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78733. * of the easing function.
  78734. * The link below provides some of the most common examples of easing functions.
  78735. * @see https://easings.net/
  78736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78737. * @returns the corresponding value on the curve defined by the easing function
  78738. */
  78739. ease(gradient: number): number;
  78740. }
  78741. /**
  78742. * Base class used for every default easing function.
  78743. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78744. */
  78745. export class EasingFunction implements IEasingFunction {
  78746. /**
  78747. * Interpolation follows the mathematical formula associated with the easing function.
  78748. */
  78749. static readonly EASINGMODE_EASEIN: number;
  78750. /**
  78751. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78752. */
  78753. static readonly EASINGMODE_EASEOUT: number;
  78754. /**
  78755. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78756. */
  78757. static readonly EASINGMODE_EASEINOUT: number;
  78758. private _easingMode;
  78759. /**
  78760. * Sets the easing mode of the current function.
  78761. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78762. */
  78763. setEasingMode(easingMode: number): void;
  78764. /**
  78765. * Gets the current easing mode.
  78766. * @returns the easing mode
  78767. */
  78768. getEasingMode(): number;
  78769. /**
  78770. * @hidden
  78771. */
  78772. easeInCore(gradient: number): number;
  78773. /**
  78774. * Given an input gradient between 0 and 1, this returns the corresponding value
  78775. * of the easing function.
  78776. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78777. * @returns the corresponding value on the curve defined by the easing function
  78778. */
  78779. ease(gradient: number): number;
  78780. }
  78781. /**
  78782. * Easing function with a circle shape (see link below).
  78783. * @see https://easings.net/#easeInCirc
  78784. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78785. */
  78786. export class CircleEase extends EasingFunction implements IEasingFunction {
  78787. /** @hidden */
  78788. easeInCore(gradient: number): number;
  78789. }
  78790. /**
  78791. * Easing function with a ease back shape (see link below).
  78792. * @see https://easings.net/#easeInBack
  78793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78794. */
  78795. export class BackEase extends EasingFunction implements IEasingFunction {
  78796. /** Defines the amplitude of the function */
  78797. amplitude: number;
  78798. /**
  78799. * Instantiates a back ease easing
  78800. * @see https://easings.net/#easeInBack
  78801. * @param amplitude Defines the amplitude of the function
  78802. */
  78803. constructor(
  78804. /** Defines the amplitude of the function */
  78805. amplitude?: number);
  78806. /** @hidden */
  78807. easeInCore(gradient: number): number;
  78808. }
  78809. /**
  78810. * Easing function with a bouncing shape (see link below).
  78811. * @see https://easings.net/#easeInBounce
  78812. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78813. */
  78814. export class BounceEase extends EasingFunction implements IEasingFunction {
  78815. /** Defines the number of bounces */
  78816. bounces: number;
  78817. /** Defines the amplitude of the bounce */
  78818. bounciness: number;
  78819. /**
  78820. * Instantiates a bounce easing
  78821. * @see https://easings.net/#easeInBounce
  78822. * @param bounces Defines the number of bounces
  78823. * @param bounciness Defines the amplitude of the bounce
  78824. */
  78825. constructor(
  78826. /** Defines the number of bounces */
  78827. bounces?: number,
  78828. /** Defines the amplitude of the bounce */
  78829. bounciness?: number);
  78830. /** @hidden */
  78831. easeInCore(gradient: number): number;
  78832. }
  78833. /**
  78834. * Easing function with a power of 3 shape (see link below).
  78835. * @see https://easings.net/#easeInCubic
  78836. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78837. */
  78838. export class CubicEase extends EasingFunction implements IEasingFunction {
  78839. /** @hidden */
  78840. easeInCore(gradient: number): number;
  78841. }
  78842. /**
  78843. * Easing function with an elastic shape (see link below).
  78844. * @see https://easings.net/#easeInElastic
  78845. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78846. */
  78847. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78848. /** Defines the number of oscillations*/
  78849. oscillations: number;
  78850. /** Defines the amplitude of the oscillations*/
  78851. springiness: number;
  78852. /**
  78853. * Instantiates an elastic easing function
  78854. * @see https://easings.net/#easeInElastic
  78855. * @param oscillations Defines the number of oscillations
  78856. * @param springiness Defines the amplitude of the oscillations
  78857. */
  78858. constructor(
  78859. /** Defines the number of oscillations*/
  78860. oscillations?: number,
  78861. /** Defines the amplitude of the oscillations*/
  78862. springiness?: number);
  78863. /** @hidden */
  78864. easeInCore(gradient: number): number;
  78865. }
  78866. /**
  78867. * Easing function with an exponential shape (see link below).
  78868. * @see https://easings.net/#easeInExpo
  78869. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78870. */
  78871. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78872. /** Defines the exponent of the function */
  78873. exponent: number;
  78874. /**
  78875. * Instantiates an exponential easing function
  78876. * @see https://easings.net/#easeInExpo
  78877. * @param exponent Defines the exponent of the function
  78878. */
  78879. constructor(
  78880. /** Defines the exponent of the function */
  78881. exponent?: number);
  78882. /** @hidden */
  78883. easeInCore(gradient: number): number;
  78884. }
  78885. /**
  78886. * Easing function with a power shape (see link below).
  78887. * @see https://easings.net/#easeInQuad
  78888. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78889. */
  78890. export class PowerEase extends EasingFunction implements IEasingFunction {
  78891. /** Defines the power of the function */
  78892. power: number;
  78893. /**
  78894. * Instantiates an power base easing function
  78895. * @see https://easings.net/#easeInQuad
  78896. * @param power Defines the power of the function
  78897. */
  78898. constructor(
  78899. /** Defines the power of the function */
  78900. power?: number);
  78901. /** @hidden */
  78902. easeInCore(gradient: number): number;
  78903. }
  78904. /**
  78905. * Easing function with a power of 2 shape (see link below).
  78906. * @see https://easings.net/#easeInQuad
  78907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78908. */
  78909. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78910. /** @hidden */
  78911. easeInCore(gradient: number): number;
  78912. }
  78913. /**
  78914. * Easing function with a power of 4 shape (see link below).
  78915. * @see https://easings.net/#easeInQuart
  78916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78917. */
  78918. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78919. /** @hidden */
  78920. easeInCore(gradient: number): number;
  78921. }
  78922. /**
  78923. * Easing function with a power of 5 shape (see link below).
  78924. * @see https://easings.net/#easeInQuint
  78925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78926. */
  78927. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78928. /** @hidden */
  78929. easeInCore(gradient: number): number;
  78930. }
  78931. /**
  78932. * Easing function with a sin shape (see link below).
  78933. * @see https://easings.net/#easeInSine
  78934. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78935. */
  78936. export class SineEase extends EasingFunction implements IEasingFunction {
  78937. /** @hidden */
  78938. easeInCore(gradient: number): number;
  78939. }
  78940. /**
  78941. * Easing function with a bezier shape (see link below).
  78942. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78943. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78944. */
  78945. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78946. /** Defines the x component of the start tangent in the bezier curve */
  78947. x1: number;
  78948. /** Defines the y component of the start tangent in the bezier curve */
  78949. y1: number;
  78950. /** Defines the x component of the end tangent in the bezier curve */
  78951. x2: number;
  78952. /** Defines the y component of the end tangent in the bezier curve */
  78953. y2: number;
  78954. /**
  78955. * Instantiates a bezier function
  78956. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78957. * @param x1 Defines the x component of the start tangent in the bezier curve
  78958. * @param y1 Defines the y component of the start tangent in the bezier curve
  78959. * @param x2 Defines the x component of the end tangent in the bezier curve
  78960. * @param y2 Defines the y component of the end tangent in the bezier curve
  78961. */
  78962. constructor(
  78963. /** Defines the x component of the start tangent in the bezier curve */
  78964. x1?: number,
  78965. /** Defines the y component of the start tangent in the bezier curve */
  78966. y1?: number,
  78967. /** Defines the x component of the end tangent in the bezier curve */
  78968. x2?: number,
  78969. /** Defines the y component of the end tangent in the bezier curve */
  78970. y2?: number);
  78971. /** @hidden */
  78972. easeInCore(gradient: number): number;
  78973. }
  78974. }
  78975. declare module BABYLON {
  78976. /**
  78977. * Class used to hold a RBG color
  78978. */
  78979. export class Color3 {
  78980. /**
  78981. * Defines the red component (between 0 and 1, default is 0)
  78982. */
  78983. r: number;
  78984. /**
  78985. * Defines the green component (between 0 and 1, default is 0)
  78986. */
  78987. g: number;
  78988. /**
  78989. * Defines the blue component (between 0 and 1, default is 0)
  78990. */
  78991. b: number;
  78992. /**
  78993. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78994. * @param r defines the red component (between 0 and 1, default is 0)
  78995. * @param g defines the green component (between 0 and 1, default is 0)
  78996. * @param b defines the blue component (between 0 and 1, default is 0)
  78997. */
  78998. constructor(
  78999. /**
  79000. * Defines the red component (between 0 and 1, default is 0)
  79001. */
  79002. r?: number,
  79003. /**
  79004. * Defines the green component (between 0 and 1, default is 0)
  79005. */
  79006. g?: number,
  79007. /**
  79008. * Defines the blue component (between 0 and 1, default is 0)
  79009. */
  79010. b?: number);
  79011. /**
  79012. * Creates a string with the Color3 current values
  79013. * @returns the string representation of the Color3 object
  79014. */
  79015. toString(): string;
  79016. /**
  79017. * Returns the string "Color3"
  79018. * @returns "Color3"
  79019. */
  79020. getClassName(): string;
  79021. /**
  79022. * Compute the Color3 hash code
  79023. * @returns an unique number that can be used to hash Color3 objects
  79024. */
  79025. getHashCode(): number;
  79026. /**
  79027. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79028. * @param array defines the array where to store the r,g,b components
  79029. * @param index defines an optional index in the target array to define where to start storing values
  79030. * @returns the current Color3 object
  79031. */
  79032. toArray(array: FloatArray, index?: number): Color3;
  79033. /**
  79034. * Returns a new Color4 object from the current Color3 and the given alpha
  79035. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79036. * @returns a new Color4 object
  79037. */
  79038. toColor4(alpha?: number): Color4;
  79039. /**
  79040. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79041. * @returns the new array
  79042. */
  79043. asArray(): number[];
  79044. /**
  79045. * Returns the luminance value
  79046. * @returns a float value
  79047. */
  79048. toLuminance(): number;
  79049. /**
  79050. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79051. * @param otherColor defines the second operand
  79052. * @returns the new Color3 object
  79053. */
  79054. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79055. /**
  79056. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79057. * @param otherColor defines the second operand
  79058. * @param result defines the Color3 object where to store the result
  79059. * @returns the current Color3
  79060. */
  79061. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79062. /**
  79063. * Determines equality between Color3 objects
  79064. * @param otherColor defines the second operand
  79065. * @returns true if the rgb values are equal to the given ones
  79066. */
  79067. equals(otherColor: DeepImmutable<Color3>): boolean;
  79068. /**
  79069. * Determines equality between the current Color3 object and a set of r,b,g values
  79070. * @param r defines the red component to check
  79071. * @param g defines the green component to check
  79072. * @param b defines the blue component to check
  79073. * @returns true if the rgb values are equal to the given ones
  79074. */
  79075. equalsFloats(r: number, g: number, b: number): boolean;
  79076. /**
  79077. * Multiplies in place each rgb value by scale
  79078. * @param scale defines the scaling factor
  79079. * @returns the updated Color3
  79080. */
  79081. scale(scale: number): Color3;
  79082. /**
  79083. * Multiplies the rgb values by scale and stores the result into "result"
  79084. * @param scale defines the scaling factor
  79085. * @param result defines the Color3 object where to store the result
  79086. * @returns the unmodified current Color3
  79087. */
  79088. scaleToRef(scale: number, result: Color3): Color3;
  79089. /**
  79090. * Scale the current Color3 values by a factor and add the result to a given Color3
  79091. * @param scale defines the scale factor
  79092. * @param result defines color to store the result into
  79093. * @returns the unmodified current Color3
  79094. */
  79095. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79096. /**
  79097. * Clamps the rgb values by the min and max values and stores the result into "result"
  79098. * @param min defines minimum clamping value (default is 0)
  79099. * @param max defines maximum clamping value (default is 1)
  79100. * @param result defines color to store the result into
  79101. * @returns the original Color3
  79102. */
  79103. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79104. /**
  79105. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79106. * @param otherColor defines the second operand
  79107. * @returns the new Color3
  79108. */
  79109. add(otherColor: DeepImmutable<Color3>): Color3;
  79110. /**
  79111. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79112. * @param otherColor defines the second operand
  79113. * @param result defines Color3 object to store the result into
  79114. * @returns the unmodified current Color3
  79115. */
  79116. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79117. /**
  79118. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79119. * @param otherColor defines the second operand
  79120. * @returns the new Color3
  79121. */
  79122. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79123. /**
  79124. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79125. * @param otherColor defines the second operand
  79126. * @param result defines Color3 object to store the result into
  79127. * @returns the unmodified current Color3
  79128. */
  79129. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79130. /**
  79131. * Copy the current object
  79132. * @returns a new Color3 copied the current one
  79133. */
  79134. clone(): Color3;
  79135. /**
  79136. * Copies the rgb values from the source in the current Color3
  79137. * @param source defines the source Color3 object
  79138. * @returns the updated Color3 object
  79139. */
  79140. copyFrom(source: DeepImmutable<Color3>): Color3;
  79141. /**
  79142. * Updates the Color3 rgb values from the given floats
  79143. * @param r defines the red component to read from
  79144. * @param g defines the green component to read from
  79145. * @param b defines the blue component to read from
  79146. * @returns the current Color3 object
  79147. */
  79148. copyFromFloats(r: number, g: number, b: number): Color3;
  79149. /**
  79150. * Updates the Color3 rgb values from the given floats
  79151. * @param r defines the red component to read from
  79152. * @param g defines the green component to read from
  79153. * @param b defines the blue component to read from
  79154. * @returns the current Color3 object
  79155. */
  79156. set(r: number, g: number, b: number): Color3;
  79157. /**
  79158. * Compute the Color3 hexadecimal code as a string
  79159. * @returns a string containing the hexadecimal representation of the Color3 object
  79160. */
  79161. toHexString(): string;
  79162. /**
  79163. * Computes a new Color3 converted from the current one to linear space
  79164. * @returns a new Color3 object
  79165. */
  79166. toLinearSpace(): Color3;
  79167. /**
  79168. * Converts current color in rgb space to HSV values
  79169. * @returns a new color3 representing the HSV values
  79170. */
  79171. toHSV(): Color3;
  79172. /**
  79173. * Converts current color in rgb space to HSV values
  79174. * @param result defines the Color3 where to store the HSV values
  79175. */
  79176. toHSVToRef(result: Color3): void;
  79177. /**
  79178. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79179. * @param convertedColor defines the Color3 object where to store the linear space version
  79180. * @returns the unmodified Color3
  79181. */
  79182. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79183. /**
  79184. * Computes a new Color3 converted from the current one to gamma space
  79185. * @returns a new Color3 object
  79186. */
  79187. toGammaSpace(): Color3;
  79188. /**
  79189. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79190. * @param convertedColor defines the Color3 object where to store the gamma space version
  79191. * @returns the unmodified Color3
  79192. */
  79193. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79194. private static _BlackReadOnly;
  79195. /**
  79196. * Convert Hue, saturation and value to a Color3 (RGB)
  79197. * @param hue defines the hue
  79198. * @param saturation defines the saturation
  79199. * @param value defines the value
  79200. * @param result defines the Color3 where to store the RGB values
  79201. */
  79202. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79203. /**
  79204. * Creates a new Color3 from the string containing valid hexadecimal values
  79205. * @param hex defines a string containing valid hexadecimal values
  79206. * @returns a new Color3 object
  79207. */
  79208. static FromHexString(hex: string): Color3;
  79209. /**
  79210. * Creates a new Color3 from the starting index of the given array
  79211. * @param array defines the source array
  79212. * @param offset defines an offset in the source array
  79213. * @returns a new Color3 object
  79214. */
  79215. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79216. /**
  79217. * Creates a new Color3 from integer values (< 256)
  79218. * @param r defines the red component to read from (value between 0 and 255)
  79219. * @param g defines the green component to read from (value between 0 and 255)
  79220. * @param b defines the blue component to read from (value between 0 and 255)
  79221. * @returns a new Color3 object
  79222. */
  79223. static FromInts(r: number, g: number, b: number): Color3;
  79224. /**
  79225. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79226. * @param start defines the start Color3 value
  79227. * @param end defines the end Color3 value
  79228. * @param amount defines the gradient value between start and end
  79229. * @returns a new Color3 object
  79230. */
  79231. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79232. /**
  79233. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79234. * @param left defines the start value
  79235. * @param right defines the end value
  79236. * @param amount defines the gradient factor
  79237. * @param result defines the Color3 object where to store the result
  79238. */
  79239. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79240. /**
  79241. * Returns a Color3 value containing a red color
  79242. * @returns a new Color3 object
  79243. */
  79244. static Red(): Color3;
  79245. /**
  79246. * Returns a Color3 value containing a green color
  79247. * @returns a new Color3 object
  79248. */
  79249. static Green(): Color3;
  79250. /**
  79251. * Returns a Color3 value containing a blue color
  79252. * @returns a new Color3 object
  79253. */
  79254. static Blue(): Color3;
  79255. /**
  79256. * Returns a Color3 value containing a black color
  79257. * @returns a new Color3 object
  79258. */
  79259. static Black(): Color3;
  79260. /**
  79261. * Gets a Color3 value containing a black color that must not be updated
  79262. */
  79263. static get BlackReadOnly(): DeepImmutable<Color3>;
  79264. /**
  79265. * Returns a Color3 value containing a white color
  79266. * @returns a new Color3 object
  79267. */
  79268. static White(): Color3;
  79269. /**
  79270. * Returns a Color3 value containing a purple color
  79271. * @returns a new Color3 object
  79272. */
  79273. static Purple(): Color3;
  79274. /**
  79275. * Returns a Color3 value containing a magenta color
  79276. * @returns a new Color3 object
  79277. */
  79278. static Magenta(): Color3;
  79279. /**
  79280. * Returns a Color3 value containing a yellow color
  79281. * @returns a new Color3 object
  79282. */
  79283. static Yellow(): Color3;
  79284. /**
  79285. * Returns a Color3 value containing a gray color
  79286. * @returns a new Color3 object
  79287. */
  79288. static Gray(): Color3;
  79289. /**
  79290. * Returns a Color3 value containing a teal color
  79291. * @returns a new Color3 object
  79292. */
  79293. static Teal(): Color3;
  79294. /**
  79295. * Returns a Color3 value containing a random color
  79296. * @returns a new Color3 object
  79297. */
  79298. static Random(): Color3;
  79299. }
  79300. /**
  79301. * Class used to hold a RBGA color
  79302. */
  79303. export class Color4 {
  79304. /**
  79305. * Defines the red component (between 0 and 1, default is 0)
  79306. */
  79307. r: number;
  79308. /**
  79309. * Defines the green component (between 0 and 1, default is 0)
  79310. */
  79311. g: number;
  79312. /**
  79313. * Defines the blue component (between 0 and 1, default is 0)
  79314. */
  79315. b: number;
  79316. /**
  79317. * Defines the alpha component (between 0 and 1, default is 1)
  79318. */
  79319. a: number;
  79320. /**
  79321. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79322. * @param r defines the red component (between 0 and 1, default is 0)
  79323. * @param g defines the green component (between 0 and 1, default is 0)
  79324. * @param b defines the blue component (between 0 and 1, default is 0)
  79325. * @param a defines the alpha component (between 0 and 1, default is 1)
  79326. */
  79327. constructor(
  79328. /**
  79329. * Defines the red component (between 0 and 1, default is 0)
  79330. */
  79331. r?: number,
  79332. /**
  79333. * Defines the green component (between 0 and 1, default is 0)
  79334. */
  79335. g?: number,
  79336. /**
  79337. * Defines the blue component (between 0 and 1, default is 0)
  79338. */
  79339. b?: number,
  79340. /**
  79341. * Defines the alpha component (between 0 and 1, default is 1)
  79342. */
  79343. a?: number);
  79344. /**
  79345. * Adds in place the given Color4 values to the current Color4 object
  79346. * @param right defines the second operand
  79347. * @returns the current updated Color4 object
  79348. */
  79349. addInPlace(right: DeepImmutable<Color4>): Color4;
  79350. /**
  79351. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79352. * @returns the new array
  79353. */
  79354. asArray(): number[];
  79355. /**
  79356. * Stores from the starting index in the given array the Color4 successive values
  79357. * @param array defines the array where to store the r,g,b components
  79358. * @param index defines an optional index in the target array to define where to start storing values
  79359. * @returns the current Color4 object
  79360. */
  79361. toArray(array: number[], index?: number): Color4;
  79362. /**
  79363. * Determines equality between Color4 objects
  79364. * @param otherColor defines the second operand
  79365. * @returns true if the rgba values are equal to the given ones
  79366. */
  79367. equals(otherColor: DeepImmutable<Color4>): boolean;
  79368. /**
  79369. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79370. * @param right defines the second operand
  79371. * @returns a new Color4 object
  79372. */
  79373. add(right: DeepImmutable<Color4>): Color4;
  79374. /**
  79375. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79376. * @param right defines the second operand
  79377. * @returns a new Color4 object
  79378. */
  79379. subtract(right: DeepImmutable<Color4>): Color4;
  79380. /**
  79381. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79382. * @param right defines the second operand
  79383. * @param result defines the Color4 object where to store the result
  79384. * @returns the current Color4 object
  79385. */
  79386. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79387. /**
  79388. * Creates a new Color4 with the current Color4 values multiplied by scale
  79389. * @param scale defines the scaling factor to apply
  79390. * @returns a new Color4 object
  79391. */
  79392. scale(scale: number): Color4;
  79393. /**
  79394. * Multiplies the current Color4 values by scale and stores the result in "result"
  79395. * @param scale defines the scaling factor to apply
  79396. * @param result defines the Color4 object where to store the result
  79397. * @returns the current unmodified Color4
  79398. */
  79399. scaleToRef(scale: number, result: Color4): Color4;
  79400. /**
  79401. * Scale the current Color4 values by a factor and add the result to a given Color4
  79402. * @param scale defines the scale factor
  79403. * @param result defines the Color4 object where to store the result
  79404. * @returns the unmodified current Color4
  79405. */
  79406. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79407. /**
  79408. * Clamps the rgb values by the min and max values and stores the result into "result"
  79409. * @param min defines minimum clamping value (default is 0)
  79410. * @param max defines maximum clamping value (default is 1)
  79411. * @param result defines color to store the result into.
  79412. * @returns the cuurent Color4
  79413. */
  79414. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79415. /**
  79416. * Multipy an Color4 value by another and return a new Color4 object
  79417. * @param color defines the Color4 value to multiply by
  79418. * @returns a new Color4 object
  79419. */
  79420. multiply(color: Color4): Color4;
  79421. /**
  79422. * Multipy a Color4 value by another and push the result in a reference value
  79423. * @param color defines the Color4 value to multiply by
  79424. * @param result defines the Color4 to fill the result in
  79425. * @returns the result Color4
  79426. */
  79427. multiplyToRef(color: Color4, result: Color4): Color4;
  79428. /**
  79429. * Creates a string with the Color4 current values
  79430. * @returns the string representation of the Color4 object
  79431. */
  79432. toString(): string;
  79433. /**
  79434. * Returns the string "Color4"
  79435. * @returns "Color4"
  79436. */
  79437. getClassName(): string;
  79438. /**
  79439. * Compute the Color4 hash code
  79440. * @returns an unique number that can be used to hash Color4 objects
  79441. */
  79442. getHashCode(): number;
  79443. /**
  79444. * Creates a new Color4 copied from the current one
  79445. * @returns a new Color4 object
  79446. */
  79447. clone(): Color4;
  79448. /**
  79449. * Copies the given Color4 values into the current one
  79450. * @param source defines the source Color4 object
  79451. * @returns the current updated Color4 object
  79452. */
  79453. copyFrom(source: Color4): Color4;
  79454. /**
  79455. * Copies the given float values into the current one
  79456. * @param r defines the red component to read from
  79457. * @param g defines the green component to read from
  79458. * @param b defines the blue component to read from
  79459. * @param a defines the alpha component to read from
  79460. * @returns the current updated Color4 object
  79461. */
  79462. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79463. /**
  79464. * Copies the given float values into the current one
  79465. * @param r defines the red component to read from
  79466. * @param g defines the green component to read from
  79467. * @param b defines the blue component to read from
  79468. * @param a defines the alpha component to read from
  79469. * @returns the current updated Color4 object
  79470. */
  79471. set(r: number, g: number, b: number, a: number): Color4;
  79472. /**
  79473. * Compute the Color4 hexadecimal code as a string
  79474. * @returns a string containing the hexadecimal representation of the Color4 object
  79475. */
  79476. toHexString(): string;
  79477. /**
  79478. * Computes a new Color4 converted from the current one to linear space
  79479. * @returns a new Color4 object
  79480. */
  79481. toLinearSpace(): Color4;
  79482. /**
  79483. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79484. * @param convertedColor defines the Color4 object where to store the linear space version
  79485. * @returns the unmodified Color4
  79486. */
  79487. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79488. /**
  79489. * Computes a new Color4 converted from the current one to gamma space
  79490. * @returns a new Color4 object
  79491. */
  79492. toGammaSpace(): Color4;
  79493. /**
  79494. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79495. * @param convertedColor defines the Color4 object where to store the gamma space version
  79496. * @returns the unmodified Color4
  79497. */
  79498. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79499. /**
  79500. * Creates a new Color4 from the string containing valid hexadecimal values
  79501. * @param hex defines a string containing valid hexadecimal values
  79502. * @returns a new Color4 object
  79503. */
  79504. static FromHexString(hex: string): Color4;
  79505. /**
  79506. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79507. * @param left defines the start value
  79508. * @param right defines the end value
  79509. * @param amount defines the gradient factor
  79510. * @returns a new Color4 object
  79511. */
  79512. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79513. /**
  79514. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79515. * @param left defines the start value
  79516. * @param right defines the end value
  79517. * @param amount defines the gradient factor
  79518. * @param result defines the Color4 object where to store data
  79519. */
  79520. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79521. /**
  79522. * Creates a new Color4 from a Color3 and an alpha value
  79523. * @param color3 defines the source Color3 to read from
  79524. * @param alpha defines the alpha component (1.0 by default)
  79525. * @returns a new Color4 object
  79526. */
  79527. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79528. /**
  79529. * Creates a new Color4 from the starting index element of the given array
  79530. * @param array defines the source array to read from
  79531. * @param offset defines the offset in the source array
  79532. * @returns a new Color4 object
  79533. */
  79534. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79535. /**
  79536. * Creates a new Color3 from integer values (< 256)
  79537. * @param r defines the red component to read from (value between 0 and 255)
  79538. * @param g defines the green component to read from (value between 0 and 255)
  79539. * @param b defines the blue component to read from (value between 0 and 255)
  79540. * @param a defines the alpha component to read from (value between 0 and 255)
  79541. * @returns a new Color3 object
  79542. */
  79543. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79544. /**
  79545. * Check the content of a given array and convert it to an array containing RGBA data
  79546. * If the original array was already containing count * 4 values then it is returned directly
  79547. * @param colors defines the array to check
  79548. * @param count defines the number of RGBA data to expect
  79549. * @returns an array containing count * 4 values (RGBA)
  79550. */
  79551. static CheckColors4(colors: number[], count: number): number[];
  79552. }
  79553. /**
  79554. * @hidden
  79555. */
  79556. export class TmpColors {
  79557. static Color3: Color3[];
  79558. static Color4: Color4[];
  79559. }
  79560. }
  79561. declare module BABYLON {
  79562. /**
  79563. * Defines an interface which represents an animation key frame
  79564. */
  79565. export interface IAnimationKey {
  79566. /**
  79567. * Frame of the key frame
  79568. */
  79569. frame: number;
  79570. /**
  79571. * Value at the specifies key frame
  79572. */
  79573. value: any;
  79574. /**
  79575. * The input tangent for the cubic hermite spline
  79576. */
  79577. inTangent?: any;
  79578. /**
  79579. * The output tangent for the cubic hermite spline
  79580. */
  79581. outTangent?: any;
  79582. /**
  79583. * The animation interpolation type
  79584. */
  79585. interpolation?: AnimationKeyInterpolation;
  79586. }
  79587. /**
  79588. * Enum for the animation key frame interpolation type
  79589. */
  79590. export enum AnimationKeyInterpolation {
  79591. /**
  79592. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79593. */
  79594. STEP = 1
  79595. }
  79596. }
  79597. declare module BABYLON {
  79598. /**
  79599. * Represents the range of an animation
  79600. */
  79601. export class AnimationRange {
  79602. /**The name of the animation range**/
  79603. name: string;
  79604. /**The starting frame of the animation */
  79605. from: number;
  79606. /**The ending frame of the animation*/
  79607. to: number;
  79608. /**
  79609. * Initializes the range of an animation
  79610. * @param name The name of the animation range
  79611. * @param from The starting frame of the animation
  79612. * @param to The ending frame of the animation
  79613. */
  79614. constructor(
  79615. /**The name of the animation range**/
  79616. name: string,
  79617. /**The starting frame of the animation */
  79618. from: number,
  79619. /**The ending frame of the animation*/
  79620. to: number);
  79621. /**
  79622. * Makes a copy of the animation range
  79623. * @returns A copy of the animation range
  79624. */
  79625. clone(): AnimationRange;
  79626. }
  79627. }
  79628. declare module BABYLON {
  79629. /**
  79630. * Composed of a frame, and an action function
  79631. */
  79632. export class AnimationEvent {
  79633. /** The frame for which the event is triggered **/
  79634. frame: number;
  79635. /** The event to perform when triggered **/
  79636. action: (currentFrame: number) => void;
  79637. /** Specifies if the event should be triggered only once**/
  79638. onlyOnce?: boolean | undefined;
  79639. /**
  79640. * Specifies if the animation event is done
  79641. */
  79642. isDone: boolean;
  79643. /**
  79644. * Initializes the animation event
  79645. * @param frame The frame for which the event is triggered
  79646. * @param action The event to perform when triggered
  79647. * @param onlyOnce Specifies if the event should be triggered only once
  79648. */
  79649. constructor(
  79650. /** The frame for which the event is triggered **/
  79651. frame: number,
  79652. /** The event to perform when triggered **/
  79653. action: (currentFrame: number) => void,
  79654. /** Specifies if the event should be triggered only once**/
  79655. onlyOnce?: boolean | undefined);
  79656. /** @hidden */
  79657. _clone(): AnimationEvent;
  79658. }
  79659. }
  79660. declare module BABYLON {
  79661. /**
  79662. * Interface used to define a behavior
  79663. */
  79664. export interface Behavior<T> {
  79665. /** gets or sets behavior's name */
  79666. name: string;
  79667. /**
  79668. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79669. */
  79670. init(): void;
  79671. /**
  79672. * Called when the behavior is attached to a target
  79673. * @param target defines the target where the behavior is attached to
  79674. */
  79675. attach(target: T): void;
  79676. /**
  79677. * Called when the behavior is detached from its target
  79678. */
  79679. detach(): void;
  79680. }
  79681. /**
  79682. * Interface implemented by classes supporting behaviors
  79683. */
  79684. export interface IBehaviorAware<T> {
  79685. /**
  79686. * Attach a behavior
  79687. * @param behavior defines the behavior to attach
  79688. * @returns the current host
  79689. */
  79690. addBehavior(behavior: Behavior<T>): T;
  79691. /**
  79692. * Remove a behavior from the current object
  79693. * @param behavior defines the behavior to detach
  79694. * @returns the current host
  79695. */
  79696. removeBehavior(behavior: Behavior<T>): T;
  79697. /**
  79698. * Gets a behavior using its name to search
  79699. * @param name defines the name to search
  79700. * @returns the behavior or null if not found
  79701. */
  79702. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79703. }
  79704. }
  79705. declare module BABYLON {
  79706. /**
  79707. * Defines an array and its length.
  79708. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79709. */
  79710. export interface ISmartArrayLike<T> {
  79711. /**
  79712. * The data of the array.
  79713. */
  79714. data: Array<T>;
  79715. /**
  79716. * The active length of the array.
  79717. */
  79718. length: number;
  79719. }
  79720. /**
  79721. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79722. */
  79723. export class SmartArray<T> implements ISmartArrayLike<T> {
  79724. /**
  79725. * The full set of data from the array.
  79726. */
  79727. data: Array<T>;
  79728. /**
  79729. * The active length of the array.
  79730. */
  79731. length: number;
  79732. protected _id: number;
  79733. /**
  79734. * Instantiates a Smart Array.
  79735. * @param capacity defines the default capacity of the array.
  79736. */
  79737. constructor(capacity: number);
  79738. /**
  79739. * Pushes a value at the end of the active data.
  79740. * @param value defines the object to push in the array.
  79741. */
  79742. push(value: T): void;
  79743. /**
  79744. * Iterates over the active data and apply the lambda to them.
  79745. * @param func defines the action to apply on each value.
  79746. */
  79747. forEach(func: (content: T) => void): void;
  79748. /**
  79749. * Sorts the full sets of data.
  79750. * @param compareFn defines the comparison function to apply.
  79751. */
  79752. sort(compareFn: (a: T, b: T) => number): void;
  79753. /**
  79754. * Resets the active data to an empty array.
  79755. */
  79756. reset(): void;
  79757. /**
  79758. * Releases all the data from the array as well as the array.
  79759. */
  79760. dispose(): void;
  79761. /**
  79762. * Concats the active data with a given array.
  79763. * @param array defines the data to concatenate with.
  79764. */
  79765. concat(array: any): void;
  79766. /**
  79767. * Returns the position of a value in the active data.
  79768. * @param value defines the value to find the index for
  79769. * @returns the index if found in the active data otherwise -1
  79770. */
  79771. indexOf(value: T): number;
  79772. /**
  79773. * Returns whether an element is part of the active data.
  79774. * @param value defines the value to look for
  79775. * @returns true if found in the active data otherwise false
  79776. */
  79777. contains(value: T): boolean;
  79778. private static _GlobalId;
  79779. }
  79780. /**
  79781. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79782. * The data in this array can only be present once
  79783. */
  79784. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79785. private _duplicateId;
  79786. /**
  79787. * Pushes a value at the end of the active data.
  79788. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79789. * @param value defines the object to push in the array.
  79790. */
  79791. push(value: T): void;
  79792. /**
  79793. * Pushes a value at the end of the active data.
  79794. * If the data is already present, it won t be added again
  79795. * @param value defines the object to push in the array.
  79796. * @returns true if added false if it was already present
  79797. */
  79798. pushNoDuplicate(value: T): boolean;
  79799. /**
  79800. * Resets the active data to an empty array.
  79801. */
  79802. reset(): void;
  79803. /**
  79804. * Concats the active data with a given array.
  79805. * This ensures no dupplicate will be present in the result.
  79806. * @param array defines the data to concatenate with.
  79807. */
  79808. concatWithNoDuplicate(array: any): void;
  79809. }
  79810. }
  79811. declare module BABYLON {
  79812. /**
  79813. * @ignore
  79814. * This is a list of all the different input types that are available in the application.
  79815. * Fo instance: ArcRotateCameraGamepadInput...
  79816. */
  79817. export var CameraInputTypes: {};
  79818. /**
  79819. * This is the contract to implement in order to create a new input class.
  79820. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79821. */
  79822. export interface ICameraInput<TCamera extends Camera> {
  79823. /**
  79824. * Defines the camera the input is attached to.
  79825. */
  79826. camera: Nullable<TCamera>;
  79827. /**
  79828. * Gets the class name of the current intput.
  79829. * @returns the class name
  79830. */
  79831. getClassName(): string;
  79832. /**
  79833. * Get the friendly name associated with the input class.
  79834. * @returns the input friendly name
  79835. */
  79836. getSimpleName(): string;
  79837. /**
  79838. * Attach the input controls to a specific dom element to get the input from.
  79839. * @param element Defines the element the controls should be listened from
  79840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79841. */
  79842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79843. /**
  79844. * Detach the current controls from the specified dom element.
  79845. * @param element Defines the element to stop listening the inputs from
  79846. */
  79847. detachControl(element: Nullable<HTMLElement>): void;
  79848. /**
  79849. * Update the current camera state depending on the inputs that have been used this frame.
  79850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79851. */
  79852. checkInputs?: () => void;
  79853. }
  79854. /**
  79855. * Represents a map of input types to input instance or input index to input instance.
  79856. */
  79857. export interface CameraInputsMap<TCamera extends Camera> {
  79858. /**
  79859. * Accessor to the input by input type.
  79860. */
  79861. [name: string]: ICameraInput<TCamera>;
  79862. /**
  79863. * Accessor to the input by input index.
  79864. */
  79865. [idx: number]: ICameraInput<TCamera>;
  79866. }
  79867. /**
  79868. * This represents the input manager used within a camera.
  79869. * It helps dealing with all the different kind of input attached to a camera.
  79870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79871. */
  79872. export class CameraInputsManager<TCamera extends Camera> {
  79873. /**
  79874. * Defines the list of inputs attahed to the camera.
  79875. */
  79876. attached: CameraInputsMap<TCamera>;
  79877. /**
  79878. * Defines the dom element the camera is collecting inputs from.
  79879. * This is null if the controls have not been attached.
  79880. */
  79881. attachedElement: Nullable<HTMLElement>;
  79882. /**
  79883. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79884. */
  79885. noPreventDefault: boolean;
  79886. /**
  79887. * Defined the camera the input manager belongs to.
  79888. */
  79889. camera: TCamera;
  79890. /**
  79891. * Update the current camera state depending on the inputs that have been used this frame.
  79892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79893. */
  79894. checkInputs: () => void;
  79895. /**
  79896. * Instantiate a new Camera Input Manager.
  79897. * @param camera Defines the camera the input manager blongs to
  79898. */
  79899. constructor(camera: TCamera);
  79900. /**
  79901. * Add an input method to a camera
  79902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79903. * @param input camera input method
  79904. */
  79905. add(input: ICameraInput<TCamera>): void;
  79906. /**
  79907. * Remove a specific input method from a camera
  79908. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79909. * @param inputToRemove camera input method
  79910. */
  79911. remove(inputToRemove: ICameraInput<TCamera>): void;
  79912. /**
  79913. * Remove a specific input type from a camera
  79914. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79915. * @param inputType the type of the input to remove
  79916. */
  79917. removeByType(inputType: string): void;
  79918. private _addCheckInputs;
  79919. /**
  79920. * Attach the input controls to the currently attached dom element to listen the events from.
  79921. * @param input Defines the input to attach
  79922. */
  79923. attachInput(input: ICameraInput<TCamera>): void;
  79924. /**
  79925. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79926. * @param element Defines the dom element to collect the events from
  79927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79928. */
  79929. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79930. /**
  79931. * Detach the current manager inputs controls from a specific dom element.
  79932. * @param element Defines the dom element to collect the events from
  79933. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79934. */
  79935. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79936. /**
  79937. * Rebuild the dynamic inputCheck function from the current list of
  79938. * defined inputs in the manager.
  79939. */
  79940. rebuildInputCheck(): void;
  79941. /**
  79942. * Remove all attached input methods from a camera
  79943. */
  79944. clear(): void;
  79945. /**
  79946. * Serialize the current input manager attached to a camera.
  79947. * This ensures than once parsed,
  79948. * the input associated to the camera will be identical to the current ones
  79949. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79950. */
  79951. serialize(serializedCamera: any): void;
  79952. /**
  79953. * Parses an input manager serialized JSON to restore the previous list of inputs
  79954. * and states associated to a camera.
  79955. * @param parsedCamera Defines the JSON to parse
  79956. */
  79957. parse(parsedCamera: any): void;
  79958. }
  79959. }
  79960. declare module BABYLON {
  79961. /**
  79962. * Class used to store data that will be store in GPU memory
  79963. */
  79964. export class Buffer {
  79965. private _engine;
  79966. private _buffer;
  79967. /** @hidden */
  79968. _data: Nullable<DataArray>;
  79969. private _updatable;
  79970. private _instanced;
  79971. private _divisor;
  79972. /**
  79973. * Gets the byte stride.
  79974. */
  79975. readonly byteStride: number;
  79976. /**
  79977. * Constructor
  79978. * @param engine the engine
  79979. * @param data the data to use for this buffer
  79980. * @param updatable whether the data is updatable
  79981. * @param stride the stride (optional)
  79982. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79983. * @param instanced whether the buffer is instanced (optional)
  79984. * @param useBytes set to true if the stride in in bytes (optional)
  79985. * @param divisor sets an optional divisor for instances (1 by default)
  79986. */
  79987. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79988. /**
  79989. * Create a new VertexBuffer based on the current buffer
  79990. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79991. * @param offset defines offset in the buffer (0 by default)
  79992. * @param size defines the size in floats of attributes (position is 3 for instance)
  79993. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79994. * @param instanced defines if the vertex buffer contains indexed data
  79995. * @param useBytes defines if the offset and stride are in bytes *
  79996. * @param divisor sets an optional divisor for instances (1 by default)
  79997. * @returns the new vertex buffer
  79998. */
  79999. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80000. /**
  80001. * Gets a boolean indicating if the Buffer is updatable?
  80002. * @returns true if the buffer is updatable
  80003. */
  80004. isUpdatable(): boolean;
  80005. /**
  80006. * Gets current buffer's data
  80007. * @returns a DataArray or null
  80008. */
  80009. getData(): Nullable<DataArray>;
  80010. /**
  80011. * Gets underlying native buffer
  80012. * @returns underlying native buffer
  80013. */
  80014. getBuffer(): Nullable<DataBuffer>;
  80015. /**
  80016. * Gets the stride in float32 units (i.e. byte stride / 4).
  80017. * May not be an integer if the byte stride is not divisible by 4.
  80018. * @returns the stride in float32 units
  80019. * @deprecated Please use byteStride instead.
  80020. */
  80021. getStrideSize(): number;
  80022. /**
  80023. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80024. * @param data defines the data to store
  80025. */
  80026. create(data?: Nullable<DataArray>): void;
  80027. /** @hidden */
  80028. _rebuild(): void;
  80029. /**
  80030. * Update current buffer data
  80031. * @param data defines the data to store
  80032. */
  80033. update(data: DataArray): void;
  80034. /**
  80035. * Updates the data directly.
  80036. * @param data the new data
  80037. * @param offset the new offset
  80038. * @param vertexCount the vertex count (optional)
  80039. * @param useBytes set to true if the offset is in bytes
  80040. */
  80041. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80042. /**
  80043. * Release all resources
  80044. */
  80045. dispose(): void;
  80046. }
  80047. /**
  80048. * Specialized buffer used to store vertex data
  80049. */
  80050. export class VertexBuffer {
  80051. /** @hidden */
  80052. _buffer: Buffer;
  80053. private _kind;
  80054. private _size;
  80055. private _ownsBuffer;
  80056. private _instanced;
  80057. private _instanceDivisor;
  80058. /**
  80059. * The byte type.
  80060. */
  80061. static readonly BYTE: number;
  80062. /**
  80063. * The unsigned byte type.
  80064. */
  80065. static readonly UNSIGNED_BYTE: number;
  80066. /**
  80067. * The short type.
  80068. */
  80069. static readonly SHORT: number;
  80070. /**
  80071. * The unsigned short type.
  80072. */
  80073. static readonly UNSIGNED_SHORT: number;
  80074. /**
  80075. * The integer type.
  80076. */
  80077. static readonly INT: number;
  80078. /**
  80079. * The unsigned integer type.
  80080. */
  80081. static readonly UNSIGNED_INT: number;
  80082. /**
  80083. * The float type.
  80084. */
  80085. static readonly FLOAT: number;
  80086. /**
  80087. * Gets or sets the instance divisor when in instanced mode
  80088. */
  80089. get instanceDivisor(): number;
  80090. set instanceDivisor(value: number);
  80091. /**
  80092. * Gets the byte stride.
  80093. */
  80094. readonly byteStride: number;
  80095. /**
  80096. * Gets the byte offset.
  80097. */
  80098. readonly byteOffset: number;
  80099. /**
  80100. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80101. */
  80102. readonly normalized: boolean;
  80103. /**
  80104. * Gets the data type of each component in the array.
  80105. */
  80106. readonly type: number;
  80107. /**
  80108. * Constructor
  80109. * @param engine the engine
  80110. * @param data the data to use for this vertex buffer
  80111. * @param kind the vertex buffer kind
  80112. * @param updatable whether the data is updatable
  80113. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80114. * @param stride the stride (optional)
  80115. * @param instanced whether the buffer is instanced (optional)
  80116. * @param offset the offset of the data (optional)
  80117. * @param size the number of components (optional)
  80118. * @param type the type of the component (optional)
  80119. * @param normalized whether the data contains normalized data (optional)
  80120. * @param useBytes set to true if stride and offset are in bytes (optional)
  80121. * @param divisor defines the instance divisor to use (1 by default)
  80122. */
  80123. 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);
  80124. /** @hidden */
  80125. _rebuild(): void;
  80126. /**
  80127. * Returns the kind of the VertexBuffer (string)
  80128. * @returns a string
  80129. */
  80130. getKind(): string;
  80131. /**
  80132. * Gets a boolean indicating if the VertexBuffer is updatable?
  80133. * @returns true if the buffer is updatable
  80134. */
  80135. isUpdatable(): boolean;
  80136. /**
  80137. * Gets current buffer's data
  80138. * @returns a DataArray or null
  80139. */
  80140. getData(): Nullable<DataArray>;
  80141. /**
  80142. * Gets underlying native buffer
  80143. * @returns underlying native buffer
  80144. */
  80145. getBuffer(): Nullable<DataBuffer>;
  80146. /**
  80147. * Gets the stride in float32 units (i.e. byte stride / 4).
  80148. * May not be an integer if the byte stride is not divisible by 4.
  80149. * @returns the stride in float32 units
  80150. * @deprecated Please use byteStride instead.
  80151. */
  80152. getStrideSize(): number;
  80153. /**
  80154. * Returns the offset as a multiple of the type byte length.
  80155. * @returns the offset in bytes
  80156. * @deprecated Please use byteOffset instead.
  80157. */
  80158. getOffset(): number;
  80159. /**
  80160. * Returns the number of components per vertex attribute (integer)
  80161. * @returns the size in float
  80162. */
  80163. getSize(): number;
  80164. /**
  80165. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80166. * @returns true if this buffer is instanced
  80167. */
  80168. getIsInstanced(): boolean;
  80169. /**
  80170. * Returns the instancing divisor, zero for non-instanced (integer).
  80171. * @returns a number
  80172. */
  80173. getInstanceDivisor(): number;
  80174. /**
  80175. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80176. * @param data defines the data to store
  80177. */
  80178. create(data?: DataArray): void;
  80179. /**
  80180. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80181. * This function will create a new buffer if the current one is not updatable
  80182. * @param data defines the data to store
  80183. */
  80184. update(data: DataArray): void;
  80185. /**
  80186. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80187. * Returns the directly updated WebGLBuffer.
  80188. * @param data the new data
  80189. * @param offset the new offset
  80190. * @param useBytes set to true if the offset is in bytes
  80191. */
  80192. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80193. /**
  80194. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80195. */
  80196. dispose(): void;
  80197. /**
  80198. * Enumerates each value of this vertex buffer as numbers.
  80199. * @param count the number of values to enumerate
  80200. * @param callback the callback function called for each value
  80201. */
  80202. forEach(count: number, callback: (value: number, index: number) => void): void;
  80203. /**
  80204. * Positions
  80205. */
  80206. static readonly PositionKind: string;
  80207. /**
  80208. * Normals
  80209. */
  80210. static readonly NormalKind: string;
  80211. /**
  80212. * Tangents
  80213. */
  80214. static readonly TangentKind: string;
  80215. /**
  80216. * Texture coordinates
  80217. */
  80218. static readonly UVKind: string;
  80219. /**
  80220. * Texture coordinates 2
  80221. */
  80222. static readonly UV2Kind: string;
  80223. /**
  80224. * Texture coordinates 3
  80225. */
  80226. static readonly UV3Kind: string;
  80227. /**
  80228. * Texture coordinates 4
  80229. */
  80230. static readonly UV4Kind: string;
  80231. /**
  80232. * Texture coordinates 5
  80233. */
  80234. static readonly UV5Kind: string;
  80235. /**
  80236. * Texture coordinates 6
  80237. */
  80238. static readonly UV6Kind: string;
  80239. /**
  80240. * Colors
  80241. */
  80242. static readonly ColorKind: string;
  80243. /**
  80244. * Matrix indices (for bones)
  80245. */
  80246. static readonly MatricesIndicesKind: string;
  80247. /**
  80248. * Matrix weights (for bones)
  80249. */
  80250. static readonly MatricesWeightsKind: string;
  80251. /**
  80252. * Additional matrix indices (for bones)
  80253. */
  80254. static readonly MatricesIndicesExtraKind: string;
  80255. /**
  80256. * Additional matrix weights (for bones)
  80257. */
  80258. static readonly MatricesWeightsExtraKind: string;
  80259. /**
  80260. * Deduces the stride given a kind.
  80261. * @param kind The kind string to deduce
  80262. * @returns The deduced stride
  80263. */
  80264. static DeduceStride(kind: string): number;
  80265. /**
  80266. * Gets the byte length of the given type.
  80267. * @param type the type
  80268. * @returns the number of bytes
  80269. */
  80270. static GetTypeByteLength(type: number): number;
  80271. /**
  80272. * Enumerates each value of the given parameters as numbers.
  80273. * @param data the data to enumerate
  80274. * @param byteOffset the byte offset of the data
  80275. * @param byteStride the byte stride of the data
  80276. * @param componentCount the number of components per element
  80277. * @param componentType the type of the component
  80278. * @param count the number of values to enumerate
  80279. * @param normalized whether the data is normalized
  80280. * @param callback the callback function called for each value
  80281. */
  80282. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80283. private static _GetFloatValue;
  80284. }
  80285. }
  80286. declare module BABYLON {
  80287. /**
  80288. * @hidden
  80289. */
  80290. export class IntersectionInfo {
  80291. bu: Nullable<number>;
  80292. bv: Nullable<number>;
  80293. distance: number;
  80294. faceId: number;
  80295. subMeshId: number;
  80296. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80297. }
  80298. }
  80299. declare module BABYLON {
  80300. /**
  80301. * Represens a plane by the equation ax + by + cz + d = 0
  80302. */
  80303. export class Plane {
  80304. private static _TmpMatrix;
  80305. /**
  80306. * Normal of the plane (a,b,c)
  80307. */
  80308. normal: Vector3;
  80309. /**
  80310. * d component of the plane
  80311. */
  80312. d: number;
  80313. /**
  80314. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80315. * @param a a component of the plane
  80316. * @param b b component of the plane
  80317. * @param c c component of the plane
  80318. * @param d d component of the plane
  80319. */
  80320. constructor(a: number, b: number, c: number, d: number);
  80321. /**
  80322. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80323. */
  80324. asArray(): number[];
  80325. /**
  80326. * @returns a new plane copied from the current Plane.
  80327. */
  80328. clone(): Plane;
  80329. /**
  80330. * @returns the string "Plane".
  80331. */
  80332. getClassName(): string;
  80333. /**
  80334. * @returns the Plane hash code.
  80335. */
  80336. getHashCode(): number;
  80337. /**
  80338. * Normalize the current Plane in place.
  80339. * @returns the updated Plane.
  80340. */
  80341. normalize(): Plane;
  80342. /**
  80343. * Applies a transformation the plane and returns the result
  80344. * @param transformation the transformation matrix to be applied to the plane
  80345. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80346. */
  80347. transform(transformation: DeepImmutable<Matrix>): Plane;
  80348. /**
  80349. * Calcualtte the dot product between the point and the plane normal
  80350. * @param point point to calculate the dot product with
  80351. * @returns the dot product (float) of the point coordinates and the plane normal.
  80352. */
  80353. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80354. /**
  80355. * Updates the current Plane from the plane defined by the three given points.
  80356. * @param point1 one of the points used to contruct the plane
  80357. * @param point2 one of the points used to contruct the plane
  80358. * @param point3 one of the points used to contruct the plane
  80359. * @returns the updated Plane.
  80360. */
  80361. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80362. /**
  80363. * Checks if the plane is facing a given direction
  80364. * @param direction the direction to check if the plane is facing
  80365. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80366. * @returns True is the vector "direction" is the same side than the plane normal.
  80367. */
  80368. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80369. /**
  80370. * Calculates the distance to a point
  80371. * @param point point to calculate distance to
  80372. * @returns the signed distance (float) from the given point to the Plane.
  80373. */
  80374. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80375. /**
  80376. * Creates a plane from an array
  80377. * @param array the array to create a plane from
  80378. * @returns a new Plane from the given array.
  80379. */
  80380. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80381. /**
  80382. * Creates a plane from three points
  80383. * @param point1 point used to create the plane
  80384. * @param point2 point used to create the plane
  80385. * @param point3 point used to create the plane
  80386. * @returns a new Plane defined by the three given points.
  80387. */
  80388. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80389. /**
  80390. * Creates a plane from an origin point and a normal
  80391. * @param origin origin of the plane to be constructed
  80392. * @param normal normal of the plane to be constructed
  80393. * @returns a new Plane the normal vector to this plane at the given origin point.
  80394. * Note : the vector "normal" is updated because normalized.
  80395. */
  80396. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80397. /**
  80398. * Calculates the distance from a plane and a point
  80399. * @param origin origin of the plane to be constructed
  80400. * @param normal normal of the plane to be constructed
  80401. * @param point point to calculate distance to
  80402. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80403. */
  80404. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80405. }
  80406. }
  80407. declare module BABYLON {
  80408. /**
  80409. * Class used to store bounding sphere information
  80410. */
  80411. export class BoundingSphere {
  80412. /**
  80413. * Gets the center of the bounding sphere in local space
  80414. */
  80415. readonly center: Vector3;
  80416. /**
  80417. * Radius of the bounding sphere in local space
  80418. */
  80419. radius: number;
  80420. /**
  80421. * Gets the center of the bounding sphere in world space
  80422. */
  80423. readonly centerWorld: Vector3;
  80424. /**
  80425. * Radius of the bounding sphere in world space
  80426. */
  80427. radiusWorld: number;
  80428. /**
  80429. * Gets the minimum vector in local space
  80430. */
  80431. readonly minimum: Vector3;
  80432. /**
  80433. * Gets the maximum vector in local space
  80434. */
  80435. readonly maximum: Vector3;
  80436. private _worldMatrix;
  80437. private static readonly TmpVector3;
  80438. /**
  80439. * Creates a new bounding sphere
  80440. * @param min defines the minimum vector (in local space)
  80441. * @param max defines the maximum vector (in local space)
  80442. * @param worldMatrix defines the new world matrix
  80443. */
  80444. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80445. /**
  80446. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80447. * @param min defines the new minimum vector (in local space)
  80448. * @param max defines the new maximum vector (in local space)
  80449. * @param worldMatrix defines the new world matrix
  80450. */
  80451. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80452. /**
  80453. * Scale the current bounding sphere by applying a scale factor
  80454. * @param factor defines the scale factor to apply
  80455. * @returns the current bounding box
  80456. */
  80457. scale(factor: number): BoundingSphere;
  80458. /**
  80459. * Gets the world matrix of the bounding box
  80460. * @returns a matrix
  80461. */
  80462. getWorldMatrix(): DeepImmutable<Matrix>;
  80463. /** @hidden */
  80464. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80465. /**
  80466. * Tests if the bounding sphere is intersecting the frustum planes
  80467. * @param frustumPlanes defines the frustum planes to test
  80468. * @returns true if there is an intersection
  80469. */
  80470. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80471. /**
  80472. * Tests if the bounding sphere center is in between the frustum planes.
  80473. * Used for optimistic fast inclusion.
  80474. * @param frustumPlanes defines the frustum planes to test
  80475. * @returns true if the sphere center is in between the frustum planes
  80476. */
  80477. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80478. /**
  80479. * Tests if a point is inside the bounding sphere
  80480. * @param point defines the point to test
  80481. * @returns true if the point is inside the bounding sphere
  80482. */
  80483. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80484. /**
  80485. * Checks if two sphere intersct
  80486. * @param sphere0 sphere 0
  80487. * @param sphere1 sphere 1
  80488. * @returns true if the speres intersect
  80489. */
  80490. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80491. }
  80492. }
  80493. declare module BABYLON {
  80494. /**
  80495. * Class used to store bounding box information
  80496. */
  80497. export class BoundingBox implements ICullable {
  80498. /**
  80499. * Gets the 8 vectors representing the bounding box in local space
  80500. */
  80501. readonly vectors: Vector3[];
  80502. /**
  80503. * Gets the center of the bounding box in local space
  80504. */
  80505. readonly center: Vector3;
  80506. /**
  80507. * Gets the center of the bounding box in world space
  80508. */
  80509. readonly centerWorld: Vector3;
  80510. /**
  80511. * Gets the extend size in local space
  80512. */
  80513. readonly extendSize: Vector3;
  80514. /**
  80515. * Gets the extend size in world space
  80516. */
  80517. readonly extendSizeWorld: Vector3;
  80518. /**
  80519. * Gets the OBB (object bounding box) directions
  80520. */
  80521. readonly directions: Vector3[];
  80522. /**
  80523. * Gets the 8 vectors representing the bounding box in world space
  80524. */
  80525. readonly vectorsWorld: Vector3[];
  80526. /**
  80527. * Gets the minimum vector in world space
  80528. */
  80529. readonly minimumWorld: Vector3;
  80530. /**
  80531. * Gets the maximum vector in world space
  80532. */
  80533. readonly maximumWorld: Vector3;
  80534. /**
  80535. * Gets the minimum vector in local space
  80536. */
  80537. readonly minimum: Vector3;
  80538. /**
  80539. * Gets the maximum vector in local space
  80540. */
  80541. readonly maximum: Vector3;
  80542. private _worldMatrix;
  80543. private static readonly TmpVector3;
  80544. /**
  80545. * @hidden
  80546. */
  80547. _tag: number;
  80548. /**
  80549. * Creates a new bounding box
  80550. * @param min defines the minimum vector (in local space)
  80551. * @param max defines the maximum vector (in local space)
  80552. * @param worldMatrix defines the new world matrix
  80553. */
  80554. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80555. /**
  80556. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80557. * @param min defines the new minimum vector (in local space)
  80558. * @param max defines the new maximum vector (in local space)
  80559. * @param worldMatrix defines the new world matrix
  80560. */
  80561. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80562. /**
  80563. * Scale the current bounding box by applying a scale factor
  80564. * @param factor defines the scale factor to apply
  80565. * @returns the current bounding box
  80566. */
  80567. scale(factor: number): BoundingBox;
  80568. /**
  80569. * Gets the world matrix of the bounding box
  80570. * @returns a matrix
  80571. */
  80572. getWorldMatrix(): DeepImmutable<Matrix>;
  80573. /** @hidden */
  80574. _update(world: DeepImmutable<Matrix>): void;
  80575. /**
  80576. * Tests if the bounding box is intersecting the frustum planes
  80577. * @param frustumPlanes defines the frustum planes to test
  80578. * @returns true if there is an intersection
  80579. */
  80580. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80581. /**
  80582. * Tests if the bounding box is entirely inside the frustum planes
  80583. * @param frustumPlanes defines the frustum planes to test
  80584. * @returns true if there is an inclusion
  80585. */
  80586. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80587. /**
  80588. * Tests if a point is inside the bounding box
  80589. * @param point defines the point to test
  80590. * @returns true if the point is inside the bounding box
  80591. */
  80592. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80593. /**
  80594. * Tests if the bounding box intersects with a bounding sphere
  80595. * @param sphere defines the sphere to test
  80596. * @returns true if there is an intersection
  80597. */
  80598. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80599. /**
  80600. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80601. * @param min defines the min vector to use
  80602. * @param max defines the max vector to use
  80603. * @returns true if there is an intersection
  80604. */
  80605. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80606. /**
  80607. * Tests if two bounding boxes are intersections
  80608. * @param box0 defines the first box to test
  80609. * @param box1 defines the second box to test
  80610. * @returns true if there is an intersection
  80611. */
  80612. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80613. /**
  80614. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80615. * @param minPoint defines the minimum vector of the bounding box
  80616. * @param maxPoint defines the maximum vector of the bounding box
  80617. * @param sphereCenter defines the sphere center
  80618. * @param sphereRadius defines the sphere radius
  80619. * @returns true if there is an intersection
  80620. */
  80621. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80622. /**
  80623. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80624. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80625. * @param frustumPlanes defines the frustum planes to test
  80626. * @return true if there is an inclusion
  80627. */
  80628. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80629. /**
  80630. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80631. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80632. * @param frustumPlanes defines the frustum planes to test
  80633. * @return true if there is an intersection
  80634. */
  80635. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80636. }
  80637. }
  80638. declare module BABYLON {
  80639. /** @hidden */
  80640. export class Collider {
  80641. /** Define if a collision was found */
  80642. collisionFound: boolean;
  80643. /**
  80644. * Define last intersection point in local space
  80645. */
  80646. intersectionPoint: Vector3;
  80647. /**
  80648. * Define last collided mesh
  80649. */
  80650. collidedMesh: Nullable<AbstractMesh>;
  80651. private _collisionPoint;
  80652. private _planeIntersectionPoint;
  80653. private _tempVector;
  80654. private _tempVector2;
  80655. private _tempVector3;
  80656. private _tempVector4;
  80657. private _edge;
  80658. private _baseToVertex;
  80659. private _destinationPoint;
  80660. private _slidePlaneNormal;
  80661. private _displacementVector;
  80662. /** @hidden */
  80663. _radius: Vector3;
  80664. /** @hidden */
  80665. _retry: number;
  80666. private _velocity;
  80667. private _basePoint;
  80668. private _epsilon;
  80669. /** @hidden */
  80670. _velocityWorldLength: number;
  80671. /** @hidden */
  80672. _basePointWorld: Vector3;
  80673. private _velocityWorld;
  80674. private _normalizedVelocity;
  80675. /** @hidden */
  80676. _initialVelocity: Vector3;
  80677. /** @hidden */
  80678. _initialPosition: Vector3;
  80679. private _nearestDistance;
  80680. private _collisionMask;
  80681. get collisionMask(): number;
  80682. set collisionMask(mask: number);
  80683. /**
  80684. * Gets the plane normal used to compute the sliding response (in local space)
  80685. */
  80686. get slidePlaneNormal(): Vector3;
  80687. /** @hidden */
  80688. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80689. /** @hidden */
  80690. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80691. /** @hidden */
  80692. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80693. /** @hidden */
  80694. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80695. /** @hidden */
  80696. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80697. /** @hidden */
  80698. _getResponse(pos: Vector3, vel: Vector3): void;
  80699. }
  80700. }
  80701. declare module BABYLON {
  80702. /**
  80703. * Interface for cullable objects
  80704. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80705. */
  80706. export interface ICullable {
  80707. /**
  80708. * Checks if the object or part of the object is in the frustum
  80709. * @param frustumPlanes Camera near/planes
  80710. * @returns true if the object is in frustum otherwise false
  80711. */
  80712. isInFrustum(frustumPlanes: Plane[]): boolean;
  80713. /**
  80714. * Checks if a cullable object (mesh...) is in the camera frustum
  80715. * Unlike isInFrustum this cheks the full bounding box
  80716. * @param frustumPlanes Camera near/planes
  80717. * @returns true if the object is in frustum otherwise false
  80718. */
  80719. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80720. }
  80721. /**
  80722. * Info for a bounding data of a mesh
  80723. */
  80724. export class BoundingInfo implements ICullable {
  80725. /**
  80726. * Bounding box for the mesh
  80727. */
  80728. readonly boundingBox: BoundingBox;
  80729. /**
  80730. * Bounding sphere for the mesh
  80731. */
  80732. readonly boundingSphere: BoundingSphere;
  80733. private _isLocked;
  80734. private static readonly TmpVector3;
  80735. /**
  80736. * Constructs bounding info
  80737. * @param minimum min vector of the bounding box/sphere
  80738. * @param maximum max vector of the bounding box/sphere
  80739. * @param worldMatrix defines the new world matrix
  80740. */
  80741. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80742. /**
  80743. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80744. * @param min defines the new minimum vector (in local space)
  80745. * @param max defines the new maximum vector (in local space)
  80746. * @param worldMatrix defines the new world matrix
  80747. */
  80748. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80749. /**
  80750. * min vector of the bounding box/sphere
  80751. */
  80752. get minimum(): Vector3;
  80753. /**
  80754. * max vector of the bounding box/sphere
  80755. */
  80756. get maximum(): Vector3;
  80757. /**
  80758. * If the info is locked and won't be updated to avoid perf overhead
  80759. */
  80760. get isLocked(): boolean;
  80761. set isLocked(value: boolean);
  80762. /**
  80763. * Updates the bounding sphere and box
  80764. * @param world world matrix to be used to update
  80765. */
  80766. update(world: DeepImmutable<Matrix>): void;
  80767. /**
  80768. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80769. * @param center New center of the bounding info
  80770. * @param extend New extend of the bounding info
  80771. * @returns the current bounding info
  80772. */
  80773. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80774. /**
  80775. * Scale the current bounding info by applying a scale factor
  80776. * @param factor defines the scale factor to apply
  80777. * @returns the current bounding info
  80778. */
  80779. scale(factor: number): BoundingInfo;
  80780. /**
  80781. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80782. * @param frustumPlanes defines the frustum to test
  80783. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80784. * @returns true if the bounding info is in the frustum planes
  80785. */
  80786. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80787. /**
  80788. * Gets the world distance between the min and max points of the bounding box
  80789. */
  80790. get diagonalLength(): number;
  80791. /**
  80792. * Checks if a cullable object (mesh...) is in the camera frustum
  80793. * Unlike isInFrustum this cheks the full bounding box
  80794. * @param frustumPlanes Camera near/planes
  80795. * @returns true if the object is in frustum otherwise false
  80796. */
  80797. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80798. /** @hidden */
  80799. _checkCollision(collider: Collider): boolean;
  80800. /**
  80801. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80802. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80803. * @param point the point to check intersection with
  80804. * @returns if the point intersects
  80805. */
  80806. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80807. /**
  80808. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80809. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80810. * @param boundingInfo the bounding info to check intersection with
  80811. * @param precise if the intersection should be done using OBB
  80812. * @returns if the bounding info intersects
  80813. */
  80814. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80815. }
  80816. }
  80817. declare module BABYLON {
  80818. /**
  80819. * Extracts minimum and maximum values from a list of indexed positions
  80820. * @param positions defines the positions to use
  80821. * @param indices defines the indices to the positions
  80822. * @param indexStart defines the start index
  80823. * @param indexCount defines the end index
  80824. * @param bias defines bias value to add to the result
  80825. * @return minimum and maximum values
  80826. */
  80827. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80828. minimum: Vector3;
  80829. maximum: Vector3;
  80830. };
  80831. /**
  80832. * Extracts minimum and maximum values from a list of positions
  80833. * @param positions defines the positions to use
  80834. * @param start defines the start index in the positions array
  80835. * @param count defines the number of positions to handle
  80836. * @param bias defines bias value to add to the result
  80837. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80838. * @return minimum and maximum values
  80839. */
  80840. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80841. minimum: Vector3;
  80842. maximum: Vector3;
  80843. };
  80844. }
  80845. declare module BABYLON {
  80846. /** @hidden */
  80847. export class WebGLDataBuffer extends DataBuffer {
  80848. private _buffer;
  80849. constructor(resource: WebGLBuffer);
  80850. get underlyingResource(): any;
  80851. }
  80852. }
  80853. declare module BABYLON {
  80854. /** @hidden */
  80855. export class WebGLPipelineContext implements IPipelineContext {
  80856. engine: ThinEngine;
  80857. program: Nullable<WebGLProgram>;
  80858. context?: WebGLRenderingContext;
  80859. vertexShader?: WebGLShader;
  80860. fragmentShader?: WebGLShader;
  80861. isParallelCompiled: boolean;
  80862. onCompiled?: () => void;
  80863. transformFeedback?: WebGLTransformFeedback | null;
  80864. vertexCompilationError: Nullable<string>;
  80865. fragmentCompilationError: Nullable<string>;
  80866. programLinkError: Nullable<string>;
  80867. programValidationError: Nullable<string>;
  80868. get isAsync(): boolean;
  80869. get isReady(): boolean;
  80870. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80871. _getVertexShaderCode(): string | null;
  80872. _getFragmentShaderCode(): string | null;
  80873. }
  80874. }
  80875. declare module BABYLON {
  80876. interface ThinEngine {
  80877. /**
  80878. * Create an uniform buffer
  80879. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80880. * @param elements defines the content of the uniform buffer
  80881. * @returns the webGL uniform buffer
  80882. */
  80883. createUniformBuffer(elements: FloatArray): DataBuffer;
  80884. /**
  80885. * Create a dynamic uniform buffer
  80886. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80887. * @param elements defines the content of the uniform buffer
  80888. * @returns the webGL uniform buffer
  80889. */
  80890. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80891. /**
  80892. * Update an existing uniform buffer
  80893. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80894. * @param uniformBuffer defines the target uniform buffer
  80895. * @param elements defines the content to update
  80896. * @param offset defines the offset in the uniform buffer where update should start
  80897. * @param count defines the size of the data to update
  80898. */
  80899. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80900. /**
  80901. * Bind an uniform buffer to the current webGL context
  80902. * @param buffer defines the buffer to bind
  80903. */
  80904. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80905. /**
  80906. * Bind a buffer to the current webGL context at a given location
  80907. * @param buffer defines the buffer to bind
  80908. * @param location defines the index where to bind the buffer
  80909. */
  80910. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80911. /**
  80912. * Bind a specific block at a given index in a specific shader program
  80913. * @param pipelineContext defines the pipeline context to use
  80914. * @param blockName defines the block name
  80915. * @param index defines the index where to bind the block
  80916. */
  80917. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80918. }
  80919. }
  80920. declare module BABYLON {
  80921. /**
  80922. * Uniform buffer objects.
  80923. *
  80924. * Handles blocks of uniform on the GPU.
  80925. *
  80926. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80927. *
  80928. * For more information, please refer to :
  80929. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80930. */
  80931. export class UniformBuffer {
  80932. private _engine;
  80933. private _buffer;
  80934. private _data;
  80935. private _bufferData;
  80936. private _dynamic?;
  80937. private _uniformLocations;
  80938. private _uniformSizes;
  80939. private _uniformLocationPointer;
  80940. private _needSync;
  80941. private _noUBO;
  80942. private _currentEffect;
  80943. /** @hidden */
  80944. _alreadyBound: boolean;
  80945. private static _MAX_UNIFORM_SIZE;
  80946. private static _tempBuffer;
  80947. /**
  80948. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80949. * This is dynamic to allow compat with webgl 1 and 2.
  80950. * You will need to pass the name of the uniform as well as the value.
  80951. */
  80952. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80953. /**
  80954. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80955. * This is dynamic to allow compat with webgl 1 and 2.
  80956. * You will need to pass the name of the uniform as well as the value.
  80957. */
  80958. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80959. /**
  80960. * Lambda to Update a single float in a uniform buffer.
  80961. * This is dynamic to allow compat with webgl 1 and 2.
  80962. * You will need to pass the name of the uniform as well as the value.
  80963. */
  80964. updateFloat: (name: string, x: number) => void;
  80965. /**
  80966. * Lambda to Update a vec2 of float in a uniform buffer.
  80967. * This is dynamic to allow compat with webgl 1 and 2.
  80968. * You will need to pass the name of the uniform as well as the value.
  80969. */
  80970. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80971. /**
  80972. * Lambda to Update a vec3 of float in a uniform buffer.
  80973. * This is dynamic to allow compat with webgl 1 and 2.
  80974. * You will need to pass the name of the uniform as well as the value.
  80975. */
  80976. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80977. /**
  80978. * Lambda to Update a vec4 of float in a uniform buffer.
  80979. * This is dynamic to allow compat with webgl 1 and 2.
  80980. * You will need to pass the name of the uniform as well as the value.
  80981. */
  80982. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80983. /**
  80984. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80985. * This is dynamic to allow compat with webgl 1 and 2.
  80986. * You will need to pass the name of the uniform as well as the value.
  80987. */
  80988. updateMatrix: (name: string, mat: Matrix) => void;
  80989. /**
  80990. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80991. * This is dynamic to allow compat with webgl 1 and 2.
  80992. * You will need to pass the name of the uniform as well as the value.
  80993. */
  80994. updateVector3: (name: string, vector: Vector3) => void;
  80995. /**
  80996. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80997. * This is dynamic to allow compat with webgl 1 and 2.
  80998. * You will need to pass the name of the uniform as well as the value.
  80999. */
  81000. updateVector4: (name: string, vector: Vector4) => void;
  81001. /**
  81002. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81003. * This is dynamic to allow compat with webgl 1 and 2.
  81004. * You will need to pass the name of the uniform as well as the value.
  81005. */
  81006. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81007. /**
  81008. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81009. * This is dynamic to allow compat with webgl 1 and 2.
  81010. * You will need to pass the name of the uniform as well as the value.
  81011. */
  81012. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81013. /**
  81014. * Instantiates a new Uniform buffer objects.
  81015. *
  81016. * Handles blocks of uniform on the GPU.
  81017. *
  81018. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81019. *
  81020. * For more information, please refer to :
  81021. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81022. * @param engine Define the engine the buffer is associated with
  81023. * @param data Define the data contained in the buffer
  81024. * @param dynamic Define if the buffer is updatable
  81025. */
  81026. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81027. /**
  81028. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81029. * or just falling back on setUniformXXX calls.
  81030. */
  81031. get useUbo(): boolean;
  81032. /**
  81033. * Indicates if the WebGL underlying uniform buffer is in sync
  81034. * with the javascript cache data.
  81035. */
  81036. get isSync(): boolean;
  81037. /**
  81038. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81039. * Also, a dynamic UniformBuffer will disable cache verification and always
  81040. * update the underlying WebGL uniform buffer to the GPU.
  81041. * @returns if Dynamic, otherwise false
  81042. */
  81043. isDynamic(): boolean;
  81044. /**
  81045. * The data cache on JS side.
  81046. * @returns the underlying data as a float array
  81047. */
  81048. getData(): Float32Array;
  81049. /**
  81050. * The underlying WebGL Uniform buffer.
  81051. * @returns the webgl buffer
  81052. */
  81053. getBuffer(): Nullable<DataBuffer>;
  81054. /**
  81055. * std140 layout specifies how to align data within an UBO structure.
  81056. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81057. * for specs.
  81058. */
  81059. private _fillAlignment;
  81060. /**
  81061. * Adds an uniform in the buffer.
  81062. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81063. * for the layout to be correct !
  81064. * @param name Name of the uniform, as used in the uniform block in the shader.
  81065. * @param size Data size, or data directly.
  81066. */
  81067. addUniform(name: string, size: number | number[]): void;
  81068. /**
  81069. * Adds a Matrix 4x4 to the uniform buffer.
  81070. * @param name Name of the uniform, as used in the uniform block in the shader.
  81071. * @param mat A 4x4 matrix.
  81072. */
  81073. addMatrix(name: string, mat: Matrix): void;
  81074. /**
  81075. * Adds a vec2 to the uniform buffer.
  81076. * @param name Name of the uniform, as used in the uniform block in the shader.
  81077. * @param x Define the x component value of the vec2
  81078. * @param y Define the y component value of the vec2
  81079. */
  81080. addFloat2(name: string, x: number, y: number): void;
  81081. /**
  81082. * Adds a vec3 to the uniform buffer.
  81083. * @param name Name of the uniform, as used in the uniform block in the shader.
  81084. * @param x Define the x component value of the vec3
  81085. * @param y Define the y component value of the vec3
  81086. * @param z Define the z component value of the vec3
  81087. */
  81088. addFloat3(name: string, x: number, y: number, z: number): void;
  81089. /**
  81090. * Adds a vec3 to the uniform buffer.
  81091. * @param name Name of the uniform, as used in the uniform block in the shader.
  81092. * @param color Define the vec3 from a Color
  81093. */
  81094. addColor3(name: string, color: Color3): void;
  81095. /**
  81096. * Adds a vec4 to the uniform buffer.
  81097. * @param name Name of the uniform, as used in the uniform block in the shader.
  81098. * @param color Define the rgb components from a Color
  81099. * @param alpha Define the a component of the vec4
  81100. */
  81101. addColor4(name: string, color: Color3, alpha: number): void;
  81102. /**
  81103. * Adds a vec3 to the uniform buffer.
  81104. * @param name Name of the uniform, as used in the uniform block in the shader.
  81105. * @param vector Define the vec3 components from a Vector
  81106. */
  81107. addVector3(name: string, vector: Vector3): void;
  81108. /**
  81109. * Adds a Matrix 3x3 to the uniform buffer.
  81110. * @param name Name of the uniform, as used in the uniform block in the shader.
  81111. */
  81112. addMatrix3x3(name: string): void;
  81113. /**
  81114. * Adds a Matrix 2x2 to the uniform buffer.
  81115. * @param name Name of the uniform, as used in the uniform block in the shader.
  81116. */
  81117. addMatrix2x2(name: string): void;
  81118. /**
  81119. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81120. */
  81121. create(): void;
  81122. /** @hidden */
  81123. _rebuild(): void;
  81124. /**
  81125. * Updates the WebGL Uniform Buffer on the GPU.
  81126. * If the `dynamic` flag is set to true, no cache comparison is done.
  81127. * Otherwise, the buffer will be updated only if the cache differs.
  81128. */
  81129. update(): void;
  81130. /**
  81131. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81132. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81133. * @param data Define the flattened data
  81134. * @param size Define the size of the data.
  81135. */
  81136. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81137. private _valueCache;
  81138. private _cacheMatrix;
  81139. private _updateMatrix3x3ForUniform;
  81140. private _updateMatrix3x3ForEffect;
  81141. private _updateMatrix2x2ForEffect;
  81142. private _updateMatrix2x2ForUniform;
  81143. private _updateFloatForEffect;
  81144. private _updateFloatForUniform;
  81145. private _updateFloat2ForEffect;
  81146. private _updateFloat2ForUniform;
  81147. private _updateFloat3ForEffect;
  81148. private _updateFloat3ForUniform;
  81149. private _updateFloat4ForEffect;
  81150. private _updateFloat4ForUniform;
  81151. private _updateMatrixForEffect;
  81152. private _updateMatrixForUniform;
  81153. private _updateVector3ForEffect;
  81154. private _updateVector3ForUniform;
  81155. private _updateVector4ForEffect;
  81156. private _updateVector4ForUniform;
  81157. private _updateColor3ForEffect;
  81158. private _updateColor3ForUniform;
  81159. private _updateColor4ForEffect;
  81160. private _updateColor4ForUniform;
  81161. /**
  81162. * Sets a sampler uniform on the effect.
  81163. * @param name Define the name of the sampler.
  81164. * @param texture Define the texture to set in the sampler
  81165. */
  81166. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81167. /**
  81168. * Directly updates the value of the uniform in the cache AND on the GPU.
  81169. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81170. * @param data Define the flattened data
  81171. */
  81172. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81173. /**
  81174. * Binds this uniform buffer to an effect.
  81175. * @param effect Define the effect to bind the buffer to
  81176. * @param name Name of the uniform block in the shader.
  81177. */
  81178. bindToEffect(effect: Effect, name: string): void;
  81179. /**
  81180. * Disposes the uniform buffer.
  81181. */
  81182. dispose(): void;
  81183. }
  81184. }
  81185. declare module BABYLON {
  81186. /**
  81187. * Enum that determines the text-wrapping mode to use.
  81188. */
  81189. export enum InspectableType {
  81190. /**
  81191. * Checkbox for booleans
  81192. */
  81193. Checkbox = 0,
  81194. /**
  81195. * Sliders for numbers
  81196. */
  81197. Slider = 1,
  81198. /**
  81199. * Vector3
  81200. */
  81201. Vector3 = 2,
  81202. /**
  81203. * Quaternions
  81204. */
  81205. Quaternion = 3,
  81206. /**
  81207. * Color3
  81208. */
  81209. Color3 = 4,
  81210. /**
  81211. * String
  81212. */
  81213. String = 5
  81214. }
  81215. /**
  81216. * Interface used to define custom inspectable properties.
  81217. * This interface is used by the inspector to display custom property grids
  81218. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81219. */
  81220. export interface IInspectable {
  81221. /**
  81222. * Gets the label to display
  81223. */
  81224. label: string;
  81225. /**
  81226. * Gets the name of the property to edit
  81227. */
  81228. propertyName: string;
  81229. /**
  81230. * Gets the type of the editor to use
  81231. */
  81232. type: InspectableType;
  81233. /**
  81234. * Gets the minimum value of the property when using in "slider" mode
  81235. */
  81236. min?: number;
  81237. /**
  81238. * Gets the maximum value of the property when using in "slider" mode
  81239. */
  81240. max?: number;
  81241. /**
  81242. * Gets the setp to use when using in "slider" mode
  81243. */
  81244. step?: number;
  81245. }
  81246. }
  81247. declare module BABYLON {
  81248. /**
  81249. * Class used to provide helper for timing
  81250. */
  81251. export class TimingTools {
  81252. /**
  81253. * Polyfill for setImmediate
  81254. * @param action defines the action to execute after the current execution block
  81255. */
  81256. static SetImmediate(action: () => void): void;
  81257. }
  81258. }
  81259. declare module BABYLON {
  81260. /**
  81261. * Class used to enable instatition of objects by class name
  81262. */
  81263. export class InstantiationTools {
  81264. /**
  81265. * Use this object to register external classes like custom textures or material
  81266. * to allow the laoders to instantiate them
  81267. */
  81268. static RegisteredExternalClasses: {
  81269. [key: string]: Object;
  81270. };
  81271. /**
  81272. * Tries to instantiate a new object from a given class name
  81273. * @param className defines the class name to instantiate
  81274. * @returns the new object or null if the system was not able to do the instantiation
  81275. */
  81276. static Instantiate(className: string): any;
  81277. }
  81278. }
  81279. declare module BABYLON {
  81280. /**
  81281. * Define options used to create a depth texture
  81282. */
  81283. export class DepthTextureCreationOptions {
  81284. /** Specifies whether or not a stencil should be allocated in the texture */
  81285. generateStencil?: boolean;
  81286. /** Specifies whether or not bilinear filtering is enable on the texture */
  81287. bilinearFiltering?: boolean;
  81288. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81289. comparisonFunction?: number;
  81290. /** Specifies if the created texture is a cube texture */
  81291. isCube?: boolean;
  81292. }
  81293. }
  81294. declare module BABYLON {
  81295. interface ThinEngine {
  81296. /**
  81297. * Creates a depth stencil cube texture.
  81298. * This is only available in WebGL 2.
  81299. * @param size The size of face edge in the cube texture.
  81300. * @param options The options defining the cube texture.
  81301. * @returns The cube texture
  81302. */
  81303. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81304. /**
  81305. * Creates a cube texture
  81306. * @param rootUrl defines the url where the files to load is located
  81307. * @param scene defines the current scene
  81308. * @param files defines the list of files to load (1 per face)
  81309. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81310. * @param onLoad defines an optional callback raised when the texture is loaded
  81311. * @param onError defines an optional callback raised if there is an issue to load the texture
  81312. * @param format defines the format of the data
  81313. * @param forcedExtension defines the extension to use to pick the right loader
  81314. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81315. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81316. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81317. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81318. * @returns the cube texture as an InternalTexture
  81319. */
  81320. 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;
  81321. /**
  81322. * Creates a cube texture
  81323. * @param rootUrl defines the url where the files to load is located
  81324. * @param scene defines the current scene
  81325. * @param files defines the list of files to load (1 per face)
  81326. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81327. * @param onLoad defines an optional callback raised when the texture is loaded
  81328. * @param onError defines an optional callback raised if there is an issue to load the texture
  81329. * @param format defines the format of the data
  81330. * @param forcedExtension defines the extension to use to pick the right loader
  81331. * @returns the cube texture as an InternalTexture
  81332. */
  81333. 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;
  81334. /**
  81335. * Creates a cube texture
  81336. * @param rootUrl defines the url where the files to load is located
  81337. * @param scene defines the current scene
  81338. * @param files defines the list of files to load (1 per face)
  81339. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81340. * @param onLoad defines an optional callback raised when the texture is loaded
  81341. * @param onError defines an optional callback raised if there is an issue to load the texture
  81342. * @param format defines the format of the data
  81343. * @param forcedExtension defines the extension to use to pick the right loader
  81344. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81345. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81346. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81347. * @returns the cube texture as an InternalTexture
  81348. */
  81349. 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;
  81350. /** @hidden */
  81351. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81352. /** @hidden */
  81353. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81354. /** @hidden */
  81355. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81356. /** @hidden */
  81357. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81358. /**
  81359. * @hidden
  81360. */
  81361. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81362. }
  81363. }
  81364. declare module BABYLON {
  81365. /**
  81366. * Class for creating a cube texture
  81367. */
  81368. export class CubeTexture extends BaseTexture {
  81369. private _delayedOnLoad;
  81370. /**
  81371. * Observable triggered once the texture has been loaded.
  81372. */
  81373. onLoadObservable: Observable<CubeTexture>;
  81374. /**
  81375. * The url of the texture
  81376. */
  81377. url: string;
  81378. /**
  81379. * Gets or sets the center of the bounding box associated with the cube texture.
  81380. * It must define where the camera used to render the texture was set
  81381. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81382. */
  81383. boundingBoxPosition: Vector3;
  81384. private _boundingBoxSize;
  81385. /**
  81386. * Gets or sets the size of the bounding box associated with the cube texture
  81387. * When defined, the cubemap will switch to local mode
  81388. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81389. * @example https://www.babylonjs-playground.com/#RNASML
  81390. */
  81391. set boundingBoxSize(value: Vector3);
  81392. /**
  81393. * Returns the bounding box size
  81394. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81395. */
  81396. get boundingBoxSize(): Vector3;
  81397. protected _rotationY: number;
  81398. /**
  81399. * Sets texture matrix rotation angle around Y axis in radians.
  81400. */
  81401. set rotationY(value: number);
  81402. /**
  81403. * Gets texture matrix rotation angle around Y axis radians.
  81404. */
  81405. get rotationY(): number;
  81406. /**
  81407. * Are mip maps generated for this texture or not.
  81408. */
  81409. get noMipmap(): boolean;
  81410. private _noMipmap;
  81411. private _files;
  81412. protected _forcedExtension: Nullable<string>;
  81413. private _extensions;
  81414. private _textureMatrix;
  81415. private _format;
  81416. private _createPolynomials;
  81417. /** @hidden */
  81418. _prefiltered: boolean;
  81419. /**
  81420. * Creates a cube texture from an array of image urls
  81421. * @param files defines an array of image urls
  81422. * @param scene defines the hosting scene
  81423. * @param noMipmap specifies if mip maps are not used
  81424. * @returns a cube texture
  81425. */
  81426. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81427. /**
  81428. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81429. * @param url defines the url of the prefiltered texture
  81430. * @param scene defines the scene the texture is attached to
  81431. * @param forcedExtension defines the extension of the file if different from the url
  81432. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81433. * @return the prefiltered texture
  81434. */
  81435. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81436. /**
  81437. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81438. * as prefiltered data.
  81439. * @param rootUrl defines the url of the texture or the root name of the six images
  81440. * @param scene defines the scene the texture is attached to
  81441. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81442. * @param noMipmap defines if mipmaps should be created or not
  81443. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81444. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81445. * @param onError defines a callback triggered in case of error during load
  81446. * @param format defines the internal format to use for the texture once loaded
  81447. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81448. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81449. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81450. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81451. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81452. * @return the cube texture
  81453. */
  81454. 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);
  81455. /**
  81456. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81457. */
  81458. get isPrefiltered(): boolean;
  81459. /**
  81460. * Get the current class name of the texture useful for serialization or dynamic coding.
  81461. * @returns "CubeTexture"
  81462. */
  81463. getClassName(): string;
  81464. /**
  81465. * Update the url (and optional buffer) of this texture if url was null during construction.
  81466. * @param url the url of the texture
  81467. * @param forcedExtension defines the extension to use
  81468. * @param onLoad callback called when the texture is loaded (defaults to null)
  81469. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81470. */
  81471. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81472. /**
  81473. * Delays loading of the cube texture
  81474. * @param forcedExtension defines the extension to use
  81475. */
  81476. delayLoad(forcedExtension?: string): void;
  81477. /**
  81478. * Returns the reflection texture matrix
  81479. * @returns the reflection texture matrix
  81480. */
  81481. getReflectionTextureMatrix(): Matrix;
  81482. /**
  81483. * Sets the reflection texture matrix
  81484. * @param value Reflection texture matrix
  81485. */
  81486. setReflectionTextureMatrix(value: Matrix): void;
  81487. /**
  81488. * Parses text to create a cube texture
  81489. * @param parsedTexture define the serialized text to read from
  81490. * @param scene defines the hosting scene
  81491. * @param rootUrl defines the root url of the cube texture
  81492. * @returns a cube texture
  81493. */
  81494. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81495. /**
  81496. * Makes a clone, or deep copy, of the cube texture
  81497. * @returns a new cube texture
  81498. */
  81499. clone(): CubeTexture;
  81500. }
  81501. }
  81502. declare module BABYLON {
  81503. /**
  81504. * Manages the defines for the Material
  81505. */
  81506. export class MaterialDefines {
  81507. /** @hidden */
  81508. protected _keys: string[];
  81509. private _isDirty;
  81510. /** @hidden */
  81511. _renderId: number;
  81512. /** @hidden */
  81513. _areLightsDirty: boolean;
  81514. /** @hidden */
  81515. _areLightsDisposed: boolean;
  81516. /** @hidden */
  81517. _areAttributesDirty: boolean;
  81518. /** @hidden */
  81519. _areTexturesDirty: boolean;
  81520. /** @hidden */
  81521. _areFresnelDirty: boolean;
  81522. /** @hidden */
  81523. _areMiscDirty: boolean;
  81524. /** @hidden */
  81525. _areImageProcessingDirty: boolean;
  81526. /** @hidden */
  81527. _normals: boolean;
  81528. /** @hidden */
  81529. _uvs: boolean;
  81530. /** @hidden */
  81531. _needNormals: boolean;
  81532. /** @hidden */
  81533. _needUVs: boolean;
  81534. [id: string]: any;
  81535. /**
  81536. * Specifies if the material needs to be re-calculated
  81537. */
  81538. get isDirty(): boolean;
  81539. /**
  81540. * Marks the material to indicate that it has been re-calculated
  81541. */
  81542. markAsProcessed(): void;
  81543. /**
  81544. * Marks the material to indicate that it needs to be re-calculated
  81545. */
  81546. markAsUnprocessed(): void;
  81547. /**
  81548. * Marks the material to indicate all of its defines need to be re-calculated
  81549. */
  81550. markAllAsDirty(): void;
  81551. /**
  81552. * Marks the material to indicate that image processing needs to be re-calculated
  81553. */
  81554. markAsImageProcessingDirty(): void;
  81555. /**
  81556. * Marks the material to indicate the lights need to be re-calculated
  81557. * @param disposed Defines whether the light is dirty due to dispose or not
  81558. */
  81559. markAsLightDirty(disposed?: boolean): void;
  81560. /**
  81561. * Marks the attribute state as changed
  81562. */
  81563. markAsAttributesDirty(): void;
  81564. /**
  81565. * Marks the texture state as changed
  81566. */
  81567. markAsTexturesDirty(): void;
  81568. /**
  81569. * Marks the fresnel state as changed
  81570. */
  81571. markAsFresnelDirty(): void;
  81572. /**
  81573. * Marks the misc state as changed
  81574. */
  81575. markAsMiscDirty(): void;
  81576. /**
  81577. * Rebuilds the material defines
  81578. */
  81579. rebuild(): void;
  81580. /**
  81581. * Specifies if two material defines are equal
  81582. * @param other - A material define instance to compare to
  81583. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81584. */
  81585. isEqual(other: MaterialDefines): boolean;
  81586. /**
  81587. * Clones this instance's defines to another instance
  81588. * @param other - material defines to clone values to
  81589. */
  81590. cloneTo(other: MaterialDefines): void;
  81591. /**
  81592. * Resets the material define values
  81593. */
  81594. reset(): void;
  81595. /**
  81596. * Converts the material define values to a string
  81597. * @returns - String of material define information
  81598. */
  81599. toString(): string;
  81600. }
  81601. }
  81602. declare module BABYLON {
  81603. /**
  81604. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81605. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81606. * 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;
  81607. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81608. */
  81609. export class ColorCurves {
  81610. private _dirty;
  81611. private _tempColor;
  81612. private _globalCurve;
  81613. private _highlightsCurve;
  81614. private _midtonesCurve;
  81615. private _shadowsCurve;
  81616. private _positiveCurve;
  81617. private _negativeCurve;
  81618. private _globalHue;
  81619. private _globalDensity;
  81620. private _globalSaturation;
  81621. private _globalExposure;
  81622. /**
  81623. * Gets the global Hue value.
  81624. * 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).
  81625. */
  81626. get globalHue(): number;
  81627. /**
  81628. * Sets the global Hue value.
  81629. * 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).
  81630. */
  81631. set globalHue(value: number);
  81632. /**
  81633. * Gets the global Density value.
  81634. * 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.
  81635. * Values less than zero provide a filter of opposite hue.
  81636. */
  81637. get globalDensity(): number;
  81638. /**
  81639. * Sets the global Density value.
  81640. * 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.
  81641. * Values less than zero provide a filter of opposite hue.
  81642. */
  81643. set globalDensity(value: number);
  81644. /**
  81645. * Gets the global Saturation value.
  81646. * 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.
  81647. */
  81648. get globalSaturation(): number;
  81649. /**
  81650. * Sets the global Saturation value.
  81651. * 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.
  81652. */
  81653. set globalSaturation(value: number);
  81654. /**
  81655. * Gets the global Exposure value.
  81656. * 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.
  81657. */
  81658. get globalExposure(): number;
  81659. /**
  81660. * Sets the global Exposure value.
  81661. * 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.
  81662. */
  81663. set globalExposure(value: number);
  81664. private _highlightsHue;
  81665. private _highlightsDensity;
  81666. private _highlightsSaturation;
  81667. private _highlightsExposure;
  81668. /**
  81669. * Gets the highlights Hue value.
  81670. * 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).
  81671. */
  81672. get highlightsHue(): number;
  81673. /**
  81674. * Sets the highlights Hue value.
  81675. * 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).
  81676. */
  81677. set highlightsHue(value: number);
  81678. /**
  81679. * Gets the highlights Density value.
  81680. * 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.
  81681. * Values less than zero provide a filter of opposite hue.
  81682. */
  81683. get highlightsDensity(): number;
  81684. /**
  81685. * Sets the highlights Density value.
  81686. * 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.
  81687. * Values less than zero provide a filter of opposite hue.
  81688. */
  81689. set highlightsDensity(value: number);
  81690. /**
  81691. * Gets the highlights Saturation value.
  81692. * 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.
  81693. */
  81694. get highlightsSaturation(): number;
  81695. /**
  81696. * Sets the highlights Saturation value.
  81697. * 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.
  81698. */
  81699. set highlightsSaturation(value: number);
  81700. /**
  81701. * Gets the highlights Exposure value.
  81702. * 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.
  81703. */
  81704. get highlightsExposure(): number;
  81705. /**
  81706. * Sets the highlights Exposure value.
  81707. * 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.
  81708. */
  81709. set highlightsExposure(value: number);
  81710. private _midtonesHue;
  81711. private _midtonesDensity;
  81712. private _midtonesSaturation;
  81713. private _midtonesExposure;
  81714. /**
  81715. * Gets the midtones Hue value.
  81716. * 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).
  81717. */
  81718. get midtonesHue(): number;
  81719. /**
  81720. * Sets the midtones Hue value.
  81721. * 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).
  81722. */
  81723. set midtonesHue(value: number);
  81724. /**
  81725. * Gets the midtones Density value.
  81726. * 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.
  81727. * Values less than zero provide a filter of opposite hue.
  81728. */
  81729. get midtonesDensity(): number;
  81730. /**
  81731. * Sets the midtones Density value.
  81732. * 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.
  81733. * Values less than zero provide a filter of opposite hue.
  81734. */
  81735. set midtonesDensity(value: number);
  81736. /**
  81737. * Gets the midtones Saturation value.
  81738. * 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.
  81739. */
  81740. get midtonesSaturation(): number;
  81741. /**
  81742. * Sets the midtones Saturation value.
  81743. * 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.
  81744. */
  81745. set midtonesSaturation(value: number);
  81746. /**
  81747. * Gets the midtones Exposure value.
  81748. * 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.
  81749. */
  81750. get midtonesExposure(): number;
  81751. /**
  81752. * Sets the midtones Exposure value.
  81753. * 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.
  81754. */
  81755. set midtonesExposure(value: number);
  81756. private _shadowsHue;
  81757. private _shadowsDensity;
  81758. private _shadowsSaturation;
  81759. private _shadowsExposure;
  81760. /**
  81761. * Gets the shadows Hue value.
  81762. * 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).
  81763. */
  81764. get shadowsHue(): number;
  81765. /**
  81766. * Sets the shadows Hue value.
  81767. * 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).
  81768. */
  81769. set shadowsHue(value: number);
  81770. /**
  81771. * Gets the shadows Density value.
  81772. * 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.
  81773. * Values less than zero provide a filter of opposite hue.
  81774. */
  81775. get shadowsDensity(): number;
  81776. /**
  81777. * Sets the shadows Density value.
  81778. * 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.
  81779. * Values less than zero provide a filter of opposite hue.
  81780. */
  81781. set shadowsDensity(value: number);
  81782. /**
  81783. * Gets the shadows Saturation value.
  81784. * 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.
  81785. */
  81786. get shadowsSaturation(): number;
  81787. /**
  81788. * Sets the shadows Saturation value.
  81789. * 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.
  81790. */
  81791. set shadowsSaturation(value: number);
  81792. /**
  81793. * Gets the shadows Exposure value.
  81794. * 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.
  81795. */
  81796. get shadowsExposure(): number;
  81797. /**
  81798. * Sets the shadows Exposure value.
  81799. * 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.
  81800. */
  81801. set shadowsExposure(value: number);
  81802. /**
  81803. * Returns the class name
  81804. * @returns The class name
  81805. */
  81806. getClassName(): string;
  81807. /**
  81808. * Binds the color curves to the shader.
  81809. * @param colorCurves The color curve to bind
  81810. * @param effect The effect to bind to
  81811. * @param positiveUniform The positive uniform shader parameter
  81812. * @param neutralUniform The neutral uniform shader parameter
  81813. * @param negativeUniform The negative uniform shader parameter
  81814. */
  81815. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81816. /**
  81817. * Prepare the list of uniforms associated with the ColorCurves effects.
  81818. * @param uniformsList The list of uniforms used in the effect
  81819. */
  81820. static PrepareUniforms(uniformsList: string[]): void;
  81821. /**
  81822. * Returns color grading data based on a hue, density, saturation and exposure value.
  81823. * @param filterHue The hue of the color filter.
  81824. * @param filterDensity The density of the color filter.
  81825. * @param saturation The saturation.
  81826. * @param exposure The exposure.
  81827. * @param result The result data container.
  81828. */
  81829. private getColorGradingDataToRef;
  81830. /**
  81831. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81832. * @param value The input slider value in range [-100,100].
  81833. * @returns Adjusted value.
  81834. */
  81835. private static applyColorGradingSliderNonlinear;
  81836. /**
  81837. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81838. * @param hue The hue (H) input.
  81839. * @param saturation The saturation (S) input.
  81840. * @param brightness The brightness (B) input.
  81841. * @result An RGBA color represented as Vector4.
  81842. */
  81843. private static fromHSBToRef;
  81844. /**
  81845. * Returns a value clamped between min and max
  81846. * @param value The value to clamp
  81847. * @param min The minimum of value
  81848. * @param max The maximum of value
  81849. * @returns The clamped value.
  81850. */
  81851. private static clamp;
  81852. /**
  81853. * Clones the current color curve instance.
  81854. * @return The cloned curves
  81855. */
  81856. clone(): ColorCurves;
  81857. /**
  81858. * Serializes the current color curve instance to a json representation.
  81859. * @return a JSON representation
  81860. */
  81861. serialize(): any;
  81862. /**
  81863. * Parses the color curve from a json representation.
  81864. * @param source the JSON source to parse
  81865. * @return The parsed curves
  81866. */
  81867. static Parse(source: any): ColorCurves;
  81868. }
  81869. }
  81870. declare module BABYLON {
  81871. /**
  81872. * Interface to follow in your material defines to integrate easily the
  81873. * Image proccessing functions.
  81874. * @hidden
  81875. */
  81876. export interface IImageProcessingConfigurationDefines {
  81877. IMAGEPROCESSING: boolean;
  81878. VIGNETTE: boolean;
  81879. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81880. VIGNETTEBLENDMODEOPAQUE: boolean;
  81881. TONEMAPPING: boolean;
  81882. TONEMAPPING_ACES: boolean;
  81883. CONTRAST: boolean;
  81884. EXPOSURE: boolean;
  81885. COLORCURVES: boolean;
  81886. COLORGRADING: boolean;
  81887. COLORGRADING3D: boolean;
  81888. SAMPLER3DGREENDEPTH: boolean;
  81889. SAMPLER3DBGRMAP: boolean;
  81890. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81891. }
  81892. /**
  81893. * @hidden
  81894. */
  81895. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81896. IMAGEPROCESSING: boolean;
  81897. VIGNETTE: boolean;
  81898. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81899. VIGNETTEBLENDMODEOPAQUE: boolean;
  81900. TONEMAPPING: boolean;
  81901. TONEMAPPING_ACES: boolean;
  81902. CONTRAST: boolean;
  81903. COLORCURVES: boolean;
  81904. COLORGRADING: boolean;
  81905. COLORGRADING3D: boolean;
  81906. SAMPLER3DGREENDEPTH: boolean;
  81907. SAMPLER3DBGRMAP: boolean;
  81908. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81909. EXPOSURE: boolean;
  81910. constructor();
  81911. }
  81912. /**
  81913. * This groups together the common properties used for image processing either in direct forward pass
  81914. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81915. * or not.
  81916. */
  81917. export class ImageProcessingConfiguration {
  81918. /**
  81919. * Default tone mapping applied in BabylonJS.
  81920. */
  81921. static readonly TONEMAPPING_STANDARD: number;
  81922. /**
  81923. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81924. * to other engines rendering to increase portability.
  81925. */
  81926. static readonly TONEMAPPING_ACES: number;
  81927. /**
  81928. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81929. */
  81930. colorCurves: Nullable<ColorCurves>;
  81931. private _colorCurvesEnabled;
  81932. /**
  81933. * Gets wether the color curves effect is enabled.
  81934. */
  81935. get colorCurvesEnabled(): boolean;
  81936. /**
  81937. * Sets wether the color curves effect is enabled.
  81938. */
  81939. set colorCurvesEnabled(value: boolean);
  81940. private _colorGradingTexture;
  81941. /**
  81942. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81943. */
  81944. get colorGradingTexture(): Nullable<BaseTexture>;
  81945. /**
  81946. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81947. */
  81948. set colorGradingTexture(value: Nullable<BaseTexture>);
  81949. private _colorGradingEnabled;
  81950. /**
  81951. * Gets wether the color grading effect is enabled.
  81952. */
  81953. get colorGradingEnabled(): boolean;
  81954. /**
  81955. * Sets wether the color grading effect is enabled.
  81956. */
  81957. set colorGradingEnabled(value: boolean);
  81958. private _colorGradingWithGreenDepth;
  81959. /**
  81960. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81961. */
  81962. get colorGradingWithGreenDepth(): boolean;
  81963. /**
  81964. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81965. */
  81966. set colorGradingWithGreenDepth(value: boolean);
  81967. private _colorGradingBGR;
  81968. /**
  81969. * Gets wether the color grading texture contains BGR values.
  81970. */
  81971. get colorGradingBGR(): boolean;
  81972. /**
  81973. * Sets wether the color grading texture contains BGR values.
  81974. */
  81975. set colorGradingBGR(value: boolean);
  81976. /** @hidden */
  81977. _exposure: number;
  81978. /**
  81979. * Gets the Exposure used in the effect.
  81980. */
  81981. get exposure(): number;
  81982. /**
  81983. * Sets the Exposure used in the effect.
  81984. */
  81985. set exposure(value: number);
  81986. private _toneMappingEnabled;
  81987. /**
  81988. * Gets wether the tone mapping effect is enabled.
  81989. */
  81990. get toneMappingEnabled(): boolean;
  81991. /**
  81992. * Sets wether the tone mapping effect is enabled.
  81993. */
  81994. set toneMappingEnabled(value: boolean);
  81995. private _toneMappingType;
  81996. /**
  81997. * Gets the type of tone mapping effect.
  81998. */
  81999. get toneMappingType(): number;
  82000. /**
  82001. * Sets the type of tone mapping effect used in BabylonJS.
  82002. */
  82003. set toneMappingType(value: number);
  82004. protected _contrast: number;
  82005. /**
  82006. * Gets the contrast used in the effect.
  82007. */
  82008. get contrast(): number;
  82009. /**
  82010. * Sets the contrast used in the effect.
  82011. */
  82012. set contrast(value: number);
  82013. /**
  82014. * Vignette stretch size.
  82015. */
  82016. vignetteStretch: number;
  82017. /**
  82018. * Vignette centre X Offset.
  82019. */
  82020. vignetteCentreX: number;
  82021. /**
  82022. * Vignette centre Y Offset.
  82023. */
  82024. vignetteCentreY: number;
  82025. /**
  82026. * Vignette weight or intensity of the vignette effect.
  82027. */
  82028. vignetteWeight: number;
  82029. /**
  82030. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82031. * if vignetteEnabled is set to true.
  82032. */
  82033. vignetteColor: Color4;
  82034. /**
  82035. * Camera field of view used by the Vignette effect.
  82036. */
  82037. vignetteCameraFov: number;
  82038. private _vignetteBlendMode;
  82039. /**
  82040. * Gets the vignette blend mode allowing different kind of effect.
  82041. */
  82042. get vignetteBlendMode(): number;
  82043. /**
  82044. * Sets the vignette blend mode allowing different kind of effect.
  82045. */
  82046. set vignetteBlendMode(value: number);
  82047. private _vignetteEnabled;
  82048. /**
  82049. * Gets wether the vignette effect is enabled.
  82050. */
  82051. get vignetteEnabled(): boolean;
  82052. /**
  82053. * Sets wether the vignette effect is enabled.
  82054. */
  82055. set vignetteEnabled(value: boolean);
  82056. private _applyByPostProcess;
  82057. /**
  82058. * Gets wether the image processing is applied through a post process or not.
  82059. */
  82060. get applyByPostProcess(): boolean;
  82061. /**
  82062. * Sets wether the image processing is applied through a post process or not.
  82063. */
  82064. set applyByPostProcess(value: boolean);
  82065. private _isEnabled;
  82066. /**
  82067. * Gets wether the image processing is enabled or not.
  82068. */
  82069. get isEnabled(): boolean;
  82070. /**
  82071. * Sets wether the image processing is enabled or not.
  82072. */
  82073. set isEnabled(value: boolean);
  82074. /**
  82075. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82076. */
  82077. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82078. /**
  82079. * Method called each time the image processing information changes requires to recompile the effect.
  82080. */
  82081. protected _updateParameters(): void;
  82082. /**
  82083. * Gets the current class name.
  82084. * @return "ImageProcessingConfiguration"
  82085. */
  82086. getClassName(): string;
  82087. /**
  82088. * Prepare the list of uniforms associated with the Image Processing effects.
  82089. * @param uniforms The list of uniforms used in the effect
  82090. * @param defines the list of defines currently in use
  82091. */
  82092. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82093. /**
  82094. * Prepare the list of samplers associated with the Image Processing effects.
  82095. * @param samplersList The list of uniforms used in the effect
  82096. * @param defines the list of defines currently in use
  82097. */
  82098. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82099. /**
  82100. * Prepare the list of defines associated to the shader.
  82101. * @param defines the list of defines to complete
  82102. * @param forPostProcess Define if we are currently in post process mode or not
  82103. */
  82104. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82105. /**
  82106. * Returns true if all the image processing information are ready.
  82107. * @returns True if ready, otherwise, false
  82108. */
  82109. isReady(): boolean;
  82110. /**
  82111. * Binds the image processing to the shader.
  82112. * @param effect The effect to bind to
  82113. * @param overrideAspectRatio Override the aspect ratio of the effect
  82114. */
  82115. bind(effect: Effect, overrideAspectRatio?: number): void;
  82116. /**
  82117. * Clones the current image processing instance.
  82118. * @return The cloned image processing
  82119. */
  82120. clone(): ImageProcessingConfiguration;
  82121. /**
  82122. * Serializes the current image processing instance to a json representation.
  82123. * @return a JSON representation
  82124. */
  82125. serialize(): any;
  82126. /**
  82127. * Parses the image processing from a json representation.
  82128. * @param source the JSON source to parse
  82129. * @return The parsed image processing
  82130. */
  82131. static Parse(source: any): ImageProcessingConfiguration;
  82132. private static _VIGNETTEMODE_MULTIPLY;
  82133. private static _VIGNETTEMODE_OPAQUE;
  82134. /**
  82135. * Used to apply the vignette as a mix with the pixel color.
  82136. */
  82137. static get VIGNETTEMODE_MULTIPLY(): number;
  82138. /**
  82139. * Used to apply the vignette as a replacement of the pixel color.
  82140. */
  82141. static get VIGNETTEMODE_OPAQUE(): number;
  82142. }
  82143. }
  82144. declare module BABYLON {
  82145. /** @hidden */
  82146. export var postprocessVertexShader: {
  82147. name: string;
  82148. shader: string;
  82149. };
  82150. }
  82151. declare module BABYLON {
  82152. interface ThinEngine {
  82153. /**
  82154. * Creates a new render target texture
  82155. * @param size defines the size of the texture
  82156. * @param options defines the options used to create the texture
  82157. * @returns a new render target texture stored in an InternalTexture
  82158. */
  82159. createRenderTargetTexture(size: number | {
  82160. width: number;
  82161. height: number;
  82162. layers?: number;
  82163. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82164. /**
  82165. * Creates a depth stencil texture.
  82166. * This is only available in WebGL 2 or with the depth texture extension available.
  82167. * @param size The size of face edge in the texture.
  82168. * @param options The options defining the texture.
  82169. * @returns The texture
  82170. */
  82171. createDepthStencilTexture(size: number | {
  82172. width: number;
  82173. height: number;
  82174. layers?: number;
  82175. }, options: DepthTextureCreationOptions): InternalTexture;
  82176. /** @hidden */
  82177. _createDepthStencilTexture(size: number | {
  82178. width: number;
  82179. height: number;
  82180. layers?: number;
  82181. }, options: DepthTextureCreationOptions): InternalTexture;
  82182. }
  82183. }
  82184. declare module BABYLON {
  82185. /** Defines supported spaces */
  82186. export enum Space {
  82187. /** Local (object) space */
  82188. LOCAL = 0,
  82189. /** World space */
  82190. WORLD = 1,
  82191. /** Bone space */
  82192. BONE = 2
  82193. }
  82194. /** Defines the 3 main axes */
  82195. export class Axis {
  82196. /** X axis */
  82197. static X: Vector3;
  82198. /** Y axis */
  82199. static Y: Vector3;
  82200. /** Z axis */
  82201. static Z: Vector3;
  82202. }
  82203. }
  82204. declare module BABYLON {
  82205. /**
  82206. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82207. * This is the base of the follow, arc rotate cameras and Free camera
  82208. * @see http://doc.babylonjs.com/features/cameras
  82209. */
  82210. export class TargetCamera extends Camera {
  82211. private static _RigCamTransformMatrix;
  82212. private static _TargetTransformMatrix;
  82213. private static _TargetFocalPoint;
  82214. /**
  82215. * Define the current direction the camera is moving to
  82216. */
  82217. cameraDirection: Vector3;
  82218. /**
  82219. * Define the current rotation the camera is rotating to
  82220. */
  82221. cameraRotation: Vector2;
  82222. /**
  82223. * When set, the up vector of the camera will be updated by the rotation of the camera
  82224. */
  82225. updateUpVectorFromRotation: boolean;
  82226. private _tmpQuaternion;
  82227. /**
  82228. * Define the current rotation of the camera
  82229. */
  82230. rotation: Vector3;
  82231. /**
  82232. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82233. */
  82234. rotationQuaternion: Quaternion;
  82235. /**
  82236. * Define the current speed of the camera
  82237. */
  82238. speed: number;
  82239. /**
  82240. * Add constraint to the camera to prevent it to move freely in all directions and
  82241. * around all axis.
  82242. */
  82243. noRotationConstraint: boolean;
  82244. /**
  82245. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82246. * panning
  82247. */
  82248. invertRotation: boolean;
  82249. /**
  82250. * Speed multiplier for inverse camera panning
  82251. */
  82252. inverseRotationSpeed: number;
  82253. /**
  82254. * Define the current target of the camera as an object or a position.
  82255. */
  82256. lockedTarget: any;
  82257. /** @hidden */
  82258. _currentTarget: Vector3;
  82259. /** @hidden */
  82260. _initialFocalDistance: number;
  82261. /** @hidden */
  82262. _viewMatrix: Matrix;
  82263. /** @hidden */
  82264. _camMatrix: Matrix;
  82265. /** @hidden */
  82266. _cameraTransformMatrix: Matrix;
  82267. /** @hidden */
  82268. _cameraRotationMatrix: Matrix;
  82269. /** @hidden */
  82270. _referencePoint: Vector3;
  82271. /** @hidden */
  82272. _transformedReferencePoint: Vector3;
  82273. protected _globalCurrentTarget: Vector3;
  82274. protected _globalCurrentUpVector: Vector3;
  82275. /** @hidden */
  82276. _reset: () => void;
  82277. private _defaultUp;
  82278. /**
  82279. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82280. * This is the base of the follow, arc rotate cameras and Free camera
  82281. * @see http://doc.babylonjs.com/features/cameras
  82282. * @param name Defines the name of the camera in the scene
  82283. * @param position Defines the start position of the camera in the scene
  82284. * @param scene Defines the scene the camera belongs to
  82285. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82286. */
  82287. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82288. /**
  82289. * Gets the position in front of the camera at a given distance.
  82290. * @param distance The distance from the camera we want the position to be
  82291. * @returns the position
  82292. */
  82293. getFrontPosition(distance: number): Vector3;
  82294. /** @hidden */
  82295. _getLockedTargetPosition(): Nullable<Vector3>;
  82296. private _storedPosition;
  82297. private _storedRotation;
  82298. private _storedRotationQuaternion;
  82299. /**
  82300. * Store current camera state of the camera (fov, position, rotation, etc..)
  82301. * @returns the camera
  82302. */
  82303. storeState(): Camera;
  82304. /**
  82305. * Restored camera state. You must call storeState() first
  82306. * @returns whether it was successful or not
  82307. * @hidden
  82308. */
  82309. _restoreStateValues(): boolean;
  82310. /** @hidden */
  82311. _initCache(): void;
  82312. /** @hidden */
  82313. _updateCache(ignoreParentClass?: boolean): void;
  82314. /** @hidden */
  82315. _isSynchronizedViewMatrix(): boolean;
  82316. /** @hidden */
  82317. _computeLocalCameraSpeed(): number;
  82318. /**
  82319. * Defines the target the camera should look at.
  82320. * @param target Defines the new target as a Vector or a mesh
  82321. */
  82322. setTarget(target: Vector3): void;
  82323. /**
  82324. * Return the current target position of the camera. This value is expressed in local space.
  82325. * @returns the target position
  82326. */
  82327. getTarget(): Vector3;
  82328. /** @hidden */
  82329. _decideIfNeedsToMove(): boolean;
  82330. /** @hidden */
  82331. _updatePosition(): void;
  82332. /** @hidden */
  82333. _checkInputs(): void;
  82334. protected _updateCameraRotationMatrix(): void;
  82335. /**
  82336. * 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)
  82337. * @returns the current camera
  82338. */
  82339. private _rotateUpVectorWithCameraRotationMatrix;
  82340. private _cachedRotationZ;
  82341. private _cachedQuaternionRotationZ;
  82342. /** @hidden */
  82343. _getViewMatrix(): Matrix;
  82344. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82345. /**
  82346. * @hidden
  82347. */
  82348. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82349. /**
  82350. * @hidden
  82351. */
  82352. _updateRigCameras(): void;
  82353. private _getRigCamPositionAndTarget;
  82354. /**
  82355. * Gets the current object class name.
  82356. * @return the class name
  82357. */
  82358. getClassName(): string;
  82359. }
  82360. }
  82361. declare module BABYLON {
  82362. /**
  82363. * Gather the list of keyboard event types as constants.
  82364. */
  82365. export class KeyboardEventTypes {
  82366. /**
  82367. * The keydown event is fired when a key becomes active (pressed).
  82368. */
  82369. static readonly KEYDOWN: number;
  82370. /**
  82371. * The keyup event is fired when a key has been released.
  82372. */
  82373. static readonly KEYUP: number;
  82374. }
  82375. /**
  82376. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82377. */
  82378. export class KeyboardInfo {
  82379. /**
  82380. * Defines the type of event (KeyboardEventTypes)
  82381. */
  82382. type: number;
  82383. /**
  82384. * Defines the related dom event
  82385. */
  82386. event: KeyboardEvent;
  82387. /**
  82388. * Instantiates a new keyboard info.
  82389. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82390. * @param type Defines the type of event (KeyboardEventTypes)
  82391. * @param event Defines the related dom event
  82392. */
  82393. constructor(
  82394. /**
  82395. * Defines the type of event (KeyboardEventTypes)
  82396. */
  82397. type: number,
  82398. /**
  82399. * Defines the related dom event
  82400. */
  82401. event: KeyboardEvent);
  82402. }
  82403. /**
  82404. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82405. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82406. */
  82407. export class KeyboardInfoPre extends KeyboardInfo {
  82408. /**
  82409. * Defines the type of event (KeyboardEventTypes)
  82410. */
  82411. type: number;
  82412. /**
  82413. * Defines the related dom event
  82414. */
  82415. event: KeyboardEvent;
  82416. /**
  82417. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82418. */
  82419. skipOnPointerObservable: boolean;
  82420. /**
  82421. * Instantiates a new keyboard pre info.
  82422. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82423. * @param type Defines the type of event (KeyboardEventTypes)
  82424. * @param event Defines the related dom event
  82425. */
  82426. constructor(
  82427. /**
  82428. * Defines the type of event (KeyboardEventTypes)
  82429. */
  82430. type: number,
  82431. /**
  82432. * Defines the related dom event
  82433. */
  82434. event: KeyboardEvent);
  82435. }
  82436. }
  82437. declare module BABYLON {
  82438. /**
  82439. * Manage the keyboard inputs to control the movement of a free camera.
  82440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82441. */
  82442. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82443. /**
  82444. * Defines the camera the input is attached to.
  82445. */
  82446. camera: FreeCamera;
  82447. /**
  82448. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82449. */
  82450. keysUp: number[];
  82451. /**
  82452. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  82453. */
  82454. keysUpward: number[];
  82455. /**
  82456. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82457. */
  82458. keysDown: number[];
  82459. /**
  82460. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  82461. */
  82462. keysDownward: number[];
  82463. /**
  82464. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82465. */
  82466. keysLeft: number[];
  82467. /**
  82468. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82469. */
  82470. keysRight: number[];
  82471. private _keys;
  82472. private _onCanvasBlurObserver;
  82473. private _onKeyboardObserver;
  82474. private _engine;
  82475. private _scene;
  82476. /**
  82477. * Attach the input controls to a specific dom element to get the input from.
  82478. * @param element Defines the element the controls should be listened from
  82479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82480. */
  82481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82482. /**
  82483. * Detach the current controls from the specified dom element.
  82484. * @param element Defines the element to stop listening the inputs from
  82485. */
  82486. detachControl(element: Nullable<HTMLElement>): void;
  82487. /**
  82488. * Update the current camera state depending on the inputs that have been used this frame.
  82489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82490. */
  82491. checkInputs(): void;
  82492. /**
  82493. * Gets the class name of the current intput.
  82494. * @returns the class name
  82495. */
  82496. getClassName(): string;
  82497. /** @hidden */
  82498. _onLostFocus(): void;
  82499. /**
  82500. * Get the friendly name associated with the input class.
  82501. * @returns the input friendly name
  82502. */
  82503. getSimpleName(): string;
  82504. }
  82505. }
  82506. declare module BABYLON {
  82507. /**
  82508. * Interface describing all the common properties and methods a shadow light needs to implement.
  82509. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82510. * as well as binding the different shadow properties to the effects.
  82511. */
  82512. export interface IShadowLight extends Light {
  82513. /**
  82514. * The light id in the scene (used in scene.findLighById for instance)
  82515. */
  82516. id: string;
  82517. /**
  82518. * The position the shdow will be casted from.
  82519. */
  82520. position: Vector3;
  82521. /**
  82522. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82523. */
  82524. direction: Vector3;
  82525. /**
  82526. * The transformed position. Position of the light in world space taking parenting in account.
  82527. */
  82528. transformedPosition: Vector3;
  82529. /**
  82530. * The transformed direction. Direction of the light in world space taking parenting in account.
  82531. */
  82532. transformedDirection: Vector3;
  82533. /**
  82534. * The friendly name of the light in the scene.
  82535. */
  82536. name: string;
  82537. /**
  82538. * Defines the shadow projection clipping minimum z value.
  82539. */
  82540. shadowMinZ: number;
  82541. /**
  82542. * Defines the shadow projection clipping maximum z value.
  82543. */
  82544. shadowMaxZ: number;
  82545. /**
  82546. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82547. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82548. */
  82549. computeTransformedInformation(): boolean;
  82550. /**
  82551. * Gets the scene the light belongs to.
  82552. * @returns The scene
  82553. */
  82554. getScene(): Scene;
  82555. /**
  82556. * Callback defining a custom Projection Matrix Builder.
  82557. * This can be used to override the default projection matrix computation.
  82558. */
  82559. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82560. /**
  82561. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82562. * @param matrix The materix to updated with the projection information
  82563. * @param viewMatrix The transform matrix of the light
  82564. * @param renderList The list of mesh to render in the map
  82565. * @returns The current light
  82566. */
  82567. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82568. /**
  82569. * Gets the current depth scale used in ESM.
  82570. * @returns The scale
  82571. */
  82572. getDepthScale(): number;
  82573. /**
  82574. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82575. * @returns true if a cube texture needs to be use
  82576. */
  82577. needCube(): boolean;
  82578. /**
  82579. * Detects if the projection matrix requires to be recomputed this frame.
  82580. * @returns true if it requires to be recomputed otherwise, false.
  82581. */
  82582. needProjectionMatrixCompute(): boolean;
  82583. /**
  82584. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82585. */
  82586. forceProjectionMatrixCompute(): void;
  82587. /**
  82588. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82589. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82590. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82591. */
  82592. getShadowDirection(faceIndex?: number): Vector3;
  82593. /**
  82594. * Gets the minZ used for shadow according to both the scene and the light.
  82595. * @param activeCamera The camera we are returning the min for
  82596. * @returns the depth min z
  82597. */
  82598. getDepthMinZ(activeCamera: Camera): number;
  82599. /**
  82600. * Gets the maxZ used for shadow according to both the scene and the light.
  82601. * @param activeCamera The camera we are returning the max for
  82602. * @returns the depth max z
  82603. */
  82604. getDepthMaxZ(activeCamera: Camera): number;
  82605. }
  82606. /**
  82607. * Base implementation IShadowLight
  82608. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82609. */
  82610. export abstract class ShadowLight extends Light implements IShadowLight {
  82611. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82612. protected _position: Vector3;
  82613. protected _setPosition(value: Vector3): void;
  82614. /**
  82615. * Sets the position the shadow will be casted from. Also use as the light position for both
  82616. * point and spot lights.
  82617. */
  82618. get position(): Vector3;
  82619. /**
  82620. * Sets the position the shadow will be casted from. Also use as the light position for both
  82621. * point and spot lights.
  82622. */
  82623. set position(value: Vector3);
  82624. protected _direction: Vector3;
  82625. protected _setDirection(value: Vector3): void;
  82626. /**
  82627. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82628. * Also use as the light direction on spot and directional lights.
  82629. */
  82630. get direction(): Vector3;
  82631. /**
  82632. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82633. * Also use as the light direction on spot and directional lights.
  82634. */
  82635. set direction(value: Vector3);
  82636. protected _shadowMinZ: number;
  82637. /**
  82638. * Gets the shadow projection clipping minimum z value.
  82639. */
  82640. get shadowMinZ(): number;
  82641. /**
  82642. * Sets the shadow projection clipping minimum z value.
  82643. */
  82644. set shadowMinZ(value: number);
  82645. protected _shadowMaxZ: number;
  82646. /**
  82647. * Sets the shadow projection clipping maximum z value.
  82648. */
  82649. get shadowMaxZ(): number;
  82650. /**
  82651. * Gets the shadow projection clipping maximum z value.
  82652. */
  82653. set shadowMaxZ(value: number);
  82654. /**
  82655. * Callback defining a custom Projection Matrix Builder.
  82656. * This can be used to override the default projection matrix computation.
  82657. */
  82658. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82659. /**
  82660. * The transformed position. Position of the light in world space taking parenting in account.
  82661. */
  82662. transformedPosition: Vector3;
  82663. /**
  82664. * The transformed direction. Direction of the light in world space taking parenting in account.
  82665. */
  82666. transformedDirection: Vector3;
  82667. private _needProjectionMatrixCompute;
  82668. /**
  82669. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82670. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82671. */
  82672. computeTransformedInformation(): boolean;
  82673. /**
  82674. * Return the depth scale used for the shadow map.
  82675. * @returns the depth scale.
  82676. */
  82677. getDepthScale(): number;
  82678. /**
  82679. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82680. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82681. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82682. */
  82683. getShadowDirection(faceIndex?: number): Vector3;
  82684. /**
  82685. * Returns the ShadowLight absolute position in the World.
  82686. * @returns the position vector in world space
  82687. */
  82688. getAbsolutePosition(): Vector3;
  82689. /**
  82690. * Sets the ShadowLight direction toward the passed target.
  82691. * @param target The point to target in local space
  82692. * @returns the updated ShadowLight direction
  82693. */
  82694. setDirectionToTarget(target: Vector3): Vector3;
  82695. /**
  82696. * Returns the light rotation in euler definition.
  82697. * @returns the x y z rotation in local space.
  82698. */
  82699. getRotation(): Vector3;
  82700. /**
  82701. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82702. * @returns true if a cube texture needs to be use
  82703. */
  82704. needCube(): boolean;
  82705. /**
  82706. * Detects if the projection matrix requires to be recomputed this frame.
  82707. * @returns true if it requires to be recomputed otherwise, false.
  82708. */
  82709. needProjectionMatrixCompute(): boolean;
  82710. /**
  82711. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82712. */
  82713. forceProjectionMatrixCompute(): void;
  82714. /** @hidden */
  82715. _initCache(): void;
  82716. /** @hidden */
  82717. _isSynchronized(): boolean;
  82718. /**
  82719. * Computes the world matrix of the node
  82720. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82721. * @returns the world matrix
  82722. */
  82723. computeWorldMatrix(force?: boolean): Matrix;
  82724. /**
  82725. * Gets the minZ used for shadow according to both the scene and the light.
  82726. * @param activeCamera The camera we are returning the min for
  82727. * @returns the depth min z
  82728. */
  82729. getDepthMinZ(activeCamera: Camera): number;
  82730. /**
  82731. * Gets the maxZ used for shadow according to both the scene and the light.
  82732. * @param activeCamera The camera we are returning the max for
  82733. * @returns the depth max z
  82734. */
  82735. getDepthMaxZ(activeCamera: Camera): number;
  82736. /**
  82737. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82738. * @param matrix The materix to updated with the projection information
  82739. * @param viewMatrix The transform matrix of the light
  82740. * @param renderList The list of mesh to render in the map
  82741. * @returns The current light
  82742. */
  82743. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82744. }
  82745. }
  82746. declare module BABYLON {
  82747. /**
  82748. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82749. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82750. */
  82751. export class EffectFallbacks implements IEffectFallbacks {
  82752. private _defines;
  82753. private _currentRank;
  82754. private _maxRank;
  82755. private _mesh;
  82756. /**
  82757. * Removes the fallback from the bound mesh.
  82758. */
  82759. unBindMesh(): void;
  82760. /**
  82761. * Adds a fallback on the specified property.
  82762. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82763. * @param define The name of the define in the shader
  82764. */
  82765. addFallback(rank: number, define: string): void;
  82766. /**
  82767. * Sets the mesh to use CPU skinning when needing to fallback.
  82768. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82769. * @param mesh The mesh to use the fallbacks.
  82770. */
  82771. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82772. /**
  82773. * Checks to see if more fallbacks are still availible.
  82774. */
  82775. get hasMoreFallbacks(): boolean;
  82776. /**
  82777. * Removes the defines that should be removed when falling back.
  82778. * @param currentDefines defines the current define statements for the shader.
  82779. * @param effect defines the current effect we try to compile
  82780. * @returns The resulting defines with defines of the current rank removed.
  82781. */
  82782. reduce(currentDefines: string, effect: Effect): string;
  82783. }
  82784. }
  82785. declare module BABYLON {
  82786. /**
  82787. * "Static Class" containing the most commonly used helper while dealing with material for
  82788. * rendering purpose.
  82789. *
  82790. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82791. *
  82792. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82793. */
  82794. export class MaterialHelper {
  82795. /**
  82796. * Bind the current view position to an effect.
  82797. * @param effect The effect to be bound
  82798. * @param scene The scene the eyes position is used from
  82799. */
  82800. static BindEyePosition(effect: Effect, scene: Scene): void;
  82801. /**
  82802. * Helps preparing the defines values about the UVs in used in the effect.
  82803. * UVs are shared as much as we can accross channels in the shaders.
  82804. * @param texture The texture we are preparing the UVs for
  82805. * @param defines The defines to update
  82806. * @param key The channel key "diffuse", "specular"... used in the shader
  82807. */
  82808. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82809. /**
  82810. * Binds a texture matrix value to its corrsponding uniform
  82811. * @param texture The texture to bind the matrix for
  82812. * @param uniformBuffer The uniform buffer receivin the data
  82813. * @param key The channel key "diffuse", "specular"... used in the shader
  82814. */
  82815. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82816. /**
  82817. * Gets the current status of the fog (should it be enabled?)
  82818. * @param mesh defines the mesh to evaluate for fog support
  82819. * @param scene defines the hosting scene
  82820. * @returns true if fog must be enabled
  82821. */
  82822. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82823. /**
  82824. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82825. * @param mesh defines the current mesh
  82826. * @param scene defines the current scene
  82827. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82828. * @param pointsCloud defines if point cloud rendering has to be turned on
  82829. * @param fogEnabled defines if fog has to be turned on
  82830. * @param alphaTest defines if alpha testing has to be turned on
  82831. * @param defines defines the current list of defines
  82832. */
  82833. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82834. /**
  82835. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82836. * @param scene defines the current scene
  82837. * @param engine defines the current engine
  82838. * @param defines specifies the list of active defines
  82839. * @param useInstances defines if instances have to be turned on
  82840. * @param useClipPlane defines if clip plane have to be turned on
  82841. */
  82842. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82843. /**
  82844. * Prepares the defines for bones
  82845. * @param mesh The mesh containing the geometry data we will draw
  82846. * @param defines The defines to update
  82847. */
  82848. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82849. /**
  82850. * Prepares the defines for morph targets
  82851. * @param mesh The mesh containing the geometry data we will draw
  82852. * @param defines The defines to update
  82853. */
  82854. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82855. /**
  82856. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82857. * @param mesh The mesh containing the geometry data we will draw
  82858. * @param defines The defines to update
  82859. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82860. * @param useBones Precise whether bones should be used or not (override mesh info)
  82861. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82862. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82863. * @returns false if defines are considered not dirty and have not been checked
  82864. */
  82865. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82866. /**
  82867. * Prepares the defines related to multiview
  82868. * @param scene The scene we are intending to draw
  82869. * @param defines The defines to update
  82870. */
  82871. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82872. /**
  82873. * Prepares the defines related to the light information passed in parameter
  82874. * @param scene The scene we are intending to draw
  82875. * @param mesh The mesh the effect is compiling for
  82876. * @param light The light the effect is compiling for
  82877. * @param lightIndex The index of the light
  82878. * @param defines The defines to update
  82879. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82880. * @param state Defines the current state regarding what is needed (normals, etc...)
  82881. */
  82882. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82883. needNormals: boolean;
  82884. needRebuild: boolean;
  82885. shadowEnabled: boolean;
  82886. specularEnabled: boolean;
  82887. lightmapMode: boolean;
  82888. }): void;
  82889. /**
  82890. * Prepares the defines related to the light information passed in parameter
  82891. * @param scene The scene we are intending to draw
  82892. * @param mesh The mesh the effect is compiling for
  82893. * @param defines The defines to update
  82894. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82895. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82896. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82897. * @returns true if normals will be required for the rest of the effect
  82898. */
  82899. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82900. /**
  82901. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82902. * @param lightIndex defines the light index
  82903. * @param uniformsList The uniform list
  82904. * @param samplersList The sampler list
  82905. * @param projectedLightTexture defines if projected texture must be used
  82906. * @param uniformBuffersList defines an optional list of uniform buffers
  82907. */
  82908. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82909. /**
  82910. * Prepares the uniforms and samplers list to be used in the effect
  82911. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82912. * @param samplersList The sampler list
  82913. * @param defines The defines helping in the list generation
  82914. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82915. */
  82916. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82917. /**
  82918. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82919. * @param defines The defines to update while falling back
  82920. * @param fallbacks The authorized effect fallbacks
  82921. * @param maxSimultaneousLights The maximum number of lights allowed
  82922. * @param rank the current rank of the Effect
  82923. * @returns The newly affected rank
  82924. */
  82925. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82926. private static _TmpMorphInfluencers;
  82927. /**
  82928. * Prepares the list of attributes required for morph targets according to the effect defines.
  82929. * @param attribs The current list of supported attribs
  82930. * @param mesh The mesh to prepare the morph targets attributes for
  82931. * @param influencers The number of influencers
  82932. */
  82933. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82934. /**
  82935. * Prepares the list of attributes required for morph targets according to the effect defines.
  82936. * @param attribs The current list of supported attribs
  82937. * @param mesh The mesh to prepare the morph targets attributes for
  82938. * @param defines The current Defines of the effect
  82939. */
  82940. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82941. /**
  82942. * Prepares the list of attributes required for bones according to the effect defines.
  82943. * @param attribs The current list of supported attribs
  82944. * @param mesh The mesh to prepare the bones attributes for
  82945. * @param defines The current Defines of the effect
  82946. * @param fallbacks The current efffect fallback strategy
  82947. */
  82948. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82949. /**
  82950. * Check and prepare the list of attributes required for instances according to the effect defines.
  82951. * @param attribs The current list of supported attribs
  82952. * @param defines The current MaterialDefines of the effect
  82953. */
  82954. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82955. /**
  82956. * Add the list of attributes required for instances to the attribs array.
  82957. * @param attribs The current list of supported attribs
  82958. */
  82959. static PushAttributesForInstances(attribs: string[]): void;
  82960. /**
  82961. * Binds the light information to the effect.
  82962. * @param light The light containing the generator
  82963. * @param effect The effect we are binding the data to
  82964. * @param lightIndex The light index in the effect used to render
  82965. */
  82966. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82967. /**
  82968. * Binds the lights information from the scene to the effect for the given mesh.
  82969. * @param light Light to bind
  82970. * @param lightIndex Light index
  82971. * @param scene The scene where the light belongs to
  82972. * @param effect The effect we are binding the data to
  82973. * @param useSpecular Defines if specular is supported
  82974. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82975. */
  82976. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82977. /**
  82978. * Binds the lights information from the scene to the effect for the given mesh.
  82979. * @param scene The scene the lights belongs to
  82980. * @param mesh The mesh we are binding the information to render
  82981. * @param effect The effect we are binding the data to
  82982. * @param defines The generated defines for the effect
  82983. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82984. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82985. */
  82986. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82987. private static _tempFogColor;
  82988. /**
  82989. * Binds the fog information from the scene to the effect for the given mesh.
  82990. * @param scene The scene the lights belongs to
  82991. * @param mesh The mesh we are binding the information to render
  82992. * @param effect The effect we are binding the data to
  82993. * @param linearSpace Defines if the fog effect is applied in linear space
  82994. */
  82995. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82996. /**
  82997. * Binds the bones information from the mesh to the effect.
  82998. * @param mesh The mesh we are binding the information to render
  82999. * @param effect The effect we are binding the data to
  83000. */
  83001. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83002. /**
  83003. * Binds the morph targets information from the mesh to the effect.
  83004. * @param abstractMesh The mesh we are binding the information to render
  83005. * @param effect The effect we are binding the data to
  83006. */
  83007. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83008. /**
  83009. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83010. * @param defines The generated defines used in the effect
  83011. * @param effect The effect we are binding the data to
  83012. * @param scene The scene we are willing to render with logarithmic scale for
  83013. */
  83014. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83015. /**
  83016. * Binds the clip plane information from the scene to the effect.
  83017. * @param scene The scene the clip plane information are extracted from
  83018. * @param effect The effect we are binding the data to
  83019. */
  83020. static BindClipPlane(effect: Effect, scene: Scene): void;
  83021. }
  83022. }
  83023. declare module BABYLON {
  83024. /** @hidden */
  83025. export var packingFunctions: {
  83026. name: string;
  83027. shader: string;
  83028. };
  83029. }
  83030. declare module BABYLON {
  83031. /** @hidden */
  83032. export var clipPlaneFragmentDeclaration: {
  83033. name: string;
  83034. shader: string;
  83035. };
  83036. }
  83037. declare module BABYLON {
  83038. /** @hidden */
  83039. export var clipPlaneFragment: {
  83040. name: string;
  83041. shader: string;
  83042. };
  83043. }
  83044. declare module BABYLON {
  83045. /** @hidden */
  83046. export var shadowMapPixelShader: {
  83047. name: string;
  83048. shader: string;
  83049. };
  83050. }
  83051. declare module BABYLON {
  83052. /** @hidden */
  83053. export var bonesDeclaration: {
  83054. name: string;
  83055. shader: string;
  83056. };
  83057. }
  83058. declare module BABYLON {
  83059. /** @hidden */
  83060. export var morphTargetsVertexGlobalDeclaration: {
  83061. name: string;
  83062. shader: string;
  83063. };
  83064. }
  83065. declare module BABYLON {
  83066. /** @hidden */
  83067. export var morphTargetsVertexDeclaration: {
  83068. name: string;
  83069. shader: string;
  83070. };
  83071. }
  83072. declare module BABYLON {
  83073. /** @hidden */
  83074. export var instancesDeclaration: {
  83075. name: string;
  83076. shader: string;
  83077. };
  83078. }
  83079. declare module BABYLON {
  83080. /** @hidden */
  83081. export var helperFunctions: {
  83082. name: string;
  83083. shader: string;
  83084. };
  83085. }
  83086. declare module BABYLON {
  83087. /** @hidden */
  83088. export var clipPlaneVertexDeclaration: {
  83089. name: string;
  83090. shader: string;
  83091. };
  83092. }
  83093. declare module BABYLON {
  83094. /** @hidden */
  83095. export var morphTargetsVertex: {
  83096. name: string;
  83097. shader: string;
  83098. };
  83099. }
  83100. declare module BABYLON {
  83101. /** @hidden */
  83102. export var instancesVertex: {
  83103. name: string;
  83104. shader: string;
  83105. };
  83106. }
  83107. declare module BABYLON {
  83108. /** @hidden */
  83109. export var bonesVertex: {
  83110. name: string;
  83111. shader: string;
  83112. };
  83113. }
  83114. declare module BABYLON {
  83115. /** @hidden */
  83116. export var clipPlaneVertex: {
  83117. name: string;
  83118. shader: string;
  83119. };
  83120. }
  83121. declare module BABYLON {
  83122. /** @hidden */
  83123. export var shadowMapVertexShader: {
  83124. name: string;
  83125. shader: string;
  83126. };
  83127. }
  83128. declare module BABYLON {
  83129. /** @hidden */
  83130. export var depthBoxBlurPixelShader: {
  83131. name: string;
  83132. shader: string;
  83133. };
  83134. }
  83135. declare module BABYLON {
  83136. /**
  83137. * Class representing a ray with position and direction
  83138. */
  83139. export class Ray {
  83140. /** origin point */
  83141. origin: Vector3;
  83142. /** direction */
  83143. direction: Vector3;
  83144. /** length of the ray */
  83145. length: number;
  83146. private static readonly TmpVector3;
  83147. private _tmpRay;
  83148. /**
  83149. * Creates a new ray
  83150. * @param origin origin point
  83151. * @param direction direction
  83152. * @param length length of the ray
  83153. */
  83154. constructor(
  83155. /** origin point */
  83156. origin: Vector3,
  83157. /** direction */
  83158. direction: Vector3,
  83159. /** length of the ray */
  83160. length?: number);
  83161. /**
  83162. * Checks if the ray intersects a box
  83163. * @param minimum bound of the box
  83164. * @param maximum bound of the box
  83165. * @param intersectionTreshold extra extend to be added to the box in all direction
  83166. * @returns if the box was hit
  83167. */
  83168. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83169. /**
  83170. * Checks if the ray intersects a box
  83171. * @param box the bounding box to check
  83172. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83173. * @returns if the box was hit
  83174. */
  83175. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83176. /**
  83177. * If the ray hits a sphere
  83178. * @param sphere the bounding sphere to check
  83179. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83180. * @returns true if it hits the sphere
  83181. */
  83182. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83183. /**
  83184. * If the ray hits a triange
  83185. * @param vertex0 triangle vertex
  83186. * @param vertex1 triangle vertex
  83187. * @param vertex2 triangle vertex
  83188. * @returns intersection information if hit
  83189. */
  83190. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83191. /**
  83192. * Checks if ray intersects a plane
  83193. * @param plane the plane to check
  83194. * @returns the distance away it was hit
  83195. */
  83196. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83197. /**
  83198. * Calculate the intercept of a ray on a given axis
  83199. * @param axis to check 'x' | 'y' | 'z'
  83200. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83201. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83202. */
  83203. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83204. /**
  83205. * Checks if ray intersects a mesh
  83206. * @param mesh the mesh to check
  83207. * @param fastCheck if only the bounding box should checked
  83208. * @returns picking info of the intersecton
  83209. */
  83210. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83211. /**
  83212. * Checks if ray intersects a mesh
  83213. * @param meshes the meshes to check
  83214. * @param fastCheck if only the bounding box should checked
  83215. * @param results array to store result in
  83216. * @returns Array of picking infos
  83217. */
  83218. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83219. private _comparePickingInfo;
  83220. private static smallnum;
  83221. private static rayl;
  83222. /**
  83223. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83224. * @param sega the first point of the segment to test the intersection against
  83225. * @param segb the second point of the segment to test the intersection against
  83226. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83227. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83228. */
  83229. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83230. /**
  83231. * Update the ray from viewport position
  83232. * @param x position
  83233. * @param y y position
  83234. * @param viewportWidth viewport width
  83235. * @param viewportHeight viewport height
  83236. * @param world world matrix
  83237. * @param view view matrix
  83238. * @param projection projection matrix
  83239. * @returns this ray updated
  83240. */
  83241. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83242. /**
  83243. * Creates a ray with origin and direction of 0,0,0
  83244. * @returns the new ray
  83245. */
  83246. static Zero(): Ray;
  83247. /**
  83248. * Creates a new ray from screen space and viewport
  83249. * @param x position
  83250. * @param y y position
  83251. * @param viewportWidth viewport width
  83252. * @param viewportHeight viewport height
  83253. * @param world world matrix
  83254. * @param view view matrix
  83255. * @param projection projection matrix
  83256. * @returns new ray
  83257. */
  83258. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83259. /**
  83260. * 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
  83261. * transformed to the given world matrix.
  83262. * @param origin The origin point
  83263. * @param end The end point
  83264. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83265. * @returns the new ray
  83266. */
  83267. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83268. /**
  83269. * Transforms a ray by a matrix
  83270. * @param ray ray to transform
  83271. * @param matrix matrix to apply
  83272. * @returns the resulting new ray
  83273. */
  83274. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83275. /**
  83276. * Transforms a ray by a matrix
  83277. * @param ray ray to transform
  83278. * @param matrix matrix to apply
  83279. * @param result ray to store result in
  83280. */
  83281. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83282. /**
  83283. * Unproject a ray from screen space to object space
  83284. * @param sourceX defines the screen space x coordinate to use
  83285. * @param sourceY defines the screen space y coordinate to use
  83286. * @param viewportWidth defines the current width of the viewport
  83287. * @param viewportHeight defines the current height of the viewport
  83288. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83289. * @param view defines the view matrix to use
  83290. * @param projection defines the projection matrix to use
  83291. */
  83292. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83293. }
  83294. /**
  83295. * Type used to define predicate used to select faces when a mesh intersection is detected
  83296. */
  83297. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83298. interface Scene {
  83299. /** @hidden */
  83300. _tempPickingRay: Nullable<Ray>;
  83301. /** @hidden */
  83302. _cachedRayForTransform: Ray;
  83303. /** @hidden */
  83304. _pickWithRayInverseMatrix: Matrix;
  83305. /** @hidden */
  83306. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83307. /** @hidden */
  83308. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83309. }
  83310. }
  83311. declare module BABYLON {
  83312. /**
  83313. * Groups all the scene component constants in one place to ease maintenance.
  83314. * @hidden
  83315. */
  83316. export class SceneComponentConstants {
  83317. static readonly NAME_EFFECTLAYER: string;
  83318. static readonly NAME_LAYER: string;
  83319. static readonly NAME_LENSFLARESYSTEM: string;
  83320. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83321. static readonly NAME_PARTICLESYSTEM: string;
  83322. static readonly NAME_GAMEPAD: string;
  83323. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83324. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83325. static readonly NAME_DEPTHRENDERER: string;
  83326. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83327. static readonly NAME_SPRITE: string;
  83328. static readonly NAME_OUTLINERENDERER: string;
  83329. static readonly NAME_PROCEDURALTEXTURE: string;
  83330. static readonly NAME_SHADOWGENERATOR: string;
  83331. static readonly NAME_OCTREE: string;
  83332. static readonly NAME_PHYSICSENGINE: string;
  83333. static readonly NAME_AUDIO: string;
  83334. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83335. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83336. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83337. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83338. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83339. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83340. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83341. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83342. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83343. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83344. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83345. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83346. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83347. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83348. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83349. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83350. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83351. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83352. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83353. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83354. static readonly STEP_AFTERRENDER_AUDIO: number;
  83355. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83356. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83357. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83358. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83359. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83360. static readonly STEP_POINTERMOVE_SPRITE: number;
  83361. static readonly STEP_POINTERDOWN_SPRITE: number;
  83362. static readonly STEP_POINTERUP_SPRITE: number;
  83363. }
  83364. /**
  83365. * This represents a scene component.
  83366. *
  83367. * This is used to decouple the dependency the scene is having on the different workloads like
  83368. * layers, post processes...
  83369. */
  83370. export interface ISceneComponent {
  83371. /**
  83372. * The name of the component. Each component must have a unique name.
  83373. */
  83374. name: string;
  83375. /**
  83376. * The scene the component belongs to.
  83377. */
  83378. scene: Scene;
  83379. /**
  83380. * Register the component to one instance of a scene.
  83381. */
  83382. register(): void;
  83383. /**
  83384. * Rebuilds the elements related to this component in case of
  83385. * context lost for instance.
  83386. */
  83387. rebuild(): void;
  83388. /**
  83389. * Disposes the component and the associated ressources.
  83390. */
  83391. dispose(): void;
  83392. }
  83393. /**
  83394. * This represents a SERIALIZABLE scene component.
  83395. *
  83396. * This extends Scene Component to add Serialization methods on top.
  83397. */
  83398. export interface ISceneSerializableComponent extends ISceneComponent {
  83399. /**
  83400. * Adds all the elements from the container to the scene
  83401. * @param container the container holding the elements
  83402. */
  83403. addFromContainer(container: AbstractScene): void;
  83404. /**
  83405. * Removes all the elements in the container from the scene
  83406. * @param container contains the elements to remove
  83407. * @param dispose if the removed element should be disposed (default: false)
  83408. */
  83409. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83410. /**
  83411. * Serializes the component data to the specified json object
  83412. * @param serializationObject The object to serialize to
  83413. */
  83414. serialize(serializationObject: any): void;
  83415. }
  83416. /**
  83417. * Strong typing of a Mesh related stage step action
  83418. */
  83419. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83420. /**
  83421. * Strong typing of a Evaluate Sub Mesh related stage step action
  83422. */
  83423. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83424. /**
  83425. * Strong typing of a Active Mesh related stage step action
  83426. */
  83427. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83428. /**
  83429. * Strong typing of a Camera related stage step action
  83430. */
  83431. export type CameraStageAction = (camera: Camera) => void;
  83432. /**
  83433. * Strong typing of a Camera Frame buffer related stage step action
  83434. */
  83435. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83436. /**
  83437. * Strong typing of a Render Target related stage step action
  83438. */
  83439. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83440. /**
  83441. * Strong typing of a RenderingGroup related stage step action
  83442. */
  83443. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83444. /**
  83445. * Strong typing of a Mesh Render related stage step action
  83446. */
  83447. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83448. /**
  83449. * Strong typing of a simple stage step action
  83450. */
  83451. export type SimpleStageAction = () => void;
  83452. /**
  83453. * Strong typing of a render target action.
  83454. */
  83455. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83456. /**
  83457. * Strong typing of a pointer move action.
  83458. */
  83459. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83460. /**
  83461. * Strong typing of a pointer up/down action.
  83462. */
  83463. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83464. /**
  83465. * Representation of a stage in the scene (Basically a list of ordered steps)
  83466. * @hidden
  83467. */
  83468. export class Stage<T extends Function> extends Array<{
  83469. index: number;
  83470. component: ISceneComponent;
  83471. action: T;
  83472. }> {
  83473. /**
  83474. * Hide ctor from the rest of the world.
  83475. * @param items The items to add.
  83476. */
  83477. private constructor();
  83478. /**
  83479. * Creates a new Stage.
  83480. * @returns A new instance of a Stage
  83481. */
  83482. static Create<T extends Function>(): Stage<T>;
  83483. /**
  83484. * Registers a step in an ordered way in the targeted stage.
  83485. * @param index Defines the position to register the step in
  83486. * @param component Defines the component attached to the step
  83487. * @param action Defines the action to launch during the step
  83488. */
  83489. registerStep(index: number, component: ISceneComponent, action: T): void;
  83490. /**
  83491. * Clears all the steps from the stage.
  83492. */
  83493. clear(): void;
  83494. }
  83495. }
  83496. declare module BABYLON {
  83497. interface Scene {
  83498. /** @hidden */
  83499. _pointerOverSprite: Nullable<Sprite>;
  83500. /** @hidden */
  83501. _pickedDownSprite: Nullable<Sprite>;
  83502. /** @hidden */
  83503. _tempSpritePickingRay: Nullable<Ray>;
  83504. /**
  83505. * All of the sprite managers added to this scene
  83506. * @see http://doc.babylonjs.com/babylon101/sprites
  83507. */
  83508. spriteManagers: Array<ISpriteManager>;
  83509. /**
  83510. * An event triggered when sprites rendering is about to start
  83511. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83512. */
  83513. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83514. /**
  83515. * An event triggered when sprites rendering is done
  83516. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83517. */
  83518. onAfterSpritesRenderingObservable: Observable<Scene>;
  83519. /** @hidden */
  83520. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83521. /** Launch a ray to try to pick a sprite in the scene
  83522. * @param x position on screen
  83523. * @param y position on screen
  83524. * @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
  83525. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83526. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83527. * @returns a PickingInfo
  83528. */
  83529. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83530. /** Use the given ray to pick a sprite in the scene
  83531. * @param ray The ray (in world space) to use to pick meshes
  83532. * @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
  83533. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83534. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83535. * @returns a PickingInfo
  83536. */
  83537. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83538. /** @hidden */
  83539. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83540. /** Launch a ray to try to pick sprites in the scene
  83541. * @param x position on screen
  83542. * @param y position on screen
  83543. * @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
  83544. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83545. * @returns a PickingInfo array
  83546. */
  83547. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83548. /** Use the given ray to pick sprites in the scene
  83549. * @param ray The ray (in world space) to use to pick meshes
  83550. * @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
  83551. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83552. * @returns a PickingInfo array
  83553. */
  83554. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83555. /**
  83556. * Force the sprite under the pointer
  83557. * @param sprite defines the sprite to use
  83558. */
  83559. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83560. /**
  83561. * Gets the sprite under the pointer
  83562. * @returns a Sprite or null if no sprite is under the pointer
  83563. */
  83564. getPointerOverSprite(): Nullable<Sprite>;
  83565. }
  83566. /**
  83567. * Defines the sprite scene component responsible to manage sprites
  83568. * in a given scene.
  83569. */
  83570. export class SpriteSceneComponent implements ISceneComponent {
  83571. /**
  83572. * The component name helpfull to identify the component in the list of scene components.
  83573. */
  83574. readonly name: string;
  83575. /**
  83576. * The scene the component belongs to.
  83577. */
  83578. scene: Scene;
  83579. /** @hidden */
  83580. private _spritePredicate;
  83581. /**
  83582. * Creates a new instance of the component for the given scene
  83583. * @param scene Defines the scene to register the component in
  83584. */
  83585. constructor(scene: Scene);
  83586. /**
  83587. * Registers the component in a given scene
  83588. */
  83589. register(): void;
  83590. /**
  83591. * Rebuilds the elements related to this component in case of
  83592. * context lost for instance.
  83593. */
  83594. rebuild(): void;
  83595. /**
  83596. * Disposes the component and the associated ressources.
  83597. */
  83598. dispose(): void;
  83599. private _pickSpriteButKeepRay;
  83600. private _pointerMove;
  83601. private _pointerDown;
  83602. private _pointerUp;
  83603. }
  83604. }
  83605. declare module BABYLON {
  83606. /** @hidden */
  83607. export var fogFragmentDeclaration: {
  83608. name: string;
  83609. shader: string;
  83610. };
  83611. }
  83612. declare module BABYLON {
  83613. /** @hidden */
  83614. export var fogFragment: {
  83615. name: string;
  83616. shader: string;
  83617. };
  83618. }
  83619. declare module BABYLON {
  83620. /** @hidden */
  83621. export var spritesPixelShader: {
  83622. name: string;
  83623. shader: string;
  83624. };
  83625. }
  83626. declare module BABYLON {
  83627. /** @hidden */
  83628. export var fogVertexDeclaration: {
  83629. name: string;
  83630. shader: string;
  83631. };
  83632. }
  83633. declare module BABYLON {
  83634. /** @hidden */
  83635. export var spritesVertexShader: {
  83636. name: string;
  83637. shader: string;
  83638. };
  83639. }
  83640. declare module BABYLON {
  83641. /**
  83642. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83643. */
  83644. export interface ISpriteManager extends IDisposable {
  83645. /**
  83646. * Restricts the camera to viewing objects with the same layerMask.
  83647. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83648. */
  83649. layerMask: number;
  83650. /**
  83651. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83652. */
  83653. isPickable: boolean;
  83654. /**
  83655. * Specifies the rendering group id for this mesh (0 by default)
  83656. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83657. */
  83658. renderingGroupId: number;
  83659. /**
  83660. * Defines the list of sprites managed by the manager.
  83661. */
  83662. sprites: Array<Sprite>;
  83663. /**
  83664. * Tests the intersection of a sprite with a specific ray.
  83665. * @param ray The ray we are sending to test the collision
  83666. * @param camera The camera space we are sending rays in
  83667. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83668. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83669. * @returns picking info or null.
  83670. */
  83671. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83672. /**
  83673. * Intersects the sprites with a ray
  83674. * @param ray defines the ray to intersect with
  83675. * @param camera defines the current active camera
  83676. * @param predicate defines a predicate used to select candidate sprites
  83677. * @returns null if no hit or a PickingInfo array
  83678. */
  83679. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83680. /**
  83681. * Renders the list of sprites on screen.
  83682. */
  83683. render(): void;
  83684. }
  83685. /**
  83686. * Class used to manage multiple sprites on the same spritesheet
  83687. * @see http://doc.babylonjs.com/babylon101/sprites
  83688. */
  83689. export class SpriteManager implements ISpriteManager {
  83690. /** defines the manager's name */
  83691. name: string;
  83692. /** Gets the list of sprites */
  83693. sprites: Sprite[];
  83694. /** Gets or sets the rendering group id (0 by default) */
  83695. renderingGroupId: number;
  83696. /** Gets or sets camera layer mask */
  83697. layerMask: number;
  83698. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83699. fogEnabled: boolean;
  83700. /** Gets or sets a boolean indicating if the sprites are pickable */
  83701. isPickable: boolean;
  83702. /** Defines the default width of a cell in the spritesheet */
  83703. cellWidth: number;
  83704. /** Defines the default height of a cell in the spritesheet */
  83705. cellHeight: number;
  83706. /** Associative array from JSON sprite data file */
  83707. private _cellData;
  83708. /** Array of sprite names from JSON sprite data file */
  83709. private _spriteMap;
  83710. /** True when packed cell data from JSON file is ready*/
  83711. private _packedAndReady;
  83712. /**
  83713. * An event triggered when the manager is disposed.
  83714. */
  83715. onDisposeObservable: Observable<SpriteManager>;
  83716. private _onDisposeObserver;
  83717. /**
  83718. * Callback called when the manager is disposed
  83719. */
  83720. set onDispose(callback: () => void);
  83721. private _capacity;
  83722. private _fromPacked;
  83723. private _spriteTexture;
  83724. private _epsilon;
  83725. private _scene;
  83726. private _vertexData;
  83727. private _buffer;
  83728. private _vertexBuffers;
  83729. private _indexBuffer;
  83730. private _effectBase;
  83731. private _effectFog;
  83732. /**
  83733. * Gets or sets the spritesheet texture
  83734. */
  83735. get texture(): Texture;
  83736. set texture(value: Texture);
  83737. private _blendMode;
  83738. /**
  83739. * Blend mode use to render the particle, it can be any of
  83740. * the static Constants.ALPHA_x properties provided in this class.
  83741. * Default value is Constants.ALPHA_COMBINE
  83742. */
  83743. get blendMode(): number;
  83744. set blendMode(blendMode: number);
  83745. /** Disables writing to the depth buffer when rendering the sprites.
  83746. * It can be handy to disable depth writing when using textures without alpha channel
  83747. * and setting some specific blend modes.
  83748. */
  83749. disableDepthWrite: boolean;
  83750. /**
  83751. * Creates a new sprite manager
  83752. * @param name defines the manager's name
  83753. * @param imgUrl defines the sprite sheet url
  83754. * @param capacity defines the maximum allowed number of sprites
  83755. * @param cellSize defines the size of a sprite cell
  83756. * @param scene defines the hosting scene
  83757. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83758. * @param samplingMode defines the smapling mode to use with spritesheet
  83759. * @param fromPacked set to false; do not alter
  83760. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83761. */
  83762. constructor(
  83763. /** defines the manager's name */
  83764. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83765. private _makePacked;
  83766. private _appendSpriteVertex;
  83767. /**
  83768. * Intersects the sprites with a ray
  83769. * @param ray defines the ray to intersect with
  83770. * @param camera defines the current active camera
  83771. * @param predicate defines a predicate used to select candidate sprites
  83772. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83773. * @returns null if no hit or a PickingInfo
  83774. */
  83775. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83776. /**
  83777. * Intersects the sprites with a ray
  83778. * @param ray defines the ray to intersect with
  83779. * @param camera defines the current active camera
  83780. * @param predicate defines a predicate used to select candidate sprites
  83781. * @returns null if no hit or a PickingInfo array
  83782. */
  83783. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83784. /**
  83785. * Render all child sprites
  83786. */
  83787. render(): void;
  83788. /**
  83789. * Release associated resources
  83790. */
  83791. dispose(): void;
  83792. }
  83793. }
  83794. declare module BABYLON {
  83795. /** Interface used by value gradients (color, factor, ...) */
  83796. export interface IValueGradient {
  83797. /**
  83798. * Gets or sets the gradient value (between 0 and 1)
  83799. */
  83800. gradient: number;
  83801. }
  83802. /** Class used to store color4 gradient */
  83803. export class ColorGradient implements IValueGradient {
  83804. /**
  83805. * Gets or sets the gradient value (between 0 and 1)
  83806. */
  83807. gradient: number;
  83808. /**
  83809. * Gets or sets first associated color
  83810. */
  83811. color1: Color4;
  83812. /**
  83813. * Gets or sets second associated color
  83814. */
  83815. color2?: Color4;
  83816. /**
  83817. * Will get a color picked randomly between color1 and color2.
  83818. * If color2 is undefined then color1 will be used
  83819. * @param result defines the target Color4 to store the result in
  83820. */
  83821. getColorToRef(result: Color4): void;
  83822. }
  83823. /** Class used to store color 3 gradient */
  83824. export class Color3Gradient implements IValueGradient {
  83825. /**
  83826. * Gets or sets the gradient value (between 0 and 1)
  83827. */
  83828. gradient: number;
  83829. /**
  83830. * Gets or sets the associated color
  83831. */
  83832. color: Color3;
  83833. }
  83834. /** Class used to store factor gradient */
  83835. export class FactorGradient implements IValueGradient {
  83836. /**
  83837. * Gets or sets the gradient value (between 0 and 1)
  83838. */
  83839. gradient: number;
  83840. /**
  83841. * Gets or sets first associated factor
  83842. */
  83843. factor1: number;
  83844. /**
  83845. * Gets or sets second associated factor
  83846. */
  83847. factor2?: number;
  83848. /**
  83849. * Will get a number picked randomly between factor1 and factor2.
  83850. * If factor2 is undefined then factor1 will be used
  83851. * @returns the picked number
  83852. */
  83853. getFactor(): number;
  83854. }
  83855. /**
  83856. * Helper used to simplify some generic gradient tasks
  83857. */
  83858. export class GradientHelper {
  83859. /**
  83860. * Gets the current gradient from an array of IValueGradient
  83861. * @param ratio defines the current ratio to get
  83862. * @param gradients defines the array of IValueGradient
  83863. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83864. */
  83865. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83866. }
  83867. }
  83868. declare module BABYLON {
  83869. /**
  83870. * Interface for the size containing width and height
  83871. */
  83872. export interface ISize {
  83873. /**
  83874. * Width
  83875. */
  83876. width: number;
  83877. /**
  83878. * Heighht
  83879. */
  83880. height: number;
  83881. }
  83882. /**
  83883. * Size containing widht and height
  83884. */
  83885. export class Size implements ISize {
  83886. /**
  83887. * Width
  83888. */
  83889. width: number;
  83890. /**
  83891. * Height
  83892. */
  83893. height: number;
  83894. /**
  83895. * Creates a Size object from the given width and height (floats).
  83896. * @param width width of the new size
  83897. * @param height height of the new size
  83898. */
  83899. constructor(width: number, height: number);
  83900. /**
  83901. * Returns a string with the Size width and height
  83902. * @returns a string with the Size width and height
  83903. */
  83904. toString(): string;
  83905. /**
  83906. * "Size"
  83907. * @returns the string "Size"
  83908. */
  83909. getClassName(): string;
  83910. /**
  83911. * Returns the Size hash code.
  83912. * @returns a hash code for a unique width and height
  83913. */
  83914. getHashCode(): number;
  83915. /**
  83916. * Updates the current size from the given one.
  83917. * @param src the given size
  83918. */
  83919. copyFrom(src: Size): void;
  83920. /**
  83921. * Updates in place the current Size from the given floats.
  83922. * @param width width of the new size
  83923. * @param height height of the new size
  83924. * @returns the updated Size.
  83925. */
  83926. copyFromFloats(width: number, height: number): Size;
  83927. /**
  83928. * Updates in place the current Size from the given floats.
  83929. * @param width width to set
  83930. * @param height height to set
  83931. * @returns the updated Size.
  83932. */
  83933. set(width: number, height: number): Size;
  83934. /**
  83935. * Multiplies the width and height by numbers
  83936. * @param w factor to multiple the width by
  83937. * @param h factor to multiple the height by
  83938. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83939. */
  83940. multiplyByFloats(w: number, h: number): Size;
  83941. /**
  83942. * Clones the size
  83943. * @returns a new Size copied from the given one.
  83944. */
  83945. clone(): Size;
  83946. /**
  83947. * True if the current Size and the given one width and height are strictly equal.
  83948. * @param other the other size to compare against
  83949. * @returns True if the current Size and the given one width and height are strictly equal.
  83950. */
  83951. equals(other: Size): boolean;
  83952. /**
  83953. * The surface of the Size : width * height (float).
  83954. */
  83955. get surface(): number;
  83956. /**
  83957. * Create a new size of zero
  83958. * @returns a new Size set to (0.0, 0.0)
  83959. */
  83960. static Zero(): Size;
  83961. /**
  83962. * Sums the width and height of two sizes
  83963. * @param otherSize size to add to this size
  83964. * @returns a new Size set as the addition result of the current Size and the given one.
  83965. */
  83966. add(otherSize: Size): Size;
  83967. /**
  83968. * Subtracts the width and height of two
  83969. * @param otherSize size to subtract to this size
  83970. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83971. */
  83972. subtract(otherSize: Size): Size;
  83973. /**
  83974. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83975. * @param start starting size to lerp between
  83976. * @param end end size to lerp between
  83977. * @param amount amount to lerp between the start and end values
  83978. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83979. */
  83980. static Lerp(start: Size, end: Size, amount: number): Size;
  83981. }
  83982. }
  83983. declare module BABYLON {
  83984. interface ThinEngine {
  83985. /**
  83986. * Creates a dynamic texture
  83987. * @param width defines the width of the texture
  83988. * @param height defines the height of the texture
  83989. * @param generateMipMaps defines if the engine should generate the mip levels
  83990. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83991. * @returns the dynamic texture inside an InternalTexture
  83992. */
  83993. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83994. /**
  83995. * Update the content of a dynamic texture
  83996. * @param texture defines the texture to update
  83997. * @param canvas defines the canvas containing the source
  83998. * @param invertY defines if data must be stored with Y axis inverted
  83999. * @param premulAlpha defines if alpha is stored as premultiplied
  84000. * @param format defines the format of the data
  84001. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84002. */
  84003. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84004. }
  84005. }
  84006. declare module BABYLON {
  84007. /**
  84008. * Helper class used to generate a canvas to manipulate images
  84009. */
  84010. export class CanvasGenerator {
  84011. /**
  84012. * Create a new canvas (or offscreen canvas depending on the context)
  84013. * @param width defines the expected width
  84014. * @param height defines the expected height
  84015. * @return a new canvas or offscreen canvas
  84016. */
  84017. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84018. }
  84019. }
  84020. declare module BABYLON {
  84021. /**
  84022. * A class extending Texture allowing drawing on a texture
  84023. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84024. */
  84025. export class DynamicTexture extends Texture {
  84026. private _generateMipMaps;
  84027. private _canvas;
  84028. private _context;
  84029. private _engine;
  84030. /**
  84031. * Creates a DynamicTexture
  84032. * @param name defines the name of the texture
  84033. * @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
  84034. * @param scene defines the scene where you want the texture
  84035. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84036. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84037. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84038. */
  84039. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84040. /**
  84041. * Get the current class name of the texture useful for serialization or dynamic coding.
  84042. * @returns "DynamicTexture"
  84043. */
  84044. getClassName(): string;
  84045. /**
  84046. * Gets the current state of canRescale
  84047. */
  84048. get canRescale(): boolean;
  84049. private _recreate;
  84050. /**
  84051. * Scales the texture
  84052. * @param ratio the scale factor to apply to both width and height
  84053. */
  84054. scale(ratio: number): void;
  84055. /**
  84056. * Resizes the texture
  84057. * @param width the new width
  84058. * @param height the new height
  84059. */
  84060. scaleTo(width: number, height: number): void;
  84061. /**
  84062. * Gets the context of the canvas used by the texture
  84063. * @returns the canvas context of the dynamic texture
  84064. */
  84065. getContext(): CanvasRenderingContext2D;
  84066. /**
  84067. * Clears the texture
  84068. */
  84069. clear(): void;
  84070. /**
  84071. * Updates the texture
  84072. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84073. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84074. */
  84075. update(invertY?: boolean, premulAlpha?: boolean): void;
  84076. /**
  84077. * Draws text onto the texture
  84078. * @param text defines the text to be drawn
  84079. * @param x defines the placement of the text from the left
  84080. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84081. * @param font defines the font to be used with font-style, font-size, font-name
  84082. * @param color defines the color used for the text
  84083. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84084. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84085. * @param update defines whether texture is immediately update (default is true)
  84086. */
  84087. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84088. /**
  84089. * Clones the texture
  84090. * @returns the clone of the texture.
  84091. */
  84092. clone(): DynamicTexture;
  84093. /**
  84094. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84095. * @returns a serialized dynamic texture object
  84096. */
  84097. serialize(): any;
  84098. /** @hidden */
  84099. _rebuild(): void;
  84100. }
  84101. }
  84102. declare module BABYLON {
  84103. interface Engine {
  84104. /**
  84105. * Creates a raw texture
  84106. * @param data defines the data to store in the texture
  84107. * @param width defines the width of the texture
  84108. * @param height defines the height of the texture
  84109. * @param format defines the format of the data
  84110. * @param generateMipMaps defines if the engine should generate the mip levels
  84111. * @param invertY defines if data must be stored with Y axis inverted
  84112. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84113. * @param compression defines the compression used (null by default)
  84114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84115. * @returns the raw texture inside an InternalTexture
  84116. */
  84117. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84118. /**
  84119. * Update a raw texture
  84120. * @param texture defines the texture to update
  84121. * @param data defines the data to store in the texture
  84122. * @param format defines the format of the data
  84123. * @param invertY defines if data must be stored with Y axis inverted
  84124. */
  84125. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84126. /**
  84127. * Update a raw texture
  84128. * @param texture defines the texture to update
  84129. * @param data defines the data to store in the texture
  84130. * @param format defines the format of the data
  84131. * @param invertY defines if data must be stored with Y axis inverted
  84132. * @param compression defines the compression used (null by default)
  84133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84134. */
  84135. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84136. /**
  84137. * Creates a new raw cube texture
  84138. * @param data defines the array of data to use to create each face
  84139. * @param size defines the size of the textures
  84140. * @param format defines the format of the data
  84141. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84142. * @param generateMipMaps defines if the engine should generate the mip levels
  84143. * @param invertY defines if data must be stored with Y axis inverted
  84144. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84145. * @param compression defines the compression used (null by default)
  84146. * @returns the cube texture as an InternalTexture
  84147. */
  84148. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84149. /**
  84150. * Update a raw cube texture
  84151. * @param texture defines the texture to udpdate
  84152. * @param data defines the data to store
  84153. * @param format defines the data format
  84154. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84155. * @param invertY defines if data must be stored with Y axis inverted
  84156. */
  84157. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84158. /**
  84159. * Update a raw cube texture
  84160. * @param texture defines the texture to udpdate
  84161. * @param data defines the data to store
  84162. * @param format defines the data format
  84163. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84164. * @param invertY defines if data must be stored with Y axis inverted
  84165. * @param compression defines the compression used (null by default)
  84166. */
  84167. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84168. /**
  84169. * Update a raw cube texture
  84170. * @param texture defines the texture to udpdate
  84171. * @param data defines the data to store
  84172. * @param format defines the data format
  84173. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84174. * @param invertY defines if data must be stored with Y axis inverted
  84175. * @param compression defines the compression used (null by default)
  84176. * @param level defines which level of the texture to update
  84177. */
  84178. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84179. /**
  84180. * Creates a new raw cube texture from a specified url
  84181. * @param url defines the url where the data is located
  84182. * @param scene defines the current scene
  84183. * @param size defines the size of the textures
  84184. * @param format defines the format of the data
  84185. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84186. * @param noMipmap defines if the engine should avoid generating the mip levels
  84187. * @param callback defines a callback used to extract texture data from loaded data
  84188. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84189. * @param onLoad defines a callback called when texture is loaded
  84190. * @param onError defines a callback called if there is an error
  84191. * @returns the cube texture as an InternalTexture
  84192. */
  84193. 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;
  84194. /**
  84195. * Creates a new raw cube texture from a specified url
  84196. * @param url defines the url where the data is located
  84197. * @param scene defines the current scene
  84198. * @param size defines the size of the textures
  84199. * @param format defines the format of the data
  84200. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84201. * @param noMipmap defines if the engine should avoid generating the mip levels
  84202. * @param callback defines a callback used to extract texture data from loaded data
  84203. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84204. * @param onLoad defines a callback called when texture is loaded
  84205. * @param onError defines a callback called if there is an error
  84206. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84207. * @param invertY defines if data must be stored with Y axis inverted
  84208. * @returns the cube texture as an InternalTexture
  84209. */
  84210. 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;
  84211. /**
  84212. * Creates a new raw 3D texture
  84213. * @param data defines the data used to create the texture
  84214. * @param width defines the width of the texture
  84215. * @param height defines the height of the texture
  84216. * @param depth defines the depth of the texture
  84217. * @param format defines the format of the texture
  84218. * @param generateMipMaps defines if the engine must generate mip levels
  84219. * @param invertY defines if data must be stored with Y axis inverted
  84220. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84221. * @param compression defines the compressed used (can be null)
  84222. * @param textureType defines the compressed used (can be null)
  84223. * @returns a new raw 3D texture (stored in an InternalTexture)
  84224. */
  84225. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84226. /**
  84227. * Update a raw 3D texture
  84228. * @param texture defines the texture to update
  84229. * @param data defines the data to store
  84230. * @param format defines the data format
  84231. * @param invertY defines if data must be stored with Y axis inverted
  84232. */
  84233. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84234. /**
  84235. * Update a raw 3D texture
  84236. * @param texture defines the texture to update
  84237. * @param data defines the data to store
  84238. * @param format defines the data format
  84239. * @param invertY defines if data must be stored with Y axis inverted
  84240. * @param compression defines the used compression (can be null)
  84241. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84242. */
  84243. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84244. /**
  84245. * Creates a new raw 2D array texture
  84246. * @param data defines the data used to create the texture
  84247. * @param width defines the width of the texture
  84248. * @param height defines the height of the texture
  84249. * @param depth defines the number of layers of the texture
  84250. * @param format defines the format of the texture
  84251. * @param generateMipMaps defines if the engine must generate mip levels
  84252. * @param invertY defines if data must be stored with Y axis inverted
  84253. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84254. * @param compression defines the compressed used (can be null)
  84255. * @param textureType defines the compressed used (can be null)
  84256. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84257. */
  84258. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84259. /**
  84260. * Update a raw 2D array texture
  84261. * @param texture defines the texture to update
  84262. * @param data defines the data to store
  84263. * @param format defines the data format
  84264. * @param invertY defines if data must be stored with Y axis inverted
  84265. */
  84266. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84267. /**
  84268. * Update a raw 2D array texture
  84269. * @param texture defines the texture to update
  84270. * @param data defines the data to store
  84271. * @param format defines the data format
  84272. * @param invertY defines if data must be stored with Y axis inverted
  84273. * @param compression defines the used compression (can be null)
  84274. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84275. */
  84276. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84277. }
  84278. }
  84279. declare module BABYLON {
  84280. /**
  84281. * Raw texture can help creating a texture directly from an array of data.
  84282. * This can be super useful if you either get the data from an uncompressed source or
  84283. * if you wish to create your texture pixel by pixel.
  84284. */
  84285. export class RawTexture extends Texture {
  84286. /**
  84287. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84288. */
  84289. format: number;
  84290. private _engine;
  84291. /**
  84292. * Instantiates a new RawTexture.
  84293. * Raw texture can help creating a texture directly from an array of data.
  84294. * This can be super useful if you either get the data from an uncompressed source or
  84295. * if you wish to create your texture pixel by pixel.
  84296. * @param data define the array of data to use to create the texture
  84297. * @param width define the width of the texture
  84298. * @param height define the height of the texture
  84299. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84300. * @param scene define the scene the texture belongs to
  84301. * @param generateMipMaps define whether mip maps should be generated or not
  84302. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84303. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84304. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84305. */
  84306. constructor(data: ArrayBufferView, width: number, height: number,
  84307. /**
  84308. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84309. */
  84310. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84311. /**
  84312. * Updates the texture underlying data.
  84313. * @param data Define the new data of the texture
  84314. */
  84315. update(data: ArrayBufferView): void;
  84316. /**
  84317. * Creates a luminance texture from some data.
  84318. * @param data Define the texture data
  84319. * @param width Define the width of the texture
  84320. * @param height Define the height of the texture
  84321. * @param scene Define the scene the texture belongs to
  84322. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84323. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84324. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84325. * @returns the luminance texture
  84326. */
  84327. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84328. /**
  84329. * Creates a luminance alpha texture from some data.
  84330. * @param data Define the texture data
  84331. * @param width Define the width of the texture
  84332. * @param height Define the height of the texture
  84333. * @param scene Define the scene the texture belongs to
  84334. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84335. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84336. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84337. * @returns the luminance alpha texture
  84338. */
  84339. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84340. /**
  84341. * Creates an alpha texture from some data.
  84342. * @param data Define the texture data
  84343. * @param width Define the width of the texture
  84344. * @param height Define the height of the texture
  84345. * @param scene Define the scene the texture belongs to
  84346. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84349. * @returns the alpha texture
  84350. */
  84351. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84352. /**
  84353. * Creates a RGB texture from some data.
  84354. * @param data Define the texture data
  84355. * @param width Define the width of the texture
  84356. * @param height Define the height of the texture
  84357. * @param scene Define the scene the texture belongs to
  84358. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84359. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84360. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84361. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84362. * @returns the RGB alpha texture
  84363. */
  84364. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84365. /**
  84366. * Creates a RGBA texture from some data.
  84367. * @param data Define the texture data
  84368. * @param width Define the width of the texture
  84369. * @param height Define the height of the texture
  84370. * @param scene Define the scene the texture belongs to
  84371. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84372. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84373. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84374. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84375. * @returns the RGBA texture
  84376. */
  84377. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84378. /**
  84379. * Creates a R texture from some data.
  84380. * @param data Define the texture data
  84381. * @param width Define the width of the texture
  84382. * @param height Define the height of the texture
  84383. * @param scene Define the scene the texture belongs to
  84384. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84385. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84386. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84387. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84388. * @returns the R texture
  84389. */
  84390. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84391. }
  84392. }
  84393. declare module BABYLON {
  84394. interface AbstractScene {
  84395. /**
  84396. * The list of procedural textures added to the scene
  84397. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84398. */
  84399. proceduralTextures: Array<ProceduralTexture>;
  84400. }
  84401. /**
  84402. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84403. * in a given scene.
  84404. */
  84405. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84406. /**
  84407. * The component name helpfull to identify the component in the list of scene components.
  84408. */
  84409. readonly name: string;
  84410. /**
  84411. * The scene the component belongs to.
  84412. */
  84413. scene: Scene;
  84414. /**
  84415. * Creates a new instance of the component for the given scene
  84416. * @param scene Defines the scene to register the component in
  84417. */
  84418. constructor(scene: Scene);
  84419. /**
  84420. * Registers the component in a given scene
  84421. */
  84422. register(): void;
  84423. /**
  84424. * Rebuilds the elements related to this component in case of
  84425. * context lost for instance.
  84426. */
  84427. rebuild(): void;
  84428. /**
  84429. * Disposes the component and the associated ressources.
  84430. */
  84431. dispose(): void;
  84432. private _beforeClear;
  84433. }
  84434. }
  84435. declare module BABYLON {
  84436. interface ThinEngine {
  84437. /**
  84438. * Creates a new render target cube texture
  84439. * @param size defines the size of the texture
  84440. * @param options defines the options used to create the texture
  84441. * @returns a new render target cube texture stored in an InternalTexture
  84442. */
  84443. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84444. }
  84445. }
  84446. declare module BABYLON {
  84447. /** @hidden */
  84448. export var proceduralVertexShader: {
  84449. name: string;
  84450. shader: string;
  84451. };
  84452. }
  84453. declare module BABYLON {
  84454. /**
  84455. * 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.
  84456. * This is the base class of any Procedural texture and contains most of the shareable code.
  84457. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84458. */
  84459. export class ProceduralTexture extends Texture {
  84460. isCube: boolean;
  84461. /**
  84462. * Define if the texture is enabled or not (disabled texture will not render)
  84463. */
  84464. isEnabled: boolean;
  84465. /**
  84466. * Define if the texture must be cleared before rendering (default is true)
  84467. */
  84468. autoClear: boolean;
  84469. /**
  84470. * Callback called when the texture is generated
  84471. */
  84472. onGenerated: () => void;
  84473. /**
  84474. * Event raised when the texture is generated
  84475. */
  84476. onGeneratedObservable: Observable<ProceduralTexture>;
  84477. /** @hidden */
  84478. _generateMipMaps: boolean;
  84479. /** @hidden **/
  84480. _effect: Effect;
  84481. /** @hidden */
  84482. _textures: {
  84483. [key: string]: Texture;
  84484. };
  84485. private _size;
  84486. private _currentRefreshId;
  84487. private _frameId;
  84488. private _refreshRate;
  84489. private _vertexBuffers;
  84490. private _indexBuffer;
  84491. private _uniforms;
  84492. private _samplers;
  84493. private _fragment;
  84494. private _floats;
  84495. private _ints;
  84496. private _floatsArrays;
  84497. private _colors3;
  84498. private _colors4;
  84499. private _vectors2;
  84500. private _vectors3;
  84501. private _matrices;
  84502. private _fallbackTexture;
  84503. private _fallbackTextureUsed;
  84504. private _engine;
  84505. private _cachedDefines;
  84506. private _contentUpdateId;
  84507. private _contentData;
  84508. /**
  84509. * Instantiates a new procedural texture.
  84510. * 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.
  84511. * This is the base class of any Procedural texture and contains most of the shareable code.
  84512. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84513. * @param name Define the name of the texture
  84514. * @param size Define the size of the texture to create
  84515. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84516. * @param scene Define the scene the texture belongs to
  84517. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84518. * @param generateMipMaps Define if the texture should creates mip maps or not
  84519. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84520. */
  84521. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84522. /**
  84523. * The effect that is created when initializing the post process.
  84524. * @returns The created effect corresponding the the postprocess.
  84525. */
  84526. getEffect(): Effect;
  84527. /**
  84528. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84529. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84530. */
  84531. getContent(): Nullable<ArrayBufferView>;
  84532. private _createIndexBuffer;
  84533. /** @hidden */
  84534. _rebuild(): void;
  84535. /**
  84536. * Resets the texture in order to recreate its associated resources.
  84537. * This can be called in case of context loss
  84538. */
  84539. reset(): void;
  84540. protected _getDefines(): string;
  84541. /**
  84542. * Is the texture ready to be used ? (rendered at least once)
  84543. * @returns true if ready, otherwise, false.
  84544. */
  84545. isReady(): boolean;
  84546. /**
  84547. * Resets the refresh counter of the texture and start bak from scratch.
  84548. * Could be useful to regenerate the texture if it is setup to render only once.
  84549. */
  84550. resetRefreshCounter(): void;
  84551. /**
  84552. * Set the fragment shader to use in order to render the texture.
  84553. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84554. */
  84555. setFragment(fragment: any): void;
  84556. /**
  84557. * Define the refresh rate of the texture or the rendering frequency.
  84558. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84559. */
  84560. get refreshRate(): number;
  84561. set refreshRate(value: number);
  84562. /** @hidden */
  84563. _shouldRender(): boolean;
  84564. /**
  84565. * Get the size the texture is rendering at.
  84566. * @returns the size (texture is always squared)
  84567. */
  84568. getRenderSize(): number;
  84569. /**
  84570. * Resize the texture to new value.
  84571. * @param size Define the new size the texture should have
  84572. * @param generateMipMaps Define whether the new texture should create mip maps
  84573. */
  84574. resize(size: number, generateMipMaps: boolean): void;
  84575. private _checkUniform;
  84576. /**
  84577. * Set a texture in the shader program used to render.
  84578. * @param name Define the name of the uniform samplers as defined in the shader
  84579. * @param texture Define the texture to bind to this sampler
  84580. * @return the texture itself allowing "fluent" like uniform updates
  84581. */
  84582. setTexture(name: string, texture: Texture): ProceduralTexture;
  84583. /**
  84584. * Set a float in the shader.
  84585. * @param name Define the name of the uniform as defined in the shader
  84586. * @param value Define the value to give to the uniform
  84587. * @return the texture itself allowing "fluent" like uniform updates
  84588. */
  84589. setFloat(name: string, value: number): ProceduralTexture;
  84590. /**
  84591. * Set a int in the shader.
  84592. * @param name Define the name of the uniform as defined in the shader
  84593. * @param value Define the value to give to the uniform
  84594. * @return the texture itself allowing "fluent" like uniform updates
  84595. */
  84596. setInt(name: string, value: number): ProceduralTexture;
  84597. /**
  84598. * Set an array of floats in the shader.
  84599. * @param name Define the name of the uniform as defined in the shader
  84600. * @param value Define the value to give to the uniform
  84601. * @return the texture itself allowing "fluent" like uniform updates
  84602. */
  84603. setFloats(name: string, value: number[]): ProceduralTexture;
  84604. /**
  84605. * Set a vec3 in the shader from a Color3.
  84606. * @param name Define the name of the uniform as defined in the shader
  84607. * @param value Define the value to give to the uniform
  84608. * @return the texture itself allowing "fluent" like uniform updates
  84609. */
  84610. setColor3(name: string, value: Color3): ProceduralTexture;
  84611. /**
  84612. * Set a vec4 in the shader from a Color4.
  84613. * @param name Define the name of the uniform as defined in the shader
  84614. * @param value Define the value to give to the uniform
  84615. * @return the texture itself allowing "fluent" like uniform updates
  84616. */
  84617. setColor4(name: string, value: Color4): ProceduralTexture;
  84618. /**
  84619. * Set a vec2 in the shader from a Vector2.
  84620. * @param name Define the name of the uniform as defined in the shader
  84621. * @param value Define the value to give to the uniform
  84622. * @return the texture itself allowing "fluent" like uniform updates
  84623. */
  84624. setVector2(name: string, value: Vector2): ProceduralTexture;
  84625. /**
  84626. * Set a vec3 in the shader from a Vector3.
  84627. * @param name Define the name of the uniform as defined in the shader
  84628. * @param value Define the value to give to the uniform
  84629. * @return the texture itself allowing "fluent" like uniform updates
  84630. */
  84631. setVector3(name: string, value: Vector3): ProceduralTexture;
  84632. /**
  84633. * Set a mat4 in the shader from a MAtrix.
  84634. * @param name Define the name of the uniform as defined in the shader
  84635. * @param value Define the value to give to the uniform
  84636. * @return the texture itself allowing "fluent" like uniform updates
  84637. */
  84638. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84639. /**
  84640. * Render the texture to its associated render target.
  84641. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84642. */
  84643. render(useCameraPostProcess?: boolean): void;
  84644. /**
  84645. * Clone the texture.
  84646. * @returns the cloned texture
  84647. */
  84648. clone(): ProceduralTexture;
  84649. /**
  84650. * Dispose the texture and release its asoociated resources.
  84651. */
  84652. dispose(): void;
  84653. }
  84654. }
  84655. declare module BABYLON {
  84656. /**
  84657. * This represents the base class for particle system in Babylon.
  84658. * 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.
  84659. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84660. * @example https://doc.babylonjs.com/babylon101/particles
  84661. */
  84662. export class BaseParticleSystem {
  84663. /**
  84664. * Source color is added to the destination color without alpha affecting the result
  84665. */
  84666. static BLENDMODE_ONEONE: number;
  84667. /**
  84668. * Blend current color and particle color using particle’s alpha
  84669. */
  84670. static BLENDMODE_STANDARD: number;
  84671. /**
  84672. * Add current color and particle color multiplied by particle’s alpha
  84673. */
  84674. static BLENDMODE_ADD: number;
  84675. /**
  84676. * Multiply current color with particle color
  84677. */
  84678. static BLENDMODE_MULTIPLY: number;
  84679. /**
  84680. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84681. */
  84682. static BLENDMODE_MULTIPLYADD: number;
  84683. /**
  84684. * List of animations used by the particle system.
  84685. */
  84686. animations: Animation[];
  84687. /**
  84688. * The id of the Particle system.
  84689. */
  84690. id: string;
  84691. /**
  84692. * The friendly name of the Particle system.
  84693. */
  84694. name: string;
  84695. /**
  84696. * The rendering group used by the Particle system to chose when to render.
  84697. */
  84698. renderingGroupId: number;
  84699. /**
  84700. * The emitter represents the Mesh or position we are attaching the particle system to.
  84701. */
  84702. emitter: Nullable<AbstractMesh | Vector3>;
  84703. /**
  84704. * The maximum number of particles to emit per frame
  84705. */
  84706. emitRate: number;
  84707. /**
  84708. * If you want to launch only a few particles at once, that can be done, as well.
  84709. */
  84710. manualEmitCount: number;
  84711. /**
  84712. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84713. */
  84714. updateSpeed: number;
  84715. /**
  84716. * The amount of time the particle system is running (depends of the overall update speed).
  84717. */
  84718. targetStopDuration: number;
  84719. /**
  84720. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84721. */
  84722. disposeOnStop: boolean;
  84723. /**
  84724. * Minimum power of emitting particles.
  84725. */
  84726. minEmitPower: number;
  84727. /**
  84728. * Maximum power of emitting particles.
  84729. */
  84730. maxEmitPower: number;
  84731. /**
  84732. * Minimum life time of emitting particles.
  84733. */
  84734. minLifeTime: number;
  84735. /**
  84736. * Maximum life time of emitting particles.
  84737. */
  84738. maxLifeTime: number;
  84739. /**
  84740. * Minimum Size of emitting particles.
  84741. */
  84742. minSize: number;
  84743. /**
  84744. * Maximum Size of emitting particles.
  84745. */
  84746. maxSize: number;
  84747. /**
  84748. * Minimum scale of emitting particles on X axis.
  84749. */
  84750. minScaleX: number;
  84751. /**
  84752. * Maximum scale of emitting particles on X axis.
  84753. */
  84754. maxScaleX: number;
  84755. /**
  84756. * Minimum scale of emitting particles on Y axis.
  84757. */
  84758. minScaleY: number;
  84759. /**
  84760. * Maximum scale of emitting particles on Y axis.
  84761. */
  84762. maxScaleY: number;
  84763. /**
  84764. * Gets or sets the minimal initial rotation in radians.
  84765. */
  84766. minInitialRotation: number;
  84767. /**
  84768. * Gets or sets the maximal initial rotation in radians.
  84769. */
  84770. maxInitialRotation: number;
  84771. /**
  84772. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84773. */
  84774. minAngularSpeed: number;
  84775. /**
  84776. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84777. */
  84778. maxAngularSpeed: number;
  84779. /**
  84780. * The texture used to render each particle. (this can be a spritesheet)
  84781. */
  84782. particleTexture: Nullable<Texture>;
  84783. /**
  84784. * The layer mask we are rendering the particles through.
  84785. */
  84786. layerMask: number;
  84787. /**
  84788. * This can help using your own shader to render the particle system.
  84789. * The according effect will be created
  84790. */
  84791. customShader: any;
  84792. /**
  84793. * By default particle system starts as soon as they are created. This prevents the
  84794. * automatic start to happen and let you decide when to start emitting particles.
  84795. */
  84796. preventAutoStart: boolean;
  84797. private _noiseTexture;
  84798. /**
  84799. * Gets or sets a texture used to add random noise to particle positions
  84800. */
  84801. get noiseTexture(): Nullable<ProceduralTexture>;
  84802. set noiseTexture(value: Nullable<ProceduralTexture>);
  84803. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84804. noiseStrength: Vector3;
  84805. /**
  84806. * Callback triggered when the particle animation is ending.
  84807. */
  84808. onAnimationEnd: Nullable<() => void>;
  84809. /**
  84810. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84811. */
  84812. blendMode: number;
  84813. /**
  84814. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84815. * to override the particles.
  84816. */
  84817. forceDepthWrite: boolean;
  84818. /** 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 */
  84819. preWarmCycles: number;
  84820. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84821. preWarmStepOffset: number;
  84822. /**
  84823. * 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)
  84824. */
  84825. spriteCellChangeSpeed: number;
  84826. /**
  84827. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84828. */
  84829. startSpriteCellID: number;
  84830. /**
  84831. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84832. */
  84833. endSpriteCellID: number;
  84834. /**
  84835. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84836. */
  84837. spriteCellWidth: number;
  84838. /**
  84839. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84840. */
  84841. spriteCellHeight: number;
  84842. /**
  84843. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84844. */
  84845. spriteRandomStartCell: boolean;
  84846. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84847. translationPivot: Vector2;
  84848. /** @hidden */
  84849. protected _isAnimationSheetEnabled: boolean;
  84850. /**
  84851. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84852. */
  84853. beginAnimationOnStart: boolean;
  84854. /**
  84855. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84856. */
  84857. beginAnimationFrom: number;
  84858. /**
  84859. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84860. */
  84861. beginAnimationTo: number;
  84862. /**
  84863. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84864. */
  84865. beginAnimationLoop: boolean;
  84866. /**
  84867. * Gets or sets a world offset applied to all particles
  84868. */
  84869. worldOffset: Vector3;
  84870. /**
  84871. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84872. */
  84873. get isAnimationSheetEnabled(): boolean;
  84874. set isAnimationSheetEnabled(value: boolean);
  84875. /**
  84876. * Get hosting scene
  84877. * @returns the scene
  84878. */
  84879. getScene(): Scene;
  84880. /**
  84881. * You can use gravity if you want to give an orientation to your particles.
  84882. */
  84883. gravity: Vector3;
  84884. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84885. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84886. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84887. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84888. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84889. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84890. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84891. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84892. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84893. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84894. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84895. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84896. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84897. /**
  84898. * Defines the delay in milliseconds before starting the system (0 by default)
  84899. */
  84900. startDelay: number;
  84901. /**
  84902. * Gets the current list of drag gradients.
  84903. * You must use addDragGradient and removeDragGradient to udpate this list
  84904. * @returns the list of drag gradients
  84905. */
  84906. getDragGradients(): Nullable<Array<FactorGradient>>;
  84907. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84908. limitVelocityDamping: number;
  84909. /**
  84910. * Gets the current list of limit velocity gradients.
  84911. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84912. * @returns the list of limit velocity gradients
  84913. */
  84914. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84915. /**
  84916. * Gets the current list of color gradients.
  84917. * You must use addColorGradient and removeColorGradient to udpate this list
  84918. * @returns the list of color gradients
  84919. */
  84920. getColorGradients(): Nullable<Array<ColorGradient>>;
  84921. /**
  84922. * Gets the current list of size gradients.
  84923. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84924. * @returns the list of size gradients
  84925. */
  84926. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84927. /**
  84928. * Gets the current list of color remap gradients.
  84929. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84930. * @returns the list of color remap gradients
  84931. */
  84932. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84933. /**
  84934. * Gets the current list of alpha remap gradients.
  84935. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84936. * @returns the list of alpha remap gradients
  84937. */
  84938. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84939. /**
  84940. * Gets the current list of life time gradients.
  84941. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84942. * @returns the list of life time gradients
  84943. */
  84944. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84945. /**
  84946. * Gets the current list of angular speed gradients.
  84947. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84948. * @returns the list of angular speed gradients
  84949. */
  84950. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84951. /**
  84952. * Gets the current list of velocity gradients.
  84953. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84954. * @returns the list of velocity gradients
  84955. */
  84956. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84957. /**
  84958. * Gets the current list of start size gradients.
  84959. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84960. * @returns the list of start size gradients
  84961. */
  84962. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84963. /**
  84964. * Gets the current list of emit rate gradients.
  84965. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84966. * @returns the list of emit rate gradients
  84967. */
  84968. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84969. /**
  84970. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84971. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84972. */
  84973. get direction1(): Vector3;
  84974. set direction1(value: Vector3);
  84975. /**
  84976. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84977. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84978. */
  84979. get direction2(): Vector3;
  84980. set direction2(value: Vector3);
  84981. /**
  84982. * 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.
  84983. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84984. */
  84985. get minEmitBox(): Vector3;
  84986. set minEmitBox(value: Vector3);
  84987. /**
  84988. * 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.
  84989. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84990. */
  84991. get maxEmitBox(): Vector3;
  84992. set maxEmitBox(value: Vector3);
  84993. /**
  84994. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84995. */
  84996. color1: Color4;
  84997. /**
  84998. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84999. */
  85000. color2: Color4;
  85001. /**
  85002. * Color the particle will have at the end of its lifetime
  85003. */
  85004. colorDead: Color4;
  85005. /**
  85006. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85007. */
  85008. textureMask: Color4;
  85009. /**
  85010. * The particle emitter type defines the emitter used by the particle system.
  85011. * It can be for example box, sphere, or cone...
  85012. */
  85013. particleEmitterType: IParticleEmitterType;
  85014. /** @hidden */
  85015. _isSubEmitter: boolean;
  85016. /**
  85017. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85018. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85019. */
  85020. billboardMode: number;
  85021. protected _isBillboardBased: boolean;
  85022. /**
  85023. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85024. */
  85025. get isBillboardBased(): boolean;
  85026. set isBillboardBased(value: boolean);
  85027. /**
  85028. * The scene the particle system belongs to.
  85029. */
  85030. protected _scene: Scene;
  85031. /**
  85032. * Local cache of defines for image processing.
  85033. */
  85034. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85035. /**
  85036. * Default configuration related to image processing available in the standard Material.
  85037. */
  85038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85039. /**
  85040. * Gets the image processing configuration used either in this material.
  85041. */
  85042. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85043. /**
  85044. * Sets the Default image processing configuration used either in the this material.
  85045. *
  85046. * If sets to null, the scene one is in use.
  85047. */
  85048. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85049. /**
  85050. * Attaches a new image processing configuration to the Standard Material.
  85051. * @param configuration
  85052. */
  85053. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85054. /** @hidden */
  85055. protected _reset(): void;
  85056. /** @hidden */
  85057. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85058. /**
  85059. * Instantiates a particle system.
  85060. * 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.
  85061. * @param name The name of the particle system
  85062. */
  85063. constructor(name: string);
  85064. /**
  85065. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85068. * @returns the emitter
  85069. */
  85070. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85071. /**
  85072. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85073. * @param radius The radius of the hemisphere to emit from
  85074. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85075. * @returns the emitter
  85076. */
  85077. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85078. /**
  85079. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85080. * @param radius The radius of the sphere to emit from
  85081. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85082. * @returns the emitter
  85083. */
  85084. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85085. /**
  85086. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85087. * @param radius The radius of the sphere to emit from
  85088. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85089. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85090. * @returns the emitter
  85091. */
  85092. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85093. /**
  85094. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85095. * @param radius The radius of the emission cylinder
  85096. * @param height The height of the emission cylinder
  85097. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85098. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85099. * @returns the emitter
  85100. */
  85101. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85102. /**
  85103. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85104. * @param radius The radius of the cylinder to emit from
  85105. * @param height The height of the emission cylinder
  85106. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85107. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85108. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85109. * @returns the emitter
  85110. */
  85111. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85112. /**
  85113. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85114. * @param radius The radius of the cone to emit from
  85115. * @param angle The base angle of the cone
  85116. * @returns the emitter
  85117. */
  85118. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85119. /**
  85120. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85121. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85122. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85123. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85124. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85125. * @returns the emitter
  85126. */
  85127. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85128. }
  85129. }
  85130. declare module BABYLON {
  85131. /**
  85132. * Type of sub emitter
  85133. */
  85134. export enum SubEmitterType {
  85135. /**
  85136. * Attached to the particle over it's lifetime
  85137. */
  85138. ATTACHED = 0,
  85139. /**
  85140. * Created when the particle dies
  85141. */
  85142. END = 1
  85143. }
  85144. /**
  85145. * Sub emitter class used to emit particles from an existing particle
  85146. */
  85147. export class SubEmitter {
  85148. /**
  85149. * the particle system to be used by the sub emitter
  85150. */
  85151. particleSystem: ParticleSystem;
  85152. /**
  85153. * Type of the submitter (Default: END)
  85154. */
  85155. type: SubEmitterType;
  85156. /**
  85157. * 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)
  85158. * Note: This only is supported when using an emitter of type Mesh
  85159. */
  85160. inheritDirection: boolean;
  85161. /**
  85162. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85163. */
  85164. inheritedVelocityAmount: number;
  85165. /**
  85166. * Creates a sub emitter
  85167. * @param particleSystem the particle system to be used by the sub emitter
  85168. */
  85169. constructor(
  85170. /**
  85171. * the particle system to be used by the sub emitter
  85172. */
  85173. particleSystem: ParticleSystem);
  85174. /**
  85175. * Clones the sub emitter
  85176. * @returns the cloned sub emitter
  85177. */
  85178. clone(): SubEmitter;
  85179. /**
  85180. * Serialize current object to a JSON object
  85181. * @returns the serialized object
  85182. */
  85183. serialize(): any;
  85184. /** @hidden */
  85185. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85186. /**
  85187. * Creates a new SubEmitter from a serialized JSON version
  85188. * @param serializationObject defines the JSON object to read from
  85189. * @param scene defines the hosting scene
  85190. * @param rootUrl defines the rootUrl for data loading
  85191. * @returns a new SubEmitter
  85192. */
  85193. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85194. /** Release associated resources */
  85195. dispose(): void;
  85196. }
  85197. }
  85198. declare module BABYLON {
  85199. /** @hidden */
  85200. export var imageProcessingDeclaration: {
  85201. name: string;
  85202. shader: string;
  85203. };
  85204. }
  85205. declare module BABYLON {
  85206. /** @hidden */
  85207. export var imageProcessingFunctions: {
  85208. name: string;
  85209. shader: string;
  85210. };
  85211. }
  85212. declare module BABYLON {
  85213. /** @hidden */
  85214. export var particlesPixelShader: {
  85215. name: string;
  85216. shader: string;
  85217. };
  85218. }
  85219. declare module BABYLON {
  85220. /** @hidden */
  85221. export var particlesVertexShader: {
  85222. name: string;
  85223. shader: string;
  85224. };
  85225. }
  85226. declare module BABYLON {
  85227. /**
  85228. * This represents a particle system in Babylon.
  85229. * 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.
  85230. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85231. * @example https://doc.babylonjs.com/babylon101/particles
  85232. */
  85233. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85234. /**
  85235. * Billboard mode will only apply to Y axis
  85236. */
  85237. static readonly BILLBOARDMODE_Y: number;
  85238. /**
  85239. * Billboard mode will apply to all axes
  85240. */
  85241. static readonly BILLBOARDMODE_ALL: number;
  85242. /**
  85243. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85244. */
  85245. static readonly BILLBOARDMODE_STRETCHED: number;
  85246. /**
  85247. * This function can be defined to provide custom update for active particles.
  85248. * This function will be called instead of regular update (age, position, color, etc.).
  85249. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85250. */
  85251. updateFunction: (particles: Particle[]) => void;
  85252. private _emitterWorldMatrix;
  85253. /**
  85254. * This function can be defined to specify initial direction for every new particle.
  85255. * It by default use the emitterType defined function
  85256. */
  85257. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85258. /**
  85259. * This function can be defined to specify initial position for every new particle.
  85260. * It by default use the emitterType defined function
  85261. */
  85262. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85263. /**
  85264. * @hidden
  85265. */
  85266. _inheritedVelocityOffset: Vector3;
  85267. /**
  85268. * An event triggered when the system is disposed
  85269. */
  85270. onDisposeObservable: Observable<ParticleSystem>;
  85271. private _onDisposeObserver;
  85272. /**
  85273. * Sets a callback that will be triggered when the system is disposed
  85274. */
  85275. set onDispose(callback: () => void);
  85276. private _particles;
  85277. private _epsilon;
  85278. private _capacity;
  85279. private _stockParticles;
  85280. private _newPartsExcess;
  85281. private _vertexData;
  85282. private _vertexBuffer;
  85283. private _vertexBuffers;
  85284. private _spriteBuffer;
  85285. private _indexBuffer;
  85286. private _effect;
  85287. private _customEffect;
  85288. private _cachedDefines;
  85289. private _scaledColorStep;
  85290. private _colorDiff;
  85291. private _scaledDirection;
  85292. private _scaledGravity;
  85293. private _currentRenderId;
  85294. private _alive;
  85295. private _useInstancing;
  85296. private _started;
  85297. private _stopped;
  85298. private _actualFrame;
  85299. private _scaledUpdateSpeed;
  85300. private _vertexBufferSize;
  85301. /** @hidden */
  85302. _currentEmitRateGradient: Nullable<FactorGradient>;
  85303. /** @hidden */
  85304. _currentEmitRate1: number;
  85305. /** @hidden */
  85306. _currentEmitRate2: number;
  85307. /** @hidden */
  85308. _currentStartSizeGradient: Nullable<FactorGradient>;
  85309. /** @hidden */
  85310. _currentStartSize1: number;
  85311. /** @hidden */
  85312. _currentStartSize2: number;
  85313. private readonly _rawTextureWidth;
  85314. private _rampGradientsTexture;
  85315. private _useRampGradients;
  85316. /** Gets or sets a boolean indicating that ramp gradients must be used
  85317. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85318. */
  85319. get useRampGradients(): boolean;
  85320. set useRampGradients(value: boolean);
  85321. /**
  85322. * 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.
  85323. * 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: [])
  85324. */
  85325. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85326. private _subEmitters;
  85327. /**
  85328. * @hidden
  85329. * If the particle systems emitter should be disposed when the particle system is disposed
  85330. */
  85331. _disposeEmitterOnDispose: boolean;
  85332. /**
  85333. * The current active Sub-systems, this property is used by the root particle system only.
  85334. */
  85335. activeSubSystems: Array<ParticleSystem>;
  85336. /**
  85337. * Specifies if the particles are updated in emitter local space or world space
  85338. */
  85339. isLocal: boolean;
  85340. private _rootParticleSystem;
  85341. /**
  85342. * Gets the current list of active particles
  85343. */
  85344. get particles(): Particle[];
  85345. /**
  85346. * Returns the string "ParticleSystem"
  85347. * @returns a string containing the class name
  85348. */
  85349. getClassName(): string;
  85350. /**
  85351. * Instantiates a particle system.
  85352. * 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.
  85353. * @param name The name of the particle system
  85354. * @param capacity The max number of particles alive at the same time
  85355. * @param scene The scene the particle system belongs to
  85356. * @param customEffect a custom effect used to change the way particles are rendered by default
  85357. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85358. * @param epsilon Offset used to render the particles
  85359. */
  85360. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85361. private _addFactorGradient;
  85362. private _removeFactorGradient;
  85363. /**
  85364. * Adds a new life time gradient
  85365. * @param gradient defines the gradient to use (between 0 and 1)
  85366. * @param factor defines the life time factor to affect to the specified gradient
  85367. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85368. * @returns the current particle system
  85369. */
  85370. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85371. /**
  85372. * Remove a specific life time gradient
  85373. * @param gradient defines the gradient to remove
  85374. * @returns the current particle system
  85375. */
  85376. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85377. /**
  85378. * Adds a new size gradient
  85379. * @param gradient defines the gradient to use (between 0 and 1)
  85380. * @param factor defines the size factor to affect to the specified gradient
  85381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85382. * @returns the current particle system
  85383. */
  85384. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85385. /**
  85386. * Remove a specific size gradient
  85387. * @param gradient defines the gradient to remove
  85388. * @returns the current particle system
  85389. */
  85390. removeSizeGradient(gradient: number): IParticleSystem;
  85391. /**
  85392. * Adds a new color remap gradient
  85393. * @param gradient defines the gradient to use (between 0 and 1)
  85394. * @param min defines the color remap minimal range
  85395. * @param max defines the color remap maximal range
  85396. * @returns the current particle system
  85397. */
  85398. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85399. /**
  85400. * Remove a specific color remap gradient
  85401. * @param gradient defines the gradient to remove
  85402. * @returns the current particle system
  85403. */
  85404. removeColorRemapGradient(gradient: number): IParticleSystem;
  85405. /**
  85406. * Adds a new alpha remap gradient
  85407. * @param gradient defines the gradient to use (between 0 and 1)
  85408. * @param min defines the alpha remap minimal range
  85409. * @param max defines the alpha remap maximal range
  85410. * @returns the current particle system
  85411. */
  85412. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85413. /**
  85414. * Remove a specific alpha remap gradient
  85415. * @param gradient defines the gradient to remove
  85416. * @returns the current particle system
  85417. */
  85418. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85419. /**
  85420. * Adds a new angular speed gradient
  85421. * @param gradient defines the gradient to use (between 0 and 1)
  85422. * @param factor defines the angular speed to affect to the specified gradient
  85423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85424. * @returns the current particle system
  85425. */
  85426. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85427. /**
  85428. * Remove a specific angular speed gradient
  85429. * @param gradient defines the gradient to remove
  85430. * @returns the current particle system
  85431. */
  85432. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85433. /**
  85434. * Adds a new velocity gradient
  85435. * @param gradient defines the gradient to use (between 0 and 1)
  85436. * @param factor defines the velocity to affect to the specified gradient
  85437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85438. * @returns the current particle system
  85439. */
  85440. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85441. /**
  85442. * Remove a specific velocity gradient
  85443. * @param gradient defines the gradient to remove
  85444. * @returns the current particle system
  85445. */
  85446. removeVelocityGradient(gradient: number): IParticleSystem;
  85447. /**
  85448. * Adds a new limit velocity gradient
  85449. * @param gradient defines the gradient to use (between 0 and 1)
  85450. * @param factor defines the limit velocity value to affect to the specified gradient
  85451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85452. * @returns the current particle system
  85453. */
  85454. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85455. /**
  85456. * Remove a specific limit velocity gradient
  85457. * @param gradient defines the gradient to remove
  85458. * @returns the current particle system
  85459. */
  85460. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85461. /**
  85462. * Adds a new drag gradient
  85463. * @param gradient defines the gradient to use (between 0 and 1)
  85464. * @param factor defines the drag value to affect to the specified gradient
  85465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85466. * @returns the current particle system
  85467. */
  85468. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85469. /**
  85470. * Remove a specific drag gradient
  85471. * @param gradient defines the gradient to remove
  85472. * @returns the current particle system
  85473. */
  85474. removeDragGradient(gradient: number): IParticleSystem;
  85475. /**
  85476. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85477. * @param gradient defines the gradient to use (between 0 and 1)
  85478. * @param factor defines the emit rate value to affect to the specified gradient
  85479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85480. * @returns the current particle system
  85481. */
  85482. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85483. /**
  85484. * Remove a specific emit rate gradient
  85485. * @param gradient defines the gradient to remove
  85486. * @returns the current particle system
  85487. */
  85488. removeEmitRateGradient(gradient: number): IParticleSystem;
  85489. /**
  85490. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85491. * @param gradient defines the gradient to use (between 0 and 1)
  85492. * @param factor defines the start size value to affect to the specified gradient
  85493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85494. * @returns the current particle system
  85495. */
  85496. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85497. /**
  85498. * Remove a specific start size gradient
  85499. * @param gradient defines the gradient to remove
  85500. * @returns the current particle system
  85501. */
  85502. removeStartSizeGradient(gradient: number): IParticleSystem;
  85503. private _createRampGradientTexture;
  85504. /**
  85505. * Gets the current list of ramp gradients.
  85506. * You must use addRampGradient and removeRampGradient to udpate this list
  85507. * @returns the list of ramp gradients
  85508. */
  85509. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85510. /**
  85511. * Adds a new ramp gradient used to remap particle colors
  85512. * @param gradient defines the gradient to use (between 0 and 1)
  85513. * @param color defines the color to affect to the specified gradient
  85514. * @returns the current particle system
  85515. */
  85516. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85517. /**
  85518. * Remove a specific ramp gradient
  85519. * @param gradient defines the gradient to remove
  85520. * @returns the current particle system
  85521. */
  85522. removeRampGradient(gradient: number): ParticleSystem;
  85523. /**
  85524. * Adds a new color gradient
  85525. * @param gradient defines the gradient to use (between 0 and 1)
  85526. * @param color1 defines the color to affect to the specified gradient
  85527. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85528. * @returns this particle system
  85529. */
  85530. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85531. /**
  85532. * Remove a specific color gradient
  85533. * @param gradient defines the gradient to remove
  85534. * @returns this particle system
  85535. */
  85536. removeColorGradient(gradient: number): IParticleSystem;
  85537. private _fetchR;
  85538. protected _reset(): void;
  85539. private _resetEffect;
  85540. private _createVertexBuffers;
  85541. private _createIndexBuffer;
  85542. /**
  85543. * Gets the maximum number of particles active at the same time.
  85544. * @returns The max number of active particles.
  85545. */
  85546. getCapacity(): number;
  85547. /**
  85548. * Gets whether there are still active particles in the system.
  85549. * @returns True if it is alive, otherwise false.
  85550. */
  85551. isAlive(): boolean;
  85552. /**
  85553. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85554. * @returns True if it has been started, otherwise false.
  85555. */
  85556. isStarted(): boolean;
  85557. private _prepareSubEmitterInternalArray;
  85558. /**
  85559. * Starts the particle system and begins to emit
  85560. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85561. */
  85562. start(delay?: number): void;
  85563. /**
  85564. * Stops the particle system.
  85565. * @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.
  85566. */
  85567. stop(stopSubEmitters?: boolean): void;
  85568. /**
  85569. * Remove all active particles
  85570. */
  85571. reset(): void;
  85572. /**
  85573. * @hidden (for internal use only)
  85574. */
  85575. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85576. /**
  85577. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85578. * Its lifetime will start back at 0.
  85579. */
  85580. recycleParticle: (particle: Particle) => void;
  85581. private _stopSubEmitters;
  85582. private _createParticle;
  85583. private _removeFromRoot;
  85584. private _emitFromParticle;
  85585. private _update;
  85586. /** @hidden */
  85587. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85588. /** @hidden */
  85589. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85590. /** @hidden */
  85591. private _getEffect;
  85592. /**
  85593. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85594. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85595. */
  85596. animate(preWarmOnly?: boolean): void;
  85597. private _appendParticleVertices;
  85598. /**
  85599. * Rebuilds the particle system.
  85600. */
  85601. rebuild(): void;
  85602. /**
  85603. * Is this system ready to be used/rendered
  85604. * @return true if the system is ready
  85605. */
  85606. isReady(): boolean;
  85607. private _render;
  85608. /**
  85609. * Renders the particle system in its current state.
  85610. * @returns the current number of particles
  85611. */
  85612. render(): number;
  85613. /**
  85614. * Disposes the particle system and free the associated resources
  85615. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85616. */
  85617. dispose(disposeTexture?: boolean): void;
  85618. /**
  85619. * Clones the particle system.
  85620. * @param name The name of the cloned object
  85621. * @param newEmitter The new emitter to use
  85622. * @returns the cloned particle system
  85623. */
  85624. clone(name: string, newEmitter: any): ParticleSystem;
  85625. /**
  85626. * Serializes the particle system to a JSON object.
  85627. * @returns the JSON object
  85628. */
  85629. serialize(): any;
  85630. /** @hidden */
  85631. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85632. /** @hidden */
  85633. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85634. /**
  85635. * Parses a JSON object to create a particle system.
  85636. * @param parsedParticleSystem The JSON object to parse
  85637. * @param scene The scene to create the particle system in
  85638. * @param rootUrl The root url to use to load external dependencies like texture
  85639. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85640. * @returns the Parsed particle system
  85641. */
  85642. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85643. }
  85644. }
  85645. declare module BABYLON {
  85646. /**
  85647. * A particle represents one of the element emitted by a particle system.
  85648. * This is mainly define by its coordinates, direction, velocity and age.
  85649. */
  85650. export class Particle {
  85651. /**
  85652. * The particle system the particle belongs to.
  85653. */
  85654. particleSystem: ParticleSystem;
  85655. private static _Count;
  85656. /**
  85657. * Unique ID of the particle
  85658. */
  85659. id: number;
  85660. /**
  85661. * The world position of the particle in the scene.
  85662. */
  85663. position: Vector3;
  85664. /**
  85665. * The world direction of the particle in the scene.
  85666. */
  85667. direction: Vector3;
  85668. /**
  85669. * The color of the particle.
  85670. */
  85671. color: Color4;
  85672. /**
  85673. * The color change of the particle per step.
  85674. */
  85675. colorStep: Color4;
  85676. /**
  85677. * Defines how long will the life of the particle be.
  85678. */
  85679. lifeTime: number;
  85680. /**
  85681. * The current age of the particle.
  85682. */
  85683. age: number;
  85684. /**
  85685. * The current size of the particle.
  85686. */
  85687. size: number;
  85688. /**
  85689. * The current scale of the particle.
  85690. */
  85691. scale: Vector2;
  85692. /**
  85693. * The current angle of the particle.
  85694. */
  85695. angle: number;
  85696. /**
  85697. * Defines how fast is the angle changing.
  85698. */
  85699. angularSpeed: number;
  85700. /**
  85701. * Defines the cell index used by the particle to be rendered from a sprite.
  85702. */
  85703. cellIndex: number;
  85704. /**
  85705. * The information required to support color remapping
  85706. */
  85707. remapData: Vector4;
  85708. /** @hidden */
  85709. _randomCellOffset?: number;
  85710. /** @hidden */
  85711. _initialDirection: Nullable<Vector3>;
  85712. /** @hidden */
  85713. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85714. /** @hidden */
  85715. _initialStartSpriteCellID: number;
  85716. /** @hidden */
  85717. _initialEndSpriteCellID: number;
  85718. /** @hidden */
  85719. _currentColorGradient: Nullable<ColorGradient>;
  85720. /** @hidden */
  85721. _currentColor1: Color4;
  85722. /** @hidden */
  85723. _currentColor2: Color4;
  85724. /** @hidden */
  85725. _currentSizeGradient: Nullable<FactorGradient>;
  85726. /** @hidden */
  85727. _currentSize1: number;
  85728. /** @hidden */
  85729. _currentSize2: number;
  85730. /** @hidden */
  85731. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85732. /** @hidden */
  85733. _currentAngularSpeed1: number;
  85734. /** @hidden */
  85735. _currentAngularSpeed2: number;
  85736. /** @hidden */
  85737. _currentVelocityGradient: Nullable<FactorGradient>;
  85738. /** @hidden */
  85739. _currentVelocity1: number;
  85740. /** @hidden */
  85741. _currentVelocity2: number;
  85742. /** @hidden */
  85743. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85744. /** @hidden */
  85745. _currentLimitVelocity1: number;
  85746. /** @hidden */
  85747. _currentLimitVelocity2: number;
  85748. /** @hidden */
  85749. _currentDragGradient: Nullable<FactorGradient>;
  85750. /** @hidden */
  85751. _currentDrag1: number;
  85752. /** @hidden */
  85753. _currentDrag2: number;
  85754. /** @hidden */
  85755. _randomNoiseCoordinates1: Vector3;
  85756. /** @hidden */
  85757. _randomNoiseCoordinates2: Vector3;
  85758. /** @hidden */
  85759. _localPosition?: Vector3;
  85760. /**
  85761. * Creates a new instance Particle
  85762. * @param particleSystem the particle system the particle belongs to
  85763. */
  85764. constructor(
  85765. /**
  85766. * The particle system the particle belongs to.
  85767. */
  85768. particleSystem: ParticleSystem);
  85769. private updateCellInfoFromSystem;
  85770. /**
  85771. * Defines how the sprite cell index is updated for the particle
  85772. */
  85773. updateCellIndex(): void;
  85774. /** @hidden */
  85775. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85776. /** @hidden */
  85777. _inheritParticleInfoToSubEmitters(): void;
  85778. /** @hidden */
  85779. _reset(): void;
  85780. /**
  85781. * Copy the properties of particle to another one.
  85782. * @param other the particle to copy the information to.
  85783. */
  85784. copyTo(other: Particle): void;
  85785. }
  85786. }
  85787. declare module BABYLON {
  85788. /**
  85789. * Particle emitter represents a volume emitting particles.
  85790. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85791. */
  85792. export interface IParticleEmitterType {
  85793. /**
  85794. * Called by the particle System when the direction is computed for the created particle.
  85795. * @param worldMatrix is the world matrix of the particle system
  85796. * @param directionToUpdate is the direction vector to update with the result
  85797. * @param particle is the particle we are computed the direction for
  85798. * @param isLocal defines if the direction should be set in local space
  85799. */
  85800. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85801. /**
  85802. * Called by the particle System when the position is computed for the created particle.
  85803. * @param worldMatrix is the world matrix of the particle system
  85804. * @param positionToUpdate is the position vector to update with the result
  85805. * @param particle is the particle we are computed the position for
  85806. * @param isLocal defines if the position should be set in local space
  85807. */
  85808. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85809. /**
  85810. * Clones the current emitter and returns a copy of it
  85811. * @returns the new emitter
  85812. */
  85813. clone(): IParticleEmitterType;
  85814. /**
  85815. * Called by the GPUParticleSystem to setup the update shader
  85816. * @param effect defines the update shader
  85817. */
  85818. applyToShader(effect: Effect): void;
  85819. /**
  85820. * Returns a string to use to update the GPU particles update shader
  85821. * @returns the effect defines string
  85822. */
  85823. getEffectDefines(): string;
  85824. /**
  85825. * Returns a string representing the class name
  85826. * @returns a string containing the class name
  85827. */
  85828. getClassName(): string;
  85829. /**
  85830. * Serializes the particle system to a JSON object.
  85831. * @returns the JSON object
  85832. */
  85833. serialize(): any;
  85834. /**
  85835. * Parse properties from a JSON object
  85836. * @param serializationObject defines the JSON object
  85837. * @param scene defines the hosting scene
  85838. */
  85839. parse(serializationObject: any, scene: Scene): void;
  85840. }
  85841. }
  85842. declare module BABYLON {
  85843. /**
  85844. * Particle emitter emitting particles from the inside of a box.
  85845. * It emits the particles randomly between 2 given directions.
  85846. */
  85847. export class BoxParticleEmitter implements IParticleEmitterType {
  85848. /**
  85849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85850. */
  85851. direction1: Vector3;
  85852. /**
  85853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85854. */
  85855. direction2: Vector3;
  85856. /**
  85857. * 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.
  85858. */
  85859. minEmitBox: Vector3;
  85860. /**
  85861. * 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.
  85862. */
  85863. maxEmitBox: Vector3;
  85864. /**
  85865. * Creates a new instance BoxParticleEmitter
  85866. */
  85867. constructor();
  85868. /**
  85869. * Called by the particle System when the direction is computed for the created particle.
  85870. * @param worldMatrix is the world matrix of the particle system
  85871. * @param directionToUpdate is the direction vector to update with the result
  85872. * @param particle is the particle we are computed the direction for
  85873. * @param isLocal defines if the direction should be set in local space
  85874. */
  85875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85876. /**
  85877. * Called by the particle System when the position is computed for the created particle.
  85878. * @param worldMatrix is the world matrix of the particle system
  85879. * @param positionToUpdate is the position vector to update with the result
  85880. * @param particle is the particle we are computed the position for
  85881. * @param isLocal defines if the position should be set in local space
  85882. */
  85883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85884. /**
  85885. * Clones the current emitter and returns a copy of it
  85886. * @returns the new emitter
  85887. */
  85888. clone(): BoxParticleEmitter;
  85889. /**
  85890. * Called by the GPUParticleSystem to setup the update shader
  85891. * @param effect defines the update shader
  85892. */
  85893. applyToShader(effect: Effect): void;
  85894. /**
  85895. * Returns a string to use to update the GPU particles update shader
  85896. * @returns a string containng the defines string
  85897. */
  85898. getEffectDefines(): string;
  85899. /**
  85900. * Returns the string "BoxParticleEmitter"
  85901. * @returns a string containing the class name
  85902. */
  85903. getClassName(): string;
  85904. /**
  85905. * Serializes the particle system to a JSON object.
  85906. * @returns the JSON object
  85907. */
  85908. serialize(): any;
  85909. /**
  85910. * Parse properties from a JSON object
  85911. * @param serializationObject defines the JSON object
  85912. */
  85913. parse(serializationObject: any): void;
  85914. }
  85915. }
  85916. declare module BABYLON {
  85917. /**
  85918. * Particle emitter emitting particles from the inside of a cone.
  85919. * It emits the particles alongside the cone volume from the base to the particle.
  85920. * The emission direction might be randomized.
  85921. */
  85922. export class ConeParticleEmitter implements IParticleEmitterType {
  85923. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85924. directionRandomizer: number;
  85925. private _radius;
  85926. private _angle;
  85927. private _height;
  85928. /**
  85929. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85930. */
  85931. radiusRange: number;
  85932. /**
  85933. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85934. */
  85935. heightRange: number;
  85936. /**
  85937. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85938. */
  85939. emitFromSpawnPointOnly: boolean;
  85940. /**
  85941. * Gets or sets the radius of the emission cone
  85942. */
  85943. get radius(): number;
  85944. set radius(value: number);
  85945. /**
  85946. * Gets or sets the angle of the emission cone
  85947. */
  85948. get angle(): number;
  85949. set angle(value: number);
  85950. private _buildHeight;
  85951. /**
  85952. * Creates a new instance ConeParticleEmitter
  85953. * @param radius the radius of the emission cone (1 by default)
  85954. * @param angle the cone base angle (PI by default)
  85955. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85956. */
  85957. constructor(radius?: number, angle?: number,
  85958. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85959. directionRandomizer?: number);
  85960. /**
  85961. * Called by the particle System when the direction is computed for the created particle.
  85962. * @param worldMatrix is the world matrix of the particle system
  85963. * @param directionToUpdate is the direction vector to update with the result
  85964. * @param particle is the particle we are computed the direction for
  85965. * @param isLocal defines if the direction should be set in local space
  85966. */
  85967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85968. /**
  85969. * Called by the particle System when the position is computed for the created particle.
  85970. * @param worldMatrix is the world matrix of the particle system
  85971. * @param positionToUpdate is the position vector to update with the result
  85972. * @param particle is the particle we are computed the position for
  85973. * @param isLocal defines if the position should be set in local space
  85974. */
  85975. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85976. /**
  85977. * Clones the current emitter and returns a copy of it
  85978. * @returns the new emitter
  85979. */
  85980. clone(): ConeParticleEmitter;
  85981. /**
  85982. * Called by the GPUParticleSystem to setup the update shader
  85983. * @param effect defines the update shader
  85984. */
  85985. applyToShader(effect: Effect): void;
  85986. /**
  85987. * Returns a string to use to update the GPU particles update shader
  85988. * @returns a string containng the defines string
  85989. */
  85990. getEffectDefines(): string;
  85991. /**
  85992. * Returns the string "ConeParticleEmitter"
  85993. * @returns a string containing the class name
  85994. */
  85995. getClassName(): string;
  85996. /**
  85997. * Serializes the particle system to a JSON object.
  85998. * @returns the JSON object
  85999. */
  86000. serialize(): any;
  86001. /**
  86002. * Parse properties from a JSON object
  86003. * @param serializationObject defines the JSON object
  86004. */
  86005. parse(serializationObject: any): void;
  86006. }
  86007. }
  86008. declare module BABYLON {
  86009. /**
  86010. * Particle emitter emitting particles from the inside of a cylinder.
  86011. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86012. */
  86013. export class CylinderParticleEmitter implements IParticleEmitterType {
  86014. /**
  86015. * The radius of the emission cylinder.
  86016. */
  86017. radius: number;
  86018. /**
  86019. * The height of the emission cylinder.
  86020. */
  86021. height: number;
  86022. /**
  86023. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86024. */
  86025. radiusRange: number;
  86026. /**
  86027. * How much to randomize the particle direction [0-1].
  86028. */
  86029. directionRandomizer: number;
  86030. /**
  86031. * Creates a new instance CylinderParticleEmitter
  86032. * @param radius the radius of the emission cylinder (1 by default)
  86033. * @param height the height of the emission cylinder (1 by default)
  86034. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86035. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86036. */
  86037. constructor(
  86038. /**
  86039. * The radius of the emission cylinder.
  86040. */
  86041. radius?: number,
  86042. /**
  86043. * The height of the emission cylinder.
  86044. */
  86045. height?: number,
  86046. /**
  86047. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86048. */
  86049. radiusRange?: number,
  86050. /**
  86051. * How much to randomize the particle direction [0-1].
  86052. */
  86053. directionRandomizer?: number);
  86054. /**
  86055. * Called by the particle System when the direction is computed for the created particle.
  86056. * @param worldMatrix is the world matrix of the particle system
  86057. * @param directionToUpdate is the direction vector to update with the result
  86058. * @param particle is the particle we are computed the direction for
  86059. * @param isLocal defines if the direction should be set in local space
  86060. */
  86061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86062. /**
  86063. * Called by the particle System when the position is computed for the created particle.
  86064. * @param worldMatrix is the world matrix of the particle system
  86065. * @param positionToUpdate is the position vector to update with the result
  86066. * @param particle is the particle we are computed the position for
  86067. * @param isLocal defines if the position should be set in local space
  86068. */
  86069. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86070. /**
  86071. * Clones the current emitter and returns a copy of it
  86072. * @returns the new emitter
  86073. */
  86074. clone(): CylinderParticleEmitter;
  86075. /**
  86076. * Called by the GPUParticleSystem to setup the update shader
  86077. * @param effect defines the update shader
  86078. */
  86079. applyToShader(effect: Effect): void;
  86080. /**
  86081. * Returns a string to use to update the GPU particles update shader
  86082. * @returns a string containng the defines string
  86083. */
  86084. getEffectDefines(): string;
  86085. /**
  86086. * Returns the string "CylinderParticleEmitter"
  86087. * @returns a string containing the class name
  86088. */
  86089. getClassName(): string;
  86090. /**
  86091. * Serializes the particle system to a JSON object.
  86092. * @returns the JSON object
  86093. */
  86094. serialize(): any;
  86095. /**
  86096. * Parse properties from a JSON object
  86097. * @param serializationObject defines the JSON object
  86098. */
  86099. parse(serializationObject: any): void;
  86100. }
  86101. /**
  86102. * Particle emitter emitting particles from the inside of a cylinder.
  86103. * It emits the particles randomly between two vectors.
  86104. */
  86105. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86106. /**
  86107. * The min limit of the emission direction.
  86108. */
  86109. direction1: Vector3;
  86110. /**
  86111. * The max limit of the emission direction.
  86112. */
  86113. direction2: Vector3;
  86114. /**
  86115. * Creates a new instance CylinderDirectedParticleEmitter
  86116. * @param radius the radius of the emission cylinder (1 by default)
  86117. * @param height the height of the emission cylinder (1 by default)
  86118. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86119. * @param direction1 the min limit of the emission direction (up vector by default)
  86120. * @param direction2 the max limit of the emission direction (up vector by default)
  86121. */
  86122. constructor(radius?: number, height?: number, radiusRange?: number,
  86123. /**
  86124. * The min limit of the emission direction.
  86125. */
  86126. direction1?: Vector3,
  86127. /**
  86128. * The max limit of the emission direction.
  86129. */
  86130. direction2?: Vector3);
  86131. /**
  86132. * Called by the particle System when the direction is computed for the created particle.
  86133. * @param worldMatrix is the world matrix of the particle system
  86134. * @param directionToUpdate is the direction vector to update with the result
  86135. * @param particle is the particle we are computed the direction for
  86136. */
  86137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86138. /**
  86139. * Clones the current emitter and returns a copy of it
  86140. * @returns the new emitter
  86141. */
  86142. clone(): CylinderDirectedParticleEmitter;
  86143. /**
  86144. * Called by the GPUParticleSystem to setup the update shader
  86145. * @param effect defines the update shader
  86146. */
  86147. applyToShader(effect: Effect): void;
  86148. /**
  86149. * Returns a string to use to update the GPU particles update shader
  86150. * @returns a string containng the defines string
  86151. */
  86152. getEffectDefines(): string;
  86153. /**
  86154. * Returns the string "CylinderDirectedParticleEmitter"
  86155. * @returns a string containing the class name
  86156. */
  86157. getClassName(): string;
  86158. /**
  86159. * Serializes the particle system to a JSON object.
  86160. * @returns the JSON object
  86161. */
  86162. serialize(): any;
  86163. /**
  86164. * Parse properties from a JSON object
  86165. * @param serializationObject defines the JSON object
  86166. */
  86167. parse(serializationObject: any): void;
  86168. }
  86169. }
  86170. declare module BABYLON {
  86171. /**
  86172. * Particle emitter emitting particles from the inside of a hemisphere.
  86173. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86174. */
  86175. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86176. /**
  86177. * The radius of the emission hemisphere.
  86178. */
  86179. radius: number;
  86180. /**
  86181. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86182. */
  86183. radiusRange: number;
  86184. /**
  86185. * How much to randomize the particle direction [0-1].
  86186. */
  86187. directionRandomizer: number;
  86188. /**
  86189. * Creates a new instance HemisphericParticleEmitter
  86190. * @param radius the radius of the emission hemisphere (1 by default)
  86191. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86192. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86193. */
  86194. constructor(
  86195. /**
  86196. * The radius of the emission hemisphere.
  86197. */
  86198. radius?: number,
  86199. /**
  86200. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86201. */
  86202. radiusRange?: number,
  86203. /**
  86204. * How much to randomize the particle direction [0-1].
  86205. */
  86206. directionRandomizer?: number);
  86207. /**
  86208. * Called by the particle System when the direction is computed for the created particle.
  86209. * @param worldMatrix is the world matrix of the particle system
  86210. * @param directionToUpdate is the direction vector to update with the result
  86211. * @param particle is the particle we are computed the direction for
  86212. * @param isLocal defines if the direction should be set in local space
  86213. */
  86214. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86215. /**
  86216. * Called by the particle System when the position is computed for the created particle.
  86217. * @param worldMatrix is the world matrix of the particle system
  86218. * @param positionToUpdate is the position vector to update with the result
  86219. * @param particle is the particle we are computed the position for
  86220. * @param isLocal defines if the position should be set in local space
  86221. */
  86222. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86223. /**
  86224. * Clones the current emitter and returns a copy of it
  86225. * @returns the new emitter
  86226. */
  86227. clone(): HemisphericParticleEmitter;
  86228. /**
  86229. * Called by the GPUParticleSystem to setup the update shader
  86230. * @param effect defines the update shader
  86231. */
  86232. applyToShader(effect: Effect): void;
  86233. /**
  86234. * Returns a string to use to update the GPU particles update shader
  86235. * @returns a string containng the defines string
  86236. */
  86237. getEffectDefines(): string;
  86238. /**
  86239. * Returns the string "HemisphericParticleEmitter"
  86240. * @returns a string containing the class name
  86241. */
  86242. getClassName(): string;
  86243. /**
  86244. * Serializes the particle system to a JSON object.
  86245. * @returns the JSON object
  86246. */
  86247. serialize(): any;
  86248. /**
  86249. * Parse properties from a JSON object
  86250. * @param serializationObject defines the JSON object
  86251. */
  86252. parse(serializationObject: any): void;
  86253. }
  86254. }
  86255. declare module BABYLON {
  86256. /**
  86257. * Particle emitter emitting particles from a point.
  86258. * It emits the particles randomly between 2 given directions.
  86259. */
  86260. export class PointParticleEmitter implements IParticleEmitterType {
  86261. /**
  86262. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86263. */
  86264. direction1: Vector3;
  86265. /**
  86266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86267. */
  86268. direction2: Vector3;
  86269. /**
  86270. * Creates a new instance PointParticleEmitter
  86271. */
  86272. constructor();
  86273. /**
  86274. * Called by the particle System when the direction is computed for the created particle.
  86275. * @param worldMatrix is the world matrix of the particle system
  86276. * @param directionToUpdate is the direction vector to update with the result
  86277. * @param particle is the particle we are computed the direction for
  86278. * @param isLocal defines if the direction should be set in local space
  86279. */
  86280. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86281. /**
  86282. * Called by the particle System when the position is computed for the created particle.
  86283. * @param worldMatrix is the world matrix of the particle system
  86284. * @param positionToUpdate is the position vector to update with the result
  86285. * @param particle is the particle we are computed the position for
  86286. * @param isLocal defines if the position should be set in local space
  86287. */
  86288. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86289. /**
  86290. * Clones the current emitter and returns a copy of it
  86291. * @returns the new emitter
  86292. */
  86293. clone(): PointParticleEmitter;
  86294. /**
  86295. * Called by the GPUParticleSystem to setup the update shader
  86296. * @param effect defines the update shader
  86297. */
  86298. applyToShader(effect: Effect): void;
  86299. /**
  86300. * Returns a string to use to update the GPU particles update shader
  86301. * @returns a string containng the defines string
  86302. */
  86303. getEffectDefines(): string;
  86304. /**
  86305. * Returns the string "PointParticleEmitter"
  86306. * @returns a string containing the class name
  86307. */
  86308. getClassName(): string;
  86309. /**
  86310. * Serializes the particle system to a JSON object.
  86311. * @returns the JSON object
  86312. */
  86313. serialize(): any;
  86314. /**
  86315. * Parse properties from a JSON object
  86316. * @param serializationObject defines the JSON object
  86317. */
  86318. parse(serializationObject: any): void;
  86319. }
  86320. }
  86321. declare module BABYLON {
  86322. /**
  86323. * Particle emitter emitting particles from the inside of a sphere.
  86324. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86325. */
  86326. export class SphereParticleEmitter implements IParticleEmitterType {
  86327. /**
  86328. * The radius of the emission sphere.
  86329. */
  86330. radius: number;
  86331. /**
  86332. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86333. */
  86334. radiusRange: number;
  86335. /**
  86336. * How much to randomize the particle direction [0-1].
  86337. */
  86338. directionRandomizer: number;
  86339. /**
  86340. * Creates a new instance SphereParticleEmitter
  86341. * @param radius the radius of the emission sphere (1 by default)
  86342. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86343. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86344. */
  86345. constructor(
  86346. /**
  86347. * The radius of the emission sphere.
  86348. */
  86349. radius?: number,
  86350. /**
  86351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86352. */
  86353. radiusRange?: number,
  86354. /**
  86355. * How much to randomize the particle direction [0-1].
  86356. */
  86357. directionRandomizer?: number);
  86358. /**
  86359. * Called by the particle System when the direction is computed for the created particle.
  86360. * @param worldMatrix is the world matrix of the particle system
  86361. * @param directionToUpdate is the direction vector to update with the result
  86362. * @param particle is the particle we are computed the direction for
  86363. * @param isLocal defines if the direction should be set in local space
  86364. */
  86365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86366. /**
  86367. * Called by the particle System when the position is computed for the created particle.
  86368. * @param worldMatrix is the world matrix of the particle system
  86369. * @param positionToUpdate is the position vector to update with the result
  86370. * @param particle is the particle we are computed the position for
  86371. * @param isLocal defines if the position should be set in local space
  86372. */
  86373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86374. /**
  86375. * Clones the current emitter and returns a copy of it
  86376. * @returns the new emitter
  86377. */
  86378. clone(): SphereParticleEmitter;
  86379. /**
  86380. * Called by the GPUParticleSystem to setup the update shader
  86381. * @param effect defines the update shader
  86382. */
  86383. applyToShader(effect: Effect): void;
  86384. /**
  86385. * Returns a string to use to update the GPU particles update shader
  86386. * @returns a string containng the defines string
  86387. */
  86388. getEffectDefines(): string;
  86389. /**
  86390. * Returns the string "SphereParticleEmitter"
  86391. * @returns a string containing the class name
  86392. */
  86393. getClassName(): string;
  86394. /**
  86395. * Serializes the particle system to a JSON object.
  86396. * @returns the JSON object
  86397. */
  86398. serialize(): any;
  86399. /**
  86400. * Parse properties from a JSON object
  86401. * @param serializationObject defines the JSON object
  86402. */
  86403. parse(serializationObject: any): void;
  86404. }
  86405. /**
  86406. * Particle emitter emitting particles from the inside of a sphere.
  86407. * It emits the particles randomly between two vectors.
  86408. */
  86409. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86410. /**
  86411. * The min limit of the emission direction.
  86412. */
  86413. direction1: Vector3;
  86414. /**
  86415. * The max limit of the emission direction.
  86416. */
  86417. direction2: Vector3;
  86418. /**
  86419. * Creates a new instance SphereDirectedParticleEmitter
  86420. * @param radius the radius of the emission sphere (1 by default)
  86421. * @param direction1 the min limit of the emission direction (up vector by default)
  86422. * @param direction2 the max limit of the emission direction (up vector by default)
  86423. */
  86424. constructor(radius?: number,
  86425. /**
  86426. * The min limit of the emission direction.
  86427. */
  86428. direction1?: Vector3,
  86429. /**
  86430. * The max limit of the emission direction.
  86431. */
  86432. direction2?: Vector3);
  86433. /**
  86434. * Called by the particle System when the direction is computed for the created particle.
  86435. * @param worldMatrix is the world matrix of the particle system
  86436. * @param directionToUpdate is the direction vector to update with the result
  86437. * @param particle is the particle we are computed the direction for
  86438. */
  86439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86440. /**
  86441. * Clones the current emitter and returns a copy of it
  86442. * @returns the new emitter
  86443. */
  86444. clone(): SphereDirectedParticleEmitter;
  86445. /**
  86446. * Called by the GPUParticleSystem to setup the update shader
  86447. * @param effect defines the update shader
  86448. */
  86449. applyToShader(effect: Effect): void;
  86450. /**
  86451. * Returns a string to use to update the GPU particles update shader
  86452. * @returns a string containng the defines string
  86453. */
  86454. getEffectDefines(): string;
  86455. /**
  86456. * Returns the string "SphereDirectedParticleEmitter"
  86457. * @returns a string containing the class name
  86458. */
  86459. getClassName(): string;
  86460. /**
  86461. * Serializes the particle system to a JSON object.
  86462. * @returns the JSON object
  86463. */
  86464. serialize(): any;
  86465. /**
  86466. * Parse properties from a JSON object
  86467. * @param serializationObject defines the JSON object
  86468. */
  86469. parse(serializationObject: any): void;
  86470. }
  86471. }
  86472. declare module BABYLON {
  86473. /**
  86474. * Particle emitter emitting particles from a custom list of positions.
  86475. */
  86476. export class CustomParticleEmitter implements IParticleEmitterType {
  86477. /**
  86478. * Gets or sets the position generator that will create the inital position of each particle.
  86479. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86480. */
  86481. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86482. /**
  86483. * Gets or sets the destination generator that will create the final destination of each particle.
  86484. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86485. */
  86486. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86487. /**
  86488. * Creates a new instance CustomParticleEmitter
  86489. */
  86490. constructor();
  86491. /**
  86492. * Called by the particle System when the direction is computed for the created particle.
  86493. * @param worldMatrix is the world matrix of the particle system
  86494. * @param directionToUpdate is the direction vector to update with the result
  86495. * @param particle is the particle we are computed the direction for
  86496. * @param isLocal defines if the direction should be set in local space
  86497. */
  86498. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86499. /**
  86500. * Called by the particle System when the position is computed for the created particle.
  86501. * @param worldMatrix is the world matrix of the particle system
  86502. * @param positionToUpdate is the position vector to update with the result
  86503. * @param particle is the particle we are computed the position for
  86504. * @param isLocal defines if the position should be set in local space
  86505. */
  86506. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86507. /**
  86508. * Clones the current emitter and returns a copy of it
  86509. * @returns the new emitter
  86510. */
  86511. clone(): CustomParticleEmitter;
  86512. /**
  86513. * Called by the GPUParticleSystem to setup the update shader
  86514. * @param effect defines the update shader
  86515. */
  86516. applyToShader(effect: Effect): void;
  86517. /**
  86518. * Returns a string to use to update the GPU particles update shader
  86519. * @returns a string containng the defines string
  86520. */
  86521. getEffectDefines(): string;
  86522. /**
  86523. * Returns the string "PointParticleEmitter"
  86524. * @returns a string containing the class name
  86525. */
  86526. getClassName(): string;
  86527. /**
  86528. * Serializes the particle system to a JSON object.
  86529. * @returns the JSON object
  86530. */
  86531. serialize(): any;
  86532. /**
  86533. * Parse properties from a JSON object
  86534. * @param serializationObject defines the JSON object
  86535. */
  86536. parse(serializationObject: any): void;
  86537. }
  86538. }
  86539. declare module BABYLON {
  86540. /**
  86541. * Particle emitter emitting particles from the inside of a box.
  86542. * It emits the particles randomly between 2 given directions.
  86543. */
  86544. export class MeshParticleEmitter implements IParticleEmitterType {
  86545. private _indices;
  86546. private _positions;
  86547. private _normals;
  86548. private _storedNormal;
  86549. private _mesh;
  86550. /**
  86551. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86552. */
  86553. direction1: Vector3;
  86554. /**
  86555. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86556. */
  86557. direction2: Vector3;
  86558. /**
  86559. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86560. */
  86561. useMeshNormalsForDirection: boolean;
  86562. /** Defines the mesh to use as source */
  86563. get mesh(): Nullable<AbstractMesh>;
  86564. set mesh(value: Nullable<AbstractMesh>);
  86565. /**
  86566. * Creates a new instance MeshParticleEmitter
  86567. * @param mesh defines the mesh to use as source
  86568. */
  86569. constructor(mesh?: Nullable<AbstractMesh>);
  86570. /**
  86571. * Called by the particle System when the direction is computed for the created particle.
  86572. * @param worldMatrix is the world matrix of the particle system
  86573. * @param directionToUpdate is the direction vector to update with the result
  86574. * @param particle is the particle we are computed the direction for
  86575. * @param isLocal defines if the direction should be set in local space
  86576. */
  86577. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86578. /**
  86579. * Called by the particle System when the position is computed for the created particle.
  86580. * @param worldMatrix is the world matrix of the particle system
  86581. * @param positionToUpdate is the position vector to update with the result
  86582. * @param particle is the particle we are computed the position for
  86583. * @param isLocal defines if the position should be set in local space
  86584. */
  86585. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86586. /**
  86587. * Clones the current emitter and returns a copy of it
  86588. * @returns the new emitter
  86589. */
  86590. clone(): MeshParticleEmitter;
  86591. /**
  86592. * Called by the GPUParticleSystem to setup the update shader
  86593. * @param effect defines the update shader
  86594. */
  86595. applyToShader(effect: Effect): void;
  86596. /**
  86597. * Returns a string to use to update the GPU particles update shader
  86598. * @returns a string containng the defines string
  86599. */
  86600. getEffectDefines(): string;
  86601. /**
  86602. * Returns the string "BoxParticleEmitter"
  86603. * @returns a string containing the class name
  86604. */
  86605. getClassName(): string;
  86606. /**
  86607. * Serializes the particle system to a JSON object.
  86608. * @returns the JSON object
  86609. */
  86610. serialize(): any;
  86611. /**
  86612. * Parse properties from a JSON object
  86613. * @param serializationObject defines the JSON object
  86614. * @param scene defines the hosting scene
  86615. */
  86616. parse(serializationObject: any, scene: Scene): void;
  86617. }
  86618. }
  86619. declare module BABYLON {
  86620. /**
  86621. * Interface representing a particle system in Babylon.js.
  86622. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86623. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86624. */
  86625. export interface IParticleSystem {
  86626. /**
  86627. * List of animations used by the particle system.
  86628. */
  86629. animations: Animation[];
  86630. /**
  86631. * The id of the Particle system.
  86632. */
  86633. id: string;
  86634. /**
  86635. * The name of the Particle system.
  86636. */
  86637. name: string;
  86638. /**
  86639. * The emitter represents the Mesh or position we are attaching the particle system to.
  86640. */
  86641. emitter: Nullable<AbstractMesh | Vector3>;
  86642. /**
  86643. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86644. */
  86645. isBillboardBased: boolean;
  86646. /**
  86647. * The rendering group used by the Particle system to chose when to render.
  86648. */
  86649. renderingGroupId: number;
  86650. /**
  86651. * The layer mask we are rendering the particles through.
  86652. */
  86653. layerMask: number;
  86654. /**
  86655. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86656. */
  86657. updateSpeed: number;
  86658. /**
  86659. * The amount of time the particle system is running (depends of the overall update speed).
  86660. */
  86661. targetStopDuration: number;
  86662. /**
  86663. * The texture used to render each particle. (this can be a spritesheet)
  86664. */
  86665. particleTexture: Nullable<Texture>;
  86666. /**
  86667. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86668. */
  86669. blendMode: number;
  86670. /**
  86671. * Minimum life time of emitting particles.
  86672. */
  86673. minLifeTime: number;
  86674. /**
  86675. * Maximum life time of emitting particles.
  86676. */
  86677. maxLifeTime: number;
  86678. /**
  86679. * Minimum Size of emitting particles.
  86680. */
  86681. minSize: number;
  86682. /**
  86683. * Maximum Size of emitting particles.
  86684. */
  86685. maxSize: number;
  86686. /**
  86687. * Minimum scale of emitting particles on X axis.
  86688. */
  86689. minScaleX: number;
  86690. /**
  86691. * Maximum scale of emitting particles on X axis.
  86692. */
  86693. maxScaleX: number;
  86694. /**
  86695. * Minimum scale of emitting particles on Y axis.
  86696. */
  86697. minScaleY: number;
  86698. /**
  86699. * Maximum scale of emitting particles on Y axis.
  86700. */
  86701. maxScaleY: number;
  86702. /**
  86703. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86704. */
  86705. color1: Color4;
  86706. /**
  86707. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86708. */
  86709. color2: Color4;
  86710. /**
  86711. * Color the particle will have at the end of its lifetime.
  86712. */
  86713. colorDead: Color4;
  86714. /**
  86715. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86716. */
  86717. emitRate: number;
  86718. /**
  86719. * You can use gravity if you want to give an orientation to your particles.
  86720. */
  86721. gravity: Vector3;
  86722. /**
  86723. * Minimum power of emitting particles.
  86724. */
  86725. minEmitPower: number;
  86726. /**
  86727. * Maximum power of emitting particles.
  86728. */
  86729. maxEmitPower: number;
  86730. /**
  86731. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86732. */
  86733. minAngularSpeed: number;
  86734. /**
  86735. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86736. */
  86737. maxAngularSpeed: number;
  86738. /**
  86739. * Gets or sets the minimal initial rotation in radians.
  86740. */
  86741. minInitialRotation: number;
  86742. /**
  86743. * Gets or sets the maximal initial rotation in radians.
  86744. */
  86745. maxInitialRotation: number;
  86746. /**
  86747. * The particle emitter type defines the emitter used by the particle system.
  86748. * It can be for example box, sphere, or cone...
  86749. */
  86750. particleEmitterType: Nullable<IParticleEmitterType>;
  86751. /**
  86752. * Defines the delay in milliseconds before starting the system (0 by default)
  86753. */
  86754. startDelay: number;
  86755. /**
  86756. * 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
  86757. */
  86758. preWarmCycles: number;
  86759. /**
  86760. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86761. */
  86762. preWarmStepOffset: number;
  86763. /**
  86764. * 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)
  86765. */
  86766. spriteCellChangeSpeed: number;
  86767. /**
  86768. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86769. */
  86770. startSpriteCellID: number;
  86771. /**
  86772. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86773. */
  86774. endSpriteCellID: number;
  86775. /**
  86776. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86777. */
  86778. spriteCellWidth: number;
  86779. /**
  86780. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86781. */
  86782. spriteCellHeight: number;
  86783. /**
  86784. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86785. */
  86786. spriteRandomStartCell: boolean;
  86787. /**
  86788. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86789. */
  86790. isAnimationSheetEnabled: boolean;
  86791. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86792. translationPivot: Vector2;
  86793. /**
  86794. * Gets or sets a texture used to add random noise to particle positions
  86795. */
  86796. noiseTexture: Nullable<BaseTexture>;
  86797. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86798. noiseStrength: Vector3;
  86799. /**
  86800. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86801. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86802. */
  86803. billboardMode: number;
  86804. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86805. limitVelocityDamping: number;
  86806. /**
  86807. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86808. */
  86809. beginAnimationOnStart: boolean;
  86810. /**
  86811. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86812. */
  86813. beginAnimationFrom: number;
  86814. /**
  86815. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86816. */
  86817. beginAnimationTo: number;
  86818. /**
  86819. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86820. */
  86821. beginAnimationLoop: boolean;
  86822. /**
  86823. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86824. */
  86825. disposeOnStop: boolean;
  86826. /**
  86827. * Specifies if the particles are updated in emitter local space or world space
  86828. */
  86829. isLocal: boolean;
  86830. /**
  86831. * Gets the maximum number of particles active at the same time.
  86832. * @returns The max number of active particles.
  86833. */
  86834. getCapacity(): number;
  86835. /**
  86836. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86837. * @returns True if it has been started, otherwise false.
  86838. */
  86839. isStarted(): boolean;
  86840. /**
  86841. * Animates the particle system for this frame.
  86842. */
  86843. animate(): void;
  86844. /**
  86845. * Renders the particle system in its current state.
  86846. * @returns the current number of particles
  86847. */
  86848. render(): number;
  86849. /**
  86850. * Dispose the particle system and frees its associated resources.
  86851. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86852. */
  86853. dispose(disposeTexture?: boolean): void;
  86854. /**
  86855. * Clones the particle system.
  86856. * @param name The name of the cloned object
  86857. * @param newEmitter The new emitter to use
  86858. * @returns the cloned particle system
  86859. */
  86860. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86861. /**
  86862. * Serializes the particle system to a JSON object.
  86863. * @returns the JSON object
  86864. */
  86865. serialize(): any;
  86866. /**
  86867. * Rebuild the particle system
  86868. */
  86869. rebuild(): void;
  86870. /**
  86871. * Starts the particle system and begins to emit
  86872. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86873. */
  86874. start(delay?: number): void;
  86875. /**
  86876. * Stops the particle system.
  86877. */
  86878. stop(): void;
  86879. /**
  86880. * Remove all active particles
  86881. */
  86882. reset(): void;
  86883. /**
  86884. * Is this system ready to be used/rendered
  86885. * @return true if the system is ready
  86886. */
  86887. isReady(): boolean;
  86888. /**
  86889. * Returns the string "ParticleSystem"
  86890. * @returns a string containing the class name
  86891. */
  86892. getClassName(): string;
  86893. /**
  86894. * Adds a new color gradient
  86895. * @param gradient defines the gradient to use (between 0 and 1)
  86896. * @param color1 defines the color to affect to the specified gradient
  86897. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86898. * @returns the current particle system
  86899. */
  86900. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86901. /**
  86902. * Remove a specific color gradient
  86903. * @param gradient defines the gradient to remove
  86904. * @returns the current particle system
  86905. */
  86906. removeColorGradient(gradient: number): IParticleSystem;
  86907. /**
  86908. * Adds a new size gradient
  86909. * @param gradient defines the gradient to use (between 0 and 1)
  86910. * @param factor defines the size factor to affect to the specified gradient
  86911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86912. * @returns the current particle system
  86913. */
  86914. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86915. /**
  86916. * Remove a specific size gradient
  86917. * @param gradient defines the gradient to remove
  86918. * @returns the current particle system
  86919. */
  86920. removeSizeGradient(gradient: number): IParticleSystem;
  86921. /**
  86922. * Gets the current list of color gradients.
  86923. * You must use addColorGradient and removeColorGradient to udpate this list
  86924. * @returns the list of color gradients
  86925. */
  86926. getColorGradients(): Nullable<Array<ColorGradient>>;
  86927. /**
  86928. * Gets the current list of size gradients.
  86929. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86930. * @returns the list of size gradients
  86931. */
  86932. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86933. /**
  86934. * Gets the current list of angular speed gradients.
  86935. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86936. * @returns the list of angular speed gradients
  86937. */
  86938. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86939. /**
  86940. * Adds a new angular speed gradient
  86941. * @param gradient defines the gradient to use (between 0 and 1)
  86942. * @param factor defines the angular speed to affect to the specified gradient
  86943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86944. * @returns the current particle system
  86945. */
  86946. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86947. /**
  86948. * Remove a specific angular speed gradient
  86949. * @param gradient defines the gradient to remove
  86950. * @returns the current particle system
  86951. */
  86952. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86953. /**
  86954. * Gets the current list of velocity gradients.
  86955. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86956. * @returns the list of velocity gradients
  86957. */
  86958. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86959. /**
  86960. * Adds a new velocity gradient
  86961. * @param gradient defines the gradient to use (between 0 and 1)
  86962. * @param factor defines the velocity to affect to the specified gradient
  86963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86964. * @returns the current particle system
  86965. */
  86966. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86967. /**
  86968. * Remove a specific velocity gradient
  86969. * @param gradient defines the gradient to remove
  86970. * @returns the current particle system
  86971. */
  86972. removeVelocityGradient(gradient: number): IParticleSystem;
  86973. /**
  86974. * Gets the current list of limit velocity gradients.
  86975. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86976. * @returns the list of limit velocity gradients
  86977. */
  86978. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86979. /**
  86980. * Adds a new limit velocity gradient
  86981. * @param gradient defines the gradient to use (between 0 and 1)
  86982. * @param factor defines the limit velocity to affect to the specified gradient
  86983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86984. * @returns the current particle system
  86985. */
  86986. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86987. /**
  86988. * Remove a specific limit velocity gradient
  86989. * @param gradient defines the gradient to remove
  86990. * @returns the current particle system
  86991. */
  86992. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86993. /**
  86994. * Adds a new drag gradient
  86995. * @param gradient defines the gradient to use (between 0 and 1)
  86996. * @param factor defines the drag to affect to the specified gradient
  86997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86998. * @returns the current particle system
  86999. */
  87000. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87001. /**
  87002. * Remove a specific drag gradient
  87003. * @param gradient defines the gradient to remove
  87004. * @returns the current particle system
  87005. */
  87006. removeDragGradient(gradient: number): IParticleSystem;
  87007. /**
  87008. * Gets the current list of drag gradients.
  87009. * You must use addDragGradient and removeDragGradient to udpate this list
  87010. * @returns the list of drag gradients
  87011. */
  87012. getDragGradients(): Nullable<Array<FactorGradient>>;
  87013. /**
  87014. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87015. * @param gradient defines the gradient to use (between 0 and 1)
  87016. * @param factor defines the emit rate to affect to the specified gradient
  87017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87018. * @returns the current particle system
  87019. */
  87020. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87021. /**
  87022. * Remove a specific emit rate gradient
  87023. * @param gradient defines the gradient to remove
  87024. * @returns the current particle system
  87025. */
  87026. removeEmitRateGradient(gradient: number): IParticleSystem;
  87027. /**
  87028. * Gets the current list of emit rate gradients.
  87029. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87030. * @returns the list of emit rate gradients
  87031. */
  87032. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87033. /**
  87034. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87035. * @param gradient defines the gradient to use (between 0 and 1)
  87036. * @param factor defines the start size to affect to the specified gradient
  87037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87038. * @returns the current particle system
  87039. */
  87040. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87041. /**
  87042. * Remove a specific start size gradient
  87043. * @param gradient defines the gradient to remove
  87044. * @returns the current particle system
  87045. */
  87046. removeStartSizeGradient(gradient: number): IParticleSystem;
  87047. /**
  87048. * Gets the current list of start size gradients.
  87049. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87050. * @returns the list of start size gradients
  87051. */
  87052. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87053. /**
  87054. * Adds a new life time gradient
  87055. * @param gradient defines the gradient to use (between 0 and 1)
  87056. * @param factor defines the life time factor to affect to the specified gradient
  87057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87058. * @returns the current particle system
  87059. */
  87060. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87061. /**
  87062. * Remove a specific life time gradient
  87063. * @param gradient defines the gradient to remove
  87064. * @returns the current particle system
  87065. */
  87066. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87067. /**
  87068. * Gets the current list of life time gradients.
  87069. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87070. * @returns the list of life time gradients
  87071. */
  87072. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87073. /**
  87074. * Gets the current list of color gradients.
  87075. * You must use addColorGradient and removeColorGradient to udpate this list
  87076. * @returns the list of color gradients
  87077. */
  87078. getColorGradients(): Nullable<Array<ColorGradient>>;
  87079. /**
  87080. * Adds a new ramp gradient used to remap particle colors
  87081. * @param gradient defines the gradient to use (between 0 and 1)
  87082. * @param color defines the color to affect to the specified gradient
  87083. * @returns the current particle system
  87084. */
  87085. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87086. /**
  87087. * Gets the current list of ramp gradients.
  87088. * You must use addRampGradient and removeRampGradient to udpate this list
  87089. * @returns the list of ramp gradients
  87090. */
  87091. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87092. /** Gets or sets a boolean indicating that ramp gradients must be used
  87093. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87094. */
  87095. useRampGradients: boolean;
  87096. /**
  87097. * Adds a new color remap gradient
  87098. * @param gradient defines the gradient to use (between 0 and 1)
  87099. * @param min defines the color remap minimal range
  87100. * @param max defines the color remap maximal range
  87101. * @returns the current particle system
  87102. */
  87103. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87104. /**
  87105. * Gets the current list of color remap gradients.
  87106. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87107. * @returns the list of color remap gradients
  87108. */
  87109. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87110. /**
  87111. * Adds a new alpha remap gradient
  87112. * @param gradient defines the gradient to use (between 0 and 1)
  87113. * @param min defines the alpha remap minimal range
  87114. * @param max defines the alpha remap maximal range
  87115. * @returns the current particle system
  87116. */
  87117. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87118. /**
  87119. * Gets the current list of alpha remap gradients.
  87120. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87121. * @returns the list of alpha remap gradients
  87122. */
  87123. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87124. /**
  87125. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87126. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87127. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87128. * @returns the emitter
  87129. */
  87130. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87131. /**
  87132. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87133. * @param radius The radius of the hemisphere to emit from
  87134. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87135. * @returns the emitter
  87136. */
  87137. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87138. /**
  87139. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87140. * @param radius The radius of the sphere to emit from
  87141. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87142. * @returns the emitter
  87143. */
  87144. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87145. /**
  87146. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87147. * @param radius The radius of the sphere to emit from
  87148. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87149. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87150. * @returns the emitter
  87151. */
  87152. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87153. /**
  87154. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87155. * @param radius The radius of the emission cylinder
  87156. * @param height The height of the emission cylinder
  87157. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87158. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87159. * @returns the emitter
  87160. */
  87161. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87162. /**
  87163. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87164. * @param radius The radius of the cylinder to emit from
  87165. * @param height The height of the emission cylinder
  87166. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87167. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87168. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87169. * @returns the emitter
  87170. */
  87171. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87172. /**
  87173. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87174. * @param radius The radius of the cone to emit from
  87175. * @param angle The base angle of the cone
  87176. * @returns the emitter
  87177. */
  87178. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87179. /**
  87180. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87181. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87182. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87183. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87184. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87185. * @returns the emitter
  87186. */
  87187. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87188. /**
  87189. * Get hosting scene
  87190. * @returns the scene
  87191. */
  87192. getScene(): Scene;
  87193. }
  87194. }
  87195. declare module BABYLON {
  87196. /**
  87197. * 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.
  87198. * @see https://doc.babylonjs.com/how_to/transformnode
  87199. */
  87200. export class TransformNode extends Node {
  87201. /**
  87202. * Object will not rotate to face the camera
  87203. */
  87204. static BILLBOARDMODE_NONE: number;
  87205. /**
  87206. * Object will rotate to face the camera but only on the x axis
  87207. */
  87208. static BILLBOARDMODE_X: number;
  87209. /**
  87210. * Object will rotate to face the camera but only on the y axis
  87211. */
  87212. static BILLBOARDMODE_Y: number;
  87213. /**
  87214. * Object will rotate to face the camera but only on the z axis
  87215. */
  87216. static BILLBOARDMODE_Z: number;
  87217. /**
  87218. * Object will rotate to face the camera
  87219. */
  87220. static BILLBOARDMODE_ALL: number;
  87221. /**
  87222. * Object will rotate to face the camera's position instead of orientation
  87223. */
  87224. static BILLBOARDMODE_USE_POSITION: number;
  87225. private _forward;
  87226. private _forwardInverted;
  87227. private _up;
  87228. private _right;
  87229. private _rightInverted;
  87230. private _position;
  87231. private _rotation;
  87232. private _rotationQuaternion;
  87233. protected _scaling: Vector3;
  87234. protected _isDirty: boolean;
  87235. private _transformToBoneReferal;
  87236. private _isAbsoluteSynced;
  87237. private _billboardMode;
  87238. /**
  87239. * Gets or sets the billboard mode. Default is 0.
  87240. *
  87241. * | Value | Type | Description |
  87242. * | --- | --- | --- |
  87243. * | 0 | BILLBOARDMODE_NONE | |
  87244. * | 1 | BILLBOARDMODE_X | |
  87245. * | 2 | BILLBOARDMODE_Y | |
  87246. * | 4 | BILLBOARDMODE_Z | |
  87247. * | 7 | BILLBOARDMODE_ALL | |
  87248. *
  87249. */
  87250. get billboardMode(): number;
  87251. set billboardMode(value: number);
  87252. private _preserveParentRotationForBillboard;
  87253. /**
  87254. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87255. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87256. */
  87257. get preserveParentRotationForBillboard(): boolean;
  87258. set preserveParentRotationForBillboard(value: boolean);
  87259. /**
  87260. * 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
  87261. */
  87262. scalingDeterminant: number;
  87263. private _infiniteDistance;
  87264. /**
  87265. * Gets or sets the distance of the object to max, often used by skybox
  87266. */
  87267. get infiniteDistance(): boolean;
  87268. set infiniteDistance(value: boolean);
  87269. /**
  87270. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87271. * By default the system will update normals to compensate
  87272. */
  87273. ignoreNonUniformScaling: boolean;
  87274. /**
  87275. * 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
  87276. */
  87277. reIntegrateRotationIntoRotationQuaternion: boolean;
  87278. /** @hidden */
  87279. _poseMatrix: Nullable<Matrix>;
  87280. /** @hidden */
  87281. _localMatrix: Matrix;
  87282. private _usePivotMatrix;
  87283. private _absolutePosition;
  87284. private _absoluteScaling;
  87285. private _absoluteRotationQuaternion;
  87286. private _pivotMatrix;
  87287. private _pivotMatrixInverse;
  87288. protected _postMultiplyPivotMatrix: boolean;
  87289. protected _isWorldMatrixFrozen: boolean;
  87290. /** @hidden */
  87291. _indexInSceneTransformNodesArray: number;
  87292. /**
  87293. * An event triggered after the world matrix is updated
  87294. */
  87295. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87296. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87297. /**
  87298. * Gets a string identifying the name of the class
  87299. * @returns "TransformNode" string
  87300. */
  87301. getClassName(): string;
  87302. /**
  87303. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87304. */
  87305. get position(): Vector3;
  87306. set position(newPosition: Vector3);
  87307. /**
  87308. * 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)).
  87309. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87310. */
  87311. get rotation(): Vector3;
  87312. set rotation(newRotation: Vector3);
  87313. /**
  87314. * 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)).
  87315. */
  87316. get scaling(): Vector3;
  87317. set scaling(newScaling: Vector3);
  87318. /**
  87319. * 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).
  87320. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87321. */
  87322. get rotationQuaternion(): Nullable<Quaternion>;
  87323. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87324. /**
  87325. * The forward direction of that transform in world space.
  87326. */
  87327. get forward(): Vector3;
  87328. /**
  87329. * The up direction of that transform in world space.
  87330. */
  87331. get up(): Vector3;
  87332. /**
  87333. * The right direction of that transform in world space.
  87334. */
  87335. get right(): Vector3;
  87336. /**
  87337. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87338. * @param matrix the matrix to copy the pose from
  87339. * @returns this TransformNode.
  87340. */
  87341. updatePoseMatrix(matrix: Matrix): TransformNode;
  87342. /**
  87343. * Returns the mesh Pose matrix.
  87344. * @returns the pose matrix
  87345. */
  87346. getPoseMatrix(): Matrix;
  87347. /** @hidden */
  87348. _isSynchronized(): boolean;
  87349. /** @hidden */
  87350. _initCache(): void;
  87351. /**
  87352. * Flag the transform node as dirty (Forcing it to update everything)
  87353. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87354. * @returns this transform node
  87355. */
  87356. markAsDirty(property: string): TransformNode;
  87357. /**
  87358. * Returns the current mesh absolute position.
  87359. * Returns a Vector3.
  87360. */
  87361. get absolutePosition(): Vector3;
  87362. /**
  87363. * Returns the current mesh absolute scaling.
  87364. * Returns a Vector3.
  87365. */
  87366. get absoluteScaling(): Vector3;
  87367. /**
  87368. * Returns the current mesh absolute rotation.
  87369. * Returns a Quaternion.
  87370. */
  87371. get absoluteRotationQuaternion(): Quaternion;
  87372. /**
  87373. * Sets a new matrix to apply before all other transformation
  87374. * @param matrix defines the transform matrix
  87375. * @returns the current TransformNode
  87376. */
  87377. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87378. /**
  87379. * Sets a new pivot matrix to the current node
  87380. * @param matrix defines the new pivot matrix to use
  87381. * @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
  87382. * @returns the current TransformNode
  87383. */
  87384. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87385. /**
  87386. * Returns the mesh pivot matrix.
  87387. * Default : Identity.
  87388. * @returns the matrix
  87389. */
  87390. getPivotMatrix(): Matrix;
  87391. /**
  87392. * Instantiate (when possible) or clone that node with its hierarchy
  87393. * @param newParent defines the new parent to use for the instance (or clone)
  87394. * @param options defines options to configure how copy is done
  87395. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87396. * @returns an instance (or a clone) of the current node with its hiearchy
  87397. */
  87398. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87399. doNotInstantiate: boolean;
  87400. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87401. /**
  87402. * Prevents the World matrix to be computed any longer
  87403. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87404. * @returns the TransformNode.
  87405. */
  87406. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87407. /**
  87408. * Allows back the World matrix computation.
  87409. * @returns the TransformNode.
  87410. */
  87411. unfreezeWorldMatrix(): this;
  87412. /**
  87413. * True if the World matrix has been frozen.
  87414. */
  87415. get isWorldMatrixFrozen(): boolean;
  87416. /**
  87417. * Retuns the mesh absolute position in the World.
  87418. * @returns a Vector3.
  87419. */
  87420. getAbsolutePosition(): Vector3;
  87421. /**
  87422. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87423. * @param absolutePosition the absolute position to set
  87424. * @returns the TransformNode.
  87425. */
  87426. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87427. /**
  87428. * Sets the mesh position in its local space.
  87429. * @param vector3 the position to set in localspace
  87430. * @returns the TransformNode.
  87431. */
  87432. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87433. /**
  87434. * Returns the mesh position in the local space from the current World matrix values.
  87435. * @returns a new Vector3.
  87436. */
  87437. getPositionExpressedInLocalSpace(): Vector3;
  87438. /**
  87439. * Translates the mesh along the passed Vector3 in its local space.
  87440. * @param vector3 the distance to translate in localspace
  87441. * @returns the TransformNode.
  87442. */
  87443. locallyTranslate(vector3: Vector3): TransformNode;
  87444. private static _lookAtVectorCache;
  87445. /**
  87446. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87447. * @param targetPoint the position (must be in same space as current mesh) to look at
  87448. * @param yawCor optional yaw (y-axis) correction in radians
  87449. * @param pitchCor optional pitch (x-axis) correction in radians
  87450. * @param rollCor optional roll (z-axis) correction in radians
  87451. * @param space the choosen space of the target
  87452. * @returns the TransformNode.
  87453. */
  87454. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87455. /**
  87456. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87457. * This Vector3 is expressed in the World space.
  87458. * @param localAxis axis to rotate
  87459. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87460. */
  87461. getDirection(localAxis: Vector3): Vector3;
  87462. /**
  87463. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87464. * localAxis is expressed in the mesh local space.
  87465. * result is computed in the Wordl space from the mesh World matrix.
  87466. * @param localAxis axis to rotate
  87467. * @param result the resulting transformnode
  87468. * @returns this TransformNode.
  87469. */
  87470. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87471. /**
  87472. * Sets this transform node rotation to the given local axis.
  87473. * @param localAxis the axis in local space
  87474. * @param yawCor optional yaw (y-axis) correction in radians
  87475. * @param pitchCor optional pitch (x-axis) correction in radians
  87476. * @param rollCor optional roll (z-axis) correction in radians
  87477. * @returns this TransformNode
  87478. */
  87479. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87480. /**
  87481. * Sets a new pivot point to the current node
  87482. * @param point defines the new pivot point to use
  87483. * @param space defines if the point is in world or local space (local by default)
  87484. * @returns the current TransformNode
  87485. */
  87486. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87487. /**
  87488. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87489. * @returns the pivot point
  87490. */
  87491. getPivotPoint(): Vector3;
  87492. /**
  87493. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87494. * @param result the vector3 to store the result
  87495. * @returns this TransformNode.
  87496. */
  87497. getPivotPointToRef(result: Vector3): TransformNode;
  87498. /**
  87499. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87500. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87501. */
  87502. getAbsolutePivotPoint(): Vector3;
  87503. /**
  87504. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87505. * @param result vector3 to store the result
  87506. * @returns this TransformNode.
  87507. */
  87508. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87509. /**
  87510. * Defines the passed node as the parent of the current node.
  87511. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87512. * @see https://doc.babylonjs.com/how_to/parenting
  87513. * @param node the node ot set as the parent
  87514. * @returns this TransformNode.
  87515. */
  87516. setParent(node: Nullable<Node>): TransformNode;
  87517. private _nonUniformScaling;
  87518. /**
  87519. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87520. */
  87521. get nonUniformScaling(): boolean;
  87522. /** @hidden */
  87523. _updateNonUniformScalingState(value: boolean): boolean;
  87524. /**
  87525. * Attach the current TransformNode to another TransformNode associated with a bone
  87526. * @param bone Bone affecting the TransformNode
  87527. * @param affectedTransformNode TransformNode associated with the bone
  87528. * @returns this object
  87529. */
  87530. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87531. /**
  87532. * Detach the transform node if its associated with a bone
  87533. * @returns this object
  87534. */
  87535. detachFromBone(): TransformNode;
  87536. private static _rotationAxisCache;
  87537. /**
  87538. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87539. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87540. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87541. * The passed axis is also normalized.
  87542. * @param axis the axis to rotate around
  87543. * @param amount the amount to rotate in radians
  87544. * @param space Space to rotate in (Default: local)
  87545. * @returns the TransformNode.
  87546. */
  87547. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87548. /**
  87549. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87550. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87551. * The passed axis is also normalized. .
  87552. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87553. * @param point the point to rotate around
  87554. * @param axis the axis to rotate around
  87555. * @param amount the amount to rotate in radians
  87556. * @returns the TransformNode
  87557. */
  87558. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87559. /**
  87560. * Translates the mesh along the axis vector for the passed distance in the given space.
  87561. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87562. * @param axis the axis to translate in
  87563. * @param distance the distance to translate
  87564. * @param space Space to rotate in (Default: local)
  87565. * @returns the TransformNode.
  87566. */
  87567. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87568. /**
  87569. * Adds a rotation step to the mesh current rotation.
  87570. * x, y, z are Euler angles expressed in radians.
  87571. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87572. * This means this rotation is made in the mesh local space only.
  87573. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87574. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87575. * ```javascript
  87576. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87577. * ```
  87578. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87579. * 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.
  87580. * @param x Rotation to add
  87581. * @param y Rotation to add
  87582. * @param z Rotation to add
  87583. * @returns the TransformNode.
  87584. */
  87585. addRotation(x: number, y: number, z: number): TransformNode;
  87586. /**
  87587. * @hidden
  87588. */
  87589. protected _getEffectiveParent(): Nullable<Node>;
  87590. /**
  87591. * Computes the world matrix of the node
  87592. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87593. * @returns the world matrix
  87594. */
  87595. computeWorldMatrix(force?: boolean): Matrix;
  87596. /**
  87597. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87598. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87599. */
  87600. resetLocalMatrix(independentOfChildren?: boolean): void;
  87601. protected _afterComputeWorldMatrix(): void;
  87602. /**
  87603. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87604. * @param func callback function to add
  87605. *
  87606. * @returns the TransformNode.
  87607. */
  87608. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87609. /**
  87610. * Removes a registered callback function.
  87611. * @param func callback function to remove
  87612. * @returns the TransformNode.
  87613. */
  87614. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87615. /**
  87616. * Gets the position of the current mesh in camera space
  87617. * @param camera defines the camera to use
  87618. * @returns a position
  87619. */
  87620. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87621. /**
  87622. * Returns the distance from the mesh to the active camera
  87623. * @param camera defines the camera to use
  87624. * @returns the distance
  87625. */
  87626. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87627. /**
  87628. * Clone the current transform node
  87629. * @param name Name of the new clone
  87630. * @param newParent New parent for the clone
  87631. * @param doNotCloneChildren Do not clone children hierarchy
  87632. * @returns the new transform node
  87633. */
  87634. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87635. /**
  87636. * Serializes the objects information.
  87637. * @param currentSerializationObject defines the object to serialize in
  87638. * @returns the serialized object
  87639. */
  87640. serialize(currentSerializationObject?: any): any;
  87641. /**
  87642. * Returns a new TransformNode object parsed from the source provided.
  87643. * @param parsedTransformNode is the source.
  87644. * @param scene the scne the object belongs to
  87645. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87646. * @returns a new TransformNode object parsed from the source provided.
  87647. */
  87648. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87649. /**
  87650. * Get all child-transformNodes of this node
  87651. * @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
  87652. * @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
  87653. * @returns an array of TransformNode
  87654. */
  87655. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87656. /**
  87657. * Releases resources associated with this transform node.
  87658. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87659. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87660. */
  87661. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87662. /**
  87663. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87664. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87665. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87666. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87667. * @returns the current mesh
  87668. */
  87669. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87670. private _syncAbsoluteScalingAndRotation;
  87671. }
  87672. }
  87673. declare module BABYLON {
  87674. /**
  87675. * Class used to override all child animations of a given target
  87676. */
  87677. export class AnimationPropertiesOverride {
  87678. /**
  87679. * Gets or sets a value indicating if animation blending must be used
  87680. */
  87681. enableBlending: boolean;
  87682. /**
  87683. * Gets or sets the blending speed to use when enableBlending is true
  87684. */
  87685. blendingSpeed: number;
  87686. /**
  87687. * Gets or sets the default loop mode to use
  87688. */
  87689. loopMode: number;
  87690. }
  87691. }
  87692. declare module BABYLON {
  87693. /**
  87694. * Class used to store bone information
  87695. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87696. */
  87697. export class Bone extends Node {
  87698. /**
  87699. * defines the bone name
  87700. */
  87701. name: string;
  87702. private static _tmpVecs;
  87703. private static _tmpQuat;
  87704. private static _tmpMats;
  87705. /**
  87706. * Gets the list of child bones
  87707. */
  87708. children: Bone[];
  87709. /** Gets the animations associated with this bone */
  87710. animations: Animation[];
  87711. /**
  87712. * Gets or sets bone length
  87713. */
  87714. length: number;
  87715. /**
  87716. * @hidden Internal only
  87717. * Set this value to map this bone to a different index in the transform matrices
  87718. * Set this value to -1 to exclude the bone from the transform matrices
  87719. */
  87720. _index: Nullable<number>;
  87721. private _skeleton;
  87722. private _localMatrix;
  87723. private _restPose;
  87724. private _baseMatrix;
  87725. private _absoluteTransform;
  87726. private _invertedAbsoluteTransform;
  87727. private _parent;
  87728. private _scalingDeterminant;
  87729. private _worldTransform;
  87730. private _localScaling;
  87731. private _localRotation;
  87732. private _localPosition;
  87733. private _needToDecompose;
  87734. private _needToCompose;
  87735. /** @hidden */
  87736. _linkedTransformNode: Nullable<TransformNode>;
  87737. /** @hidden */
  87738. _waitingTransformNodeId: Nullable<string>;
  87739. /** @hidden */
  87740. get _matrix(): Matrix;
  87741. /** @hidden */
  87742. set _matrix(value: Matrix);
  87743. /**
  87744. * Create a new bone
  87745. * @param name defines the bone name
  87746. * @param skeleton defines the parent skeleton
  87747. * @param parentBone defines the parent (can be null if the bone is the root)
  87748. * @param localMatrix defines the local matrix
  87749. * @param restPose defines the rest pose matrix
  87750. * @param baseMatrix defines the base matrix
  87751. * @param index defines index of the bone in the hiearchy
  87752. */
  87753. constructor(
  87754. /**
  87755. * defines the bone name
  87756. */
  87757. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87758. /**
  87759. * Gets the current object class name.
  87760. * @return the class name
  87761. */
  87762. getClassName(): string;
  87763. /**
  87764. * Gets the parent skeleton
  87765. * @returns a skeleton
  87766. */
  87767. getSkeleton(): Skeleton;
  87768. /**
  87769. * Gets parent bone
  87770. * @returns a bone or null if the bone is the root of the bone hierarchy
  87771. */
  87772. getParent(): Nullable<Bone>;
  87773. /**
  87774. * Returns an array containing the root bones
  87775. * @returns an array containing the root bones
  87776. */
  87777. getChildren(): Array<Bone>;
  87778. /**
  87779. * Gets the node index in matrix array generated for rendering
  87780. * @returns the node index
  87781. */
  87782. getIndex(): number;
  87783. /**
  87784. * Sets the parent bone
  87785. * @param parent defines the parent (can be null if the bone is the root)
  87786. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87787. */
  87788. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87789. /**
  87790. * Gets the local matrix
  87791. * @returns a matrix
  87792. */
  87793. getLocalMatrix(): Matrix;
  87794. /**
  87795. * Gets the base matrix (initial matrix which remains unchanged)
  87796. * @returns a matrix
  87797. */
  87798. getBaseMatrix(): Matrix;
  87799. /**
  87800. * Gets the rest pose matrix
  87801. * @returns a matrix
  87802. */
  87803. getRestPose(): Matrix;
  87804. /**
  87805. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87806. */
  87807. getWorldMatrix(): Matrix;
  87808. /**
  87809. * Sets the local matrix to rest pose matrix
  87810. */
  87811. returnToRest(): void;
  87812. /**
  87813. * Gets the inverse of the absolute transform matrix.
  87814. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87815. * @returns a matrix
  87816. */
  87817. getInvertedAbsoluteTransform(): Matrix;
  87818. /**
  87819. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87820. * @returns a matrix
  87821. */
  87822. getAbsoluteTransform(): Matrix;
  87823. /**
  87824. * Links with the given transform node.
  87825. * The local matrix of this bone is copied from the transform node every frame.
  87826. * @param transformNode defines the transform node to link to
  87827. */
  87828. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87829. /**
  87830. * Gets the node used to drive the bone's transformation
  87831. * @returns a transform node or null
  87832. */
  87833. getTransformNode(): Nullable<TransformNode>;
  87834. /** Gets or sets current position (in local space) */
  87835. get position(): Vector3;
  87836. set position(newPosition: Vector3);
  87837. /** Gets or sets current rotation (in local space) */
  87838. get rotation(): Vector3;
  87839. set rotation(newRotation: Vector3);
  87840. /** Gets or sets current rotation quaternion (in local space) */
  87841. get rotationQuaternion(): Quaternion;
  87842. set rotationQuaternion(newRotation: Quaternion);
  87843. /** Gets or sets current scaling (in local space) */
  87844. get scaling(): Vector3;
  87845. set scaling(newScaling: Vector3);
  87846. /**
  87847. * Gets the animation properties override
  87848. */
  87849. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87850. private _decompose;
  87851. private _compose;
  87852. /**
  87853. * Update the base and local matrices
  87854. * @param matrix defines the new base or local matrix
  87855. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87856. * @param updateLocalMatrix defines if the local matrix should be updated
  87857. */
  87858. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87859. /** @hidden */
  87860. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87861. /**
  87862. * Flag the bone as dirty (Forcing it to update everything)
  87863. */
  87864. markAsDirty(): void;
  87865. /** @hidden */
  87866. _markAsDirtyAndCompose(): void;
  87867. private _markAsDirtyAndDecompose;
  87868. /**
  87869. * Translate the bone in local or world space
  87870. * @param vec The amount to translate the bone
  87871. * @param space The space that the translation is in
  87872. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87873. */
  87874. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87875. /**
  87876. * Set the postion of the bone in local or world space
  87877. * @param position The position to set the bone
  87878. * @param space The space that the position is in
  87879. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87880. */
  87881. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87882. /**
  87883. * Set the absolute position of the bone (world space)
  87884. * @param position The position to set the bone
  87885. * @param mesh The mesh that this bone is attached to
  87886. */
  87887. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87888. /**
  87889. * Scale the bone on the x, y and z axes (in local space)
  87890. * @param x The amount to scale the bone on the x axis
  87891. * @param y The amount to scale the bone on the y axis
  87892. * @param z The amount to scale the bone on the z axis
  87893. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87894. */
  87895. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87896. /**
  87897. * Set the bone scaling in local space
  87898. * @param scale defines the scaling vector
  87899. */
  87900. setScale(scale: Vector3): void;
  87901. /**
  87902. * Gets the current scaling in local space
  87903. * @returns the current scaling vector
  87904. */
  87905. getScale(): Vector3;
  87906. /**
  87907. * Gets the current scaling in local space and stores it in a target vector
  87908. * @param result defines the target vector
  87909. */
  87910. getScaleToRef(result: Vector3): void;
  87911. /**
  87912. * Set the yaw, pitch, and roll of the bone in local or world space
  87913. * @param yaw The rotation of the bone on the y axis
  87914. * @param pitch The rotation of the bone on the x axis
  87915. * @param roll The rotation of the bone on the z axis
  87916. * @param space The space that the axes of rotation are in
  87917. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87918. */
  87919. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87920. /**
  87921. * Add a rotation to the bone on an axis in local or world space
  87922. * @param axis The axis to rotate the bone on
  87923. * @param amount The amount to rotate the bone
  87924. * @param space The space that the axis is in
  87925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87926. */
  87927. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87928. /**
  87929. * Set the rotation of the bone to a particular axis angle in local or world space
  87930. * @param axis The axis to rotate the bone on
  87931. * @param angle The angle that the bone should be rotated to
  87932. * @param space The space that the axis is in
  87933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87934. */
  87935. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87936. /**
  87937. * Set the euler rotation of the bone in local of world space
  87938. * @param rotation The euler rotation that the bone should be set to
  87939. * @param space The space that the rotation is in
  87940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87941. */
  87942. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87943. /**
  87944. * Set the quaternion rotation of the bone in local of world space
  87945. * @param quat The quaternion rotation that the bone should be set to
  87946. * @param space The space that the rotation is in
  87947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87948. */
  87949. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87950. /**
  87951. * Set the rotation matrix of the bone in local of world space
  87952. * @param rotMat The rotation matrix that the bone should be set to
  87953. * @param space The space that the rotation is in
  87954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87955. */
  87956. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87957. private _rotateWithMatrix;
  87958. private _getNegativeRotationToRef;
  87959. /**
  87960. * Get the position of the bone in local or world space
  87961. * @param space The space that the returned position is in
  87962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87963. * @returns The position of the bone
  87964. */
  87965. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87966. /**
  87967. * Copy the position of the bone to a vector3 in local or world space
  87968. * @param space The space that the returned position is in
  87969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87970. * @param result The vector3 to copy the position to
  87971. */
  87972. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87973. /**
  87974. * Get the absolute position of the bone (world space)
  87975. * @param mesh The mesh that this bone is attached to
  87976. * @returns The absolute position of the bone
  87977. */
  87978. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87979. /**
  87980. * Copy the absolute position of the bone (world space) to the result param
  87981. * @param mesh The mesh that this bone is attached to
  87982. * @param result The vector3 to copy the absolute position to
  87983. */
  87984. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87985. /**
  87986. * Compute the absolute transforms of this bone and its children
  87987. */
  87988. computeAbsoluteTransforms(): void;
  87989. /**
  87990. * Get the world direction from an axis that is in the local space of the bone
  87991. * @param localAxis The local direction that is used to compute the world direction
  87992. * @param mesh The mesh that this bone is attached to
  87993. * @returns The world direction
  87994. */
  87995. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87996. /**
  87997. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87998. * @param localAxis The local direction that is used to compute the world direction
  87999. * @param mesh The mesh that this bone is attached to
  88000. * @param result The vector3 that the world direction will be copied to
  88001. */
  88002. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88003. /**
  88004. * Get the euler rotation of the bone in local or world space
  88005. * @param space The space that the rotation should be in
  88006. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88007. * @returns The euler rotation
  88008. */
  88009. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88010. /**
  88011. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88012. * @param space The space that the rotation should be in
  88013. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88014. * @param result The vector3 that the rotation should be copied to
  88015. */
  88016. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88017. /**
  88018. * Get the quaternion rotation of the bone in either local or world space
  88019. * @param space The space that the rotation should be in
  88020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88021. * @returns The quaternion rotation
  88022. */
  88023. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  88024. /**
  88025. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  88026. * @param space The space that the rotation should be in
  88027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88028. * @param result The quaternion that the rotation should be copied to
  88029. */
  88030. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  88031. /**
  88032. * Get the rotation matrix of the bone in local or world space
  88033. * @param space The space that the rotation should be in
  88034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88035. * @returns The rotation matrix
  88036. */
  88037. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  88038. /**
  88039. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  88040. * @param space The space that the rotation should be in
  88041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88042. * @param result The quaternion that the rotation should be copied to
  88043. */
  88044. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  88045. /**
  88046. * Get the world position of a point that is in the local space of the bone
  88047. * @param position The local position
  88048. * @param mesh The mesh that this bone is attached to
  88049. * @returns The world position
  88050. */
  88051. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88052. /**
  88053. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  88054. * @param position The local position
  88055. * @param mesh The mesh that this bone is attached to
  88056. * @param result The vector3 that the world position should be copied to
  88057. */
  88058. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88059. /**
  88060. * Get the local position of a point that is in world space
  88061. * @param position The world position
  88062. * @param mesh The mesh that this bone is attached to
  88063. * @returns The local position
  88064. */
  88065. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88066. /**
  88067. * Get the local position of a point that is in world space and copy it to the result param
  88068. * @param position The world position
  88069. * @param mesh The mesh that this bone is attached to
  88070. * @param result The vector3 that the local position should be copied to
  88071. */
  88072. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88073. }
  88074. }
  88075. declare module BABYLON {
  88076. /**
  88077. * Defines a runtime animation
  88078. */
  88079. export class RuntimeAnimation {
  88080. private _events;
  88081. /**
  88082. * The current frame of the runtime animation
  88083. */
  88084. private _currentFrame;
  88085. /**
  88086. * The animation used by the runtime animation
  88087. */
  88088. private _animation;
  88089. /**
  88090. * The target of the runtime animation
  88091. */
  88092. private _target;
  88093. /**
  88094. * The initiating animatable
  88095. */
  88096. private _host;
  88097. /**
  88098. * The original value of the runtime animation
  88099. */
  88100. private _originalValue;
  88101. /**
  88102. * The original blend value of the runtime animation
  88103. */
  88104. private _originalBlendValue;
  88105. /**
  88106. * The offsets cache of the runtime animation
  88107. */
  88108. private _offsetsCache;
  88109. /**
  88110. * The high limits cache of the runtime animation
  88111. */
  88112. private _highLimitsCache;
  88113. /**
  88114. * Specifies if the runtime animation has been stopped
  88115. */
  88116. private _stopped;
  88117. /**
  88118. * The blending factor of the runtime animation
  88119. */
  88120. private _blendingFactor;
  88121. /**
  88122. * The BabylonJS scene
  88123. */
  88124. private _scene;
  88125. /**
  88126. * The current value of the runtime animation
  88127. */
  88128. private _currentValue;
  88129. /** @hidden */
  88130. _animationState: _IAnimationState;
  88131. /**
  88132. * The active target of the runtime animation
  88133. */
  88134. private _activeTargets;
  88135. private _currentActiveTarget;
  88136. private _directTarget;
  88137. /**
  88138. * The target path of the runtime animation
  88139. */
  88140. private _targetPath;
  88141. /**
  88142. * The weight of the runtime animation
  88143. */
  88144. private _weight;
  88145. /**
  88146. * The ratio offset of the runtime animation
  88147. */
  88148. private _ratioOffset;
  88149. /**
  88150. * The previous delay of the runtime animation
  88151. */
  88152. private _previousDelay;
  88153. /**
  88154. * The previous ratio of the runtime animation
  88155. */
  88156. private _previousRatio;
  88157. private _enableBlending;
  88158. private _keys;
  88159. private _minFrame;
  88160. private _maxFrame;
  88161. private _minValue;
  88162. private _maxValue;
  88163. private _targetIsArray;
  88164. /**
  88165. * Gets the current frame of the runtime animation
  88166. */
  88167. get currentFrame(): number;
  88168. /**
  88169. * Gets the weight of the runtime animation
  88170. */
  88171. get weight(): number;
  88172. /**
  88173. * Gets the current value of the runtime animation
  88174. */
  88175. get currentValue(): any;
  88176. /**
  88177. * Gets the target path of the runtime animation
  88178. */
  88179. get targetPath(): string;
  88180. /**
  88181. * Gets the actual target of the runtime animation
  88182. */
  88183. get target(): any;
  88184. /** @hidden */
  88185. _onLoop: () => void;
  88186. /**
  88187. * Create a new RuntimeAnimation object
  88188. * @param target defines the target of the animation
  88189. * @param animation defines the source animation object
  88190. * @param scene defines the hosting scene
  88191. * @param host defines the initiating Animatable
  88192. */
  88193. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88194. private _preparePath;
  88195. /**
  88196. * Gets the animation from the runtime animation
  88197. */
  88198. get animation(): Animation;
  88199. /**
  88200. * Resets the runtime animation to the beginning
  88201. * @param restoreOriginal defines whether to restore the target property to the original value
  88202. */
  88203. reset(restoreOriginal?: boolean): void;
  88204. /**
  88205. * Specifies if the runtime animation is stopped
  88206. * @returns Boolean specifying if the runtime animation is stopped
  88207. */
  88208. isStopped(): boolean;
  88209. /**
  88210. * Disposes of the runtime animation
  88211. */
  88212. dispose(): void;
  88213. /**
  88214. * Apply the interpolated value to the target
  88215. * @param currentValue defines the value computed by the animation
  88216. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88217. */
  88218. setValue(currentValue: any, weight: number): void;
  88219. private _getOriginalValues;
  88220. private _setValue;
  88221. /**
  88222. * Gets the loop pmode of the runtime animation
  88223. * @returns Loop Mode
  88224. */
  88225. private _getCorrectLoopMode;
  88226. /**
  88227. * Move the current animation to a given frame
  88228. * @param frame defines the frame to move to
  88229. */
  88230. goToFrame(frame: number): void;
  88231. /**
  88232. * @hidden Internal use only
  88233. */
  88234. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88235. /**
  88236. * Execute the current animation
  88237. * @param delay defines the delay to add to the current frame
  88238. * @param from defines the lower bound of the animation range
  88239. * @param to defines the upper bound of the animation range
  88240. * @param loop defines if the current animation must loop
  88241. * @param speedRatio defines the current speed ratio
  88242. * @param weight defines the weight of the animation (default is -1 so no weight)
  88243. * @param onLoop optional callback called when animation loops
  88244. * @returns a boolean indicating if the animation is running
  88245. */
  88246. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88247. }
  88248. }
  88249. declare module BABYLON {
  88250. /**
  88251. * Class used to store an actual running animation
  88252. */
  88253. export class Animatable {
  88254. /** defines the target object */
  88255. target: any;
  88256. /** defines the starting frame number (default is 0) */
  88257. fromFrame: number;
  88258. /** defines the ending frame number (default is 100) */
  88259. toFrame: number;
  88260. /** defines if the animation must loop (default is false) */
  88261. loopAnimation: boolean;
  88262. /** defines a callback to call when animation ends if it is not looping */
  88263. onAnimationEnd?: (() => void) | null | undefined;
  88264. /** defines a callback to call when animation loops */
  88265. onAnimationLoop?: (() => void) | null | undefined;
  88266. private _localDelayOffset;
  88267. private _pausedDelay;
  88268. private _runtimeAnimations;
  88269. private _paused;
  88270. private _scene;
  88271. private _speedRatio;
  88272. private _weight;
  88273. private _syncRoot;
  88274. /**
  88275. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88276. * This will only apply for non looping animation (default is true)
  88277. */
  88278. disposeOnEnd: boolean;
  88279. /**
  88280. * Gets a boolean indicating if the animation has started
  88281. */
  88282. animationStarted: boolean;
  88283. /**
  88284. * Observer raised when the animation ends
  88285. */
  88286. onAnimationEndObservable: Observable<Animatable>;
  88287. /**
  88288. * Observer raised when the animation loops
  88289. */
  88290. onAnimationLoopObservable: Observable<Animatable>;
  88291. /**
  88292. * Gets the root Animatable used to synchronize and normalize animations
  88293. */
  88294. get syncRoot(): Nullable<Animatable>;
  88295. /**
  88296. * Gets the current frame of the first RuntimeAnimation
  88297. * Used to synchronize Animatables
  88298. */
  88299. get masterFrame(): number;
  88300. /**
  88301. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88302. */
  88303. get weight(): number;
  88304. set weight(value: number);
  88305. /**
  88306. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88307. */
  88308. get speedRatio(): number;
  88309. set speedRatio(value: number);
  88310. /**
  88311. * Creates a new Animatable
  88312. * @param scene defines the hosting scene
  88313. * @param target defines the target object
  88314. * @param fromFrame defines the starting frame number (default is 0)
  88315. * @param toFrame defines the ending frame number (default is 100)
  88316. * @param loopAnimation defines if the animation must loop (default is false)
  88317. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88318. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88319. * @param animations defines a group of animation to add to the new Animatable
  88320. * @param onAnimationLoop defines a callback to call when animation loops
  88321. */
  88322. constructor(scene: Scene,
  88323. /** defines the target object */
  88324. target: any,
  88325. /** defines the starting frame number (default is 0) */
  88326. fromFrame?: number,
  88327. /** defines the ending frame number (default is 100) */
  88328. toFrame?: number,
  88329. /** defines if the animation must loop (default is false) */
  88330. loopAnimation?: boolean, speedRatio?: number,
  88331. /** defines a callback to call when animation ends if it is not looping */
  88332. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  88333. /** defines a callback to call when animation loops */
  88334. onAnimationLoop?: (() => void) | null | undefined);
  88335. /**
  88336. * Synchronize and normalize current Animatable with a source Animatable
  88337. * This is useful when using animation weights and when animations are not of the same length
  88338. * @param root defines the root Animatable to synchronize with
  88339. * @returns the current Animatable
  88340. */
  88341. syncWith(root: Animatable): Animatable;
  88342. /**
  88343. * Gets the list of runtime animations
  88344. * @returns an array of RuntimeAnimation
  88345. */
  88346. getAnimations(): RuntimeAnimation[];
  88347. /**
  88348. * Adds more animations to the current animatable
  88349. * @param target defines the target of the animations
  88350. * @param animations defines the new animations to add
  88351. */
  88352. appendAnimations(target: any, animations: Animation[]): void;
  88353. /**
  88354. * Gets the source animation for a specific property
  88355. * @param property defines the propertyu to look for
  88356. * @returns null or the source animation for the given property
  88357. */
  88358. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  88359. /**
  88360. * Gets the runtime animation for a specific property
  88361. * @param property defines the propertyu to look for
  88362. * @returns null or the runtime animation for the given property
  88363. */
  88364. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  88365. /**
  88366. * Resets the animatable to its original state
  88367. */
  88368. reset(): void;
  88369. /**
  88370. * Allows the animatable to blend with current running animations
  88371. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88372. * @param blendingSpeed defines the blending speed to use
  88373. */
  88374. enableBlending(blendingSpeed: number): void;
  88375. /**
  88376. * Disable animation blending
  88377. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88378. */
  88379. disableBlending(): void;
  88380. /**
  88381. * Jump directly to a given frame
  88382. * @param frame defines the frame to jump to
  88383. */
  88384. goToFrame(frame: number): void;
  88385. /**
  88386. * Pause the animation
  88387. */
  88388. pause(): void;
  88389. /**
  88390. * Restart the animation
  88391. */
  88392. restart(): void;
  88393. private _raiseOnAnimationEnd;
  88394. /**
  88395. * Stop and delete the current animation
  88396. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  88397. * @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)
  88398. */
  88399. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  88400. /**
  88401. * Wait asynchronously for the animation to end
  88402. * @returns a promise which will be fullfilled when the animation ends
  88403. */
  88404. waitAsync(): Promise<Animatable>;
  88405. /** @hidden */
  88406. _animate(delay: number): boolean;
  88407. }
  88408. interface Scene {
  88409. /** @hidden */
  88410. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88411. /** @hidden */
  88412. _processLateAnimationBindingsForMatrices(holder: {
  88413. totalWeight: number;
  88414. animations: RuntimeAnimation[];
  88415. originalValue: Matrix;
  88416. }): any;
  88417. /** @hidden */
  88418. _processLateAnimationBindingsForQuaternions(holder: {
  88419. totalWeight: number;
  88420. animations: RuntimeAnimation[];
  88421. originalValue: Quaternion;
  88422. }, refQuaternion: Quaternion): Quaternion;
  88423. /** @hidden */
  88424. _processLateAnimationBindings(): void;
  88425. /**
  88426. * Will start the animation sequence of a given target
  88427. * @param target defines the target
  88428. * @param from defines from which frame should animation start
  88429. * @param to defines until which frame should animation run.
  88430. * @param weight defines the weight to apply to the animation (1.0 by default)
  88431. * @param loop defines if the animation loops
  88432. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88433. * @param onAnimationEnd defines the function to be executed when the animation ends
  88434. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88435. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88436. * @param onAnimationLoop defines the callback to call when an animation loops
  88437. * @returns the animatable object created for this animation
  88438. */
  88439. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88440. /**
  88441. * Will start the animation sequence of a given target
  88442. * @param target defines the target
  88443. * @param from defines from which frame should animation start
  88444. * @param to defines until which frame should animation run.
  88445. * @param loop defines if the animation loops
  88446. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88447. * @param onAnimationEnd defines the function to be executed when the animation ends
  88448. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88449. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88450. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88451. * @param onAnimationLoop defines the callback to call when an animation loops
  88452. * @returns the animatable object created for this animation
  88453. */
  88454. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88455. /**
  88456. * Will start the animation sequence of a given target and its hierarchy
  88457. * @param target defines the target
  88458. * @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.
  88459. * @param from defines from which frame should animation start
  88460. * @param to defines until which frame should animation run.
  88461. * @param loop defines if the animation loops
  88462. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88463. * @param onAnimationEnd defines the function to be executed when the animation ends
  88464. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88465. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88466. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88467. * @param onAnimationLoop defines the callback to call when an animation loops
  88468. * @returns the list of created animatables
  88469. */
  88470. 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[];
  88471. /**
  88472. * Begin a new animation on a given node
  88473. * @param target defines the target where the animation will take place
  88474. * @param animations defines the list of animations to start
  88475. * @param from defines the initial value
  88476. * @param to defines the final value
  88477. * @param loop defines if you want animation to loop (off by default)
  88478. * @param speedRatio defines the speed ratio to apply to all animations
  88479. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88480. * @param onAnimationLoop defines the callback to call when an animation loops
  88481. * @returns the list of created animatables
  88482. */
  88483. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88484. /**
  88485. * Begin a new animation on a given node and its hierarchy
  88486. * @param target defines the root node where the animation will take place
  88487. * @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.
  88488. * @param animations defines the list of animations to start
  88489. * @param from defines the initial value
  88490. * @param to defines the final value
  88491. * @param loop defines if you want animation to loop (off by default)
  88492. * @param speedRatio defines the speed ratio to apply to all animations
  88493. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88494. * @param onAnimationLoop defines the callback to call when an animation loops
  88495. * @returns the list of animatables created for all nodes
  88496. */
  88497. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88498. /**
  88499. * Gets the animatable associated with a specific target
  88500. * @param target defines the target of the animatable
  88501. * @returns the required animatable if found
  88502. */
  88503. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88504. /**
  88505. * Gets all animatables associated with a given target
  88506. * @param target defines the target to look animatables for
  88507. * @returns an array of Animatables
  88508. */
  88509. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88510. /**
  88511. * Stops and removes all animations that have been applied to the scene
  88512. */
  88513. stopAllAnimations(): void;
  88514. /**
  88515. * Gets the current delta time used by animation engine
  88516. */
  88517. deltaTime: number;
  88518. }
  88519. interface Bone {
  88520. /**
  88521. * Copy an animation range from another bone
  88522. * @param source defines the source bone
  88523. * @param rangeName defines the range name to copy
  88524. * @param frameOffset defines the frame offset
  88525. * @param rescaleAsRequired defines if rescaling must be applied if required
  88526. * @param skelDimensionsRatio defines the scaling ratio
  88527. * @returns true if operation was successful
  88528. */
  88529. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88530. }
  88531. }
  88532. declare module BABYLON {
  88533. /**
  88534. * Class used to handle skinning animations
  88535. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88536. */
  88537. export class Skeleton implements IAnimatable {
  88538. /** defines the skeleton name */
  88539. name: string;
  88540. /** defines the skeleton Id */
  88541. id: string;
  88542. /**
  88543. * Defines the list of child bones
  88544. */
  88545. bones: Bone[];
  88546. /**
  88547. * Defines an estimate of the dimension of the skeleton at rest
  88548. */
  88549. dimensionsAtRest: Vector3;
  88550. /**
  88551. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88552. */
  88553. needInitialSkinMatrix: boolean;
  88554. /**
  88555. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88556. */
  88557. overrideMesh: Nullable<AbstractMesh>;
  88558. /**
  88559. * Gets the list of animations attached to this skeleton
  88560. */
  88561. animations: Array<Animation>;
  88562. private _scene;
  88563. private _isDirty;
  88564. private _transformMatrices;
  88565. private _transformMatrixTexture;
  88566. private _meshesWithPoseMatrix;
  88567. private _animatables;
  88568. private _identity;
  88569. private _synchronizedWithMesh;
  88570. private _ranges;
  88571. private _lastAbsoluteTransformsUpdateId;
  88572. private _canUseTextureForBones;
  88573. private _uniqueId;
  88574. /** @hidden */
  88575. _numBonesWithLinkedTransformNode: number;
  88576. /** @hidden */
  88577. _hasWaitingData: Nullable<boolean>;
  88578. /**
  88579. * Specifies if the skeleton should be serialized
  88580. */
  88581. doNotSerialize: boolean;
  88582. private _useTextureToStoreBoneMatrices;
  88583. /**
  88584. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88585. * Please note that this option is not available if the hardware does not support it
  88586. */
  88587. get useTextureToStoreBoneMatrices(): boolean;
  88588. set useTextureToStoreBoneMatrices(value: boolean);
  88589. private _animationPropertiesOverride;
  88590. /**
  88591. * Gets or sets the animation properties override
  88592. */
  88593. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88594. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88595. /**
  88596. * List of inspectable custom properties (used by the Inspector)
  88597. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88598. */
  88599. inspectableCustomProperties: IInspectable[];
  88600. /**
  88601. * An observable triggered before computing the skeleton's matrices
  88602. */
  88603. onBeforeComputeObservable: Observable<Skeleton>;
  88604. /**
  88605. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88606. */
  88607. get isUsingTextureForMatrices(): boolean;
  88608. /**
  88609. * Gets the unique ID of this skeleton
  88610. */
  88611. get uniqueId(): number;
  88612. /**
  88613. * Creates a new skeleton
  88614. * @param name defines the skeleton name
  88615. * @param id defines the skeleton Id
  88616. * @param scene defines the hosting scene
  88617. */
  88618. constructor(
  88619. /** defines the skeleton name */
  88620. name: string,
  88621. /** defines the skeleton Id */
  88622. id: string, scene: Scene);
  88623. /**
  88624. * Gets the current object class name.
  88625. * @return the class name
  88626. */
  88627. getClassName(): string;
  88628. /**
  88629. * Returns an array containing the root bones
  88630. * @returns an array containing the root bones
  88631. */
  88632. getChildren(): Array<Bone>;
  88633. /**
  88634. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88635. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88636. * @returns a Float32Array containing matrices data
  88637. */
  88638. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88639. /**
  88640. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88641. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88642. * @returns a raw texture containing the data
  88643. */
  88644. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88645. /**
  88646. * Gets the current hosting scene
  88647. * @returns a scene object
  88648. */
  88649. getScene(): Scene;
  88650. /**
  88651. * Gets a string representing the current skeleton data
  88652. * @param fullDetails defines a boolean indicating if we want a verbose version
  88653. * @returns a string representing the current skeleton data
  88654. */
  88655. toString(fullDetails?: boolean): string;
  88656. /**
  88657. * Get bone's index searching by name
  88658. * @param name defines bone's name to search for
  88659. * @return the indice of the bone. Returns -1 if not found
  88660. */
  88661. getBoneIndexByName(name: string): number;
  88662. /**
  88663. * Creater a new animation range
  88664. * @param name defines the name of the range
  88665. * @param from defines the start key
  88666. * @param to defines the end key
  88667. */
  88668. createAnimationRange(name: string, from: number, to: number): void;
  88669. /**
  88670. * Delete a specific animation range
  88671. * @param name defines the name of the range
  88672. * @param deleteFrames defines if frames must be removed as well
  88673. */
  88674. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88675. /**
  88676. * Gets a specific animation range
  88677. * @param name defines the name of the range to look for
  88678. * @returns the requested animation range or null if not found
  88679. */
  88680. getAnimationRange(name: string): Nullable<AnimationRange>;
  88681. /**
  88682. * Gets the list of all animation ranges defined on this skeleton
  88683. * @returns an array
  88684. */
  88685. getAnimationRanges(): Nullable<AnimationRange>[];
  88686. /**
  88687. * Copy animation range from a source skeleton.
  88688. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88689. * @param source defines the source skeleton
  88690. * @param name defines the name of the range to copy
  88691. * @param rescaleAsRequired defines if rescaling must be applied if required
  88692. * @returns true if operation was successful
  88693. */
  88694. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88695. /**
  88696. * Forces the skeleton to go to rest pose
  88697. */
  88698. returnToRest(): void;
  88699. private _getHighestAnimationFrame;
  88700. /**
  88701. * Begin a specific animation range
  88702. * @param name defines the name of the range to start
  88703. * @param loop defines if looping must be turned on (false by default)
  88704. * @param speedRatio defines the speed ratio to apply (1 by default)
  88705. * @param onAnimationEnd defines a callback which will be called when animation will end
  88706. * @returns a new animatable
  88707. */
  88708. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88709. /** @hidden */
  88710. _markAsDirty(): void;
  88711. /** @hidden */
  88712. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88713. /** @hidden */
  88714. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88715. private _computeTransformMatrices;
  88716. /**
  88717. * Build all resources required to render a skeleton
  88718. */
  88719. prepare(): void;
  88720. /**
  88721. * Gets the list of animatables currently running for this skeleton
  88722. * @returns an array of animatables
  88723. */
  88724. getAnimatables(): IAnimatable[];
  88725. /**
  88726. * Clone the current skeleton
  88727. * @param name defines the name of the new skeleton
  88728. * @param id defines the id of the new skeleton
  88729. * @returns the new skeleton
  88730. */
  88731. clone(name: string, id?: string): Skeleton;
  88732. /**
  88733. * Enable animation blending for this skeleton
  88734. * @param blendingSpeed defines the blending speed to apply
  88735. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88736. */
  88737. enableBlending(blendingSpeed?: number): void;
  88738. /**
  88739. * Releases all resources associated with the current skeleton
  88740. */
  88741. dispose(): void;
  88742. /**
  88743. * Serialize the skeleton in a JSON object
  88744. * @returns a JSON object
  88745. */
  88746. serialize(): any;
  88747. /**
  88748. * Creates a new skeleton from serialized data
  88749. * @param parsedSkeleton defines the serialized data
  88750. * @param scene defines the hosting scene
  88751. * @returns a new skeleton
  88752. */
  88753. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88754. /**
  88755. * Compute all node absolute transforms
  88756. * @param forceUpdate defines if computation must be done even if cache is up to date
  88757. */
  88758. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88759. /**
  88760. * Gets the root pose matrix
  88761. * @returns a matrix
  88762. */
  88763. getPoseMatrix(): Nullable<Matrix>;
  88764. /**
  88765. * Sorts bones per internal index
  88766. */
  88767. sortBones(): void;
  88768. private _sortBones;
  88769. }
  88770. }
  88771. declare module BABYLON {
  88772. /**
  88773. * Creates an instance based on a source mesh.
  88774. */
  88775. export class InstancedMesh extends AbstractMesh {
  88776. private _sourceMesh;
  88777. private _currentLOD;
  88778. /** @hidden */
  88779. _indexInSourceMeshInstanceArray: number;
  88780. constructor(name: string, source: Mesh);
  88781. /**
  88782. * Returns the string "InstancedMesh".
  88783. */
  88784. getClassName(): string;
  88785. /** Gets the list of lights affecting that mesh */
  88786. get lightSources(): Light[];
  88787. _resyncLightSources(): void;
  88788. _resyncLightSource(light: Light): void;
  88789. _removeLightSource(light: Light, dispose: boolean): void;
  88790. /**
  88791. * If the source mesh receives shadows
  88792. */
  88793. get receiveShadows(): boolean;
  88794. /**
  88795. * The material of the source mesh
  88796. */
  88797. get material(): Nullable<Material>;
  88798. /**
  88799. * Visibility of the source mesh
  88800. */
  88801. get visibility(): number;
  88802. /**
  88803. * Skeleton of the source mesh
  88804. */
  88805. get skeleton(): Nullable<Skeleton>;
  88806. /**
  88807. * Rendering ground id of the source mesh
  88808. */
  88809. get renderingGroupId(): number;
  88810. set renderingGroupId(value: number);
  88811. /**
  88812. * Returns the total number of vertices (integer).
  88813. */
  88814. getTotalVertices(): number;
  88815. /**
  88816. * Returns a positive integer : the total number of indices in this mesh geometry.
  88817. * @returns the numner of indices or zero if the mesh has no geometry.
  88818. */
  88819. getTotalIndices(): number;
  88820. /**
  88821. * The source mesh of the instance
  88822. */
  88823. get sourceMesh(): Mesh;
  88824. /**
  88825. * Is this node ready to be used/rendered
  88826. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88827. * @return {boolean} is it ready
  88828. */
  88829. isReady(completeCheck?: boolean): boolean;
  88830. /**
  88831. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88832. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88833. * @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.
  88834. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88835. */
  88836. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88837. /**
  88838. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88839. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88840. * The `data` are either a numeric array either a Float32Array.
  88841. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88842. * 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).
  88843. * Note that a new underlying VertexBuffer object is created each call.
  88844. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88845. *
  88846. * Possible `kind` values :
  88847. * - VertexBuffer.PositionKind
  88848. * - VertexBuffer.UVKind
  88849. * - VertexBuffer.UV2Kind
  88850. * - VertexBuffer.UV3Kind
  88851. * - VertexBuffer.UV4Kind
  88852. * - VertexBuffer.UV5Kind
  88853. * - VertexBuffer.UV6Kind
  88854. * - VertexBuffer.ColorKind
  88855. * - VertexBuffer.MatricesIndicesKind
  88856. * - VertexBuffer.MatricesIndicesExtraKind
  88857. * - VertexBuffer.MatricesWeightsKind
  88858. * - VertexBuffer.MatricesWeightsExtraKind
  88859. *
  88860. * Returns the Mesh.
  88861. */
  88862. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88863. /**
  88864. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88865. * If the mesh has no geometry, it is simply returned as it is.
  88866. * The `data` are either a numeric array either a Float32Array.
  88867. * No new underlying VertexBuffer object is created.
  88868. * 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.
  88869. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88870. *
  88871. * Possible `kind` values :
  88872. * - VertexBuffer.PositionKind
  88873. * - VertexBuffer.UVKind
  88874. * - VertexBuffer.UV2Kind
  88875. * - VertexBuffer.UV3Kind
  88876. * - VertexBuffer.UV4Kind
  88877. * - VertexBuffer.UV5Kind
  88878. * - VertexBuffer.UV6Kind
  88879. * - VertexBuffer.ColorKind
  88880. * - VertexBuffer.MatricesIndicesKind
  88881. * - VertexBuffer.MatricesIndicesExtraKind
  88882. * - VertexBuffer.MatricesWeightsKind
  88883. * - VertexBuffer.MatricesWeightsExtraKind
  88884. *
  88885. * Returns the Mesh.
  88886. */
  88887. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88888. /**
  88889. * Sets the mesh indices.
  88890. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88891. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88892. * This method creates a new index buffer each call.
  88893. * Returns the Mesh.
  88894. */
  88895. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88896. /**
  88897. * Boolean : True if the mesh owns the requested kind of data.
  88898. */
  88899. isVerticesDataPresent(kind: string): boolean;
  88900. /**
  88901. * Returns an array of indices (IndicesArray).
  88902. */
  88903. getIndices(): Nullable<IndicesArray>;
  88904. get _positions(): Nullable<Vector3[]>;
  88905. /**
  88906. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88907. * This means the mesh underlying bounding box and sphere are recomputed.
  88908. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88909. * @returns the current mesh
  88910. */
  88911. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88912. /** @hidden */
  88913. _preActivate(): InstancedMesh;
  88914. /** @hidden */
  88915. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88916. /** @hidden */
  88917. _postActivate(): void;
  88918. getWorldMatrix(): Matrix;
  88919. get isAnInstance(): boolean;
  88920. /**
  88921. * Returns the current associated LOD AbstractMesh.
  88922. */
  88923. getLOD(camera: Camera): AbstractMesh;
  88924. /** @hidden */
  88925. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88926. /** @hidden */
  88927. _syncSubMeshes(): InstancedMesh;
  88928. /** @hidden */
  88929. _generatePointsArray(): boolean;
  88930. /**
  88931. * Creates a new InstancedMesh from the current mesh.
  88932. * - name (string) : the cloned mesh name
  88933. * - newParent (optional Node) : the optional Node to parent the clone to.
  88934. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88935. *
  88936. * Returns the clone.
  88937. */
  88938. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88939. /**
  88940. * Disposes the InstancedMesh.
  88941. * Returns nothing.
  88942. */
  88943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88944. }
  88945. interface Mesh {
  88946. /**
  88947. * Register a custom buffer that will be instanced
  88948. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88949. * @param kind defines the buffer kind
  88950. * @param stride defines the stride in floats
  88951. */
  88952. registerInstancedBuffer(kind: string, stride: number): void;
  88953. /** @hidden */
  88954. _userInstancedBuffersStorage: {
  88955. data: {
  88956. [key: string]: Float32Array;
  88957. };
  88958. sizes: {
  88959. [key: string]: number;
  88960. };
  88961. vertexBuffers: {
  88962. [key: string]: Nullable<VertexBuffer>;
  88963. };
  88964. strides: {
  88965. [key: string]: number;
  88966. };
  88967. };
  88968. }
  88969. interface AbstractMesh {
  88970. /**
  88971. * Object used to store instanced buffers defined by user
  88972. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88973. */
  88974. instancedBuffers: {
  88975. [key: string]: any;
  88976. };
  88977. }
  88978. }
  88979. declare module BABYLON {
  88980. /**
  88981. * Defines the options associated with the creation of a shader material.
  88982. */
  88983. export interface IShaderMaterialOptions {
  88984. /**
  88985. * Does the material work in alpha blend mode
  88986. */
  88987. needAlphaBlending: boolean;
  88988. /**
  88989. * Does the material work in alpha test mode
  88990. */
  88991. needAlphaTesting: boolean;
  88992. /**
  88993. * The list of attribute names used in the shader
  88994. */
  88995. attributes: string[];
  88996. /**
  88997. * The list of unifrom names used in the shader
  88998. */
  88999. uniforms: string[];
  89000. /**
  89001. * The list of UBO names used in the shader
  89002. */
  89003. uniformBuffers: string[];
  89004. /**
  89005. * The list of sampler names used in the shader
  89006. */
  89007. samplers: string[];
  89008. /**
  89009. * The list of defines used in the shader
  89010. */
  89011. defines: string[];
  89012. }
  89013. /**
  89014. * 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.
  89015. *
  89016. * This returned material effects how the mesh will look based on the code in the shaders.
  89017. *
  89018. * @see http://doc.babylonjs.com/how_to/shader_material
  89019. */
  89020. export class ShaderMaterial extends Material {
  89021. private _shaderPath;
  89022. private _options;
  89023. private _textures;
  89024. private _textureArrays;
  89025. private _floats;
  89026. private _ints;
  89027. private _floatsArrays;
  89028. private _colors3;
  89029. private _colors3Arrays;
  89030. private _colors4;
  89031. private _colors4Arrays;
  89032. private _vectors2;
  89033. private _vectors3;
  89034. private _vectors4;
  89035. private _matrices;
  89036. private _matrixArrays;
  89037. private _matrices3x3;
  89038. private _matrices2x2;
  89039. private _vectors2Arrays;
  89040. private _vectors3Arrays;
  89041. private _vectors4Arrays;
  89042. private _cachedWorldViewMatrix;
  89043. private _cachedWorldViewProjectionMatrix;
  89044. private _renderId;
  89045. private _multiview;
  89046. /**
  89047. * Instantiate a new shader material.
  89048. * 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.
  89049. * This returned material effects how the mesh will look based on the code in the shaders.
  89050. * @see http://doc.babylonjs.com/how_to/shader_material
  89051. * @param name Define the name of the material in the scene
  89052. * @param scene Define the scene the material belongs to
  89053. * @param shaderPath Defines the route to the shader code in one of three ways:
  89054. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89055. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89056. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89057. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89058. * @param options Define the options used to create the shader
  89059. */
  89060. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89061. /**
  89062. * Gets the shader path used to define the shader code
  89063. * It can be modified to trigger a new compilation
  89064. */
  89065. get shaderPath(): any;
  89066. /**
  89067. * Sets the shader path used to define the shader code
  89068. * It can be modified to trigger a new compilation
  89069. */
  89070. set shaderPath(shaderPath: any);
  89071. /**
  89072. * Gets the options used to compile the shader.
  89073. * They can be modified to trigger a new compilation
  89074. */
  89075. get options(): IShaderMaterialOptions;
  89076. /**
  89077. * Gets the current class name of the material e.g. "ShaderMaterial"
  89078. * Mainly use in serialization.
  89079. * @returns the class name
  89080. */
  89081. getClassName(): string;
  89082. /**
  89083. * Specifies if the material will require alpha blending
  89084. * @returns a boolean specifying if alpha blending is needed
  89085. */
  89086. needAlphaBlending(): boolean;
  89087. /**
  89088. * Specifies if this material should be rendered in alpha test mode
  89089. * @returns a boolean specifying if an alpha test is needed.
  89090. */
  89091. needAlphaTesting(): boolean;
  89092. private _checkUniform;
  89093. /**
  89094. * Set a texture in the shader.
  89095. * @param name Define the name of the uniform samplers as defined in the shader
  89096. * @param texture Define the texture to bind to this sampler
  89097. * @return the material itself allowing "fluent" like uniform updates
  89098. */
  89099. setTexture(name: string, texture: Texture): ShaderMaterial;
  89100. /**
  89101. * Set a texture array in the shader.
  89102. * @param name Define the name of the uniform sampler array as defined in the shader
  89103. * @param textures Define the list of textures to bind to this sampler
  89104. * @return the material itself allowing "fluent" like uniform updates
  89105. */
  89106. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  89107. /**
  89108. * Set a float in the shader.
  89109. * @param name Define the name of the uniform as defined in the shader
  89110. * @param value Define the value to give to the uniform
  89111. * @return the material itself allowing "fluent" like uniform updates
  89112. */
  89113. setFloat(name: string, value: number): ShaderMaterial;
  89114. /**
  89115. * Set a int in the shader.
  89116. * @param name Define the name of the uniform as defined in the shader
  89117. * @param value Define the value to give to the uniform
  89118. * @return the material itself allowing "fluent" like uniform updates
  89119. */
  89120. setInt(name: string, value: number): ShaderMaterial;
  89121. /**
  89122. * Set an array of floats in the shader.
  89123. * @param name Define the name of the uniform as defined in the shader
  89124. * @param value Define the value to give to the uniform
  89125. * @return the material itself allowing "fluent" like uniform updates
  89126. */
  89127. setFloats(name: string, value: number[]): ShaderMaterial;
  89128. /**
  89129. * Set a vec3 in the shader from a Color3.
  89130. * @param name Define the name of the uniform as defined in the shader
  89131. * @param value Define the value to give to the uniform
  89132. * @return the material itself allowing "fluent" like uniform updates
  89133. */
  89134. setColor3(name: string, value: Color3): ShaderMaterial;
  89135. /**
  89136. * Set a vec3 array in the shader from a Color3 array.
  89137. * @param name Define the name of the uniform as defined in the shader
  89138. * @param value Define the value to give to the uniform
  89139. * @return the material itself allowing "fluent" like uniform updates
  89140. */
  89141. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89142. /**
  89143. * Set a vec4 in the shader from a Color4.
  89144. * @param name Define the name of the uniform as defined in the shader
  89145. * @param value Define the value to give to the uniform
  89146. * @return the material itself allowing "fluent" like uniform updates
  89147. */
  89148. setColor4(name: string, value: Color4): ShaderMaterial;
  89149. /**
  89150. * Set a vec4 array in the shader from a Color4 array.
  89151. * @param name Define the name of the uniform as defined in the shader
  89152. * @param value Define the value to give to the uniform
  89153. * @return the material itself allowing "fluent" like uniform updates
  89154. */
  89155. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89156. /**
  89157. * Set a vec2 in the shader from a Vector2.
  89158. * @param name Define the name of the uniform as defined in the shader
  89159. * @param value Define the value to give to the uniform
  89160. * @return the material itself allowing "fluent" like uniform updates
  89161. */
  89162. setVector2(name: string, value: Vector2): ShaderMaterial;
  89163. /**
  89164. * Set a vec3 in the shader from a Vector3.
  89165. * @param name Define the name of the uniform as defined in the shader
  89166. * @param value Define the value to give to the uniform
  89167. * @return the material itself allowing "fluent" like uniform updates
  89168. */
  89169. setVector3(name: string, value: Vector3): ShaderMaterial;
  89170. /**
  89171. * Set a vec4 in the shader from a Vector4.
  89172. * @param name Define the name of the uniform as defined in the shader
  89173. * @param value Define the value to give to the uniform
  89174. * @return the material itself allowing "fluent" like uniform updates
  89175. */
  89176. setVector4(name: string, value: Vector4): ShaderMaterial;
  89177. /**
  89178. * Set a mat4 in the shader from a Matrix.
  89179. * @param name Define the name of the uniform as defined in the shader
  89180. * @param value Define the value to give to the uniform
  89181. * @return the material itself allowing "fluent" like uniform updates
  89182. */
  89183. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89184. /**
  89185. * Set a float32Array in the shader from a matrix array.
  89186. * @param name Define the name of the uniform as defined in the shader
  89187. * @param value Define the value to give to the uniform
  89188. * @return the material itself allowing "fluent" like uniform updates
  89189. */
  89190. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89191. /**
  89192. * Set a mat3 in the shader from a Float32Array.
  89193. * @param name Define the name of the uniform as defined in the shader
  89194. * @param value Define the value to give to the uniform
  89195. * @return the material itself allowing "fluent" like uniform updates
  89196. */
  89197. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89198. /**
  89199. * Set a mat2 in the shader from a Float32Array.
  89200. * @param name Define the name of the uniform as defined in the shader
  89201. * @param value Define the value to give to the uniform
  89202. * @return the material itself allowing "fluent" like uniform updates
  89203. */
  89204. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89205. /**
  89206. * Set a vec2 array in the shader from a number array.
  89207. * @param name Define the name of the uniform as defined in the shader
  89208. * @param value Define the value to give to the uniform
  89209. * @return the material itself allowing "fluent" like uniform updates
  89210. */
  89211. setArray2(name: string, value: number[]): ShaderMaterial;
  89212. /**
  89213. * Set a vec3 array in the shader from a number array.
  89214. * @param name Define the name of the uniform as defined in the shader
  89215. * @param value Define the value to give to the uniform
  89216. * @return the material itself allowing "fluent" like uniform updates
  89217. */
  89218. setArray3(name: string, value: number[]): ShaderMaterial;
  89219. /**
  89220. * Set a vec4 array in the shader from a number array.
  89221. * @param name Define the name of the uniform as defined in the shader
  89222. * @param value Define the value to give to the uniform
  89223. * @return the material itself allowing "fluent" like uniform updates
  89224. */
  89225. setArray4(name: string, value: number[]): ShaderMaterial;
  89226. private _checkCache;
  89227. /**
  89228. * Specifies that the submesh is ready to be used
  89229. * @param mesh defines the mesh to check
  89230. * @param subMesh defines which submesh to check
  89231. * @param useInstances specifies that instances should be used
  89232. * @returns a boolean indicating that the submesh is ready or not
  89233. */
  89234. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89235. /**
  89236. * Checks if the material is ready to render the requested mesh
  89237. * @param mesh Define the mesh to render
  89238. * @param useInstances Define whether or not the material is used with instances
  89239. * @returns true if ready, otherwise false
  89240. */
  89241. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89242. /**
  89243. * Binds the world matrix to the material
  89244. * @param world defines the world transformation matrix
  89245. */
  89246. bindOnlyWorldMatrix(world: Matrix): void;
  89247. /**
  89248. * Binds the material to the mesh
  89249. * @param world defines the world transformation matrix
  89250. * @param mesh defines the mesh to bind the material to
  89251. */
  89252. bind(world: Matrix, mesh?: Mesh): void;
  89253. /**
  89254. * Gets the active textures from the material
  89255. * @returns an array of textures
  89256. */
  89257. getActiveTextures(): BaseTexture[];
  89258. /**
  89259. * Specifies if the material uses a texture
  89260. * @param texture defines the texture to check against the material
  89261. * @returns a boolean specifying if the material uses the texture
  89262. */
  89263. hasTexture(texture: BaseTexture): boolean;
  89264. /**
  89265. * Makes a duplicate of the material, and gives it a new name
  89266. * @param name defines the new name for the duplicated material
  89267. * @returns the cloned material
  89268. */
  89269. clone(name: string): ShaderMaterial;
  89270. /**
  89271. * Disposes the material
  89272. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89273. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89274. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89275. */
  89276. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89277. /**
  89278. * Serializes this material in a JSON representation
  89279. * @returns the serialized material object
  89280. */
  89281. serialize(): any;
  89282. /**
  89283. * Creates a shader material from parsed shader material data
  89284. * @param source defines the JSON represnetation of the material
  89285. * @param scene defines the hosting scene
  89286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89287. * @returns a new material
  89288. */
  89289. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89290. }
  89291. }
  89292. declare module BABYLON {
  89293. /** @hidden */
  89294. export var colorPixelShader: {
  89295. name: string;
  89296. shader: string;
  89297. };
  89298. }
  89299. declare module BABYLON {
  89300. /** @hidden */
  89301. export var colorVertexShader: {
  89302. name: string;
  89303. shader: string;
  89304. };
  89305. }
  89306. declare module BABYLON {
  89307. /**
  89308. * Line mesh
  89309. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  89310. */
  89311. export class LinesMesh extends Mesh {
  89312. /**
  89313. * If vertex color should be applied to the mesh
  89314. */
  89315. readonly useVertexColor?: boolean | undefined;
  89316. /**
  89317. * If vertex alpha should be applied to the mesh
  89318. */
  89319. readonly useVertexAlpha?: boolean | undefined;
  89320. /**
  89321. * Color of the line (Default: White)
  89322. */
  89323. color: Color3;
  89324. /**
  89325. * Alpha of the line (Default: 1)
  89326. */
  89327. alpha: number;
  89328. /**
  89329. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89330. * This margin is expressed in world space coordinates, so its value may vary.
  89331. * Default value is 0.1
  89332. */
  89333. intersectionThreshold: number;
  89334. private _colorShader;
  89335. private color4;
  89336. /**
  89337. * Creates a new LinesMesh
  89338. * @param name defines the name
  89339. * @param scene defines the hosting scene
  89340. * @param parent defines the parent mesh if any
  89341. * @param source defines the optional source LinesMesh used to clone data from
  89342. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89343. * When false, achieved by calling a clone(), also passing False.
  89344. * This will make creation of children, recursive.
  89345. * @param useVertexColor defines if this LinesMesh supports vertex color
  89346. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89347. */
  89348. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89349. /**
  89350. * If vertex color should be applied to the mesh
  89351. */
  89352. useVertexColor?: boolean | undefined,
  89353. /**
  89354. * If vertex alpha should be applied to the mesh
  89355. */
  89356. useVertexAlpha?: boolean | undefined);
  89357. private _addClipPlaneDefine;
  89358. private _removeClipPlaneDefine;
  89359. isReady(): boolean;
  89360. /**
  89361. * Returns the string "LineMesh"
  89362. */
  89363. getClassName(): string;
  89364. /**
  89365. * @hidden
  89366. */
  89367. get material(): Material;
  89368. /**
  89369. * @hidden
  89370. */
  89371. set material(value: Material);
  89372. /**
  89373. * @hidden
  89374. */
  89375. get checkCollisions(): boolean;
  89376. /** @hidden */
  89377. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89378. /** @hidden */
  89379. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89380. /**
  89381. * Disposes of the line mesh
  89382. * @param doNotRecurse If children should be disposed
  89383. */
  89384. dispose(doNotRecurse?: boolean): void;
  89385. /**
  89386. * Returns a new LineMesh object cloned from the current one.
  89387. */
  89388. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  89389. /**
  89390. * Creates a new InstancedLinesMesh object from the mesh model.
  89391. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89392. * @param name defines the name of the new instance
  89393. * @returns a new InstancedLinesMesh
  89394. */
  89395. createInstance(name: string): InstancedLinesMesh;
  89396. }
  89397. /**
  89398. * Creates an instance based on a source LinesMesh
  89399. */
  89400. export class InstancedLinesMesh extends InstancedMesh {
  89401. /**
  89402. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89403. * This margin is expressed in world space coordinates, so its value may vary.
  89404. * Initilized with the intersectionThreshold value of the source LinesMesh
  89405. */
  89406. intersectionThreshold: number;
  89407. constructor(name: string, source: LinesMesh);
  89408. /**
  89409. * Returns the string "InstancedLinesMesh".
  89410. */
  89411. getClassName(): string;
  89412. }
  89413. }
  89414. declare module BABYLON {
  89415. /** @hidden */
  89416. export var linePixelShader: {
  89417. name: string;
  89418. shader: string;
  89419. };
  89420. }
  89421. declare module BABYLON {
  89422. /** @hidden */
  89423. export var lineVertexShader: {
  89424. name: string;
  89425. shader: string;
  89426. };
  89427. }
  89428. declare module BABYLON {
  89429. interface AbstractMesh {
  89430. /**
  89431. * Gets the edgesRenderer associated with the mesh
  89432. */
  89433. edgesRenderer: Nullable<EdgesRenderer>;
  89434. }
  89435. interface LinesMesh {
  89436. /**
  89437. * Enables the edge rendering mode on the mesh.
  89438. * This mode makes the mesh edges visible
  89439. * @param epsilon defines the maximal distance between two angles to detect a face
  89440. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89441. * @returns the currentAbstractMesh
  89442. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89443. */
  89444. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89445. }
  89446. interface InstancedLinesMesh {
  89447. /**
  89448. * Enables the edge rendering mode on the mesh.
  89449. * This mode makes the mesh edges visible
  89450. * @param epsilon defines the maximal distance between two angles to detect a face
  89451. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89452. * @returns the current InstancedLinesMesh
  89453. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89454. */
  89455. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89456. }
  89457. /**
  89458. * Defines the minimum contract an Edges renderer should follow.
  89459. */
  89460. export interface IEdgesRenderer extends IDisposable {
  89461. /**
  89462. * Gets or sets a boolean indicating if the edgesRenderer is active
  89463. */
  89464. isEnabled: boolean;
  89465. /**
  89466. * Renders the edges of the attached mesh,
  89467. */
  89468. render(): void;
  89469. /**
  89470. * Checks wether or not the edges renderer is ready to render.
  89471. * @return true if ready, otherwise false.
  89472. */
  89473. isReady(): boolean;
  89474. }
  89475. /**
  89476. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89477. */
  89478. export class EdgesRenderer implements IEdgesRenderer {
  89479. /**
  89480. * Define the size of the edges with an orthographic camera
  89481. */
  89482. edgesWidthScalerForOrthographic: number;
  89483. /**
  89484. * Define the size of the edges with a perspective camera
  89485. */
  89486. edgesWidthScalerForPerspective: number;
  89487. protected _source: AbstractMesh;
  89488. protected _linesPositions: number[];
  89489. protected _linesNormals: number[];
  89490. protected _linesIndices: number[];
  89491. protected _epsilon: number;
  89492. protected _indicesCount: number;
  89493. protected _lineShader: ShaderMaterial;
  89494. protected _ib: DataBuffer;
  89495. protected _buffers: {
  89496. [key: string]: Nullable<VertexBuffer>;
  89497. };
  89498. protected _checkVerticesInsteadOfIndices: boolean;
  89499. private _meshRebuildObserver;
  89500. private _meshDisposeObserver;
  89501. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89502. isEnabled: boolean;
  89503. /**
  89504. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89505. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89506. * @param source Mesh used to create edges
  89507. * @param epsilon sum of angles in adjacency to check for edge
  89508. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89509. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89510. */
  89511. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89512. protected _prepareRessources(): void;
  89513. /** @hidden */
  89514. _rebuild(): void;
  89515. /**
  89516. * Releases the required resources for the edges renderer
  89517. */
  89518. dispose(): void;
  89519. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89520. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89521. /**
  89522. * Checks if the pair of p0 and p1 is en edge
  89523. * @param faceIndex
  89524. * @param edge
  89525. * @param faceNormals
  89526. * @param p0
  89527. * @param p1
  89528. * @private
  89529. */
  89530. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89531. /**
  89532. * push line into the position, normal and index buffer
  89533. * @protected
  89534. */
  89535. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89536. /**
  89537. * Generates lines edges from adjacencjes
  89538. * @private
  89539. */
  89540. _generateEdgesLines(): void;
  89541. /**
  89542. * Checks wether or not the edges renderer is ready to render.
  89543. * @return true if ready, otherwise false.
  89544. */
  89545. isReady(): boolean;
  89546. /**
  89547. * Renders the edges of the attached mesh,
  89548. */
  89549. render(): void;
  89550. }
  89551. /**
  89552. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89553. */
  89554. export class LineEdgesRenderer extends EdgesRenderer {
  89555. /**
  89556. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89557. * @param source LineMesh used to generate edges
  89558. * @param epsilon not important (specified angle for edge detection)
  89559. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89560. */
  89561. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89562. /**
  89563. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89564. */
  89565. _generateEdgesLines(): void;
  89566. }
  89567. }
  89568. declare module BABYLON {
  89569. /**
  89570. * This represents the object necessary to create a rendering group.
  89571. * This is exclusively used and created by the rendering manager.
  89572. * To modify the behavior, you use the available helpers in your scene or meshes.
  89573. * @hidden
  89574. */
  89575. export class RenderingGroup {
  89576. index: number;
  89577. private static _zeroVector;
  89578. private _scene;
  89579. private _opaqueSubMeshes;
  89580. private _transparentSubMeshes;
  89581. private _alphaTestSubMeshes;
  89582. private _depthOnlySubMeshes;
  89583. private _particleSystems;
  89584. private _spriteManagers;
  89585. private _opaqueSortCompareFn;
  89586. private _alphaTestSortCompareFn;
  89587. private _transparentSortCompareFn;
  89588. private _renderOpaque;
  89589. private _renderAlphaTest;
  89590. private _renderTransparent;
  89591. /** @hidden */
  89592. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89593. onBeforeTransparentRendering: () => void;
  89594. /**
  89595. * Set the opaque sort comparison function.
  89596. * If null the sub meshes will be render in the order they were created
  89597. */
  89598. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89599. /**
  89600. * Set the alpha test sort comparison function.
  89601. * If null the sub meshes will be render in the order they were created
  89602. */
  89603. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89604. /**
  89605. * Set the transparent sort comparison function.
  89606. * If null the sub meshes will be render in the order they were created
  89607. */
  89608. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89609. /**
  89610. * Creates a new rendering group.
  89611. * @param index The rendering group index
  89612. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89613. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89614. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89615. */
  89616. 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>);
  89617. /**
  89618. * Render all the sub meshes contained in the group.
  89619. * @param customRenderFunction Used to override the default render behaviour of the group.
  89620. * @returns true if rendered some submeshes.
  89621. */
  89622. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89623. /**
  89624. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89625. * @param subMeshes The submeshes to render
  89626. */
  89627. private renderOpaqueSorted;
  89628. /**
  89629. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89630. * @param subMeshes The submeshes to render
  89631. */
  89632. private renderAlphaTestSorted;
  89633. /**
  89634. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89635. * @param subMeshes The submeshes to render
  89636. */
  89637. private renderTransparentSorted;
  89638. /**
  89639. * Renders the submeshes in a specified order.
  89640. * @param subMeshes The submeshes to sort before render
  89641. * @param sortCompareFn The comparison function use to sort
  89642. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89643. * @param transparent Specifies to activate blending if true
  89644. */
  89645. private static renderSorted;
  89646. /**
  89647. * Renders the submeshes in the order they were dispatched (no sort applied).
  89648. * @param subMeshes The submeshes to render
  89649. */
  89650. private static renderUnsorted;
  89651. /**
  89652. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89653. * are rendered back to front if in the same alpha index.
  89654. *
  89655. * @param a The first submesh
  89656. * @param b The second submesh
  89657. * @returns The result of the comparison
  89658. */
  89659. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89660. /**
  89661. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89662. * are rendered back to front.
  89663. *
  89664. * @param a The first submesh
  89665. * @param b The second submesh
  89666. * @returns The result of the comparison
  89667. */
  89668. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89669. /**
  89670. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89671. * are rendered front to back (prevent overdraw).
  89672. *
  89673. * @param a The first submesh
  89674. * @param b The second submesh
  89675. * @returns The result of the comparison
  89676. */
  89677. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89678. /**
  89679. * Resets the different lists of submeshes to prepare a new frame.
  89680. */
  89681. prepare(): void;
  89682. dispose(): void;
  89683. /**
  89684. * Inserts the submesh in its correct queue depending on its material.
  89685. * @param subMesh The submesh to dispatch
  89686. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89687. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89688. */
  89689. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89690. dispatchSprites(spriteManager: ISpriteManager): void;
  89691. dispatchParticles(particleSystem: IParticleSystem): void;
  89692. private _renderParticles;
  89693. private _renderSprites;
  89694. }
  89695. }
  89696. declare module BABYLON {
  89697. /**
  89698. * Interface describing the different options available in the rendering manager
  89699. * regarding Auto Clear between groups.
  89700. */
  89701. export interface IRenderingManagerAutoClearSetup {
  89702. /**
  89703. * Defines whether or not autoclear is enable.
  89704. */
  89705. autoClear: boolean;
  89706. /**
  89707. * Defines whether or not to autoclear the depth buffer.
  89708. */
  89709. depth: boolean;
  89710. /**
  89711. * Defines whether or not to autoclear the stencil buffer.
  89712. */
  89713. stencil: boolean;
  89714. }
  89715. /**
  89716. * This class is used by the onRenderingGroupObservable
  89717. */
  89718. export class RenderingGroupInfo {
  89719. /**
  89720. * The Scene that being rendered
  89721. */
  89722. scene: Scene;
  89723. /**
  89724. * The camera currently used for the rendering pass
  89725. */
  89726. camera: Nullable<Camera>;
  89727. /**
  89728. * The ID of the renderingGroup being processed
  89729. */
  89730. renderingGroupId: number;
  89731. }
  89732. /**
  89733. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89734. * It is enable to manage the different groups as well as the different necessary sort functions.
  89735. * This should not be used directly aside of the few static configurations
  89736. */
  89737. export class RenderingManager {
  89738. /**
  89739. * The max id used for rendering groups (not included)
  89740. */
  89741. static MAX_RENDERINGGROUPS: number;
  89742. /**
  89743. * The min id used for rendering groups (included)
  89744. */
  89745. static MIN_RENDERINGGROUPS: number;
  89746. /**
  89747. * Used to globally prevent autoclearing scenes.
  89748. */
  89749. static AUTOCLEAR: boolean;
  89750. /**
  89751. * @hidden
  89752. */
  89753. _useSceneAutoClearSetup: boolean;
  89754. private _scene;
  89755. private _renderingGroups;
  89756. private _depthStencilBufferAlreadyCleaned;
  89757. private _autoClearDepthStencil;
  89758. private _customOpaqueSortCompareFn;
  89759. private _customAlphaTestSortCompareFn;
  89760. private _customTransparentSortCompareFn;
  89761. private _renderingGroupInfo;
  89762. /**
  89763. * Instantiates a new rendering group for a particular scene
  89764. * @param scene Defines the scene the groups belongs to
  89765. */
  89766. constructor(scene: Scene);
  89767. private _clearDepthStencilBuffer;
  89768. /**
  89769. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89770. * @hidden
  89771. */
  89772. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89773. /**
  89774. * Resets the different information of the group to prepare a new frame
  89775. * @hidden
  89776. */
  89777. reset(): void;
  89778. /**
  89779. * Dispose and release the group and its associated resources.
  89780. * @hidden
  89781. */
  89782. dispose(): void;
  89783. /**
  89784. * Clear the info related to rendering groups preventing retention points during dispose.
  89785. */
  89786. freeRenderingGroups(): void;
  89787. private _prepareRenderingGroup;
  89788. /**
  89789. * Add a sprite manager to the rendering manager in order to render it this frame.
  89790. * @param spriteManager Define the sprite manager to render
  89791. */
  89792. dispatchSprites(spriteManager: ISpriteManager): void;
  89793. /**
  89794. * Add a particle system to the rendering manager in order to render it this frame.
  89795. * @param particleSystem Define the particle system to render
  89796. */
  89797. dispatchParticles(particleSystem: IParticleSystem): void;
  89798. /**
  89799. * Add a submesh to the manager in order to render it this frame
  89800. * @param subMesh The submesh to dispatch
  89801. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89802. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89803. */
  89804. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89805. /**
  89806. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89807. * This allowed control for front to back rendering or reversly depending of the special needs.
  89808. *
  89809. * @param renderingGroupId The rendering group id corresponding to its index
  89810. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89811. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89812. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89813. */
  89814. 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;
  89815. /**
  89816. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89817. *
  89818. * @param renderingGroupId The rendering group id corresponding to its index
  89819. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89820. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89821. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89822. */
  89823. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89824. /**
  89825. * Gets the current auto clear configuration for one rendering group of the rendering
  89826. * manager.
  89827. * @param index the rendering group index to get the information for
  89828. * @returns The auto clear setup for the requested rendering group
  89829. */
  89830. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89831. }
  89832. }
  89833. declare module BABYLON {
  89834. /**
  89835. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89836. */
  89837. export interface ICustomShaderOptions {
  89838. /**
  89839. * Gets or sets the custom shader name to use
  89840. */
  89841. shaderName: string;
  89842. /**
  89843. * The list of attribute names used in the shader
  89844. */
  89845. attributes?: string[];
  89846. /**
  89847. * The list of unifrom names used in the shader
  89848. */
  89849. uniforms?: string[];
  89850. /**
  89851. * The list of sampler names used in the shader
  89852. */
  89853. samplers?: string[];
  89854. /**
  89855. * The list of defines used in the shader
  89856. */
  89857. defines?: string[];
  89858. }
  89859. /**
  89860. * Interface to implement to create a shadow generator compatible with BJS.
  89861. */
  89862. export interface IShadowGenerator {
  89863. /**
  89864. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89865. * @returns The render target texture if present otherwise, null
  89866. */
  89867. getShadowMap(): Nullable<RenderTargetTexture>;
  89868. /**
  89869. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89870. * @param subMesh The submesh we want to render in the shadow map
  89871. * @param useInstances Defines wether will draw in the map using instances
  89872. * @returns true if ready otherwise, false
  89873. */
  89874. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89875. /**
  89876. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89877. * @param defines Defines of the material we want to update
  89878. * @param lightIndex Index of the light in the enabled light list of the material
  89879. */
  89880. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89881. /**
  89882. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89883. * defined in the generator but impacting the effect).
  89884. * It implies the unifroms available on the materials are the standard BJS ones.
  89885. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89886. * @param effect The effect we are binfing the information for
  89887. */
  89888. bindShadowLight(lightIndex: string, effect: Effect): void;
  89889. /**
  89890. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89891. * (eq to shadow prjection matrix * light transform matrix)
  89892. * @returns The transform matrix used to create the shadow map
  89893. */
  89894. getTransformMatrix(): Matrix;
  89895. /**
  89896. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89897. * Cube and 2D textures for instance.
  89898. */
  89899. recreateShadowMap(): void;
  89900. /**
  89901. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89902. * @param onCompiled Callback triggered at the and of the effects compilation
  89903. * @param options Sets of optional options forcing the compilation with different modes
  89904. */
  89905. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89906. useInstances: boolean;
  89907. }>): void;
  89908. /**
  89909. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89910. * @param options Sets of optional options forcing the compilation with different modes
  89911. * @returns A promise that resolves when the compilation completes
  89912. */
  89913. forceCompilationAsync(options?: Partial<{
  89914. useInstances: boolean;
  89915. }>): Promise<void>;
  89916. /**
  89917. * Serializes the shadow generator setup to a json object.
  89918. * @returns The serialized JSON object
  89919. */
  89920. serialize(): any;
  89921. /**
  89922. * Disposes the Shadow map and related Textures and effects.
  89923. */
  89924. dispose(): void;
  89925. }
  89926. /**
  89927. * Default implementation IShadowGenerator.
  89928. * This is the main object responsible of generating shadows in the framework.
  89929. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89930. */
  89931. export class ShadowGenerator implements IShadowGenerator {
  89932. /**
  89933. * Name of the shadow generator class
  89934. */
  89935. static CLASSNAME: string;
  89936. /**
  89937. * Shadow generator mode None: no filtering applied.
  89938. */
  89939. static readonly FILTER_NONE: number;
  89940. /**
  89941. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89942. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89943. */
  89944. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89945. /**
  89946. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89947. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89948. */
  89949. static readonly FILTER_POISSONSAMPLING: number;
  89950. /**
  89951. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89952. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89953. */
  89954. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89955. /**
  89956. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89957. * edge artifacts on steep falloff.
  89958. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89959. */
  89960. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89961. /**
  89962. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89963. * edge artifacts on steep falloff.
  89964. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89965. */
  89966. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89967. /**
  89968. * Shadow generator mode PCF: Percentage Closer Filtering
  89969. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89970. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89971. */
  89972. static readonly FILTER_PCF: number;
  89973. /**
  89974. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89975. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89976. * Contact Hardening
  89977. */
  89978. static readonly FILTER_PCSS: number;
  89979. /**
  89980. * Reserved for PCF and PCSS
  89981. * Highest Quality.
  89982. *
  89983. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89984. *
  89985. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89986. */
  89987. static readonly QUALITY_HIGH: number;
  89988. /**
  89989. * Reserved for PCF and PCSS
  89990. * Good tradeoff for quality/perf cross devices
  89991. *
  89992. * Execute PCF on a 3*3 kernel.
  89993. *
  89994. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89995. */
  89996. static readonly QUALITY_MEDIUM: number;
  89997. /**
  89998. * Reserved for PCF and PCSS
  89999. * The lowest quality but the fastest.
  90000. *
  90001. * Execute PCF on a 1*1 kernel.
  90002. *
  90003. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  90004. */
  90005. static readonly QUALITY_LOW: number;
  90006. /** Gets or sets the custom shader name to use */
  90007. customShaderOptions: ICustomShaderOptions;
  90008. /**
  90009. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  90010. */
  90011. onBeforeShadowMapRenderObservable: Observable<Effect>;
  90012. /**
  90013. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  90014. */
  90015. onAfterShadowMapRenderObservable: Observable<Effect>;
  90016. /**
  90017. * Observable triggered before a mesh is rendered in the shadow map.
  90018. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  90019. */
  90020. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  90021. /**
  90022. * Observable triggered after a mesh is rendered in the shadow map.
  90023. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  90024. */
  90025. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  90026. protected _bias: number;
  90027. /**
  90028. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  90029. */
  90030. get bias(): number;
  90031. /**
  90032. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  90033. */
  90034. set bias(bias: number);
  90035. protected _normalBias: number;
  90036. /**
  90037. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90038. */
  90039. get normalBias(): number;
  90040. /**
  90041. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90042. */
  90043. set normalBias(normalBias: number);
  90044. protected _blurBoxOffset: number;
  90045. /**
  90046. * Gets the blur box offset: offset applied during the blur pass.
  90047. * Only useful if useKernelBlur = false
  90048. */
  90049. get blurBoxOffset(): number;
  90050. /**
  90051. * Sets the blur box offset: offset applied during the blur pass.
  90052. * Only useful if useKernelBlur = false
  90053. */
  90054. set blurBoxOffset(value: number);
  90055. protected _blurScale: number;
  90056. /**
  90057. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  90058. * 2 means half of the size.
  90059. */
  90060. get blurScale(): number;
  90061. /**
  90062. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  90063. * 2 means half of the size.
  90064. */
  90065. set blurScale(value: number);
  90066. protected _blurKernel: number;
  90067. /**
  90068. * Gets the blur kernel: kernel size of the blur pass.
  90069. * Only useful if useKernelBlur = true
  90070. */
  90071. get blurKernel(): number;
  90072. /**
  90073. * Sets the blur kernel: kernel size of the blur pass.
  90074. * Only useful if useKernelBlur = true
  90075. */
  90076. set blurKernel(value: number);
  90077. protected _useKernelBlur: boolean;
  90078. /**
  90079. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  90080. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90081. */
  90082. get useKernelBlur(): boolean;
  90083. /**
  90084. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  90085. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90086. */
  90087. set useKernelBlur(value: boolean);
  90088. protected _depthScale: number;
  90089. /**
  90090. * Gets the depth scale used in ESM mode.
  90091. */
  90092. get depthScale(): number;
  90093. /**
  90094. * Sets the depth scale used in ESM mode.
  90095. * This can override the scale stored on the light.
  90096. */
  90097. set depthScale(value: number);
  90098. protected _validateFilter(filter: number): number;
  90099. protected _filter: number;
  90100. /**
  90101. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  90102. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90103. */
  90104. get filter(): number;
  90105. /**
  90106. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  90107. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90108. */
  90109. set filter(value: number);
  90110. /**
  90111. * Gets if the current filter is set to Poisson Sampling.
  90112. */
  90113. get usePoissonSampling(): boolean;
  90114. /**
  90115. * Sets the current filter to Poisson Sampling.
  90116. */
  90117. set usePoissonSampling(value: boolean);
  90118. /**
  90119. * Gets if the current filter is set to ESM.
  90120. */
  90121. get useExponentialShadowMap(): boolean;
  90122. /**
  90123. * Sets the current filter is to ESM.
  90124. */
  90125. set useExponentialShadowMap(value: boolean);
  90126. /**
  90127. * Gets if the current filter is set to filtered ESM.
  90128. */
  90129. get useBlurExponentialShadowMap(): boolean;
  90130. /**
  90131. * Gets if the current filter is set to filtered ESM.
  90132. */
  90133. set useBlurExponentialShadowMap(value: boolean);
  90134. /**
  90135. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90136. * exponential to prevent steep falloff artifacts).
  90137. */
  90138. get useCloseExponentialShadowMap(): boolean;
  90139. /**
  90140. * Sets the current filter to "close ESM" (using the inverse of the
  90141. * exponential to prevent steep falloff artifacts).
  90142. */
  90143. set useCloseExponentialShadowMap(value: boolean);
  90144. /**
  90145. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90146. * exponential to prevent steep falloff artifacts).
  90147. */
  90148. get useBlurCloseExponentialShadowMap(): boolean;
  90149. /**
  90150. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90151. * exponential to prevent steep falloff artifacts).
  90152. */
  90153. set useBlurCloseExponentialShadowMap(value: boolean);
  90154. /**
  90155. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90156. */
  90157. get usePercentageCloserFiltering(): boolean;
  90158. /**
  90159. * Sets the current filter to "PCF" (percentage closer filtering).
  90160. */
  90161. set usePercentageCloserFiltering(value: boolean);
  90162. protected _filteringQuality: number;
  90163. /**
  90164. * Gets the PCF or PCSS Quality.
  90165. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90166. */
  90167. get filteringQuality(): number;
  90168. /**
  90169. * Sets the PCF or PCSS Quality.
  90170. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90171. */
  90172. set filteringQuality(filteringQuality: number);
  90173. /**
  90174. * Gets if the current filter is set to "PCSS" (contact hardening).
  90175. */
  90176. get useContactHardeningShadow(): boolean;
  90177. /**
  90178. * Sets the current filter to "PCSS" (contact hardening).
  90179. */
  90180. set useContactHardeningShadow(value: boolean);
  90181. protected _contactHardeningLightSizeUVRatio: number;
  90182. /**
  90183. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90184. * Using a ratio helps keeping shape stability independently of the map size.
  90185. *
  90186. * It does not account for the light projection as it was having too much
  90187. * instability during the light setup or during light position changes.
  90188. *
  90189. * Only valid if useContactHardeningShadow is true.
  90190. */
  90191. get contactHardeningLightSizeUVRatio(): number;
  90192. /**
  90193. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90194. * Using a ratio helps keeping shape stability independently of the map size.
  90195. *
  90196. * It does not account for the light projection as it was having too much
  90197. * instability during the light setup or during light position changes.
  90198. *
  90199. * Only valid if useContactHardeningShadow is true.
  90200. */
  90201. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90202. protected _darkness: number;
  90203. /** Gets or sets the actual darkness of a shadow */
  90204. get darkness(): number;
  90205. set darkness(value: number);
  90206. /**
  90207. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90208. * 0 means strongest and 1 would means no shadow.
  90209. * @returns the darkness.
  90210. */
  90211. getDarkness(): number;
  90212. /**
  90213. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90214. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90215. * @returns the shadow generator allowing fluent coding.
  90216. */
  90217. setDarkness(darkness: number): ShadowGenerator;
  90218. protected _transparencyShadow: boolean;
  90219. /** Gets or sets the ability to have transparent shadow */
  90220. get transparencyShadow(): boolean;
  90221. set transparencyShadow(value: boolean);
  90222. /**
  90223. * Sets the ability to have transparent shadow (boolean).
  90224. * @param transparent True if transparent else False
  90225. * @returns the shadow generator allowing fluent coding
  90226. */
  90227. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90228. protected _shadowMap: Nullable<RenderTargetTexture>;
  90229. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90230. /**
  90231. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90232. * @returns The render target texture if present otherwise, null
  90233. */
  90234. getShadowMap(): Nullable<RenderTargetTexture>;
  90235. /**
  90236. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90237. * @returns The render target texture if the shadow map is present otherwise, null
  90238. */
  90239. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90240. /**
  90241. * Gets the class name of that object
  90242. * @returns "ShadowGenerator"
  90243. */
  90244. getClassName(): string;
  90245. /**
  90246. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90247. * @param mesh Mesh to add
  90248. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90249. * @returns the Shadow Generator itself
  90250. */
  90251. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90252. /**
  90253. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90254. * @param mesh Mesh to remove
  90255. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90256. * @returns the Shadow Generator itself
  90257. */
  90258. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90259. /**
  90260. * Controls the extent to which the shadows fade out at the edge of the frustum
  90261. */
  90262. frustumEdgeFalloff: number;
  90263. protected _light: IShadowLight;
  90264. /**
  90265. * Returns the associated light object.
  90266. * @returns the light generating the shadow
  90267. */
  90268. getLight(): IShadowLight;
  90269. /**
  90270. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90271. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90272. * It might on the other hand introduce peter panning.
  90273. */
  90274. forceBackFacesOnly: boolean;
  90275. protected _scene: Scene;
  90276. protected _lightDirection: Vector3;
  90277. protected _effect: Effect;
  90278. protected _viewMatrix: Matrix;
  90279. protected _projectionMatrix: Matrix;
  90280. protected _transformMatrix: Matrix;
  90281. protected _cachedPosition: Vector3;
  90282. protected _cachedDirection: Vector3;
  90283. protected _cachedDefines: string;
  90284. protected _currentRenderID: number;
  90285. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90286. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90287. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90288. protected _blurPostProcesses: PostProcess[];
  90289. protected _mapSize: number;
  90290. protected _currentFaceIndex: number;
  90291. protected _currentFaceIndexCache: number;
  90292. protected _textureType: number;
  90293. protected _defaultTextureMatrix: Matrix;
  90294. protected _storedUniqueId: Nullable<number>;
  90295. /** @hidden */
  90296. static _SceneComponentInitialization: (scene: Scene) => void;
  90297. /**
  90298. * Creates a ShadowGenerator object.
  90299. * A ShadowGenerator is the required tool to use the shadows.
  90300. * Each light casting shadows needs to use its own ShadowGenerator.
  90301. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  90302. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  90303. * @param light The light object generating the shadows.
  90304. * @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.
  90305. */
  90306. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  90307. protected _initializeGenerator(): void;
  90308. protected _createTargetRenderTexture(): void;
  90309. protected _initializeShadowMap(): void;
  90310. protected _initializeBlurRTTAndPostProcesses(): void;
  90311. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  90312. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  90313. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  90314. protected _applyFilterValues(): void;
  90315. /**
  90316. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90317. * @param onCompiled Callback triggered at the and of the effects compilation
  90318. * @param options Sets of optional options forcing the compilation with different modes
  90319. */
  90320. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90321. useInstances: boolean;
  90322. }>): void;
  90323. /**
  90324. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90325. * @param options Sets of optional options forcing the compilation with different modes
  90326. * @returns A promise that resolves when the compilation completes
  90327. */
  90328. forceCompilationAsync(options?: Partial<{
  90329. useInstances: boolean;
  90330. }>): Promise<void>;
  90331. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  90332. /**
  90333. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90334. * @param subMesh The submesh we want to render in the shadow map
  90335. * @param useInstances Defines wether will draw in the map using instances
  90336. * @returns true if ready otherwise, false
  90337. */
  90338. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90339. /**
  90340. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90341. * @param defines Defines of the material we want to update
  90342. * @param lightIndex Index of the light in the enabled light list of the material
  90343. */
  90344. prepareDefines(defines: any, lightIndex: number): void;
  90345. /**
  90346. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90347. * defined in the generator but impacting the effect).
  90348. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90349. * @param effect The effect we are binfing the information for
  90350. */
  90351. bindShadowLight(lightIndex: string, effect: Effect): void;
  90352. /**
  90353. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90354. * (eq to shadow prjection matrix * light transform matrix)
  90355. * @returns The transform matrix used to create the shadow map
  90356. */
  90357. getTransformMatrix(): Matrix;
  90358. /**
  90359. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90360. * Cube and 2D textures for instance.
  90361. */
  90362. recreateShadowMap(): void;
  90363. protected _disposeBlurPostProcesses(): void;
  90364. protected _disposeRTTandPostProcesses(): void;
  90365. /**
  90366. * Disposes the ShadowGenerator.
  90367. * Returns nothing.
  90368. */
  90369. dispose(): void;
  90370. /**
  90371. * Serializes the shadow generator setup to a json object.
  90372. * @returns The serialized JSON object
  90373. */
  90374. serialize(): any;
  90375. /**
  90376. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  90377. * @param parsedShadowGenerator The JSON object to parse
  90378. * @param scene The scene to create the shadow map for
  90379. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  90380. * @returns The parsed shadow generator
  90381. */
  90382. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  90383. }
  90384. }
  90385. declare module BABYLON {
  90386. /**
  90387. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  90388. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  90389. * 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.
  90390. */
  90391. export abstract class Light extends Node {
  90392. /**
  90393. * Falloff Default: light is falling off following the material specification:
  90394. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  90395. */
  90396. static readonly FALLOFF_DEFAULT: number;
  90397. /**
  90398. * Falloff Physical: light is falling off following the inverse squared distance law.
  90399. */
  90400. static readonly FALLOFF_PHYSICAL: number;
  90401. /**
  90402. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  90403. * to enhance interoperability with other engines.
  90404. */
  90405. static readonly FALLOFF_GLTF: number;
  90406. /**
  90407. * Falloff Standard: light is falling off like in the standard material
  90408. * to enhance interoperability with other materials.
  90409. */
  90410. static readonly FALLOFF_STANDARD: number;
  90411. /**
  90412. * If every light affecting the material is in this lightmapMode,
  90413. * material.lightmapTexture adds or multiplies
  90414. * (depends on material.useLightmapAsShadowmap)
  90415. * after every other light calculations.
  90416. */
  90417. static readonly LIGHTMAP_DEFAULT: number;
  90418. /**
  90419. * material.lightmapTexture as only diffuse lighting from this light
  90420. * adds only specular lighting from this light
  90421. * adds dynamic shadows
  90422. */
  90423. static readonly LIGHTMAP_SPECULAR: number;
  90424. /**
  90425. * material.lightmapTexture as only lighting
  90426. * no light calculation from this light
  90427. * only adds dynamic shadows from this light
  90428. */
  90429. static readonly LIGHTMAP_SHADOWSONLY: number;
  90430. /**
  90431. * Each light type uses the default quantity according to its type:
  90432. * point/spot lights use luminous intensity
  90433. * directional lights use illuminance
  90434. */
  90435. static readonly INTENSITYMODE_AUTOMATIC: number;
  90436. /**
  90437. * lumen (lm)
  90438. */
  90439. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90440. /**
  90441. * candela (lm/sr)
  90442. */
  90443. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90444. /**
  90445. * lux (lm/m^2)
  90446. */
  90447. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90448. /**
  90449. * nit (cd/m^2)
  90450. */
  90451. static readonly INTENSITYMODE_LUMINANCE: number;
  90452. /**
  90453. * Light type const id of the point light.
  90454. */
  90455. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90456. /**
  90457. * Light type const id of the directional light.
  90458. */
  90459. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90460. /**
  90461. * Light type const id of the spot light.
  90462. */
  90463. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90464. /**
  90465. * Light type const id of the hemispheric light.
  90466. */
  90467. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90468. /**
  90469. * Diffuse gives the basic color to an object.
  90470. */
  90471. diffuse: Color3;
  90472. /**
  90473. * Specular produces a highlight color on an object.
  90474. * Note: This is note affecting PBR materials.
  90475. */
  90476. specular: Color3;
  90477. /**
  90478. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90479. * falling off base on range or angle.
  90480. * This can be set to any values in Light.FALLOFF_x.
  90481. *
  90482. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90483. * other types of materials.
  90484. */
  90485. falloffType: number;
  90486. /**
  90487. * Strength of the light.
  90488. * Note: By default it is define in the framework own unit.
  90489. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90490. */
  90491. intensity: number;
  90492. private _range;
  90493. protected _inverseSquaredRange: number;
  90494. /**
  90495. * Defines how far from the source the light is impacting in scene units.
  90496. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90497. */
  90498. get range(): number;
  90499. /**
  90500. * Defines how far from the source the light is impacting in scene units.
  90501. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90502. */
  90503. set range(value: number);
  90504. /**
  90505. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90506. * of light.
  90507. */
  90508. private _photometricScale;
  90509. private _intensityMode;
  90510. /**
  90511. * Gets the photometric scale used to interpret the intensity.
  90512. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90513. */
  90514. get intensityMode(): number;
  90515. /**
  90516. * Sets the photometric scale used to interpret the intensity.
  90517. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90518. */
  90519. set intensityMode(value: number);
  90520. private _radius;
  90521. /**
  90522. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90523. */
  90524. get radius(): number;
  90525. /**
  90526. * sets the light radius used by PBR Materials to simulate soft area lights.
  90527. */
  90528. set radius(value: number);
  90529. private _renderPriority;
  90530. /**
  90531. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90532. * exceeding the number allowed of the materials.
  90533. */
  90534. renderPriority: number;
  90535. private _shadowEnabled;
  90536. /**
  90537. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90538. * the current shadow generator.
  90539. */
  90540. get shadowEnabled(): boolean;
  90541. /**
  90542. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90543. * the current shadow generator.
  90544. */
  90545. set shadowEnabled(value: boolean);
  90546. private _includedOnlyMeshes;
  90547. /**
  90548. * Gets the only meshes impacted by this light.
  90549. */
  90550. get includedOnlyMeshes(): AbstractMesh[];
  90551. /**
  90552. * Sets the only meshes impacted by this light.
  90553. */
  90554. set includedOnlyMeshes(value: AbstractMesh[]);
  90555. private _excludedMeshes;
  90556. /**
  90557. * Gets the meshes not impacted by this light.
  90558. */
  90559. get excludedMeshes(): AbstractMesh[];
  90560. /**
  90561. * Sets the meshes not impacted by this light.
  90562. */
  90563. set excludedMeshes(value: AbstractMesh[]);
  90564. private _excludeWithLayerMask;
  90565. /**
  90566. * Gets the layer id use to find what meshes are not impacted by the light.
  90567. * Inactive if 0
  90568. */
  90569. get excludeWithLayerMask(): number;
  90570. /**
  90571. * Sets the layer id use to find what meshes are not impacted by the light.
  90572. * Inactive if 0
  90573. */
  90574. set excludeWithLayerMask(value: number);
  90575. private _includeOnlyWithLayerMask;
  90576. /**
  90577. * Gets the layer id use to find what meshes are impacted by the light.
  90578. * Inactive if 0
  90579. */
  90580. get includeOnlyWithLayerMask(): number;
  90581. /**
  90582. * Sets the layer id use to find what meshes are impacted by the light.
  90583. * Inactive if 0
  90584. */
  90585. set includeOnlyWithLayerMask(value: number);
  90586. private _lightmapMode;
  90587. /**
  90588. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90589. */
  90590. get lightmapMode(): number;
  90591. /**
  90592. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90593. */
  90594. set lightmapMode(value: number);
  90595. /**
  90596. * Shadow generator associted to the light.
  90597. * @hidden Internal use only.
  90598. */
  90599. _shadowGenerator: Nullable<IShadowGenerator>;
  90600. /**
  90601. * @hidden Internal use only.
  90602. */
  90603. _excludedMeshesIds: string[];
  90604. /**
  90605. * @hidden Internal use only.
  90606. */
  90607. _includedOnlyMeshesIds: string[];
  90608. /**
  90609. * The current light unifom buffer.
  90610. * @hidden Internal use only.
  90611. */
  90612. _uniformBuffer: UniformBuffer;
  90613. /** @hidden */
  90614. _renderId: number;
  90615. /**
  90616. * Creates a Light object in the scene.
  90617. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90618. * @param name The firendly name of the light
  90619. * @param scene The scene the light belongs too
  90620. */
  90621. constructor(name: string, scene: Scene);
  90622. protected abstract _buildUniformLayout(): void;
  90623. /**
  90624. * Sets the passed Effect "effect" with the Light information.
  90625. * @param effect The effect to update
  90626. * @param lightIndex The index of the light in the effect to update
  90627. * @returns The light
  90628. */
  90629. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90630. /**
  90631. * Sets the passed Effect "effect" with the Light textures.
  90632. * @param effect The effect to update
  90633. * @param lightIndex The index of the light in the effect to update
  90634. * @returns The light
  90635. */
  90636. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90637. /**
  90638. * Binds the lights information from the scene to the effect for the given mesh.
  90639. * @param lightIndex Light index
  90640. * @param scene The scene where the light belongs to
  90641. * @param effect The effect we are binding the data to
  90642. * @param useSpecular Defines if specular is supported
  90643. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90644. */
  90645. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90646. /**
  90647. * Sets the passed Effect "effect" with the Light information.
  90648. * @param effect The effect to update
  90649. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90650. * @returns The light
  90651. */
  90652. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90653. /**
  90654. * Returns the string "Light".
  90655. * @returns the class name
  90656. */
  90657. getClassName(): string;
  90658. /** @hidden */
  90659. readonly _isLight: boolean;
  90660. /**
  90661. * Converts the light information to a readable string for debug purpose.
  90662. * @param fullDetails Supports for multiple levels of logging within scene loading
  90663. * @returns the human readable light info
  90664. */
  90665. toString(fullDetails?: boolean): string;
  90666. /** @hidden */
  90667. protected _syncParentEnabledState(): void;
  90668. /**
  90669. * Set the enabled state of this node.
  90670. * @param value - the new enabled state
  90671. */
  90672. setEnabled(value: boolean): void;
  90673. /**
  90674. * Returns the Light associated shadow generator if any.
  90675. * @return the associated shadow generator.
  90676. */
  90677. getShadowGenerator(): Nullable<IShadowGenerator>;
  90678. /**
  90679. * Returns a Vector3, the absolute light position in the World.
  90680. * @returns the world space position of the light
  90681. */
  90682. getAbsolutePosition(): Vector3;
  90683. /**
  90684. * Specifies if the light will affect the passed mesh.
  90685. * @param mesh The mesh to test against the light
  90686. * @return true the mesh is affected otherwise, false.
  90687. */
  90688. canAffectMesh(mesh: AbstractMesh): boolean;
  90689. /**
  90690. * Sort function to order lights for rendering.
  90691. * @param a First Light object to compare to second.
  90692. * @param b Second Light object to compare first.
  90693. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90694. */
  90695. static CompareLightsPriority(a: Light, b: Light): number;
  90696. /**
  90697. * Releases resources associated with this node.
  90698. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90699. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90700. */
  90701. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90702. /**
  90703. * Returns the light type ID (integer).
  90704. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90705. */
  90706. getTypeID(): number;
  90707. /**
  90708. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90709. * @returns the scaled intensity in intensity mode unit
  90710. */
  90711. getScaledIntensity(): number;
  90712. /**
  90713. * Returns a new Light object, named "name", from the current one.
  90714. * @param name The name of the cloned light
  90715. * @returns the new created light
  90716. */
  90717. clone(name: string): Nullable<Light>;
  90718. /**
  90719. * Serializes the current light into a Serialization object.
  90720. * @returns the serialized object.
  90721. */
  90722. serialize(): any;
  90723. /**
  90724. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90725. * This new light is named "name" and added to the passed scene.
  90726. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90727. * @param name The friendly name of the light
  90728. * @param scene The scene the new light will belong to
  90729. * @returns the constructor function
  90730. */
  90731. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90732. /**
  90733. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90734. * @param parsedLight The JSON representation of the light
  90735. * @param scene The scene to create the parsed light in
  90736. * @returns the created light after parsing
  90737. */
  90738. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90739. private _hookArrayForExcluded;
  90740. private _hookArrayForIncludedOnly;
  90741. private _resyncMeshes;
  90742. /**
  90743. * Forces the meshes to update their light related information in their rendering used effects
  90744. * @hidden Internal Use Only
  90745. */
  90746. _markMeshesAsLightDirty(): void;
  90747. /**
  90748. * Recomputes the cached photometric scale if needed.
  90749. */
  90750. private _computePhotometricScale;
  90751. /**
  90752. * Returns the Photometric Scale according to the light type and intensity mode.
  90753. */
  90754. private _getPhotometricScale;
  90755. /**
  90756. * Reorder the light in the scene according to their defined priority.
  90757. * @hidden Internal Use Only
  90758. */
  90759. _reorderLightsInScene(): void;
  90760. /**
  90761. * Prepares the list of defines specific to the light type.
  90762. * @param defines the list of defines
  90763. * @param lightIndex defines the index of the light for the effect
  90764. */
  90765. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90766. }
  90767. }
  90768. declare module BABYLON {
  90769. /**
  90770. * Interface used to define Action
  90771. */
  90772. export interface IAction {
  90773. /**
  90774. * Trigger for the action
  90775. */
  90776. trigger: number;
  90777. /** Options of the trigger */
  90778. triggerOptions: any;
  90779. /**
  90780. * Gets the trigger parameters
  90781. * @returns the trigger parameters
  90782. */
  90783. getTriggerParameter(): any;
  90784. /**
  90785. * Internal only - executes current action event
  90786. * @hidden
  90787. */
  90788. _executeCurrent(evt?: ActionEvent): void;
  90789. /**
  90790. * Serialize placeholder for child classes
  90791. * @param parent of child
  90792. * @returns the serialized object
  90793. */
  90794. serialize(parent: any): any;
  90795. /**
  90796. * Internal only
  90797. * @hidden
  90798. */
  90799. _prepare(): void;
  90800. /**
  90801. * Internal only - manager for action
  90802. * @hidden
  90803. */
  90804. _actionManager: AbstractActionManager;
  90805. /**
  90806. * Adds action to chain of actions, may be a DoNothingAction
  90807. * @param action defines the next action to execute
  90808. * @returns The action passed in
  90809. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90810. */
  90811. then(action: IAction): IAction;
  90812. }
  90813. /**
  90814. * The action to be carried out following a trigger
  90815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90816. */
  90817. export class Action implements IAction {
  90818. /** the trigger, with or without parameters, for the action */
  90819. triggerOptions: any;
  90820. /**
  90821. * Trigger for the action
  90822. */
  90823. trigger: number;
  90824. /**
  90825. * Internal only - manager for action
  90826. * @hidden
  90827. */
  90828. _actionManager: ActionManager;
  90829. private _nextActiveAction;
  90830. private _child;
  90831. private _condition?;
  90832. private _triggerParameter;
  90833. /**
  90834. * An event triggered prior to action being executed.
  90835. */
  90836. onBeforeExecuteObservable: Observable<Action>;
  90837. /**
  90838. * Creates a new Action
  90839. * @param triggerOptions the trigger, with or without parameters, for the action
  90840. * @param condition an optional determinant of action
  90841. */
  90842. constructor(
  90843. /** the trigger, with or without parameters, for the action */
  90844. triggerOptions: any, condition?: Condition);
  90845. /**
  90846. * Internal only
  90847. * @hidden
  90848. */
  90849. _prepare(): void;
  90850. /**
  90851. * Gets the trigger parameters
  90852. * @returns the trigger parameters
  90853. */
  90854. getTriggerParameter(): any;
  90855. /**
  90856. * Internal only - executes current action event
  90857. * @hidden
  90858. */
  90859. _executeCurrent(evt?: ActionEvent): void;
  90860. /**
  90861. * Execute placeholder for child classes
  90862. * @param evt optional action event
  90863. */
  90864. execute(evt?: ActionEvent): void;
  90865. /**
  90866. * Skips to next active action
  90867. */
  90868. skipToNextActiveAction(): void;
  90869. /**
  90870. * Adds action to chain of actions, may be a DoNothingAction
  90871. * @param action defines the next action to execute
  90872. * @returns The action passed in
  90873. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90874. */
  90875. then(action: Action): Action;
  90876. /**
  90877. * Internal only
  90878. * @hidden
  90879. */
  90880. _getProperty(propertyPath: string): string;
  90881. /**
  90882. * Internal only
  90883. * @hidden
  90884. */
  90885. _getEffectiveTarget(target: any, propertyPath: string): any;
  90886. /**
  90887. * Serialize placeholder for child classes
  90888. * @param parent of child
  90889. * @returns the serialized object
  90890. */
  90891. serialize(parent: any): any;
  90892. /**
  90893. * Internal only called by serialize
  90894. * @hidden
  90895. */
  90896. protected _serialize(serializedAction: any, parent?: any): any;
  90897. /**
  90898. * Internal only
  90899. * @hidden
  90900. */
  90901. static _SerializeValueAsString: (value: any) => string;
  90902. /**
  90903. * Internal only
  90904. * @hidden
  90905. */
  90906. static _GetTargetProperty: (target: Node | Scene) => {
  90907. name: string;
  90908. targetType: string;
  90909. value: string;
  90910. };
  90911. }
  90912. }
  90913. declare module BABYLON {
  90914. /**
  90915. * A Condition applied to an Action
  90916. */
  90917. export class Condition {
  90918. /**
  90919. * Internal only - manager for action
  90920. * @hidden
  90921. */
  90922. _actionManager: ActionManager;
  90923. /**
  90924. * Internal only
  90925. * @hidden
  90926. */
  90927. _evaluationId: number;
  90928. /**
  90929. * Internal only
  90930. * @hidden
  90931. */
  90932. _currentResult: boolean;
  90933. /**
  90934. * Creates a new Condition
  90935. * @param actionManager the manager of the action the condition is applied to
  90936. */
  90937. constructor(actionManager: ActionManager);
  90938. /**
  90939. * Check if the current condition is valid
  90940. * @returns a boolean
  90941. */
  90942. isValid(): boolean;
  90943. /**
  90944. * Internal only
  90945. * @hidden
  90946. */
  90947. _getProperty(propertyPath: string): string;
  90948. /**
  90949. * Internal only
  90950. * @hidden
  90951. */
  90952. _getEffectiveTarget(target: any, propertyPath: string): any;
  90953. /**
  90954. * Serialize placeholder for child classes
  90955. * @returns the serialized object
  90956. */
  90957. serialize(): any;
  90958. /**
  90959. * Internal only
  90960. * @hidden
  90961. */
  90962. protected _serialize(serializedCondition: any): any;
  90963. }
  90964. /**
  90965. * Defines specific conditional operators as extensions of Condition
  90966. */
  90967. export class ValueCondition extends Condition {
  90968. /** path to specify the property of the target the conditional operator uses */
  90969. propertyPath: string;
  90970. /** the value compared by the conditional operator against the current value of the property */
  90971. value: any;
  90972. /** the conditional operator, default ValueCondition.IsEqual */
  90973. operator: number;
  90974. /**
  90975. * Internal only
  90976. * @hidden
  90977. */
  90978. private static _IsEqual;
  90979. /**
  90980. * Internal only
  90981. * @hidden
  90982. */
  90983. private static _IsDifferent;
  90984. /**
  90985. * Internal only
  90986. * @hidden
  90987. */
  90988. private static _IsGreater;
  90989. /**
  90990. * Internal only
  90991. * @hidden
  90992. */
  90993. private static _IsLesser;
  90994. /**
  90995. * returns the number for IsEqual
  90996. */
  90997. static get IsEqual(): number;
  90998. /**
  90999. * Returns the number for IsDifferent
  91000. */
  91001. static get IsDifferent(): number;
  91002. /**
  91003. * Returns the number for IsGreater
  91004. */
  91005. static get IsGreater(): number;
  91006. /**
  91007. * Returns the number for IsLesser
  91008. */
  91009. static get IsLesser(): number;
  91010. /**
  91011. * Internal only The action manager for the condition
  91012. * @hidden
  91013. */
  91014. _actionManager: ActionManager;
  91015. /**
  91016. * Internal only
  91017. * @hidden
  91018. */
  91019. private _target;
  91020. /**
  91021. * Internal only
  91022. * @hidden
  91023. */
  91024. private _effectiveTarget;
  91025. /**
  91026. * Internal only
  91027. * @hidden
  91028. */
  91029. private _property;
  91030. /**
  91031. * Creates a new ValueCondition
  91032. * @param actionManager manager for the action the condition applies to
  91033. * @param target for the action
  91034. * @param propertyPath path to specify the property of the target the conditional operator uses
  91035. * @param value the value compared by the conditional operator against the current value of the property
  91036. * @param operator the conditional operator, default ValueCondition.IsEqual
  91037. */
  91038. constructor(actionManager: ActionManager, target: any,
  91039. /** path to specify the property of the target the conditional operator uses */
  91040. propertyPath: string,
  91041. /** the value compared by the conditional operator against the current value of the property */
  91042. value: any,
  91043. /** the conditional operator, default ValueCondition.IsEqual */
  91044. operator?: number);
  91045. /**
  91046. * Compares the given value with the property value for the specified conditional operator
  91047. * @returns the result of the comparison
  91048. */
  91049. isValid(): boolean;
  91050. /**
  91051. * Serialize the ValueCondition into a JSON compatible object
  91052. * @returns serialization object
  91053. */
  91054. serialize(): any;
  91055. /**
  91056. * Gets the name of the conditional operator for the ValueCondition
  91057. * @param operator the conditional operator
  91058. * @returns the name
  91059. */
  91060. static GetOperatorName(operator: number): string;
  91061. }
  91062. /**
  91063. * Defines a predicate condition as an extension of Condition
  91064. */
  91065. export class PredicateCondition extends Condition {
  91066. /** defines the predicate function used to validate the condition */
  91067. predicate: () => boolean;
  91068. /**
  91069. * Internal only - manager for action
  91070. * @hidden
  91071. */
  91072. _actionManager: ActionManager;
  91073. /**
  91074. * Creates a new PredicateCondition
  91075. * @param actionManager manager for the action the condition applies to
  91076. * @param predicate defines the predicate function used to validate the condition
  91077. */
  91078. constructor(actionManager: ActionManager,
  91079. /** defines the predicate function used to validate the condition */
  91080. predicate: () => boolean);
  91081. /**
  91082. * @returns the validity of the predicate condition
  91083. */
  91084. isValid(): boolean;
  91085. }
  91086. /**
  91087. * Defines a state condition as an extension of Condition
  91088. */
  91089. export class StateCondition extends Condition {
  91090. /** Value to compare with target state */
  91091. value: string;
  91092. /**
  91093. * Internal only - manager for action
  91094. * @hidden
  91095. */
  91096. _actionManager: ActionManager;
  91097. /**
  91098. * Internal only
  91099. * @hidden
  91100. */
  91101. private _target;
  91102. /**
  91103. * Creates a new StateCondition
  91104. * @param actionManager manager for the action the condition applies to
  91105. * @param target of the condition
  91106. * @param value to compare with target state
  91107. */
  91108. constructor(actionManager: ActionManager, target: any,
  91109. /** Value to compare with target state */
  91110. value: string);
  91111. /**
  91112. * Gets a boolean indicating if the current condition is met
  91113. * @returns the validity of the state
  91114. */
  91115. isValid(): boolean;
  91116. /**
  91117. * Serialize the StateCondition into a JSON compatible object
  91118. * @returns serialization object
  91119. */
  91120. serialize(): any;
  91121. }
  91122. }
  91123. declare module BABYLON {
  91124. /**
  91125. * This defines an action responsible to toggle a boolean once triggered.
  91126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91127. */
  91128. export class SwitchBooleanAction extends Action {
  91129. /**
  91130. * The path to the boolean property in the target object
  91131. */
  91132. propertyPath: string;
  91133. private _target;
  91134. private _effectiveTarget;
  91135. private _property;
  91136. /**
  91137. * Instantiate the action
  91138. * @param triggerOptions defines the trigger options
  91139. * @param target defines the object containing the boolean
  91140. * @param propertyPath defines the path to the boolean property in the target object
  91141. * @param condition defines the trigger related conditions
  91142. */
  91143. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91144. /** @hidden */
  91145. _prepare(): void;
  91146. /**
  91147. * Execute the action toggle the boolean value.
  91148. */
  91149. execute(): void;
  91150. /**
  91151. * Serializes the actions and its related information.
  91152. * @param parent defines the object to serialize in
  91153. * @returns the serialized object
  91154. */
  91155. serialize(parent: any): any;
  91156. }
  91157. /**
  91158. * This defines an action responsible to set a the state field of the target
  91159. * to a desired value once triggered.
  91160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91161. */
  91162. export class SetStateAction extends Action {
  91163. /**
  91164. * The value to store in the state field.
  91165. */
  91166. value: string;
  91167. private _target;
  91168. /**
  91169. * Instantiate the action
  91170. * @param triggerOptions defines the trigger options
  91171. * @param target defines the object containing the state property
  91172. * @param value defines the value to store in the state field
  91173. * @param condition defines the trigger related conditions
  91174. */
  91175. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91176. /**
  91177. * Execute the action and store the value on the target state property.
  91178. */
  91179. execute(): void;
  91180. /**
  91181. * Serializes the actions and its related information.
  91182. * @param parent defines the object to serialize in
  91183. * @returns the serialized object
  91184. */
  91185. serialize(parent: any): any;
  91186. }
  91187. /**
  91188. * This defines an action responsible to set a property of the target
  91189. * to a desired value once triggered.
  91190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91191. */
  91192. export class SetValueAction extends Action {
  91193. /**
  91194. * The path of the property to set in the target.
  91195. */
  91196. propertyPath: string;
  91197. /**
  91198. * The value to set in the property
  91199. */
  91200. value: any;
  91201. private _target;
  91202. private _effectiveTarget;
  91203. private _property;
  91204. /**
  91205. * Instantiate the action
  91206. * @param triggerOptions defines the trigger options
  91207. * @param target defines the object containing the property
  91208. * @param propertyPath defines the path of the property to set in the target
  91209. * @param value defines the value to set in the property
  91210. * @param condition defines the trigger related conditions
  91211. */
  91212. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91213. /** @hidden */
  91214. _prepare(): void;
  91215. /**
  91216. * Execute the action and set the targetted property to the desired value.
  91217. */
  91218. execute(): void;
  91219. /**
  91220. * Serializes the actions and its related information.
  91221. * @param parent defines the object to serialize in
  91222. * @returns the serialized object
  91223. */
  91224. serialize(parent: any): any;
  91225. }
  91226. /**
  91227. * This defines an action responsible to increment the target value
  91228. * to a desired value once triggered.
  91229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91230. */
  91231. export class IncrementValueAction extends Action {
  91232. /**
  91233. * The path of the property to increment in the target.
  91234. */
  91235. propertyPath: string;
  91236. /**
  91237. * The value we should increment the property by.
  91238. */
  91239. value: any;
  91240. private _target;
  91241. private _effectiveTarget;
  91242. private _property;
  91243. /**
  91244. * Instantiate the action
  91245. * @param triggerOptions defines the trigger options
  91246. * @param target defines the object containing the property
  91247. * @param propertyPath defines the path of the property to increment in the target
  91248. * @param value defines the value value we should increment the property by
  91249. * @param condition defines the trigger related conditions
  91250. */
  91251. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91252. /** @hidden */
  91253. _prepare(): void;
  91254. /**
  91255. * Execute the action and increment the target of the value amount.
  91256. */
  91257. execute(): void;
  91258. /**
  91259. * Serializes the actions and its related information.
  91260. * @param parent defines the object to serialize in
  91261. * @returns the serialized object
  91262. */
  91263. serialize(parent: any): any;
  91264. }
  91265. /**
  91266. * This defines an action responsible to start an animation once triggered.
  91267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91268. */
  91269. export class PlayAnimationAction extends Action {
  91270. /**
  91271. * Where the animation should start (animation frame)
  91272. */
  91273. from: number;
  91274. /**
  91275. * Where the animation should stop (animation frame)
  91276. */
  91277. to: number;
  91278. /**
  91279. * Define if the animation should loop or stop after the first play.
  91280. */
  91281. loop?: boolean;
  91282. private _target;
  91283. /**
  91284. * Instantiate the action
  91285. * @param triggerOptions defines the trigger options
  91286. * @param target defines the target animation or animation name
  91287. * @param from defines from where the animation should start (animation frame)
  91288. * @param end defines where the animation should stop (animation frame)
  91289. * @param loop defines if the animation should loop or stop after the first play
  91290. * @param condition defines the trigger related conditions
  91291. */
  91292. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91293. /** @hidden */
  91294. _prepare(): void;
  91295. /**
  91296. * Execute the action and play the animation.
  91297. */
  91298. execute(): void;
  91299. /**
  91300. * Serializes the actions and its related information.
  91301. * @param parent defines the object to serialize in
  91302. * @returns the serialized object
  91303. */
  91304. serialize(parent: any): any;
  91305. }
  91306. /**
  91307. * This defines an action responsible to stop an animation once triggered.
  91308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91309. */
  91310. export class StopAnimationAction extends Action {
  91311. private _target;
  91312. /**
  91313. * Instantiate the action
  91314. * @param triggerOptions defines the trigger options
  91315. * @param target defines the target animation or animation name
  91316. * @param condition defines the trigger related conditions
  91317. */
  91318. constructor(triggerOptions: any, target: any, condition?: Condition);
  91319. /** @hidden */
  91320. _prepare(): void;
  91321. /**
  91322. * Execute the action and stop the animation.
  91323. */
  91324. execute(): void;
  91325. /**
  91326. * Serializes the actions and its related information.
  91327. * @param parent defines the object to serialize in
  91328. * @returns the serialized object
  91329. */
  91330. serialize(parent: any): any;
  91331. }
  91332. /**
  91333. * This defines an action responsible that does nothing once triggered.
  91334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91335. */
  91336. export class DoNothingAction extends Action {
  91337. /**
  91338. * Instantiate the action
  91339. * @param triggerOptions defines the trigger options
  91340. * @param condition defines the trigger related conditions
  91341. */
  91342. constructor(triggerOptions?: any, condition?: Condition);
  91343. /**
  91344. * Execute the action and do nothing.
  91345. */
  91346. execute(): void;
  91347. /**
  91348. * Serializes the actions and its related information.
  91349. * @param parent defines the object to serialize in
  91350. * @returns the serialized object
  91351. */
  91352. serialize(parent: any): any;
  91353. }
  91354. /**
  91355. * This defines an action responsible to trigger several actions once triggered.
  91356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91357. */
  91358. export class CombineAction extends Action {
  91359. /**
  91360. * The list of aggregated animations to run.
  91361. */
  91362. children: Action[];
  91363. /**
  91364. * Instantiate the action
  91365. * @param triggerOptions defines the trigger options
  91366. * @param children defines the list of aggregated animations to run
  91367. * @param condition defines the trigger related conditions
  91368. */
  91369. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91370. /** @hidden */
  91371. _prepare(): void;
  91372. /**
  91373. * Execute the action and executes all the aggregated actions.
  91374. */
  91375. execute(evt: ActionEvent): void;
  91376. /**
  91377. * Serializes the actions and its related information.
  91378. * @param parent defines the object to serialize in
  91379. * @returns the serialized object
  91380. */
  91381. serialize(parent: any): any;
  91382. }
  91383. /**
  91384. * This defines an action responsible to run code (external event) once triggered.
  91385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91386. */
  91387. export class ExecuteCodeAction extends Action {
  91388. /**
  91389. * The callback function to run.
  91390. */
  91391. func: (evt: ActionEvent) => void;
  91392. /**
  91393. * Instantiate the action
  91394. * @param triggerOptions defines the trigger options
  91395. * @param func defines the callback function to run
  91396. * @param condition defines the trigger related conditions
  91397. */
  91398. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91399. /**
  91400. * Execute the action and run the attached code.
  91401. */
  91402. execute(evt: ActionEvent): void;
  91403. }
  91404. /**
  91405. * This defines an action responsible to set the parent property of the target once triggered.
  91406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91407. */
  91408. export class SetParentAction extends Action {
  91409. private _parent;
  91410. private _target;
  91411. /**
  91412. * Instantiate the action
  91413. * @param triggerOptions defines the trigger options
  91414. * @param target defines the target containing the parent property
  91415. * @param parent defines from where the animation should start (animation frame)
  91416. * @param condition defines the trigger related conditions
  91417. */
  91418. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91419. /** @hidden */
  91420. _prepare(): void;
  91421. /**
  91422. * Execute the action and set the parent property.
  91423. */
  91424. execute(): void;
  91425. /**
  91426. * Serializes the actions and its related information.
  91427. * @param parent defines the object to serialize in
  91428. * @returns the serialized object
  91429. */
  91430. serialize(parent: any): any;
  91431. }
  91432. }
  91433. declare module BABYLON {
  91434. /**
  91435. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91436. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91438. */
  91439. export class ActionManager extends AbstractActionManager {
  91440. /**
  91441. * Nothing
  91442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91443. */
  91444. static readonly NothingTrigger: number;
  91445. /**
  91446. * On pick
  91447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91448. */
  91449. static readonly OnPickTrigger: number;
  91450. /**
  91451. * On left pick
  91452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91453. */
  91454. static readonly OnLeftPickTrigger: number;
  91455. /**
  91456. * On right pick
  91457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91458. */
  91459. static readonly OnRightPickTrigger: number;
  91460. /**
  91461. * On center pick
  91462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91463. */
  91464. static readonly OnCenterPickTrigger: number;
  91465. /**
  91466. * On pick down
  91467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91468. */
  91469. static readonly OnPickDownTrigger: number;
  91470. /**
  91471. * On double pick
  91472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91473. */
  91474. static readonly OnDoublePickTrigger: number;
  91475. /**
  91476. * On pick up
  91477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91478. */
  91479. static readonly OnPickUpTrigger: number;
  91480. /**
  91481. * On pick out.
  91482. * This trigger will only be raised if you also declared a OnPickDown
  91483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91484. */
  91485. static readonly OnPickOutTrigger: number;
  91486. /**
  91487. * On long press
  91488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91489. */
  91490. static readonly OnLongPressTrigger: number;
  91491. /**
  91492. * On pointer over
  91493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91494. */
  91495. static readonly OnPointerOverTrigger: number;
  91496. /**
  91497. * On pointer out
  91498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91499. */
  91500. static readonly OnPointerOutTrigger: number;
  91501. /**
  91502. * On every frame
  91503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91504. */
  91505. static readonly OnEveryFrameTrigger: number;
  91506. /**
  91507. * On intersection enter
  91508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91509. */
  91510. static readonly OnIntersectionEnterTrigger: number;
  91511. /**
  91512. * On intersection exit
  91513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91514. */
  91515. static readonly OnIntersectionExitTrigger: number;
  91516. /**
  91517. * On key down
  91518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91519. */
  91520. static readonly OnKeyDownTrigger: number;
  91521. /**
  91522. * On key up
  91523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91524. */
  91525. static readonly OnKeyUpTrigger: number;
  91526. private _scene;
  91527. /**
  91528. * Creates a new action manager
  91529. * @param scene defines the hosting scene
  91530. */
  91531. constructor(scene: Scene);
  91532. /**
  91533. * Releases all associated resources
  91534. */
  91535. dispose(): void;
  91536. /**
  91537. * Gets hosting scene
  91538. * @returns the hosting scene
  91539. */
  91540. getScene(): Scene;
  91541. /**
  91542. * Does this action manager handles actions of any of the given triggers
  91543. * @param triggers defines the triggers to be tested
  91544. * @return a boolean indicating whether one (or more) of the triggers is handled
  91545. */
  91546. hasSpecificTriggers(triggers: number[]): boolean;
  91547. /**
  91548. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91549. * speed.
  91550. * @param triggerA defines the trigger to be tested
  91551. * @param triggerB defines the trigger to be tested
  91552. * @return a boolean indicating whether one (or more) of the triggers is handled
  91553. */
  91554. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91555. /**
  91556. * Does this action manager handles actions of a given trigger
  91557. * @param trigger defines the trigger to be tested
  91558. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91559. * @return whether the trigger is handled
  91560. */
  91561. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91562. /**
  91563. * Does this action manager has pointer triggers
  91564. */
  91565. get hasPointerTriggers(): boolean;
  91566. /**
  91567. * Does this action manager has pick triggers
  91568. */
  91569. get hasPickTriggers(): boolean;
  91570. /**
  91571. * Registers an action to this action manager
  91572. * @param action defines the action to be registered
  91573. * @return the action amended (prepared) after registration
  91574. */
  91575. registerAction(action: IAction): Nullable<IAction>;
  91576. /**
  91577. * Unregisters an action to this action manager
  91578. * @param action defines the action to be unregistered
  91579. * @return a boolean indicating whether the action has been unregistered
  91580. */
  91581. unregisterAction(action: IAction): Boolean;
  91582. /**
  91583. * Process a specific trigger
  91584. * @param trigger defines the trigger to process
  91585. * @param evt defines the event details to be processed
  91586. */
  91587. processTrigger(trigger: number, evt?: IActionEvent): void;
  91588. /** @hidden */
  91589. _getEffectiveTarget(target: any, propertyPath: string): any;
  91590. /** @hidden */
  91591. _getProperty(propertyPath: string): string;
  91592. /**
  91593. * Serialize this manager to a JSON object
  91594. * @param name defines the property name to store this manager
  91595. * @returns a JSON representation of this manager
  91596. */
  91597. serialize(name: string): any;
  91598. /**
  91599. * Creates a new ActionManager from a JSON data
  91600. * @param parsedActions defines the JSON data to read from
  91601. * @param object defines the hosting mesh
  91602. * @param scene defines the hosting scene
  91603. */
  91604. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91605. /**
  91606. * Get a trigger name by index
  91607. * @param trigger defines the trigger index
  91608. * @returns a trigger name
  91609. */
  91610. static GetTriggerName(trigger: number): string;
  91611. }
  91612. }
  91613. declare module BABYLON {
  91614. /**
  91615. * Class used to represent a sprite
  91616. * @see http://doc.babylonjs.com/babylon101/sprites
  91617. */
  91618. export class Sprite {
  91619. /** defines the name */
  91620. name: string;
  91621. /** Gets or sets the current world position */
  91622. position: Vector3;
  91623. /** Gets or sets the main color */
  91624. color: Color4;
  91625. /** Gets or sets the width */
  91626. width: number;
  91627. /** Gets or sets the height */
  91628. height: number;
  91629. /** Gets or sets rotation angle */
  91630. angle: number;
  91631. /** Gets or sets the cell index in the sprite sheet */
  91632. cellIndex: number;
  91633. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91634. cellRef: string;
  91635. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91636. invertU: number;
  91637. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91638. invertV: number;
  91639. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91640. disposeWhenFinishedAnimating: boolean;
  91641. /** Gets the list of attached animations */
  91642. animations: Animation[];
  91643. /** Gets or sets a boolean indicating if the sprite can be picked */
  91644. isPickable: boolean;
  91645. /**
  91646. * Gets or sets the associated action manager
  91647. */
  91648. actionManager: Nullable<ActionManager>;
  91649. private _animationStarted;
  91650. private _loopAnimation;
  91651. private _fromIndex;
  91652. private _toIndex;
  91653. private _delay;
  91654. private _direction;
  91655. private _manager;
  91656. private _time;
  91657. private _onAnimationEnd;
  91658. /**
  91659. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91660. */
  91661. isVisible: boolean;
  91662. /**
  91663. * Gets or sets the sprite size
  91664. */
  91665. get size(): number;
  91666. set size(value: number);
  91667. /**
  91668. * Creates a new Sprite
  91669. * @param name defines the name
  91670. * @param manager defines the manager
  91671. */
  91672. constructor(
  91673. /** defines the name */
  91674. name: string, manager: ISpriteManager);
  91675. /**
  91676. * Starts an animation
  91677. * @param from defines the initial key
  91678. * @param to defines the end key
  91679. * @param loop defines if the animation must loop
  91680. * @param delay defines the start delay (in ms)
  91681. * @param onAnimationEnd defines a callback to call when animation ends
  91682. */
  91683. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91684. /** Stops current animation (if any) */
  91685. stopAnimation(): void;
  91686. /** @hidden */
  91687. _animate(deltaTime: number): void;
  91688. /** Release associated resources */
  91689. dispose(): void;
  91690. }
  91691. }
  91692. declare module BABYLON {
  91693. /**
  91694. * Information about the result of picking within a scene
  91695. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91696. */
  91697. export class PickingInfo {
  91698. /** @hidden */
  91699. _pickingUnavailable: boolean;
  91700. /**
  91701. * If the pick collided with an object
  91702. */
  91703. hit: boolean;
  91704. /**
  91705. * Distance away where the pick collided
  91706. */
  91707. distance: number;
  91708. /**
  91709. * The location of pick collision
  91710. */
  91711. pickedPoint: Nullable<Vector3>;
  91712. /**
  91713. * The mesh corresponding the the pick collision
  91714. */
  91715. pickedMesh: Nullable<AbstractMesh>;
  91716. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91717. bu: number;
  91718. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91719. bv: number;
  91720. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91721. faceId: number;
  91722. /** Id of the the submesh that was picked */
  91723. subMeshId: number;
  91724. /** If a sprite was picked, this will be the sprite the pick collided with */
  91725. pickedSprite: Nullable<Sprite>;
  91726. /**
  91727. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91728. */
  91729. originMesh: Nullable<AbstractMesh>;
  91730. /**
  91731. * The ray that was used to perform the picking.
  91732. */
  91733. ray: Nullable<Ray>;
  91734. /**
  91735. * Gets the normal correspodning to the face the pick collided with
  91736. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91737. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91738. * @returns The normal correspodning to the face the pick collided with
  91739. */
  91740. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91741. /**
  91742. * Gets the texture coordinates of where the pick occured
  91743. * @returns the vector containing the coordnates of the texture
  91744. */
  91745. getTextureCoordinates(): Nullable<Vector2>;
  91746. }
  91747. }
  91748. declare module BABYLON {
  91749. /**
  91750. * Gather the list of pointer event types as constants.
  91751. */
  91752. export class PointerEventTypes {
  91753. /**
  91754. * 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.
  91755. */
  91756. static readonly POINTERDOWN: number;
  91757. /**
  91758. * The pointerup event is fired when a pointer is no longer active.
  91759. */
  91760. static readonly POINTERUP: number;
  91761. /**
  91762. * The pointermove event is fired when a pointer changes coordinates.
  91763. */
  91764. static readonly POINTERMOVE: number;
  91765. /**
  91766. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91767. */
  91768. static readonly POINTERWHEEL: number;
  91769. /**
  91770. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91771. */
  91772. static readonly POINTERPICK: number;
  91773. /**
  91774. * The pointertap event is fired when a the object has been touched and released without drag.
  91775. */
  91776. static readonly POINTERTAP: number;
  91777. /**
  91778. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91779. */
  91780. static readonly POINTERDOUBLETAP: number;
  91781. }
  91782. /**
  91783. * Base class of pointer info types.
  91784. */
  91785. export class PointerInfoBase {
  91786. /**
  91787. * Defines the type of event (PointerEventTypes)
  91788. */
  91789. type: number;
  91790. /**
  91791. * Defines the related dom event
  91792. */
  91793. event: PointerEvent | MouseWheelEvent;
  91794. /**
  91795. * Instantiates the base class of pointers info.
  91796. * @param type Defines the type of event (PointerEventTypes)
  91797. * @param event Defines the related dom event
  91798. */
  91799. constructor(
  91800. /**
  91801. * Defines the type of event (PointerEventTypes)
  91802. */
  91803. type: number,
  91804. /**
  91805. * Defines the related dom event
  91806. */
  91807. event: PointerEvent | MouseWheelEvent);
  91808. }
  91809. /**
  91810. * This class is used to store pointer related info for the onPrePointerObservable event.
  91811. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91812. */
  91813. export class PointerInfoPre extends PointerInfoBase {
  91814. /**
  91815. * Ray from a pointer if availible (eg. 6dof controller)
  91816. */
  91817. ray: Nullable<Ray>;
  91818. /**
  91819. * Defines the local position of the pointer on the canvas.
  91820. */
  91821. localPosition: Vector2;
  91822. /**
  91823. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91824. */
  91825. skipOnPointerObservable: boolean;
  91826. /**
  91827. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91828. * @param type Defines the type of event (PointerEventTypes)
  91829. * @param event Defines the related dom event
  91830. * @param localX Defines the local x coordinates of the pointer when the event occured
  91831. * @param localY Defines the local y coordinates of the pointer when the event occured
  91832. */
  91833. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91834. }
  91835. /**
  91836. * This type contains all the data related to a pointer event in Babylon.js.
  91837. * 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.
  91838. */
  91839. export class PointerInfo extends PointerInfoBase {
  91840. /**
  91841. * Defines the picking info associated to the info (if any)\
  91842. */
  91843. pickInfo: Nullable<PickingInfo>;
  91844. /**
  91845. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91846. * @param type Defines the type of event (PointerEventTypes)
  91847. * @param event Defines the related dom event
  91848. * @param pickInfo Defines the picking info associated to the info (if any)\
  91849. */
  91850. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91851. /**
  91852. * Defines the picking info associated to the info (if any)\
  91853. */
  91854. pickInfo: Nullable<PickingInfo>);
  91855. }
  91856. /**
  91857. * Data relating to a touch event on the screen.
  91858. */
  91859. export interface PointerTouch {
  91860. /**
  91861. * X coordinate of touch.
  91862. */
  91863. x: number;
  91864. /**
  91865. * Y coordinate of touch.
  91866. */
  91867. y: number;
  91868. /**
  91869. * Id of touch. Unique for each finger.
  91870. */
  91871. pointerId: number;
  91872. /**
  91873. * Event type passed from DOM.
  91874. */
  91875. type: any;
  91876. }
  91877. }
  91878. declare module BABYLON {
  91879. /**
  91880. * Manage the mouse inputs to control the movement of a free camera.
  91881. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91882. */
  91883. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91884. /**
  91885. * Define if touch is enabled in the mouse input
  91886. */
  91887. touchEnabled: boolean;
  91888. /**
  91889. * Defines the camera the input is attached to.
  91890. */
  91891. camera: FreeCamera;
  91892. /**
  91893. * Defines the buttons associated with the input to handle camera move.
  91894. */
  91895. buttons: number[];
  91896. /**
  91897. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91898. */
  91899. angularSensibility: number;
  91900. private _pointerInput;
  91901. private _onMouseMove;
  91902. private _observer;
  91903. private previousPosition;
  91904. /**
  91905. * Observable for when a pointer move event occurs containing the move offset
  91906. */
  91907. onPointerMovedObservable: Observable<{
  91908. offsetX: number;
  91909. offsetY: number;
  91910. }>;
  91911. /**
  91912. * @hidden
  91913. * If the camera should be rotated automatically based on pointer movement
  91914. */
  91915. _allowCameraRotation: boolean;
  91916. /**
  91917. * Manage the mouse inputs to control the movement of a free camera.
  91918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91919. * @param touchEnabled Defines if touch is enabled or not
  91920. */
  91921. constructor(
  91922. /**
  91923. * Define if touch is enabled in the mouse input
  91924. */
  91925. touchEnabled?: boolean);
  91926. /**
  91927. * Attach the input controls to a specific dom element to get the input from.
  91928. * @param element Defines the element the controls should be listened from
  91929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91930. */
  91931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91932. /**
  91933. * Called on JS contextmenu event.
  91934. * Override this method to provide functionality.
  91935. */
  91936. protected onContextMenu(evt: PointerEvent): void;
  91937. /**
  91938. * Detach the current controls from the specified dom element.
  91939. * @param element Defines the element to stop listening the inputs from
  91940. */
  91941. detachControl(element: Nullable<HTMLElement>): void;
  91942. /**
  91943. * Gets the class name of the current intput.
  91944. * @returns the class name
  91945. */
  91946. getClassName(): string;
  91947. /**
  91948. * Get the friendly name associated with the input class.
  91949. * @returns the input friendly name
  91950. */
  91951. getSimpleName(): string;
  91952. }
  91953. }
  91954. declare module BABYLON {
  91955. /**
  91956. * Manage the touch inputs to control the movement of a free camera.
  91957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91958. */
  91959. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91960. /**
  91961. * Defines the camera the input is attached to.
  91962. */
  91963. camera: FreeCamera;
  91964. /**
  91965. * Defines the touch sensibility for rotation.
  91966. * The higher the faster.
  91967. */
  91968. touchAngularSensibility: number;
  91969. /**
  91970. * Defines the touch sensibility for move.
  91971. * The higher the faster.
  91972. */
  91973. touchMoveSensibility: number;
  91974. private _offsetX;
  91975. private _offsetY;
  91976. private _pointerPressed;
  91977. private _pointerInput;
  91978. private _observer;
  91979. private _onLostFocus;
  91980. /**
  91981. * Attach the input controls to a specific dom element to get the input from.
  91982. * @param element Defines the element the controls should be listened from
  91983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91984. */
  91985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91986. /**
  91987. * Detach the current controls from the specified dom element.
  91988. * @param element Defines the element to stop listening the inputs from
  91989. */
  91990. detachControl(element: Nullable<HTMLElement>): void;
  91991. /**
  91992. * Update the current camera state depending on the inputs that have been used this frame.
  91993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91994. */
  91995. checkInputs(): void;
  91996. /**
  91997. * Gets the class name of the current intput.
  91998. * @returns the class name
  91999. */
  92000. getClassName(): string;
  92001. /**
  92002. * Get the friendly name associated with the input class.
  92003. * @returns the input friendly name
  92004. */
  92005. getSimpleName(): string;
  92006. }
  92007. }
  92008. declare module BABYLON {
  92009. /**
  92010. * Default Inputs manager for the FreeCamera.
  92011. * It groups all the default supported inputs for ease of use.
  92012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92013. */
  92014. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  92015. /**
  92016. * @hidden
  92017. */
  92018. _mouseInput: Nullable<FreeCameraMouseInput>;
  92019. /**
  92020. * Instantiates a new FreeCameraInputsManager.
  92021. * @param camera Defines the camera the inputs belong to
  92022. */
  92023. constructor(camera: FreeCamera);
  92024. /**
  92025. * Add keyboard input support to the input manager.
  92026. * @returns the current input manager
  92027. */
  92028. addKeyboard(): FreeCameraInputsManager;
  92029. /**
  92030. * Add mouse input support to the input manager.
  92031. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  92032. * @returns the current input manager
  92033. */
  92034. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  92035. /**
  92036. * Removes the mouse input support from the manager
  92037. * @returns the current input manager
  92038. */
  92039. removeMouse(): FreeCameraInputsManager;
  92040. /**
  92041. * Add touch input support to the input manager.
  92042. * @returns the current input manager
  92043. */
  92044. addTouch(): FreeCameraInputsManager;
  92045. /**
  92046. * Remove all attached input methods from a camera
  92047. */
  92048. clear(): void;
  92049. }
  92050. }
  92051. declare module BABYLON {
  92052. /**
  92053. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92054. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  92055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92056. */
  92057. export class FreeCamera extends TargetCamera {
  92058. /**
  92059. * Define the collision ellipsoid of the camera.
  92060. * This is helpful to simulate a camera body like the player body around the camera
  92061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92062. */
  92063. ellipsoid: Vector3;
  92064. /**
  92065. * Define an offset for the position of the ellipsoid around the camera.
  92066. * This can be helpful to determine the center of the body near the gravity center of the body
  92067. * instead of its head.
  92068. */
  92069. ellipsoidOffset: Vector3;
  92070. /**
  92071. * Enable or disable collisions of the camera with the rest of the scene objects.
  92072. */
  92073. checkCollisions: boolean;
  92074. /**
  92075. * Enable or disable gravity on the camera.
  92076. */
  92077. applyGravity: boolean;
  92078. /**
  92079. * Define the input manager associated to the camera.
  92080. */
  92081. inputs: FreeCameraInputsManager;
  92082. /**
  92083. * Gets the input sensibility for a mouse input. (default is 2000.0)
  92084. * Higher values reduce sensitivity.
  92085. */
  92086. get angularSensibility(): number;
  92087. /**
  92088. * Sets the input sensibility for a mouse input. (default is 2000.0)
  92089. * Higher values reduce sensitivity.
  92090. */
  92091. set angularSensibility(value: number);
  92092. /**
  92093. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  92094. */
  92095. get keysUp(): number[];
  92096. set keysUp(value: number[]);
  92097. /**
  92098. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  92099. */
  92100. get keysUpward(): number[];
  92101. set keysUpward(value: number[]);
  92102. /**
  92103. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  92104. */
  92105. get keysDown(): number[];
  92106. set keysDown(value: number[]);
  92107. /**
  92108. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92109. */
  92110. get keysDownward(): number[];
  92111. set keysDownward(value: number[]);
  92112. /**
  92113. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92114. */
  92115. get keysLeft(): number[];
  92116. set keysLeft(value: number[]);
  92117. /**
  92118. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92119. */
  92120. get keysRight(): number[];
  92121. set keysRight(value: number[]);
  92122. /**
  92123. * Event raised when the camera collide with a mesh in the scene.
  92124. */
  92125. onCollide: (collidedMesh: AbstractMesh) => void;
  92126. private _collider;
  92127. private _needMoveForGravity;
  92128. private _oldPosition;
  92129. private _diffPosition;
  92130. private _newPosition;
  92131. /** @hidden */
  92132. _localDirection: Vector3;
  92133. /** @hidden */
  92134. _transformedDirection: Vector3;
  92135. /**
  92136. * Instantiates a Free Camera.
  92137. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92138. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92140. * @param name Define the name of the camera in the scene
  92141. * @param position Define the start position of the camera in the scene
  92142. * @param scene Define the scene the camera belongs to
  92143. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92144. */
  92145. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92146. /**
  92147. * Attached controls to the current camera.
  92148. * @param element Defines the element the controls should be listened from
  92149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92150. */
  92151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92152. /**
  92153. * Detach the current controls from the camera.
  92154. * The camera will stop reacting to inputs.
  92155. * @param element Defines the element to stop listening the inputs from
  92156. */
  92157. detachControl(element: HTMLElement): void;
  92158. private _collisionMask;
  92159. /**
  92160. * Define a collision mask to limit the list of object the camera can collide with
  92161. */
  92162. get collisionMask(): number;
  92163. set collisionMask(mask: number);
  92164. /** @hidden */
  92165. _collideWithWorld(displacement: Vector3): void;
  92166. private _onCollisionPositionChange;
  92167. /** @hidden */
  92168. _checkInputs(): void;
  92169. /** @hidden */
  92170. _decideIfNeedsToMove(): boolean;
  92171. /** @hidden */
  92172. _updatePosition(): void;
  92173. /**
  92174. * Destroy the camera and release the current resources hold by it.
  92175. */
  92176. dispose(): void;
  92177. /**
  92178. * Gets the current object class name.
  92179. * @return the class name
  92180. */
  92181. getClassName(): string;
  92182. }
  92183. }
  92184. declare module BABYLON {
  92185. /**
  92186. * Represents a gamepad control stick position
  92187. */
  92188. export class StickValues {
  92189. /**
  92190. * The x component of the control stick
  92191. */
  92192. x: number;
  92193. /**
  92194. * The y component of the control stick
  92195. */
  92196. y: number;
  92197. /**
  92198. * Initializes the gamepad x and y control stick values
  92199. * @param x The x component of the gamepad control stick value
  92200. * @param y The y component of the gamepad control stick value
  92201. */
  92202. constructor(
  92203. /**
  92204. * The x component of the control stick
  92205. */
  92206. x: number,
  92207. /**
  92208. * The y component of the control stick
  92209. */
  92210. y: number);
  92211. }
  92212. /**
  92213. * An interface which manages callbacks for gamepad button changes
  92214. */
  92215. export interface GamepadButtonChanges {
  92216. /**
  92217. * Called when a gamepad has been changed
  92218. */
  92219. changed: boolean;
  92220. /**
  92221. * Called when a gamepad press event has been triggered
  92222. */
  92223. pressChanged: boolean;
  92224. /**
  92225. * Called when a touch event has been triggered
  92226. */
  92227. touchChanged: boolean;
  92228. /**
  92229. * Called when a value has changed
  92230. */
  92231. valueChanged: boolean;
  92232. }
  92233. /**
  92234. * Represents a gamepad
  92235. */
  92236. export class Gamepad {
  92237. /**
  92238. * The id of the gamepad
  92239. */
  92240. id: string;
  92241. /**
  92242. * The index of the gamepad
  92243. */
  92244. index: number;
  92245. /**
  92246. * The browser gamepad
  92247. */
  92248. browserGamepad: any;
  92249. /**
  92250. * Specifies what type of gamepad this represents
  92251. */
  92252. type: number;
  92253. private _leftStick;
  92254. private _rightStick;
  92255. /** @hidden */
  92256. _isConnected: boolean;
  92257. private _leftStickAxisX;
  92258. private _leftStickAxisY;
  92259. private _rightStickAxisX;
  92260. private _rightStickAxisY;
  92261. /**
  92262. * Triggered when the left control stick has been changed
  92263. */
  92264. private _onleftstickchanged;
  92265. /**
  92266. * Triggered when the right control stick has been changed
  92267. */
  92268. private _onrightstickchanged;
  92269. /**
  92270. * Represents a gamepad controller
  92271. */
  92272. static GAMEPAD: number;
  92273. /**
  92274. * Represents a generic controller
  92275. */
  92276. static GENERIC: number;
  92277. /**
  92278. * Represents an XBox controller
  92279. */
  92280. static XBOX: number;
  92281. /**
  92282. * Represents a pose-enabled controller
  92283. */
  92284. static POSE_ENABLED: number;
  92285. /**
  92286. * Represents an Dual Shock controller
  92287. */
  92288. static DUALSHOCK: number;
  92289. /**
  92290. * Specifies whether the left control stick should be Y-inverted
  92291. */
  92292. protected _invertLeftStickY: boolean;
  92293. /**
  92294. * Specifies if the gamepad has been connected
  92295. */
  92296. get isConnected(): boolean;
  92297. /**
  92298. * Initializes the gamepad
  92299. * @param id The id of the gamepad
  92300. * @param index The index of the gamepad
  92301. * @param browserGamepad The browser gamepad
  92302. * @param leftStickX The x component of the left joystick
  92303. * @param leftStickY The y component of the left joystick
  92304. * @param rightStickX The x component of the right joystick
  92305. * @param rightStickY The y component of the right joystick
  92306. */
  92307. constructor(
  92308. /**
  92309. * The id of the gamepad
  92310. */
  92311. id: string,
  92312. /**
  92313. * The index of the gamepad
  92314. */
  92315. index: number,
  92316. /**
  92317. * The browser gamepad
  92318. */
  92319. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  92320. /**
  92321. * Callback triggered when the left joystick has changed
  92322. * @param callback
  92323. */
  92324. onleftstickchanged(callback: (values: StickValues) => void): void;
  92325. /**
  92326. * Callback triggered when the right joystick has changed
  92327. * @param callback
  92328. */
  92329. onrightstickchanged(callback: (values: StickValues) => void): void;
  92330. /**
  92331. * Gets the left joystick
  92332. */
  92333. get leftStick(): StickValues;
  92334. /**
  92335. * Sets the left joystick values
  92336. */
  92337. set leftStick(newValues: StickValues);
  92338. /**
  92339. * Gets the right joystick
  92340. */
  92341. get rightStick(): StickValues;
  92342. /**
  92343. * Sets the right joystick value
  92344. */
  92345. set rightStick(newValues: StickValues);
  92346. /**
  92347. * Updates the gamepad joystick positions
  92348. */
  92349. update(): void;
  92350. /**
  92351. * Disposes the gamepad
  92352. */
  92353. dispose(): void;
  92354. }
  92355. /**
  92356. * Represents a generic gamepad
  92357. */
  92358. export class GenericPad extends Gamepad {
  92359. private _buttons;
  92360. private _onbuttondown;
  92361. private _onbuttonup;
  92362. /**
  92363. * Observable triggered when a button has been pressed
  92364. */
  92365. onButtonDownObservable: Observable<number>;
  92366. /**
  92367. * Observable triggered when a button has been released
  92368. */
  92369. onButtonUpObservable: Observable<number>;
  92370. /**
  92371. * Callback triggered when a button has been pressed
  92372. * @param callback Called when a button has been pressed
  92373. */
  92374. onbuttondown(callback: (buttonPressed: number) => void): void;
  92375. /**
  92376. * Callback triggered when a button has been released
  92377. * @param callback Called when a button has been released
  92378. */
  92379. onbuttonup(callback: (buttonReleased: number) => void): void;
  92380. /**
  92381. * Initializes the generic gamepad
  92382. * @param id The id of the generic gamepad
  92383. * @param index The index of the generic gamepad
  92384. * @param browserGamepad The browser gamepad
  92385. */
  92386. constructor(id: string, index: number, browserGamepad: any);
  92387. private _setButtonValue;
  92388. /**
  92389. * Updates the generic gamepad
  92390. */
  92391. update(): void;
  92392. /**
  92393. * Disposes the generic gamepad
  92394. */
  92395. dispose(): void;
  92396. }
  92397. }
  92398. declare module BABYLON {
  92399. /**
  92400. * Defines the types of pose enabled controllers that are supported
  92401. */
  92402. export enum PoseEnabledControllerType {
  92403. /**
  92404. * HTC Vive
  92405. */
  92406. VIVE = 0,
  92407. /**
  92408. * Oculus Rift
  92409. */
  92410. OCULUS = 1,
  92411. /**
  92412. * Windows mixed reality
  92413. */
  92414. WINDOWS = 2,
  92415. /**
  92416. * Samsung gear VR
  92417. */
  92418. GEAR_VR = 3,
  92419. /**
  92420. * Google Daydream
  92421. */
  92422. DAYDREAM = 4,
  92423. /**
  92424. * Generic
  92425. */
  92426. GENERIC = 5
  92427. }
  92428. /**
  92429. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92430. */
  92431. export interface MutableGamepadButton {
  92432. /**
  92433. * Value of the button/trigger
  92434. */
  92435. value: number;
  92436. /**
  92437. * If the button/trigger is currently touched
  92438. */
  92439. touched: boolean;
  92440. /**
  92441. * If the button/trigger is currently pressed
  92442. */
  92443. pressed: boolean;
  92444. }
  92445. /**
  92446. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92447. * @hidden
  92448. */
  92449. export interface ExtendedGamepadButton extends GamepadButton {
  92450. /**
  92451. * If the button/trigger is currently pressed
  92452. */
  92453. readonly pressed: boolean;
  92454. /**
  92455. * If the button/trigger is currently touched
  92456. */
  92457. readonly touched: boolean;
  92458. /**
  92459. * Value of the button/trigger
  92460. */
  92461. readonly value: number;
  92462. }
  92463. /** @hidden */
  92464. export interface _GamePadFactory {
  92465. /**
  92466. * Returns whether or not the current gamepad can be created for this type of controller.
  92467. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92468. * @returns true if it can be created, otherwise false
  92469. */
  92470. canCreate(gamepadInfo: any): boolean;
  92471. /**
  92472. * Creates a new instance of the Gamepad.
  92473. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92474. * @returns the new gamepad instance
  92475. */
  92476. create(gamepadInfo: any): Gamepad;
  92477. }
  92478. /**
  92479. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92480. */
  92481. export class PoseEnabledControllerHelper {
  92482. /** @hidden */
  92483. static _ControllerFactories: _GamePadFactory[];
  92484. /** @hidden */
  92485. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92486. /**
  92487. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92488. * @param vrGamepad the gamepad to initialized
  92489. * @returns a vr controller of the type the gamepad identified as
  92490. */
  92491. static InitiateController(vrGamepad: any): Gamepad;
  92492. }
  92493. /**
  92494. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92495. */
  92496. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92497. /**
  92498. * If the controller is used in a webXR session
  92499. */
  92500. isXR: boolean;
  92501. private _deviceRoomPosition;
  92502. private _deviceRoomRotationQuaternion;
  92503. /**
  92504. * The device position in babylon space
  92505. */
  92506. devicePosition: Vector3;
  92507. /**
  92508. * The device rotation in babylon space
  92509. */
  92510. deviceRotationQuaternion: Quaternion;
  92511. /**
  92512. * The scale factor of the device in babylon space
  92513. */
  92514. deviceScaleFactor: number;
  92515. /**
  92516. * (Likely devicePosition should be used instead) The device position in its room space
  92517. */
  92518. position: Vector3;
  92519. /**
  92520. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92521. */
  92522. rotationQuaternion: Quaternion;
  92523. /**
  92524. * The type of controller (Eg. Windows mixed reality)
  92525. */
  92526. controllerType: PoseEnabledControllerType;
  92527. protected _calculatedPosition: Vector3;
  92528. private _calculatedRotation;
  92529. /**
  92530. * The raw pose from the device
  92531. */
  92532. rawPose: DevicePose;
  92533. private _trackPosition;
  92534. private _maxRotationDistFromHeadset;
  92535. private _draggedRoomRotation;
  92536. /**
  92537. * @hidden
  92538. */
  92539. _disableTrackPosition(fixedPosition: Vector3): void;
  92540. /**
  92541. * Internal, the mesh attached to the controller
  92542. * @hidden
  92543. */
  92544. _mesh: Nullable<AbstractMesh>;
  92545. private _poseControlledCamera;
  92546. private _leftHandSystemQuaternion;
  92547. /**
  92548. * Internal, matrix used to convert room space to babylon space
  92549. * @hidden
  92550. */
  92551. _deviceToWorld: Matrix;
  92552. /**
  92553. * Node to be used when casting a ray from the controller
  92554. * @hidden
  92555. */
  92556. _pointingPoseNode: Nullable<TransformNode>;
  92557. /**
  92558. * Name of the child mesh that can be used to cast a ray from the controller
  92559. */
  92560. static readonly POINTING_POSE: string;
  92561. /**
  92562. * Creates a new PoseEnabledController from a gamepad
  92563. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92564. */
  92565. constructor(browserGamepad: any);
  92566. private _workingMatrix;
  92567. /**
  92568. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92569. */
  92570. update(): void;
  92571. /**
  92572. * Updates only the pose device and mesh without doing any button event checking
  92573. */
  92574. protected _updatePoseAndMesh(): void;
  92575. /**
  92576. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92577. * @param poseData raw pose fromthe device
  92578. */
  92579. updateFromDevice(poseData: DevicePose): void;
  92580. /**
  92581. * @hidden
  92582. */
  92583. _meshAttachedObservable: Observable<AbstractMesh>;
  92584. /**
  92585. * Attaches a mesh to the controller
  92586. * @param mesh the mesh to be attached
  92587. */
  92588. attachToMesh(mesh: AbstractMesh): void;
  92589. /**
  92590. * Attaches the controllers mesh to a camera
  92591. * @param camera the camera the mesh should be attached to
  92592. */
  92593. attachToPoseControlledCamera(camera: TargetCamera): void;
  92594. /**
  92595. * Disposes of the controller
  92596. */
  92597. dispose(): void;
  92598. /**
  92599. * The mesh that is attached to the controller
  92600. */
  92601. get mesh(): Nullable<AbstractMesh>;
  92602. /**
  92603. * Gets the ray of the controller in the direction the controller is pointing
  92604. * @param length the length the resulting ray should be
  92605. * @returns a ray in the direction the controller is pointing
  92606. */
  92607. getForwardRay(length?: number): Ray;
  92608. }
  92609. }
  92610. declare module BABYLON {
  92611. /**
  92612. * Defines the WebVRController object that represents controllers tracked in 3D space
  92613. */
  92614. export abstract class WebVRController extends PoseEnabledController {
  92615. /**
  92616. * Internal, the default controller model for the controller
  92617. */
  92618. protected _defaultModel: Nullable<AbstractMesh>;
  92619. /**
  92620. * Fired when the trigger state has changed
  92621. */
  92622. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92623. /**
  92624. * Fired when the main button state has changed
  92625. */
  92626. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92627. /**
  92628. * Fired when the secondary button state has changed
  92629. */
  92630. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92631. /**
  92632. * Fired when the pad state has changed
  92633. */
  92634. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92635. /**
  92636. * Fired when controllers stick values have changed
  92637. */
  92638. onPadValuesChangedObservable: Observable<StickValues>;
  92639. /**
  92640. * Array of button availible on the controller
  92641. */
  92642. protected _buttons: Array<MutableGamepadButton>;
  92643. private _onButtonStateChange;
  92644. /**
  92645. * Fired when a controller button's state has changed
  92646. * @param callback the callback containing the button that was modified
  92647. */
  92648. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92649. /**
  92650. * X and Y axis corresponding to the controllers joystick
  92651. */
  92652. pad: StickValues;
  92653. /**
  92654. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92655. */
  92656. hand: string;
  92657. /**
  92658. * The default controller model for the controller
  92659. */
  92660. get defaultModel(): Nullable<AbstractMesh>;
  92661. /**
  92662. * Creates a new WebVRController from a gamepad
  92663. * @param vrGamepad the gamepad that the WebVRController should be created from
  92664. */
  92665. constructor(vrGamepad: any);
  92666. /**
  92667. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92668. */
  92669. update(): void;
  92670. /**
  92671. * Function to be called when a button is modified
  92672. */
  92673. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92674. /**
  92675. * Loads a mesh and attaches it to the controller
  92676. * @param scene the scene the mesh should be added to
  92677. * @param meshLoaded callback for when the mesh has been loaded
  92678. */
  92679. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92680. private _setButtonValue;
  92681. private _changes;
  92682. private _checkChanges;
  92683. /**
  92684. * Disposes of th webVRCOntroller
  92685. */
  92686. dispose(): void;
  92687. }
  92688. }
  92689. declare module BABYLON {
  92690. /**
  92691. * The HemisphericLight simulates the ambient environment light,
  92692. * so the passed direction is the light reflection direction, not the incoming direction.
  92693. */
  92694. export class HemisphericLight extends Light {
  92695. /**
  92696. * The groundColor is the light in the opposite direction to the one specified during creation.
  92697. * 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.
  92698. */
  92699. groundColor: Color3;
  92700. /**
  92701. * The light reflection direction, not the incoming direction.
  92702. */
  92703. direction: Vector3;
  92704. /**
  92705. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92706. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92707. * The HemisphericLight can't cast shadows.
  92708. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92709. * @param name The friendly name of the light
  92710. * @param direction The direction of the light reflection
  92711. * @param scene The scene the light belongs to
  92712. */
  92713. constructor(name: string, direction: Vector3, scene: Scene);
  92714. protected _buildUniformLayout(): void;
  92715. /**
  92716. * Returns the string "HemisphericLight".
  92717. * @return The class name
  92718. */
  92719. getClassName(): string;
  92720. /**
  92721. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92722. * Returns the updated direction.
  92723. * @param target The target the direction should point to
  92724. * @return The computed direction
  92725. */
  92726. setDirectionToTarget(target: Vector3): Vector3;
  92727. /**
  92728. * Returns the shadow generator associated to the light.
  92729. * @returns Always null for hemispheric lights because it does not support shadows.
  92730. */
  92731. getShadowGenerator(): Nullable<IShadowGenerator>;
  92732. /**
  92733. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92734. * @param effect The effect to update
  92735. * @param lightIndex The index of the light in the effect to update
  92736. * @returns The hemispheric light
  92737. */
  92738. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92739. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92740. /**
  92741. * Computes the world matrix of the node
  92742. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92743. * @param useWasUpdatedFlag defines a reserved property
  92744. * @returns the world matrix
  92745. */
  92746. computeWorldMatrix(): Matrix;
  92747. /**
  92748. * Returns the integer 3.
  92749. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92750. */
  92751. getTypeID(): number;
  92752. /**
  92753. * Prepares the list of defines specific to the light type.
  92754. * @param defines the list of defines
  92755. * @param lightIndex defines the index of the light for the effect
  92756. */
  92757. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92758. }
  92759. }
  92760. declare module BABYLON {
  92761. /** @hidden */
  92762. export var vrMultiviewToSingleviewPixelShader: {
  92763. name: string;
  92764. shader: string;
  92765. };
  92766. }
  92767. declare module BABYLON {
  92768. /**
  92769. * Renders to multiple views with a single draw call
  92770. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92771. */
  92772. export class MultiviewRenderTarget extends RenderTargetTexture {
  92773. /**
  92774. * Creates a multiview render target
  92775. * @param scene scene used with the render target
  92776. * @param size the size of the render target (used for each view)
  92777. */
  92778. constructor(scene: Scene, size?: number | {
  92779. width: number;
  92780. height: number;
  92781. } | {
  92782. ratio: number;
  92783. });
  92784. /**
  92785. * @hidden
  92786. * @param faceIndex the face index, if its a cube texture
  92787. */
  92788. _bindFrameBuffer(faceIndex?: number): void;
  92789. /**
  92790. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92791. * @returns the view count
  92792. */
  92793. getViewCount(): number;
  92794. }
  92795. }
  92796. declare module BABYLON {
  92797. /**
  92798. * Represents a camera frustum
  92799. */
  92800. export class Frustum {
  92801. /**
  92802. * Gets the planes representing the frustum
  92803. * @param transform matrix to be applied to the returned planes
  92804. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92805. */
  92806. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92807. /**
  92808. * Gets the near frustum plane transformed by the transform matrix
  92809. * @param transform transformation matrix to be applied to the resulting frustum plane
  92810. * @param frustumPlane the resuling frustum plane
  92811. */
  92812. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92813. /**
  92814. * Gets the far frustum plane transformed by the transform matrix
  92815. * @param transform transformation matrix to be applied to the resulting frustum plane
  92816. * @param frustumPlane the resuling frustum plane
  92817. */
  92818. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92819. /**
  92820. * Gets the left frustum plane transformed by the transform matrix
  92821. * @param transform transformation matrix to be applied to the resulting frustum plane
  92822. * @param frustumPlane the resuling frustum plane
  92823. */
  92824. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92825. /**
  92826. * Gets the right frustum plane transformed by the transform matrix
  92827. * @param transform transformation matrix to be applied to the resulting frustum plane
  92828. * @param frustumPlane the resuling frustum plane
  92829. */
  92830. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92831. /**
  92832. * Gets the top frustum plane transformed by the transform matrix
  92833. * @param transform transformation matrix to be applied to the resulting frustum plane
  92834. * @param frustumPlane the resuling frustum plane
  92835. */
  92836. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92837. /**
  92838. * Gets the bottom frustum plane transformed by the transform matrix
  92839. * @param transform transformation matrix to be applied to the resulting frustum plane
  92840. * @param frustumPlane the resuling frustum plane
  92841. */
  92842. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92843. /**
  92844. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92845. * @param transform transformation matrix to be applied to the resulting frustum planes
  92846. * @param frustumPlanes the resuling frustum planes
  92847. */
  92848. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92849. }
  92850. }
  92851. declare module BABYLON {
  92852. interface Engine {
  92853. /**
  92854. * Creates a new multiview render target
  92855. * @param width defines the width of the texture
  92856. * @param height defines the height of the texture
  92857. * @returns the created multiview texture
  92858. */
  92859. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92860. /**
  92861. * Binds a multiview framebuffer to be drawn to
  92862. * @param multiviewTexture texture to bind
  92863. */
  92864. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92865. }
  92866. interface Camera {
  92867. /**
  92868. * @hidden
  92869. * 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)
  92870. */
  92871. _useMultiviewToSingleView: boolean;
  92872. /**
  92873. * @hidden
  92874. * 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)
  92875. */
  92876. _multiviewTexture: Nullable<RenderTargetTexture>;
  92877. /**
  92878. * @hidden
  92879. * ensures the multiview texture of the camera exists and has the specified width/height
  92880. * @param width height to set on the multiview texture
  92881. * @param height width to set on the multiview texture
  92882. */
  92883. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92884. }
  92885. interface Scene {
  92886. /** @hidden */
  92887. _transformMatrixR: Matrix;
  92888. /** @hidden */
  92889. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92890. /** @hidden */
  92891. _createMultiviewUbo(): void;
  92892. /** @hidden */
  92893. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92894. /** @hidden */
  92895. _renderMultiviewToSingleView(camera: Camera): void;
  92896. }
  92897. }
  92898. declare module BABYLON {
  92899. /**
  92900. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92901. * This will not be used for webXR as it supports displaying texture arrays directly
  92902. */
  92903. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92904. /**
  92905. * Initializes a VRMultiviewToSingleview
  92906. * @param name name of the post process
  92907. * @param camera camera to be applied to
  92908. * @param scaleFactor scaling factor to the size of the output texture
  92909. */
  92910. constructor(name: string, camera: Camera, scaleFactor: number);
  92911. }
  92912. }
  92913. declare module BABYLON {
  92914. /**
  92915. * Interface used to define additional presentation attributes
  92916. */
  92917. export interface IVRPresentationAttributes {
  92918. /**
  92919. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92920. */
  92921. highRefreshRate: boolean;
  92922. /**
  92923. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92924. */
  92925. foveationLevel: number;
  92926. }
  92927. interface Engine {
  92928. /** @hidden */
  92929. _vrDisplay: any;
  92930. /** @hidden */
  92931. _vrSupported: boolean;
  92932. /** @hidden */
  92933. _oldSize: Size;
  92934. /** @hidden */
  92935. _oldHardwareScaleFactor: number;
  92936. /** @hidden */
  92937. _vrExclusivePointerMode: boolean;
  92938. /** @hidden */
  92939. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92940. /** @hidden */
  92941. _onVRDisplayPointerRestricted: () => void;
  92942. /** @hidden */
  92943. _onVRDisplayPointerUnrestricted: () => void;
  92944. /** @hidden */
  92945. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92946. /** @hidden */
  92947. _onVrDisplayDisconnect: Nullable<() => void>;
  92948. /** @hidden */
  92949. _onVrDisplayPresentChange: Nullable<() => void>;
  92950. /**
  92951. * Observable signaled when VR display mode changes
  92952. */
  92953. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92954. /**
  92955. * Observable signaled when VR request present is complete
  92956. */
  92957. onVRRequestPresentComplete: Observable<boolean>;
  92958. /**
  92959. * Observable signaled when VR request present starts
  92960. */
  92961. onVRRequestPresentStart: Observable<Engine>;
  92962. /**
  92963. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92964. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92965. */
  92966. isInVRExclusivePointerMode: boolean;
  92967. /**
  92968. * Gets a boolean indicating if a webVR device was detected
  92969. * @returns true if a webVR device was detected
  92970. */
  92971. isVRDevicePresent(): boolean;
  92972. /**
  92973. * Gets the current webVR device
  92974. * @returns the current webVR device (or null)
  92975. */
  92976. getVRDevice(): any;
  92977. /**
  92978. * Initializes a webVR display and starts listening to display change events
  92979. * The onVRDisplayChangedObservable will be notified upon these changes
  92980. * @returns A promise containing a VRDisplay and if vr is supported
  92981. */
  92982. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92983. /** @hidden */
  92984. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92985. /**
  92986. * Gets or sets the presentation attributes used to configure VR rendering
  92987. */
  92988. vrPresentationAttributes?: IVRPresentationAttributes;
  92989. /**
  92990. * Call this function to switch to webVR mode
  92991. * Will do nothing if webVR is not supported or if there is no webVR device
  92992. * @param options the webvr options provided to the camera. mainly used for multiview
  92993. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92994. */
  92995. enableVR(options: WebVROptions): void;
  92996. /** @hidden */
  92997. _onVRFullScreenTriggered(): void;
  92998. }
  92999. }
  93000. declare module BABYLON {
  93001. /**
  93002. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  93003. * IMPORTANT!! The data is right-hand data.
  93004. * @export
  93005. * @interface DevicePose
  93006. */
  93007. export interface DevicePose {
  93008. /**
  93009. * The position of the device, values in array are [x,y,z].
  93010. */
  93011. readonly position: Nullable<Float32Array>;
  93012. /**
  93013. * The linearVelocity of the device, values in array are [x,y,z].
  93014. */
  93015. readonly linearVelocity: Nullable<Float32Array>;
  93016. /**
  93017. * The linearAcceleration of the device, values in array are [x,y,z].
  93018. */
  93019. readonly linearAcceleration: Nullable<Float32Array>;
  93020. /**
  93021. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  93022. */
  93023. readonly orientation: Nullable<Float32Array>;
  93024. /**
  93025. * The angularVelocity of the device, values in array are [x,y,z].
  93026. */
  93027. readonly angularVelocity: Nullable<Float32Array>;
  93028. /**
  93029. * The angularAcceleration of the device, values in array are [x,y,z].
  93030. */
  93031. readonly angularAcceleration: Nullable<Float32Array>;
  93032. }
  93033. /**
  93034. * Interface representing a pose controlled object in Babylon.
  93035. * A pose controlled object has both regular pose values as well as pose values
  93036. * from an external device such as a VR head mounted display
  93037. */
  93038. export interface PoseControlled {
  93039. /**
  93040. * The position of the object in babylon space.
  93041. */
  93042. position: Vector3;
  93043. /**
  93044. * The rotation quaternion of the object in babylon space.
  93045. */
  93046. rotationQuaternion: Quaternion;
  93047. /**
  93048. * The position of the device in babylon space.
  93049. */
  93050. devicePosition?: Vector3;
  93051. /**
  93052. * The rotation quaternion of the device in babylon space.
  93053. */
  93054. deviceRotationQuaternion: Quaternion;
  93055. /**
  93056. * The raw pose coming from the device.
  93057. */
  93058. rawPose: Nullable<DevicePose>;
  93059. /**
  93060. * The scale of the device to be used when translating from device space to babylon space.
  93061. */
  93062. deviceScaleFactor: number;
  93063. /**
  93064. * Updates the poseControlled values based on the input device pose.
  93065. * @param poseData the pose data to update the object with
  93066. */
  93067. updateFromDevice(poseData: DevicePose): void;
  93068. }
  93069. /**
  93070. * Set of options to customize the webVRCamera
  93071. */
  93072. export interface WebVROptions {
  93073. /**
  93074. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  93075. */
  93076. trackPosition?: boolean;
  93077. /**
  93078. * Sets the scale of the vrDevice in babylon space. (default: 1)
  93079. */
  93080. positionScale?: number;
  93081. /**
  93082. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  93083. */
  93084. displayName?: string;
  93085. /**
  93086. * Should the native controller meshes be initialized. (default: true)
  93087. */
  93088. controllerMeshes?: boolean;
  93089. /**
  93090. * Creating a default HemiLight only on controllers. (default: true)
  93091. */
  93092. defaultLightingOnControllers?: boolean;
  93093. /**
  93094. * If you don't want to use the default VR button of the helper. (default: false)
  93095. */
  93096. useCustomVRButton?: boolean;
  93097. /**
  93098. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  93099. */
  93100. customVRButton?: HTMLButtonElement;
  93101. /**
  93102. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  93103. */
  93104. rayLength?: number;
  93105. /**
  93106. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  93107. */
  93108. defaultHeight?: number;
  93109. /**
  93110. * If multiview should be used if availible (default: false)
  93111. */
  93112. useMultiview?: boolean;
  93113. }
  93114. /**
  93115. * This represents a WebVR camera.
  93116. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93117. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93118. */
  93119. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93120. private webVROptions;
  93121. /**
  93122. * @hidden
  93123. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93124. */
  93125. _vrDevice: any;
  93126. /**
  93127. * The rawPose of the vrDevice.
  93128. */
  93129. rawPose: Nullable<DevicePose>;
  93130. private _onVREnabled;
  93131. private _specsVersion;
  93132. private _attached;
  93133. private _frameData;
  93134. protected _descendants: Array<Node>;
  93135. private _deviceRoomPosition;
  93136. /** @hidden */
  93137. _deviceRoomRotationQuaternion: Quaternion;
  93138. private _standingMatrix;
  93139. /**
  93140. * Represents device position in babylon space.
  93141. */
  93142. devicePosition: Vector3;
  93143. /**
  93144. * Represents device rotation in babylon space.
  93145. */
  93146. deviceRotationQuaternion: Quaternion;
  93147. /**
  93148. * The scale of the device to be used when translating from device space to babylon space.
  93149. */
  93150. deviceScaleFactor: number;
  93151. private _deviceToWorld;
  93152. private _worldToDevice;
  93153. /**
  93154. * References to the webVR controllers for the vrDevice.
  93155. */
  93156. controllers: Array<WebVRController>;
  93157. /**
  93158. * Emits an event when a controller is attached.
  93159. */
  93160. onControllersAttachedObservable: Observable<WebVRController[]>;
  93161. /**
  93162. * Emits an event when a controller's mesh has been loaded;
  93163. */
  93164. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93165. /**
  93166. * Emits an event when the HMD's pose has been updated.
  93167. */
  93168. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93169. private _poseSet;
  93170. /**
  93171. * If the rig cameras be used as parent instead of this camera.
  93172. */
  93173. rigParenting: boolean;
  93174. private _lightOnControllers;
  93175. private _defaultHeight?;
  93176. /**
  93177. * Instantiates a WebVRFreeCamera.
  93178. * @param name The name of the WebVRFreeCamera
  93179. * @param position The starting anchor position for the camera
  93180. * @param scene The scene the camera belongs to
  93181. * @param webVROptions a set of customizable options for the webVRCamera
  93182. */
  93183. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93184. /**
  93185. * Gets the device distance from the ground in meters.
  93186. * @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.
  93187. */
  93188. deviceDistanceToRoomGround(): number;
  93189. /**
  93190. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93191. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93192. */
  93193. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93194. /**
  93195. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93196. * @returns A promise with a boolean set to if the standing matrix is supported.
  93197. */
  93198. useStandingMatrixAsync(): Promise<boolean>;
  93199. /**
  93200. * Disposes the camera
  93201. */
  93202. dispose(): void;
  93203. /**
  93204. * Gets a vrController by name.
  93205. * @param name The name of the controller to retreive
  93206. * @returns the controller matching the name specified or null if not found
  93207. */
  93208. getControllerByName(name: string): Nullable<WebVRController>;
  93209. private _leftController;
  93210. /**
  93211. * The controller corresponding to the users left hand.
  93212. */
  93213. get leftController(): Nullable<WebVRController>;
  93214. private _rightController;
  93215. /**
  93216. * The controller corresponding to the users right hand.
  93217. */
  93218. get rightController(): Nullable<WebVRController>;
  93219. /**
  93220. * Casts a ray forward from the vrCamera's gaze.
  93221. * @param length Length of the ray (default: 100)
  93222. * @returns the ray corresponding to the gaze
  93223. */
  93224. getForwardRay(length?: number): Ray;
  93225. /**
  93226. * @hidden
  93227. * Updates the camera based on device's frame data
  93228. */
  93229. _checkInputs(): void;
  93230. /**
  93231. * Updates the poseControlled values based on the input device pose.
  93232. * @param poseData Pose coming from the device
  93233. */
  93234. updateFromDevice(poseData: DevicePose): void;
  93235. private _htmlElementAttached;
  93236. private _detachIfAttached;
  93237. /**
  93238. * WebVR's attach control will start broadcasting frames to the device.
  93239. * Note that in certain browsers (chrome for example) this function must be called
  93240. * within a user-interaction callback. Example:
  93241. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93242. *
  93243. * @param element html element to attach the vrDevice to
  93244. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93245. */
  93246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93247. /**
  93248. * Detaches the camera from the html element and disables VR
  93249. *
  93250. * @param element html element to detach from
  93251. */
  93252. detachControl(element: HTMLElement): void;
  93253. /**
  93254. * @returns the name of this class
  93255. */
  93256. getClassName(): string;
  93257. /**
  93258. * Calls resetPose on the vrDisplay
  93259. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93260. */
  93261. resetToCurrentRotation(): void;
  93262. /**
  93263. * @hidden
  93264. * Updates the rig cameras (left and right eye)
  93265. */
  93266. _updateRigCameras(): void;
  93267. private _workingVector;
  93268. private _oneVector;
  93269. private _workingMatrix;
  93270. private updateCacheCalled;
  93271. private _correctPositionIfNotTrackPosition;
  93272. /**
  93273. * @hidden
  93274. * Updates the cached values of the camera
  93275. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93276. */
  93277. _updateCache(ignoreParentClass?: boolean): void;
  93278. /**
  93279. * @hidden
  93280. * Get current device position in babylon world
  93281. */
  93282. _computeDevicePosition(): void;
  93283. /**
  93284. * Updates the current device position and rotation in the babylon world
  93285. */
  93286. update(): void;
  93287. /**
  93288. * @hidden
  93289. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  93290. * @returns an identity matrix
  93291. */
  93292. _getViewMatrix(): Matrix;
  93293. private _tmpMatrix;
  93294. /**
  93295. * This function is called by the two RIG cameras.
  93296. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  93297. * @hidden
  93298. */
  93299. _getWebVRViewMatrix(): Matrix;
  93300. /** @hidden */
  93301. _getWebVRProjectionMatrix(): Matrix;
  93302. private _onGamepadConnectedObserver;
  93303. private _onGamepadDisconnectedObserver;
  93304. private _updateCacheWhenTrackingDisabledObserver;
  93305. /**
  93306. * Initializes the controllers and their meshes
  93307. */
  93308. initControllers(): void;
  93309. }
  93310. }
  93311. declare module BABYLON {
  93312. /**
  93313. * Size options for a post process
  93314. */
  93315. export type PostProcessOptions = {
  93316. width: number;
  93317. height: number;
  93318. };
  93319. /**
  93320. * PostProcess can be used to apply a shader to a texture after it has been rendered
  93321. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93322. */
  93323. export class PostProcess {
  93324. /** Name of the PostProcess. */
  93325. name: string;
  93326. /**
  93327. * Gets or sets the unique id of the post process
  93328. */
  93329. uniqueId: number;
  93330. /**
  93331. * Width of the texture to apply the post process on
  93332. */
  93333. width: number;
  93334. /**
  93335. * Height of the texture to apply the post process on
  93336. */
  93337. height: number;
  93338. /**
  93339. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  93340. * @hidden
  93341. */
  93342. _outputTexture: Nullable<InternalTexture>;
  93343. /**
  93344. * Sampling mode used by the shader
  93345. * See https://doc.babylonjs.com/classes/3.1/texture
  93346. */
  93347. renderTargetSamplingMode: number;
  93348. /**
  93349. * Clear color to use when screen clearing
  93350. */
  93351. clearColor: Color4;
  93352. /**
  93353. * If the buffer needs to be cleared before applying the post process. (default: true)
  93354. * Should be set to false if shader will overwrite all previous pixels.
  93355. */
  93356. autoClear: boolean;
  93357. /**
  93358. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  93359. */
  93360. alphaMode: number;
  93361. /**
  93362. * Sets the setAlphaBlendConstants of the babylon engine
  93363. */
  93364. alphaConstants: Color4;
  93365. /**
  93366. * Animations to be used for the post processing
  93367. */
  93368. animations: Animation[];
  93369. /**
  93370. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  93371. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  93372. */
  93373. enablePixelPerfectMode: boolean;
  93374. /**
  93375. * Force the postprocess to be applied without taking in account viewport
  93376. */
  93377. forceFullscreenViewport: boolean;
  93378. /**
  93379. * List of inspectable custom properties (used by the Inspector)
  93380. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93381. */
  93382. inspectableCustomProperties: IInspectable[];
  93383. /**
  93384. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  93385. *
  93386. * | Value | Type | Description |
  93387. * | ----- | ----------------------------------- | ----------- |
  93388. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  93389. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  93390. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  93391. *
  93392. */
  93393. scaleMode: number;
  93394. /**
  93395. * Force textures to be a power of two (default: false)
  93396. */
  93397. alwaysForcePOT: boolean;
  93398. private _samples;
  93399. /**
  93400. * Number of sample textures (default: 1)
  93401. */
  93402. get samples(): number;
  93403. set samples(n: number);
  93404. /**
  93405. * Modify the scale of the post process to be the same as the viewport (default: false)
  93406. */
  93407. adaptScaleToCurrentViewport: boolean;
  93408. private _camera;
  93409. private _scene;
  93410. private _engine;
  93411. private _options;
  93412. private _reusable;
  93413. private _textureType;
  93414. private _textureFormat;
  93415. /**
  93416. * Smart array of input and output textures for the post process.
  93417. * @hidden
  93418. */
  93419. _textures: SmartArray<InternalTexture>;
  93420. /**
  93421. * The index in _textures that corresponds to the output texture.
  93422. * @hidden
  93423. */
  93424. _currentRenderTextureInd: number;
  93425. private _effect;
  93426. private _samplers;
  93427. private _fragmentUrl;
  93428. private _vertexUrl;
  93429. private _parameters;
  93430. private _scaleRatio;
  93431. protected _indexParameters: any;
  93432. private _shareOutputWithPostProcess;
  93433. private _texelSize;
  93434. private _forcedOutputTexture;
  93435. /**
  93436. * Returns the fragment url or shader name used in the post process.
  93437. * @returns the fragment url or name in the shader store.
  93438. */
  93439. getEffectName(): string;
  93440. /**
  93441. * An event triggered when the postprocess is activated.
  93442. */
  93443. onActivateObservable: Observable<Camera>;
  93444. private _onActivateObserver;
  93445. /**
  93446. * A function that is added to the onActivateObservable
  93447. */
  93448. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93449. /**
  93450. * An event triggered when the postprocess changes its size.
  93451. */
  93452. onSizeChangedObservable: Observable<PostProcess>;
  93453. private _onSizeChangedObserver;
  93454. /**
  93455. * A function that is added to the onSizeChangedObservable
  93456. */
  93457. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93458. /**
  93459. * An event triggered when the postprocess applies its effect.
  93460. */
  93461. onApplyObservable: Observable<Effect>;
  93462. private _onApplyObserver;
  93463. /**
  93464. * A function that is added to the onApplyObservable
  93465. */
  93466. set onApply(callback: (effect: Effect) => void);
  93467. /**
  93468. * An event triggered before rendering the postprocess
  93469. */
  93470. onBeforeRenderObservable: Observable<Effect>;
  93471. private _onBeforeRenderObserver;
  93472. /**
  93473. * A function that is added to the onBeforeRenderObservable
  93474. */
  93475. set onBeforeRender(callback: (effect: Effect) => void);
  93476. /**
  93477. * An event triggered after rendering the postprocess
  93478. */
  93479. onAfterRenderObservable: Observable<Effect>;
  93480. private _onAfterRenderObserver;
  93481. /**
  93482. * A function that is added to the onAfterRenderObservable
  93483. */
  93484. set onAfterRender(callback: (efect: Effect) => void);
  93485. /**
  93486. * 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
  93487. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93488. */
  93489. get inputTexture(): InternalTexture;
  93490. set inputTexture(value: InternalTexture);
  93491. /**
  93492. * Gets the camera which post process is applied to.
  93493. * @returns The camera the post process is applied to.
  93494. */
  93495. getCamera(): Camera;
  93496. /**
  93497. * Gets the texel size of the postprocess.
  93498. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93499. */
  93500. get texelSize(): Vector2;
  93501. /**
  93502. * Creates a new instance PostProcess
  93503. * @param name The name of the PostProcess.
  93504. * @param fragmentUrl The url of the fragment shader to be used.
  93505. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93506. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93507. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93508. * @param camera The camera to apply the render pass to.
  93509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93510. * @param engine The engine which the post process will be applied. (default: current engine)
  93511. * @param reusable If the post process can be reused on the same frame. (default: false)
  93512. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93513. * @param textureType Type of textures used when performing the post process. (default: 0)
  93514. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93515. * @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
  93516. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93517. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93518. */
  93519. constructor(
  93520. /** Name of the PostProcess. */
  93521. 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);
  93522. /**
  93523. * Gets a string idenfifying the name of the class
  93524. * @returns "PostProcess" string
  93525. */
  93526. getClassName(): string;
  93527. /**
  93528. * Gets the engine which this post process belongs to.
  93529. * @returns The engine the post process was enabled with.
  93530. */
  93531. getEngine(): Engine;
  93532. /**
  93533. * The effect that is created when initializing the post process.
  93534. * @returns The created effect corresponding the the postprocess.
  93535. */
  93536. getEffect(): Effect;
  93537. /**
  93538. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93539. * @param postProcess The post process to share the output with.
  93540. * @returns This post process.
  93541. */
  93542. shareOutputWith(postProcess: PostProcess): PostProcess;
  93543. /**
  93544. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93545. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93546. */
  93547. useOwnOutput(): void;
  93548. /**
  93549. * Updates the effect with the current post process compile time values and recompiles the shader.
  93550. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93551. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93552. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93553. * @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
  93554. * @param onCompiled Called when the shader has been compiled.
  93555. * @param onError Called if there is an error when compiling a shader.
  93556. */
  93557. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93558. /**
  93559. * The post process is reusable if it can be used multiple times within one frame.
  93560. * @returns If the post process is reusable
  93561. */
  93562. isReusable(): boolean;
  93563. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93564. markTextureDirty(): void;
  93565. /**
  93566. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93567. * 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.
  93568. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93569. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93570. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93571. * @returns The target texture that was bound to be written to.
  93572. */
  93573. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93574. /**
  93575. * If the post process is supported.
  93576. */
  93577. get isSupported(): boolean;
  93578. /**
  93579. * The aspect ratio of the output texture.
  93580. */
  93581. get aspectRatio(): number;
  93582. /**
  93583. * Get a value indicating if the post-process is ready to be used
  93584. * @returns true if the post-process is ready (shader is compiled)
  93585. */
  93586. isReady(): boolean;
  93587. /**
  93588. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93589. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93590. */
  93591. apply(): Nullable<Effect>;
  93592. private _disposeTextures;
  93593. /**
  93594. * Disposes the post process.
  93595. * @param camera The camera to dispose the post process on.
  93596. */
  93597. dispose(camera?: Camera): void;
  93598. }
  93599. }
  93600. declare module BABYLON {
  93601. /** @hidden */
  93602. export var kernelBlurVaryingDeclaration: {
  93603. name: string;
  93604. shader: string;
  93605. };
  93606. }
  93607. declare module BABYLON {
  93608. /** @hidden */
  93609. export var kernelBlurFragment: {
  93610. name: string;
  93611. shader: string;
  93612. };
  93613. }
  93614. declare module BABYLON {
  93615. /** @hidden */
  93616. export var kernelBlurFragment2: {
  93617. name: string;
  93618. shader: string;
  93619. };
  93620. }
  93621. declare module BABYLON {
  93622. /** @hidden */
  93623. export var kernelBlurPixelShader: {
  93624. name: string;
  93625. shader: string;
  93626. };
  93627. }
  93628. declare module BABYLON {
  93629. /** @hidden */
  93630. export var kernelBlurVertex: {
  93631. name: string;
  93632. shader: string;
  93633. };
  93634. }
  93635. declare module BABYLON {
  93636. /** @hidden */
  93637. export var kernelBlurVertexShader: {
  93638. name: string;
  93639. shader: string;
  93640. };
  93641. }
  93642. declare module BABYLON {
  93643. /**
  93644. * The Blur Post Process which blurs an image based on a kernel and direction.
  93645. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93646. */
  93647. export class BlurPostProcess extends PostProcess {
  93648. /** The direction in which to blur the image. */
  93649. direction: Vector2;
  93650. private blockCompilation;
  93651. protected _kernel: number;
  93652. protected _idealKernel: number;
  93653. protected _packedFloat: boolean;
  93654. private _staticDefines;
  93655. /**
  93656. * Sets the length in pixels of the blur sample region
  93657. */
  93658. set kernel(v: number);
  93659. /**
  93660. * Gets the length in pixels of the blur sample region
  93661. */
  93662. get kernel(): number;
  93663. /**
  93664. * Sets wether or not the blur needs to unpack/repack floats
  93665. */
  93666. set packedFloat(v: boolean);
  93667. /**
  93668. * Gets wether or not the blur is unpacking/repacking floats
  93669. */
  93670. get packedFloat(): boolean;
  93671. /**
  93672. * Creates a new instance BlurPostProcess
  93673. * @param name The name of the effect.
  93674. * @param direction The direction in which to blur the image.
  93675. * @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.
  93676. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93677. * @param camera The camera to apply the render pass to.
  93678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93679. * @param engine The engine which the post process will be applied. (default: current engine)
  93680. * @param reusable If the post process can be reused on the same frame. (default: false)
  93681. * @param textureType Type of textures used when performing the post process. (default: 0)
  93682. * @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)
  93683. */
  93684. constructor(name: string,
  93685. /** The direction in which to blur the image. */
  93686. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93687. /**
  93688. * Updates the effect with the current post process compile time values and recompiles the shader.
  93689. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93690. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93691. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93692. * @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
  93693. * @param onCompiled Called when the shader has been compiled.
  93694. * @param onError Called if there is an error when compiling a shader.
  93695. */
  93696. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93697. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93698. /**
  93699. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93700. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93701. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93702. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93703. * The gaps between physical kernels are compensated for in the weighting of the samples
  93704. * @param idealKernel Ideal blur kernel.
  93705. * @return Nearest best kernel.
  93706. */
  93707. protected _nearestBestKernel(idealKernel: number): number;
  93708. /**
  93709. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93710. * @param x The point on the Gaussian distribution to sample.
  93711. * @return the value of the Gaussian function at x.
  93712. */
  93713. protected _gaussianWeight(x: number): number;
  93714. /**
  93715. * Generates a string that can be used as a floating point number in GLSL.
  93716. * @param x Value to print.
  93717. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93718. * @return GLSL float string.
  93719. */
  93720. protected _glslFloat(x: number, decimalFigures?: number): string;
  93721. }
  93722. }
  93723. declare module BABYLON {
  93724. /**
  93725. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93726. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93727. * You can then easily use it as a reflectionTexture on a flat surface.
  93728. * In case the surface is not a plane, please consider relying on reflection probes.
  93729. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93730. */
  93731. export class MirrorTexture extends RenderTargetTexture {
  93732. private scene;
  93733. /**
  93734. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93735. * 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.
  93736. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93737. */
  93738. mirrorPlane: Plane;
  93739. /**
  93740. * Define the blur ratio used to blur the reflection if needed.
  93741. */
  93742. set blurRatio(value: number);
  93743. get blurRatio(): number;
  93744. /**
  93745. * Define the adaptive blur kernel used to blur the reflection if needed.
  93746. * This will autocompute the closest best match for the `blurKernel`
  93747. */
  93748. set adaptiveBlurKernel(value: number);
  93749. /**
  93750. * Define the blur kernel used to blur the reflection if needed.
  93751. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93752. */
  93753. set blurKernel(value: number);
  93754. /**
  93755. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93756. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93757. */
  93758. set blurKernelX(value: number);
  93759. get blurKernelX(): number;
  93760. /**
  93761. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93762. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93763. */
  93764. set blurKernelY(value: number);
  93765. get blurKernelY(): number;
  93766. private _autoComputeBlurKernel;
  93767. protected _onRatioRescale(): void;
  93768. private _updateGammaSpace;
  93769. private _imageProcessingConfigChangeObserver;
  93770. private _transformMatrix;
  93771. private _mirrorMatrix;
  93772. private _savedViewMatrix;
  93773. private _blurX;
  93774. private _blurY;
  93775. private _adaptiveBlurKernel;
  93776. private _blurKernelX;
  93777. private _blurKernelY;
  93778. private _blurRatio;
  93779. /**
  93780. * Instantiates a Mirror Texture.
  93781. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93782. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93783. * You can then easily use it as a reflectionTexture on a flat surface.
  93784. * In case the surface is not a plane, please consider relying on reflection probes.
  93785. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93786. * @param name
  93787. * @param size
  93788. * @param scene
  93789. * @param generateMipMaps
  93790. * @param type
  93791. * @param samplingMode
  93792. * @param generateDepthBuffer
  93793. */
  93794. constructor(name: string, size: number | {
  93795. width: number;
  93796. height: number;
  93797. } | {
  93798. ratio: number;
  93799. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93800. private _preparePostProcesses;
  93801. /**
  93802. * Clone the mirror texture.
  93803. * @returns the cloned texture
  93804. */
  93805. clone(): MirrorTexture;
  93806. /**
  93807. * Serialize the texture to a JSON representation you could use in Parse later on
  93808. * @returns the serialized JSON representation
  93809. */
  93810. serialize(): any;
  93811. /**
  93812. * Dispose the texture and release its associated resources.
  93813. */
  93814. dispose(): void;
  93815. }
  93816. }
  93817. declare module BABYLON {
  93818. /**
  93819. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93820. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93821. */
  93822. export class Texture extends BaseTexture {
  93823. /**
  93824. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93825. */
  93826. static SerializeBuffers: boolean;
  93827. /** @hidden */
  93828. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93829. /** @hidden */
  93830. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93831. /** @hidden */
  93832. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93833. /** nearest is mag = nearest and min = nearest and mip = linear */
  93834. static readonly NEAREST_SAMPLINGMODE: number;
  93835. /** nearest is mag = nearest and min = nearest and mip = linear */
  93836. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93838. static readonly BILINEAR_SAMPLINGMODE: number;
  93839. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93840. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93841. /** Trilinear is mag = linear and min = linear and mip = linear */
  93842. static readonly TRILINEAR_SAMPLINGMODE: number;
  93843. /** Trilinear is mag = linear and min = linear and mip = linear */
  93844. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93845. /** mag = nearest and min = nearest and mip = nearest */
  93846. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93847. /** mag = nearest and min = linear and mip = nearest */
  93848. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93849. /** mag = nearest and min = linear and mip = linear */
  93850. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93851. /** mag = nearest and min = linear and mip = none */
  93852. static readonly NEAREST_LINEAR: number;
  93853. /** mag = nearest and min = nearest and mip = none */
  93854. static readonly NEAREST_NEAREST: number;
  93855. /** mag = linear and min = nearest and mip = nearest */
  93856. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93857. /** mag = linear and min = nearest and mip = linear */
  93858. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93859. /** mag = linear and min = linear and mip = none */
  93860. static readonly LINEAR_LINEAR: number;
  93861. /** mag = linear and min = nearest and mip = none */
  93862. static readonly LINEAR_NEAREST: number;
  93863. /** Explicit coordinates mode */
  93864. static readonly EXPLICIT_MODE: number;
  93865. /** Spherical coordinates mode */
  93866. static readonly SPHERICAL_MODE: number;
  93867. /** Planar coordinates mode */
  93868. static readonly PLANAR_MODE: number;
  93869. /** Cubic coordinates mode */
  93870. static readonly CUBIC_MODE: number;
  93871. /** Projection coordinates mode */
  93872. static readonly PROJECTION_MODE: number;
  93873. /** Inverse Cubic coordinates mode */
  93874. static readonly SKYBOX_MODE: number;
  93875. /** Inverse Cubic coordinates mode */
  93876. static readonly INVCUBIC_MODE: number;
  93877. /** Equirectangular coordinates mode */
  93878. static readonly EQUIRECTANGULAR_MODE: number;
  93879. /** Equirectangular Fixed coordinates mode */
  93880. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93881. /** Equirectangular Fixed Mirrored coordinates mode */
  93882. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93883. /** Texture is not repeating outside of 0..1 UVs */
  93884. static readonly CLAMP_ADDRESSMODE: number;
  93885. /** Texture is repeating outside of 0..1 UVs */
  93886. static readonly WRAP_ADDRESSMODE: number;
  93887. /** Texture is repeating and mirrored */
  93888. static readonly MIRROR_ADDRESSMODE: number;
  93889. /**
  93890. * 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
  93891. */
  93892. static UseSerializedUrlIfAny: boolean;
  93893. /**
  93894. * Define the url of the texture.
  93895. */
  93896. url: Nullable<string>;
  93897. /**
  93898. * Define an offset on the texture to offset the u coordinates of the UVs
  93899. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93900. */
  93901. uOffset: number;
  93902. /**
  93903. * Define an offset on the texture to offset the v coordinates of the UVs
  93904. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93905. */
  93906. vOffset: number;
  93907. /**
  93908. * Define an offset on the texture to scale the u coordinates of the UVs
  93909. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93910. */
  93911. uScale: number;
  93912. /**
  93913. * Define an offset on the texture to scale the v coordinates of the UVs
  93914. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93915. */
  93916. vScale: number;
  93917. /**
  93918. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93919. * @see http://doc.babylonjs.com/how_to/more_materials
  93920. */
  93921. uAng: number;
  93922. /**
  93923. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93924. * @see http://doc.babylonjs.com/how_to/more_materials
  93925. */
  93926. vAng: number;
  93927. /**
  93928. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93929. * @see http://doc.babylonjs.com/how_to/more_materials
  93930. */
  93931. wAng: number;
  93932. /**
  93933. * Defines the center of rotation (U)
  93934. */
  93935. uRotationCenter: number;
  93936. /**
  93937. * Defines the center of rotation (V)
  93938. */
  93939. vRotationCenter: number;
  93940. /**
  93941. * Defines the center of rotation (W)
  93942. */
  93943. wRotationCenter: number;
  93944. /**
  93945. * Are mip maps generated for this texture or not.
  93946. */
  93947. get noMipmap(): boolean;
  93948. /**
  93949. * List of inspectable custom properties (used by the Inspector)
  93950. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93951. */
  93952. inspectableCustomProperties: Nullable<IInspectable[]>;
  93953. private _noMipmap;
  93954. /** @hidden */
  93955. _invertY: boolean;
  93956. private _rowGenerationMatrix;
  93957. private _cachedTextureMatrix;
  93958. private _projectionModeMatrix;
  93959. private _t0;
  93960. private _t1;
  93961. private _t2;
  93962. private _cachedUOffset;
  93963. private _cachedVOffset;
  93964. private _cachedUScale;
  93965. private _cachedVScale;
  93966. private _cachedUAng;
  93967. private _cachedVAng;
  93968. private _cachedWAng;
  93969. private _cachedProjectionMatrixId;
  93970. private _cachedCoordinatesMode;
  93971. /** @hidden */
  93972. protected _initialSamplingMode: number;
  93973. /** @hidden */
  93974. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93975. private _deleteBuffer;
  93976. protected _format: Nullable<number>;
  93977. private _delayedOnLoad;
  93978. private _delayedOnError;
  93979. private _mimeType?;
  93980. /**
  93981. * Observable triggered once the texture has been loaded.
  93982. */
  93983. onLoadObservable: Observable<Texture>;
  93984. protected _isBlocking: boolean;
  93985. /**
  93986. * Is the texture preventing material to render while loading.
  93987. * If false, a default texture will be used instead of the loading one during the preparation step.
  93988. */
  93989. set isBlocking(value: boolean);
  93990. get isBlocking(): boolean;
  93991. /**
  93992. * Get the current sampling mode associated with the texture.
  93993. */
  93994. get samplingMode(): number;
  93995. /**
  93996. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93997. */
  93998. get invertY(): boolean;
  93999. /**
  94000. * Instantiates a new texture.
  94001. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94002. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94003. * @param url defines the url of the picture to load as a texture
  94004. * @param scene defines the scene or engine the texture will belong to
  94005. * @param noMipmap defines if the texture will require mip maps or not
  94006. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  94007. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94008. * @param onLoad defines a callback triggered when the texture has been loaded
  94009. * @param onError defines a callback triggered when an error occurred during the loading session
  94010. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  94011. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  94012. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94013. * @param mimeType defines an optional mime type information
  94014. */
  94015. 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);
  94016. /**
  94017. * Update the url (and optional buffer) of this texture if url was null during construction.
  94018. * @param url the url of the texture
  94019. * @param buffer the buffer of the texture (defaults to null)
  94020. * @param onLoad callback called when the texture is loaded (defaults to null)
  94021. */
  94022. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  94023. /**
  94024. * Finish the loading sequence of a texture flagged as delayed load.
  94025. * @hidden
  94026. */
  94027. delayLoad(): void;
  94028. private _prepareRowForTextureGeneration;
  94029. /**
  94030. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  94031. * @returns the transform matrix of the texture.
  94032. */
  94033. getTextureMatrix(uBase?: number): Matrix;
  94034. /**
  94035. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  94036. * @returns The reflection texture transform
  94037. */
  94038. getReflectionTextureMatrix(): Matrix;
  94039. /**
  94040. * Clones the texture.
  94041. * @returns the cloned texture
  94042. */
  94043. clone(): Texture;
  94044. /**
  94045. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94046. * @returns The JSON representation of the texture
  94047. */
  94048. serialize(): any;
  94049. /**
  94050. * Get the current class name of the texture useful for serialization or dynamic coding.
  94051. * @returns "Texture"
  94052. */
  94053. getClassName(): string;
  94054. /**
  94055. * Dispose the texture and release its associated resources.
  94056. */
  94057. dispose(): void;
  94058. /**
  94059. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  94060. * @param parsedTexture Define the JSON representation of the texture
  94061. * @param scene Define the scene the parsed texture should be instantiated in
  94062. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  94063. * @returns The parsed texture if successful
  94064. */
  94065. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  94066. /**
  94067. * Creates a texture from its base 64 representation.
  94068. * @param data Define the base64 payload without the data: prefix
  94069. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94070. * @param scene Define the scene the texture should belong to
  94071. * @param noMipmap Forces the texture to not create mip map information if true
  94072. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94073. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94074. * @param onLoad define a callback triggered when the texture has been loaded
  94075. * @param onError define a callback triggered when an error occurred during the loading session
  94076. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94077. * @returns the created texture
  94078. */
  94079. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  94080. /**
  94081. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  94082. * @param data Define the base64 payload without the data: prefix
  94083. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94084. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  94085. * @param scene Define the scene the texture should belong to
  94086. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  94087. * @param noMipmap Forces the texture to not create mip map information if true
  94088. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94089. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94090. * @param onLoad define a callback triggered when the texture has been loaded
  94091. * @param onError define a callback triggered when an error occurred during the loading session
  94092. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94093. * @returns the created texture
  94094. */
  94095. 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;
  94096. }
  94097. }
  94098. declare module BABYLON {
  94099. /**
  94100. * PostProcessManager is used to manage one or more post processes or post process pipelines
  94101. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94102. */
  94103. export class PostProcessManager {
  94104. private _scene;
  94105. private _indexBuffer;
  94106. private _vertexBuffers;
  94107. /**
  94108. * Creates a new instance PostProcess
  94109. * @param scene The scene that the post process is associated with.
  94110. */
  94111. constructor(scene: Scene);
  94112. private _prepareBuffers;
  94113. private _buildIndexBuffer;
  94114. /**
  94115. * Rebuilds the vertex buffers of the manager.
  94116. * @hidden
  94117. */
  94118. _rebuild(): void;
  94119. /**
  94120. * Prepares a frame to be run through a post process.
  94121. * @param sourceTexture The input texture to the post procesess. (default: null)
  94122. * @param postProcesses An array of post processes to be run. (default: null)
  94123. * @returns True if the post processes were able to be run.
  94124. * @hidden
  94125. */
  94126. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94127. /**
  94128. * Manually render a set of post processes to a texture.
  94129. * @param postProcesses An array of post processes to be run.
  94130. * @param targetTexture The target texture to render to.
  94131. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94132. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94133. * @param lodLevel defines which lod of the texture to render to
  94134. */
  94135. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94136. /**
  94137. * Finalize the result of the output of the postprocesses.
  94138. * @param doNotPresent If true the result will not be displayed to the screen.
  94139. * @param targetTexture The target texture to render to.
  94140. * @param faceIndex The index of the face to bind the target texture to.
  94141. * @param postProcesses The array of post processes to render.
  94142. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94143. * @hidden
  94144. */
  94145. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94146. /**
  94147. * Disposes of the post process manager.
  94148. */
  94149. dispose(): void;
  94150. }
  94151. }
  94152. declare module BABYLON {
  94153. /**
  94154. * This Helps creating a texture that will be created from a camera in your scene.
  94155. * It is basically a dynamic texture that could be used to create special effects for instance.
  94156. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94157. */
  94158. export class RenderTargetTexture extends Texture {
  94159. isCube: boolean;
  94160. /**
  94161. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94162. */
  94163. static readonly REFRESHRATE_RENDER_ONCE: number;
  94164. /**
  94165. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94166. */
  94167. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94168. /**
  94169. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94170. * the central point of your effect and can save a lot of performances.
  94171. */
  94172. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94173. /**
  94174. * Use this predicate to dynamically define the list of mesh you want to render.
  94175. * If set, the renderList property will be overwritten.
  94176. */
  94177. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94178. private _renderList;
  94179. /**
  94180. * Use this list to define the list of mesh you want to render.
  94181. */
  94182. get renderList(): Nullable<Array<AbstractMesh>>;
  94183. set renderList(value: Nullable<Array<AbstractMesh>>);
  94184. /**
  94185. * Use this function to overload the renderList array at rendering time.
  94186. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94187. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94188. * the cube (if the RTT is a cube, else layerOrFace=0).
  94189. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94190. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94191. * hold dummy elements!
  94192. */
  94193. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94194. private _hookArray;
  94195. /**
  94196. * Define if particles should be rendered in your texture.
  94197. */
  94198. renderParticles: boolean;
  94199. /**
  94200. * Define if sprites should be rendered in your texture.
  94201. */
  94202. renderSprites: boolean;
  94203. /**
  94204. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94205. */
  94206. coordinatesMode: number;
  94207. /**
  94208. * Define the camera used to render the texture.
  94209. */
  94210. activeCamera: Nullable<Camera>;
  94211. /**
  94212. * Override the render function of the texture with your own one.
  94213. */
  94214. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94215. /**
  94216. * Define if camera post processes should be use while rendering the texture.
  94217. */
  94218. useCameraPostProcesses: boolean;
  94219. /**
  94220. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94221. */
  94222. ignoreCameraViewport: boolean;
  94223. private _postProcessManager;
  94224. private _postProcesses;
  94225. private _resizeObserver;
  94226. /**
  94227. * An event triggered when the texture is unbind.
  94228. */
  94229. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94230. /**
  94231. * An event triggered when the texture is unbind.
  94232. */
  94233. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94234. private _onAfterUnbindObserver;
  94235. /**
  94236. * Set a after unbind callback in the texture.
  94237. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94238. */
  94239. set onAfterUnbind(callback: () => void);
  94240. /**
  94241. * An event triggered before rendering the texture
  94242. */
  94243. onBeforeRenderObservable: Observable<number>;
  94244. private _onBeforeRenderObserver;
  94245. /**
  94246. * Set a before render callback in the texture.
  94247. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94248. */
  94249. set onBeforeRender(callback: (faceIndex: number) => void);
  94250. /**
  94251. * An event triggered after rendering the texture
  94252. */
  94253. onAfterRenderObservable: Observable<number>;
  94254. private _onAfterRenderObserver;
  94255. /**
  94256. * Set a after render callback in the texture.
  94257. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94258. */
  94259. set onAfterRender(callback: (faceIndex: number) => void);
  94260. /**
  94261. * An event triggered after the texture clear
  94262. */
  94263. onClearObservable: Observable<Engine>;
  94264. private _onClearObserver;
  94265. /**
  94266. * Set a clear callback in the texture.
  94267. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94268. */
  94269. set onClear(callback: (Engine: Engine) => void);
  94270. /**
  94271. * An event triggered when the texture is resized.
  94272. */
  94273. onResizeObservable: Observable<RenderTargetTexture>;
  94274. /**
  94275. * Define the clear color of the Render Target if it should be different from the scene.
  94276. */
  94277. clearColor: Color4;
  94278. protected _size: number | {
  94279. width: number;
  94280. height: number;
  94281. layers?: number;
  94282. };
  94283. protected _initialSizeParameter: number | {
  94284. width: number;
  94285. height: number;
  94286. } | {
  94287. ratio: number;
  94288. };
  94289. protected _sizeRatio: Nullable<number>;
  94290. /** @hidden */
  94291. _generateMipMaps: boolean;
  94292. protected _renderingManager: RenderingManager;
  94293. /** @hidden */
  94294. _waitingRenderList: string[];
  94295. protected _doNotChangeAspectRatio: boolean;
  94296. protected _currentRefreshId: number;
  94297. protected _refreshRate: number;
  94298. protected _textureMatrix: Matrix;
  94299. protected _samples: number;
  94300. protected _renderTargetOptions: RenderTargetCreationOptions;
  94301. /**
  94302. * Gets render target creation options that were used.
  94303. */
  94304. get renderTargetOptions(): RenderTargetCreationOptions;
  94305. protected _engine: Engine;
  94306. protected _onRatioRescale(): void;
  94307. /**
  94308. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  94309. * It must define where the camera used to render the texture is set
  94310. */
  94311. boundingBoxPosition: Vector3;
  94312. private _boundingBoxSize;
  94313. /**
  94314. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  94315. * When defined, the cubemap will switch to local mode
  94316. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  94317. * @example https://www.babylonjs-playground.com/#RNASML
  94318. */
  94319. set boundingBoxSize(value: Vector3);
  94320. get boundingBoxSize(): Vector3;
  94321. /**
  94322. * In case the RTT has been created with a depth texture, get the associated
  94323. * depth texture.
  94324. * Otherwise, return null.
  94325. */
  94326. get depthStencilTexture(): Nullable<InternalTexture>;
  94327. /**
  94328. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  94329. * or used a shadow, depth texture...
  94330. * @param name The friendly name of the texture
  94331. * @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)
  94332. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  94333. * @param generateMipMaps True if mip maps need to be generated after render.
  94334. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  94335. * @param type The type of the buffer in the RTT (int, half float, float...)
  94336. * @param isCube True if a cube texture needs to be created
  94337. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  94338. * @param generateDepthBuffer True to generate a depth buffer
  94339. * @param generateStencilBuffer True to generate a stencil buffer
  94340. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  94341. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  94342. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94343. */
  94344. constructor(name: string, size: number | {
  94345. width: number;
  94346. height: number;
  94347. layers?: number;
  94348. } | {
  94349. ratio: number;
  94350. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  94351. /**
  94352. * Creates a depth stencil texture.
  94353. * This is only available in WebGL 2 or with the depth texture extension available.
  94354. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  94355. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  94356. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  94357. */
  94358. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  94359. private _processSizeParameter;
  94360. /**
  94361. * Define the number of samples to use in case of MSAA.
  94362. * It defaults to one meaning no MSAA has been enabled.
  94363. */
  94364. get samples(): number;
  94365. set samples(value: number);
  94366. /**
  94367. * Resets the refresh counter of the texture and start bak from scratch.
  94368. * Could be useful to regenerate the texture if it is setup to render only once.
  94369. */
  94370. resetRefreshCounter(): void;
  94371. /**
  94372. * Define the refresh rate of the texture or the rendering frequency.
  94373. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  94374. */
  94375. get refreshRate(): number;
  94376. set refreshRate(value: number);
  94377. /**
  94378. * Adds a post process to the render target rendering passes.
  94379. * @param postProcess define the post process to add
  94380. */
  94381. addPostProcess(postProcess: PostProcess): void;
  94382. /**
  94383. * Clear all the post processes attached to the render target
  94384. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  94385. */
  94386. clearPostProcesses(dispose?: boolean): void;
  94387. /**
  94388. * Remove one of the post process from the list of attached post processes to the texture
  94389. * @param postProcess define the post process to remove from the list
  94390. */
  94391. removePostProcess(postProcess: PostProcess): void;
  94392. /** @hidden */
  94393. _shouldRender(): boolean;
  94394. /**
  94395. * Gets the actual render size of the texture.
  94396. * @returns the width of the render size
  94397. */
  94398. getRenderSize(): number;
  94399. /**
  94400. * Gets the actual render width of the texture.
  94401. * @returns the width of the render size
  94402. */
  94403. getRenderWidth(): number;
  94404. /**
  94405. * Gets the actual render height of the texture.
  94406. * @returns the height of the render size
  94407. */
  94408. getRenderHeight(): number;
  94409. /**
  94410. * Gets the actual number of layers of the texture.
  94411. * @returns the number of layers
  94412. */
  94413. getRenderLayers(): number;
  94414. /**
  94415. * Get if the texture can be rescaled or not.
  94416. */
  94417. get canRescale(): boolean;
  94418. /**
  94419. * Resize the texture using a ratio.
  94420. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  94421. */
  94422. scale(ratio: number): void;
  94423. /**
  94424. * Get the texture reflection matrix used to rotate/transform the reflection.
  94425. * @returns the reflection matrix
  94426. */
  94427. getReflectionTextureMatrix(): Matrix;
  94428. /**
  94429. * Resize the texture to a new desired size.
  94430. * Be carrefull as it will recreate all the data in the new texture.
  94431. * @param size Define the new size. It can be:
  94432. * - a number for squared texture,
  94433. * - an object containing { width: number, height: number }
  94434. * - or an object containing a ratio { ratio: number }
  94435. */
  94436. resize(size: number | {
  94437. width: number;
  94438. height: number;
  94439. } | {
  94440. ratio: number;
  94441. }): void;
  94442. private _defaultRenderListPrepared;
  94443. /**
  94444. * Renders all the objects from the render list into the texture.
  94445. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94446. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94447. */
  94448. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94449. private _bestReflectionRenderTargetDimension;
  94450. private _prepareRenderingManager;
  94451. /**
  94452. * @hidden
  94453. * @param faceIndex face index to bind to if this is a cubetexture
  94454. * @param layer defines the index of the texture to bind in the array
  94455. */
  94456. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94457. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94458. private renderToTarget;
  94459. /**
  94460. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94461. * This allowed control for front to back rendering or reversly depending of the special needs.
  94462. *
  94463. * @param renderingGroupId The rendering group id corresponding to its index
  94464. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94465. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94466. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94467. */
  94468. 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;
  94469. /**
  94470. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94471. *
  94472. * @param renderingGroupId The rendering group id corresponding to its index
  94473. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94474. */
  94475. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94476. /**
  94477. * Clones the texture.
  94478. * @returns the cloned texture
  94479. */
  94480. clone(): RenderTargetTexture;
  94481. /**
  94482. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94483. * @returns The JSON representation of the texture
  94484. */
  94485. serialize(): any;
  94486. /**
  94487. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94488. */
  94489. disposeFramebufferObjects(): void;
  94490. /**
  94491. * Dispose the texture and release its associated resources.
  94492. */
  94493. dispose(): void;
  94494. /** @hidden */
  94495. _rebuild(): void;
  94496. /**
  94497. * Clear the info related to rendering groups preventing retention point in material dispose.
  94498. */
  94499. freeRenderingGroups(): void;
  94500. /**
  94501. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94502. * @returns the view count
  94503. */
  94504. getViewCount(): number;
  94505. }
  94506. }
  94507. declare module BABYLON {
  94508. /**
  94509. * Options for compiling materials.
  94510. */
  94511. export interface IMaterialCompilationOptions {
  94512. /**
  94513. * Defines whether clip planes are enabled.
  94514. */
  94515. clipPlane: boolean;
  94516. /**
  94517. * Defines whether instances are enabled.
  94518. */
  94519. useInstances: boolean;
  94520. }
  94521. /**
  94522. * Base class for the main features of a material in Babylon.js
  94523. */
  94524. export class Material implements IAnimatable {
  94525. /**
  94526. * Returns the triangle fill mode
  94527. */
  94528. static readonly TriangleFillMode: number;
  94529. /**
  94530. * Returns the wireframe mode
  94531. */
  94532. static readonly WireFrameFillMode: number;
  94533. /**
  94534. * Returns the point fill mode
  94535. */
  94536. static readonly PointFillMode: number;
  94537. /**
  94538. * Returns the point list draw mode
  94539. */
  94540. static readonly PointListDrawMode: number;
  94541. /**
  94542. * Returns the line list draw mode
  94543. */
  94544. static readonly LineListDrawMode: number;
  94545. /**
  94546. * Returns the line loop draw mode
  94547. */
  94548. static readonly LineLoopDrawMode: number;
  94549. /**
  94550. * Returns the line strip draw mode
  94551. */
  94552. static readonly LineStripDrawMode: number;
  94553. /**
  94554. * Returns the triangle strip draw mode
  94555. */
  94556. static readonly TriangleStripDrawMode: number;
  94557. /**
  94558. * Returns the triangle fan draw mode
  94559. */
  94560. static readonly TriangleFanDrawMode: number;
  94561. /**
  94562. * Stores the clock-wise side orientation
  94563. */
  94564. static readonly ClockWiseSideOrientation: number;
  94565. /**
  94566. * Stores the counter clock-wise side orientation
  94567. */
  94568. static readonly CounterClockWiseSideOrientation: number;
  94569. /**
  94570. * The dirty texture flag value
  94571. */
  94572. static readonly TextureDirtyFlag: number;
  94573. /**
  94574. * The dirty light flag value
  94575. */
  94576. static readonly LightDirtyFlag: number;
  94577. /**
  94578. * The dirty fresnel flag value
  94579. */
  94580. static readonly FresnelDirtyFlag: number;
  94581. /**
  94582. * The dirty attribute flag value
  94583. */
  94584. static readonly AttributesDirtyFlag: number;
  94585. /**
  94586. * The dirty misc flag value
  94587. */
  94588. static readonly MiscDirtyFlag: number;
  94589. /**
  94590. * The all dirty flag value
  94591. */
  94592. static readonly AllDirtyFlag: number;
  94593. /**
  94594. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  94595. */
  94596. static readonly MATERIAL_OPAQUE: number;
  94597. /**
  94598. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  94599. */
  94600. static readonly MATERIAL_ALPHATEST: number;
  94601. /**
  94602. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  94603. */
  94604. static readonly MATERIAL_ALPHABLEND: number;
  94605. /**
  94606. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  94607. * They are also discarded below the alpha cutoff threshold to improve performances.
  94608. */
  94609. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  94610. /**
  94611. * The ID of the material
  94612. */
  94613. id: string;
  94614. /**
  94615. * Gets or sets the unique id of the material
  94616. */
  94617. uniqueId: number;
  94618. /**
  94619. * The name of the material
  94620. */
  94621. name: string;
  94622. /**
  94623. * Gets or sets user defined metadata
  94624. */
  94625. metadata: any;
  94626. /**
  94627. * For internal use only. Please do not use.
  94628. */
  94629. reservedDataStore: any;
  94630. /**
  94631. * Specifies if the ready state should be checked on each call
  94632. */
  94633. checkReadyOnEveryCall: boolean;
  94634. /**
  94635. * Specifies if the ready state should be checked once
  94636. */
  94637. checkReadyOnlyOnce: boolean;
  94638. /**
  94639. * The state of the material
  94640. */
  94641. state: string;
  94642. /**
  94643. * The alpha value of the material
  94644. */
  94645. protected _alpha: number;
  94646. /**
  94647. * List of inspectable custom properties (used by the Inspector)
  94648. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94649. */
  94650. inspectableCustomProperties: IInspectable[];
  94651. /**
  94652. * Sets the alpha value of the material
  94653. */
  94654. set alpha(value: number);
  94655. /**
  94656. * Gets the alpha value of the material
  94657. */
  94658. get alpha(): number;
  94659. /**
  94660. * Specifies if back face culling is enabled
  94661. */
  94662. protected _backFaceCulling: boolean;
  94663. /**
  94664. * Sets the back-face culling state
  94665. */
  94666. set backFaceCulling(value: boolean);
  94667. /**
  94668. * Gets the back-face culling state
  94669. */
  94670. get backFaceCulling(): boolean;
  94671. /**
  94672. * Stores the value for side orientation
  94673. */
  94674. sideOrientation: number;
  94675. /**
  94676. * Callback triggered when the material is compiled
  94677. */
  94678. onCompiled: Nullable<(effect: Effect) => void>;
  94679. /**
  94680. * Callback triggered when an error occurs
  94681. */
  94682. onError: Nullable<(effect: Effect, errors: string) => void>;
  94683. /**
  94684. * Callback triggered to get the render target textures
  94685. */
  94686. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94687. /**
  94688. * Gets a boolean indicating that current material needs to register RTT
  94689. */
  94690. get hasRenderTargetTextures(): boolean;
  94691. /**
  94692. * Specifies if the material should be serialized
  94693. */
  94694. doNotSerialize: boolean;
  94695. /**
  94696. * @hidden
  94697. */
  94698. _storeEffectOnSubMeshes: boolean;
  94699. /**
  94700. * Stores the animations for the material
  94701. */
  94702. animations: Nullable<Array<Animation>>;
  94703. /**
  94704. * An event triggered when the material is disposed
  94705. */
  94706. onDisposeObservable: Observable<Material>;
  94707. /**
  94708. * An observer which watches for dispose events
  94709. */
  94710. private _onDisposeObserver;
  94711. private _onUnBindObservable;
  94712. /**
  94713. * Called during a dispose event
  94714. */
  94715. set onDispose(callback: () => void);
  94716. private _onBindObservable;
  94717. /**
  94718. * An event triggered when the material is bound
  94719. */
  94720. get onBindObservable(): Observable<AbstractMesh>;
  94721. /**
  94722. * An observer which watches for bind events
  94723. */
  94724. private _onBindObserver;
  94725. /**
  94726. * Called during a bind event
  94727. */
  94728. set onBind(callback: (Mesh: AbstractMesh) => void);
  94729. /**
  94730. * An event triggered when the material is unbound
  94731. */
  94732. get onUnBindObservable(): Observable<Material>;
  94733. /**
  94734. * Stores the value of the alpha mode
  94735. */
  94736. private _alphaMode;
  94737. /**
  94738. * Sets the value of the alpha mode.
  94739. *
  94740. * | Value | Type | Description |
  94741. * | --- | --- | --- |
  94742. * | 0 | ALPHA_DISABLE | |
  94743. * | 1 | ALPHA_ADD | |
  94744. * | 2 | ALPHA_COMBINE | |
  94745. * | 3 | ALPHA_SUBTRACT | |
  94746. * | 4 | ALPHA_MULTIPLY | |
  94747. * | 5 | ALPHA_MAXIMIZED | |
  94748. * | 6 | ALPHA_ONEONE | |
  94749. * | 7 | ALPHA_PREMULTIPLIED | |
  94750. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94751. * | 9 | ALPHA_INTERPOLATE | |
  94752. * | 10 | ALPHA_SCREENMODE | |
  94753. *
  94754. */
  94755. set alphaMode(value: number);
  94756. /**
  94757. * Gets the value of the alpha mode
  94758. */
  94759. get alphaMode(): number;
  94760. /**
  94761. * Stores the state of the need depth pre-pass value
  94762. */
  94763. private _needDepthPrePass;
  94764. /**
  94765. * Sets the need depth pre-pass value
  94766. */
  94767. set needDepthPrePass(value: boolean);
  94768. /**
  94769. * Gets the depth pre-pass value
  94770. */
  94771. get needDepthPrePass(): boolean;
  94772. /**
  94773. * Specifies if depth writing should be disabled
  94774. */
  94775. disableDepthWrite: boolean;
  94776. /**
  94777. * Specifies if depth writing should be forced
  94778. */
  94779. forceDepthWrite: boolean;
  94780. /**
  94781. * Specifies the depth function that should be used. 0 means the default engine function
  94782. */
  94783. depthFunction: number;
  94784. /**
  94785. * Specifies if there should be a separate pass for culling
  94786. */
  94787. separateCullingPass: boolean;
  94788. /**
  94789. * Stores the state specifing if fog should be enabled
  94790. */
  94791. private _fogEnabled;
  94792. /**
  94793. * Sets the state for enabling fog
  94794. */
  94795. set fogEnabled(value: boolean);
  94796. /**
  94797. * Gets the value of the fog enabled state
  94798. */
  94799. get fogEnabled(): boolean;
  94800. /**
  94801. * Stores the size of points
  94802. */
  94803. pointSize: number;
  94804. /**
  94805. * Stores the z offset value
  94806. */
  94807. zOffset: number;
  94808. /**
  94809. * Gets a value specifying if wireframe mode is enabled
  94810. */
  94811. get wireframe(): boolean;
  94812. /**
  94813. * Sets the state of wireframe mode
  94814. */
  94815. set wireframe(value: boolean);
  94816. /**
  94817. * Gets the value specifying if point clouds are enabled
  94818. */
  94819. get pointsCloud(): boolean;
  94820. /**
  94821. * Sets the state of point cloud mode
  94822. */
  94823. set pointsCloud(value: boolean);
  94824. /**
  94825. * Gets the material fill mode
  94826. */
  94827. get fillMode(): number;
  94828. /**
  94829. * Sets the material fill mode
  94830. */
  94831. set fillMode(value: number);
  94832. /**
  94833. * @hidden
  94834. * Stores the effects for the material
  94835. */
  94836. _effect: Nullable<Effect>;
  94837. /**
  94838. * Specifies if uniform buffers should be used
  94839. */
  94840. private _useUBO;
  94841. /**
  94842. * Stores a reference to the scene
  94843. */
  94844. private _scene;
  94845. /**
  94846. * Stores the fill mode state
  94847. */
  94848. private _fillMode;
  94849. /**
  94850. * Specifies if the depth write state should be cached
  94851. */
  94852. private _cachedDepthWriteState;
  94853. /**
  94854. * Specifies if the depth function state should be cached
  94855. */
  94856. private _cachedDepthFunctionState;
  94857. /**
  94858. * Stores the uniform buffer
  94859. */
  94860. protected _uniformBuffer: UniformBuffer;
  94861. /** @hidden */
  94862. _indexInSceneMaterialArray: number;
  94863. /** @hidden */
  94864. meshMap: Nullable<{
  94865. [id: string]: AbstractMesh | undefined;
  94866. }>;
  94867. /**
  94868. * Creates a material instance
  94869. * @param name defines the name of the material
  94870. * @param scene defines the scene to reference
  94871. * @param doNotAdd specifies if the material should be added to the scene
  94872. */
  94873. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94874. /**
  94875. * Returns a string representation of the current material
  94876. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94877. * @returns a string with material information
  94878. */
  94879. toString(fullDetails?: boolean): string;
  94880. /**
  94881. * Gets the class name of the material
  94882. * @returns a string with the class name of the material
  94883. */
  94884. getClassName(): string;
  94885. /**
  94886. * Specifies if updates for the material been locked
  94887. */
  94888. get isFrozen(): boolean;
  94889. /**
  94890. * Locks updates for the material
  94891. */
  94892. freeze(): void;
  94893. /**
  94894. * Unlocks updates for the material
  94895. */
  94896. unfreeze(): void;
  94897. /**
  94898. * Specifies if the material is ready to be used
  94899. * @param mesh defines the mesh to check
  94900. * @param useInstances specifies if instances should be used
  94901. * @returns a boolean indicating if the material is ready to be used
  94902. */
  94903. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94904. /**
  94905. * Specifies that the submesh is ready to be used
  94906. * @param mesh defines the mesh to check
  94907. * @param subMesh defines which submesh to check
  94908. * @param useInstances specifies that instances should be used
  94909. * @returns a boolean indicating that the submesh is ready or not
  94910. */
  94911. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94912. /**
  94913. * Returns the material effect
  94914. * @returns the effect associated with the material
  94915. */
  94916. getEffect(): Nullable<Effect>;
  94917. /**
  94918. * Returns the current scene
  94919. * @returns a Scene
  94920. */
  94921. getScene(): Scene;
  94922. /**
  94923. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  94924. */
  94925. protected _forceAlphaTest: boolean;
  94926. /**
  94927. * The transparency mode of the material.
  94928. */
  94929. protected _transparencyMode: Nullable<number>;
  94930. /**
  94931. * Gets the current transparency mode.
  94932. */
  94933. get transparencyMode(): Nullable<number>;
  94934. /**
  94935. * Sets the transparency mode of the material.
  94936. *
  94937. * | Value | Type | Description |
  94938. * | ----- | ----------------------------------- | ----------- |
  94939. * | 0 | OPAQUE | |
  94940. * | 1 | ALPHATEST | |
  94941. * | 2 | ALPHABLEND | |
  94942. * | 3 | ALPHATESTANDBLEND | |
  94943. *
  94944. */
  94945. set transparencyMode(value: Nullable<number>);
  94946. /**
  94947. * Returns true if alpha blending should be disabled.
  94948. */
  94949. protected get _disableAlphaBlending(): boolean;
  94950. /**
  94951. * Specifies whether or not this material should be rendered in alpha blend mode.
  94952. * @returns a boolean specifying if alpha blending is needed
  94953. */
  94954. needAlphaBlending(): boolean;
  94955. /**
  94956. * Specifies if the mesh will require alpha blending
  94957. * @param mesh defines the mesh to check
  94958. * @returns a boolean specifying if alpha blending is needed for the mesh
  94959. */
  94960. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94961. /**
  94962. * Specifies whether or not this material should be rendered in alpha test mode.
  94963. * @returns a boolean specifying if an alpha test is needed.
  94964. */
  94965. needAlphaTesting(): boolean;
  94966. /**
  94967. * Specifies if material alpha testing should be turned on for the mesh
  94968. * @param mesh defines the mesh to check
  94969. */
  94970. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94971. /**
  94972. * Gets the texture used for the alpha test
  94973. * @returns the texture to use for alpha testing
  94974. */
  94975. getAlphaTestTexture(): Nullable<BaseTexture>;
  94976. /**
  94977. * Marks the material to indicate that it needs to be re-calculated
  94978. */
  94979. markDirty(): void;
  94980. /** @hidden */
  94981. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94982. /**
  94983. * Binds the material to the mesh
  94984. * @param world defines the world transformation matrix
  94985. * @param mesh defines the mesh to bind the material to
  94986. */
  94987. bind(world: Matrix, mesh?: Mesh): void;
  94988. /**
  94989. * Binds the submesh to the material
  94990. * @param world defines the world transformation matrix
  94991. * @param mesh defines the mesh containing the submesh
  94992. * @param subMesh defines the submesh to bind the material to
  94993. */
  94994. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94995. /**
  94996. * Binds the world matrix to the material
  94997. * @param world defines the world transformation matrix
  94998. */
  94999. bindOnlyWorldMatrix(world: Matrix): void;
  95000. /**
  95001. * Binds the scene's uniform buffer to the effect.
  95002. * @param effect defines the effect to bind to the scene uniform buffer
  95003. * @param sceneUbo defines the uniform buffer storing scene data
  95004. */
  95005. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  95006. /**
  95007. * Binds the view matrix to the effect
  95008. * @param effect defines the effect to bind the view matrix to
  95009. */
  95010. bindView(effect: Effect): void;
  95011. /**
  95012. * Binds the view projection matrix to the effect
  95013. * @param effect defines the effect to bind the view projection matrix to
  95014. */
  95015. bindViewProjection(effect: Effect): void;
  95016. /**
  95017. * Processes to execute after binding the material to a mesh
  95018. * @param mesh defines the rendered mesh
  95019. */
  95020. protected _afterBind(mesh?: Mesh): void;
  95021. /**
  95022. * Unbinds the material from the mesh
  95023. */
  95024. unbind(): void;
  95025. /**
  95026. * Gets the active textures from the material
  95027. * @returns an array of textures
  95028. */
  95029. getActiveTextures(): BaseTexture[];
  95030. /**
  95031. * Specifies if the material uses a texture
  95032. * @param texture defines the texture to check against the material
  95033. * @returns a boolean specifying if the material uses the texture
  95034. */
  95035. hasTexture(texture: BaseTexture): boolean;
  95036. /**
  95037. * Makes a duplicate of the material, and gives it a new name
  95038. * @param name defines the new name for the duplicated material
  95039. * @returns the cloned material
  95040. */
  95041. clone(name: string): Nullable<Material>;
  95042. /**
  95043. * Gets the meshes bound to the material
  95044. * @returns an array of meshes bound to the material
  95045. */
  95046. getBindedMeshes(): AbstractMesh[];
  95047. /**
  95048. * Force shader compilation
  95049. * @param mesh defines the mesh associated with this material
  95050. * @param onCompiled defines a function to execute once the material is compiled
  95051. * @param options defines the options to configure the compilation
  95052. * @param onError defines a function to execute if the material fails compiling
  95053. */
  95054. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  95055. /**
  95056. * Force shader compilation
  95057. * @param mesh defines the mesh that will use this material
  95058. * @param options defines additional options for compiling the shaders
  95059. * @returns a promise that resolves when the compilation completes
  95060. */
  95061. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  95062. private static readonly _AllDirtyCallBack;
  95063. private static readonly _ImageProcessingDirtyCallBack;
  95064. private static readonly _TextureDirtyCallBack;
  95065. private static readonly _FresnelDirtyCallBack;
  95066. private static readonly _MiscDirtyCallBack;
  95067. private static readonly _LightsDirtyCallBack;
  95068. private static readonly _AttributeDirtyCallBack;
  95069. private static _FresnelAndMiscDirtyCallBack;
  95070. private static _TextureAndMiscDirtyCallBack;
  95071. private static readonly _DirtyCallbackArray;
  95072. private static readonly _RunDirtyCallBacks;
  95073. /**
  95074. * Marks a define in the material to indicate that it needs to be re-computed
  95075. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  95076. */
  95077. markAsDirty(flag: number): void;
  95078. /**
  95079. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  95080. * @param func defines a function which checks material defines against the submeshes
  95081. */
  95082. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  95083. /**
  95084. * Indicates that we need to re-calculated for all submeshes
  95085. */
  95086. protected _markAllSubMeshesAsAllDirty(): void;
  95087. /**
  95088. * Indicates that image processing needs to be re-calculated for all submeshes
  95089. */
  95090. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  95091. /**
  95092. * Indicates that textures need to be re-calculated for all submeshes
  95093. */
  95094. protected _markAllSubMeshesAsTexturesDirty(): void;
  95095. /**
  95096. * Indicates that fresnel needs to be re-calculated for all submeshes
  95097. */
  95098. protected _markAllSubMeshesAsFresnelDirty(): void;
  95099. /**
  95100. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  95101. */
  95102. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  95103. /**
  95104. * Indicates that lights need to be re-calculated for all submeshes
  95105. */
  95106. protected _markAllSubMeshesAsLightsDirty(): void;
  95107. /**
  95108. * Indicates that attributes need to be re-calculated for all submeshes
  95109. */
  95110. protected _markAllSubMeshesAsAttributesDirty(): void;
  95111. /**
  95112. * Indicates that misc needs to be re-calculated for all submeshes
  95113. */
  95114. protected _markAllSubMeshesAsMiscDirty(): void;
  95115. /**
  95116. * Indicates that textures and misc need to be re-calculated for all submeshes
  95117. */
  95118. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95119. /**
  95120. * Disposes the material
  95121. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95122. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95123. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95124. */
  95125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95126. /** @hidden */
  95127. private releaseVertexArrayObject;
  95128. /**
  95129. * Serializes this material
  95130. * @returns the serialized material object
  95131. */
  95132. serialize(): any;
  95133. /**
  95134. * Creates a material from parsed material data
  95135. * @param parsedMaterial defines parsed material data
  95136. * @param scene defines the hosting scene
  95137. * @param rootUrl defines the root URL to use to load textures
  95138. * @returns a new material
  95139. */
  95140. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95141. }
  95142. }
  95143. declare module BABYLON {
  95144. /**
  95145. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95146. * separate meshes. This can be use to improve performances.
  95147. * @see http://doc.babylonjs.com/how_to/multi_materials
  95148. */
  95149. export class MultiMaterial extends Material {
  95150. private _subMaterials;
  95151. /**
  95152. * Gets or Sets the list of Materials used within the multi material.
  95153. * They need to be ordered according to the submeshes order in the associated mesh
  95154. */
  95155. get subMaterials(): Nullable<Material>[];
  95156. set subMaterials(value: Nullable<Material>[]);
  95157. /**
  95158. * Function used to align with Node.getChildren()
  95159. * @returns the list of Materials used within the multi material
  95160. */
  95161. getChildren(): Nullable<Material>[];
  95162. /**
  95163. * Instantiates a new Multi Material
  95164. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95165. * separate meshes. This can be use to improve performances.
  95166. * @see http://doc.babylonjs.com/how_to/multi_materials
  95167. * @param name Define the name in the scene
  95168. * @param scene Define the scene the material belongs to
  95169. */
  95170. constructor(name: string, scene: Scene);
  95171. private _hookArray;
  95172. /**
  95173. * Get one of the submaterial by its index in the submaterials array
  95174. * @param index The index to look the sub material at
  95175. * @returns The Material if the index has been defined
  95176. */
  95177. getSubMaterial(index: number): Nullable<Material>;
  95178. /**
  95179. * Get the list of active textures for the whole sub materials list.
  95180. * @returns All the textures that will be used during the rendering
  95181. */
  95182. getActiveTextures(): BaseTexture[];
  95183. /**
  95184. * Gets the current class name of the material e.g. "MultiMaterial"
  95185. * Mainly use in serialization.
  95186. * @returns the class name
  95187. */
  95188. getClassName(): string;
  95189. /**
  95190. * Checks if the material is ready to render the requested sub mesh
  95191. * @param mesh Define the mesh the submesh belongs to
  95192. * @param subMesh Define the sub mesh to look readyness for
  95193. * @param useInstances Define whether or not the material is used with instances
  95194. * @returns true if ready, otherwise false
  95195. */
  95196. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95197. /**
  95198. * Clones the current material and its related sub materials
  95199. * @param name Define the name of the newly cloned material
  95200. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95201. * @returns the cloned material
  95202. */
  95203. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95204. /**
  95205. * Serializes the materials into a JSON representation.
  95206. * @returns the JSON representation
  95207. */
  95208. serialize(): any;
  95209. /**
  95210. * Dispose the material and release its associated resources
  95211. * @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)
  95212. * @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)
  95213. * @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)
  95214. */
  95215. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95216. /**
  95217. * Creates a MultiMaterial from parsed MultiMaterial data.
  95218. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95219. * @param scene defines the hosting scene
  95220. * @returns a new MultiMaterial
  95221. */
  95222. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95223. }
  95224. }
  95225. declare module BABYLON {
  95226. /**
  95227. * Base class for submeshes
  95228. */
  95229. export class BaseSubMesh {
  95230. /** @hidden */
  95231. _materialDefines: Nullable<MaterialDefines>;
  95232. /** @hidden */
  95233. _materialEffect: Nullable<Effect>;
  95234. /**
  95235. * Gets material defines used by the effect associated to the sub mesh
  95236. */
  95237. get materialDefines(): Nullable<MaterialDefines>;
  95238. /**
  95239. * Sets material defines used by the effect associated to the sub mesh
  95240. */
  95241. set materialDefines(defines: Nullable<MaterialDefines>);
  95242. /**
  95243. * Gets associated effect
  95244. */
  95245. get effect(): Nullable<Effect>;
  95246. /**
  95247. * Sets associated effect (effect used to render this submesh)
  95248. * @param effect defines the effect to associate with
  95249. * @param defines defines the set of defines used to compile this effect
  95250. */
  95251. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95252. }
  95253. /**
  95254. * Defines a subdivision inside a mesh
  95255. */
  95256. export class SubMesh extends BaseSubMesh implements ICullable {
  95257. /** the material index to use */
  95258. materialIndex: number;
  95259. /** vertex index start */
  95260. verticesStart: number;
  95261. /** vertices count */
  95262. verticesCount: number;
  95263. /** index start */
  95264. indexStart: number;
  95265. /** indices count */
  95266. indexCount: number;
  95267. /** @hidden */
  95268. _linesIndexCount: number;
  95269. private _mesh;
  95270. private _renderingMesh;
  95271. private _boundingInfo;
  95272. private _linesIndexBuffer;
  95273. /** @hidden */
  95274. _lastColliderWorldVertices: Nullable<Vector3[]>;
  95275. /** @hidden */
  95276. _trianglePlanes: Plane[];
  95277. /** @hidden */
  95278. _lastColliderTransformMatrix: Nullable<Matrix>;
  95279. /** @hidden */
  95280. _renderId: number;
  95281. /** @hidden */
  95282. _alphaIndex: number;
  95283. /** @hidden */
  95284. _distanceToCamera: number;
  95285. /** @hidden */
  95286. _id: number;
  95287. private _currentMaterial;
  95288. /**
  95289. * Add a new submesh to a mesh
  95290. * @param materialIndex defines the material index to use
  95291. * @param verticesStart defines vertex index start
  95292. * @param verticesCount defines vertices count
  95293. * @param indexStart defines index start
  95294. * @param indexCount defines indices count
  95295. * @param mesh defines the parent mesh
  95296. * @param renderingMesh defines an optional rendering mesh
  95297. * @param createBoundingBox defines if bounding box should be created for this submesh
  95298. * @returns the new submesh
  95299. */
  95300. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  95301. /**
  95302. * Creates a new submesh
  95303. * @param materialIndex defines the material index to use
  95304. * @param verticesStart defines vertex index start
  95305. * @param verticesCount defines vertices count
  95306. * @param indexStart defines index start
  95307. * @param indexCount defines indices count
  95308. * @param mesh defines the parent mesh
  95309. * @param renderingMesh defines an optional rendering mesh
  95310. * @param createBoundingBox defines if bounding box should be created for this submesh
  95311. */
  95312. constructor(
  95313. /** the material index to use */
  95314. materialIndex: number,
  95315. /** vertex index start */
  95316. verticesStart: number,
  95317. /** vertices count */
  95318. verticesCount: number,
  95319. /** index start */
  95320. indexStart: number,
  95321. /** indices count */
  95322. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  95323. /**
  95324. * Returns true if this submesh covers the entire parent mesh
  95325. * @ignorenaming
  95326. */
  95327. get IsGlobal(): boolean;
  95328. /**
  95329. * Returns the submesh BoudingInfo object
  95330. * @returns current bounding info (or mesh's one if the submesh is global)
  95331. */
  95332. getBoundingInfo(): BoundingInfo;
  95333. /**
  95334. * Sets the submesh BoundingInfo
  95335. * @param boundingInfo defines the new bounding info to use
  95336. * @returns the SubMesh
  95337. */
  95338. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  95339. /**
  95340. * Returns the mesh of the current submesh
  95341. * @return the parent mesh
  95342. */
  95343. getMesh(): AbstractMesh;
  95344. /**
  95345. * Returns the rendering mesh of the submesh
  95346. * @returns the rendering mesh (could be different from parent mesh)
  95347. */
  95348. getRenderingMesh(): Mesh;
  95349. /**
  95350. * Returns the submesh material
  95351. * @returns null or the current material
  95352. */
  95353. getMaterial(): Nullable<Material>;
  95354. /**
  95355. * Sets a new updated BoundingInfo object to the submesh
  95356. * @param data defines an optional position array to use to determine the bounding info
  95357. * @returns the SubMesh
  95358. */
  95359. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  95360. /** @hidden */
  95361. _checkCollision(collider: Collider): boolean;
  95362. /**
  95363. * Updates the submesh BoundingInfo
  95364. * @param world defines the world matrix to use to update the bounding info
  95365. * @returns the submesh
  95366. */
  95367. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  95368. /**
  95369. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  95370. * @param frustumPlanes defines the frustum planes
  95371. * @returns true if the submesh is intersecting with the frustum
  95372. */
  95373. isInFrustum(frustumPlanes: Plane[]): boolean;
  95374. /**
  95375. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  95376. * @param frustumPlanes defines the frustum planes
  95377. * @returns true if the submesh is inside the frustum
  95378. */
  95379. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95380. /**
  95381. * Renders the submesh
  95382. * @param enableAlphaMode defines if alpha needs to be used
  95383. * @returns the submesh
  95384. */
  95385. render(enableAlphaMode: boolean): SubMesh;
  95386. /**
  95387. * @hidden
  95388. */
  95389. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  95390. /**
  95391. * Checks if the submesh intersects with a ray
  95392. * @param ray defines the ray to test
  95393. * @returns true is the passed ray intersects the submesh bounding box
  95394. */
  95395. canIntersects(ray: Ray): boolean;
  95396. /**
  95397. * Intersects current submesh with a ray
  95398. * @param ray defines the ray to test
  95399. * @param positions defines mesh's positions array
  95400. * @param indices defines mesh's indices array
  95401. * @param fastCheck defines if only bounding info should be used
  95402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95403. * @returns intersection info or null if no intersection
  95404. */
  95405. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  95406. /** @hidden */
  95407. private _intersectLines;
  95408. /** @hidden */
  95409. private _intersectUnIndexedLines;
  95410. /** @hidden */
  95411. private _intersectTriangles;
  95412. /** @hidden */
  95413. private _intersectUnIndexedTriangles;
  95414. /** @hidden */
  95415. _rebuild(): void;
  95416. /**
  95417. * Creates a new submesh from the passed mesh
  95418. * @param newMesh defines the new hosting mesh
  95419. * @param newRenderingMesh defines an optional rendering mesh
  95420. * @returns the new submesh
  95421. */
  95422. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  95423. /**
  95424. * Release associated resources
  95425. */
  95426. dispose(): void;
  95427. /**
  95428. * Gets the class name
  95429. * @returns the string "SubMesh".
  95430. */
  95431. getClassName(): string;
  95432. /**
  95433. * Creates a new submesh from indices data
  95434. * @param materialIndex the index of the main mesh material
  95435. * @param startIndex the index where to start the copy in the mesh indices array
  95436. * @param indexCount the number of indices to copy then from the startIndex
  95437. * @param mesh the main mesh to create the submesh from
  95438. * @param renderingMesh the optional rendering mesh
  95439. * @returns a new submesh
  95440. */
  95441. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  95442. }
  95443. }
  95444. declare module BABYLON {
  95445. /**
  95446. * Class used to represent data loading progression
  95447. */
  95448. export class SceneLoaderFlags {
  95449. private static _ForceFullSceneLoadingForIncremental;
  95450. private static _ShowLoadingScreen;
  95451. private static _CleanBoneMatrixWeights;
  95452. private static _loggingLevel;
  95453. /**
  95454. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  95455. */
  95456. static get ForceFullSceneLoadingForIncremental(): boolean;
  95457. static set ForceFullSceneLoadingForIncremental(value: boolean);
  95458. /**
  95459. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  95460. */
  95461. static get ShowLoadingScreen(): boolean;
  95462. static set ShowLoadingScreen(value: boolean);
  95463. /**
  95464. * Defines the current logging level (while loading the scene)
  95465. * @ignorenaming
  95466. */
  95467. static get loggingLevel(): number;
  95468. static set loggingLevel(value: number);
  95469. /**
  95470. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  95471. */
  95472. static get CleanBoneMatrixWeights(): boolean;
  95473. static set CleanBoneMatrixWeights(value: boolean);
  95474. }
  95475. }
  95476. declare module BABYLON {
  95477. /**
  95478. * Class used to store geometry data (vertex buffers + index buffer)
  95479. */
  95480. export class Geometry implements IGetSetVerticesData {
  95481. /**
  95482. * Gets or sets the ID of the geometry
  95483. */
  95484. id: string;
  95485. /**
  95486. * Gets or sets the unique ID of the geometry
  95487. */
  95488. uniqueId: number;
  95489. /**
  95490. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95491. */
  95492. delayLoadState: number;
  95493. /**
  95494. * Gets the file containing the data to load when running in delay load state
  95495. */
  95496. delayLoadingFile: Nullable<string>;
  95497. /**
  95498. * Callback called when the geometry is updated
  95499. */
  95500. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95501. private _scene;
  95502. private _engine;
  95503. private _meshes;
  95504. private _totalVertices;
  95505. /** @hidden */
  95506. _indices: IndicesArray;
  95507. /** @hidden */
  95508. _vertexBuffers: {
  95509. [key: string]: VertexBuffer;
  95510. };
  95511. private _isDisposed;
  95512. private _extend;
  95513. private _boundingBias;
  95514. /** @hidden */
  95515. _delayInfo: Array<string>;
  95516. private _indexBuffer;
  95517. private _indexBufferIsUpdatable;
  95518. /** @hidden */
  95519. _boundingInfo: Nullable<BoundingInfo>;
  95520. /** @hidden */
  95521. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95522. /** @hidden */
  95523. _softwareSkinningFrameId: number;
  95524. private _vertexArrayObjects;
  95525. private _updatable;
  95526. /** @hidden */
  95527. _positions: Nullable<Vector3[]>;
  95528. /**
  95529. * 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
  95530. */
  95531. get boundingBias(): Vector2;
  95532. /**
  95533. * 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
  95534. */
  95535. set boundingBias(value: Vector2);
  95536. /**
  95537. * Static function used to attach a new empty geometry to a mesh
  95538. * @param mesh defines the mesh to attach the geometry to
  95539. * @returns the new Geometry
  95540. */
  95541. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95542. /**
  95543. * Creates a new geometry
  95544. * @param id defines the unique ID
  95545. * @param scene defines the hosting scene
  95546. * @param vertexData defines the VertexData used to get geometry data
  95547. * @param updatable defines if geometry must be updatable (false by default)
  95548. * @param mesh defines the mesh that will be associated with the geometry
  95549. */
  95550. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95551. /**
  95552. * Gets the current extend of the geometry
  95553. */
  95554. get extend(): {
  95555. minimum: Vector3;
  95556. maximum: Vector3;
  95557. };
  95558. /**
  95559. * Gets the hosting scene
  95560. * @returns the hosting Scene
  95561. */
  95562. getScene(): Scene;
  95563. /**
  95564. * Gets the hosting engine
  95565. * @returns the hosting Engine
  95566. */
  95567. getEngine(): Engine;
  95568. /**
  95569. * Defines if the geometry is ready to use
  95570. * @returns true if the geometry is ready to be used
  95571. */
  95572. isReady(): boolean;
  95573. /**
  95574. * Gets a value indicating that the geometry should not be serialized
  95575. */
  95576. get doNotSerialize(): boolean;
  95577. /** @hidden */
  95578. _rebuild(): void;
  95579. /**
  95580. * Affects all geometry data in one call
  95581. * @param vertexData defines the geometry data
  95582. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95583. */
  95584. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95585. /**
  95586. * Set specific vertex data
  95587. * @param kind defines the data kind (Position, normal, etc...)
  95588. * @param data defines the vertex data to use
  95589. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95590. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95591. */
  95592. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95593. /**
  95594. * Removes a specific vertex data
  95595. * @param kind defines the data kind (Position, normal, etc...)
  95596. */
  95597. removeVerticesData(kind: string): void;
  95598. /**
  95599. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95600. * @param buffer defines the vertex buffer to use
  95601. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95602. */
  95603. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95604. /**
  95605. * Update a specific vertex buffer
  95606. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95607. * It will do nothing if the buffer is not updatable
  95608. * @param kind defines the data kind (Position, normal, etc...)
  95609. * @param data defines the data to use
  95610. * @param offset defines the offset in the target buffer where to store the data
  95611. * @param useBytes set to true if the offset is in bytes
  95612. */
  95613. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95614. /**
  95615. * Update a specific vertex buffer
  95616. * This function will create a new buffer if the current one is not updatable
  95617. * @param kind defines the data kind (Position, normal, etc...)
  95618. * @param data defines the data to use
  95619. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95620. */
  95621. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95622. private _updateBoundingInfo;
  95623. /** @hidden */
  95624. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95625. /**
  95626. * Gets total number of vertices
  95627. * @returns the total number of vertices
  95628. */
  95629. getTotalVertices(): number;
  95630. /**
  95631. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95632. * @param kind defines the data kind (Position, normal, etc...)
  95633. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95635. * @returns a float array containing vertex data
  95636. */
  95637. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95638. /**
  95639. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95640. * @param kind defines the data kind (Position, normal, etc...)
  95641. * @returns true if the vertex buffer with the specified kind is updatable
  95642. */
  95643. isVertexBufferUpdatable(kind: string): boolean;
  95644. /**
  95645. * Gets a specific vertex buffer
  95646. * @param kind defines the data kind (Position, normal, etc...)
  95647. * @returns a VertexBuffer
  95648. */
  95649. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95650. /**
  95651. * Returns all vertex buffers
  95652. * @return an object holding all vertex buffers indexed by kind
  95653. */
  95654. getVertexBuffers(): Nullable<{
  95655. [key: string]: VertexBuffer;
  95656. }>;
  95657. /**
  95658. * Gets a boolean indicating if specific vertex buffer is present
  95659. * @param kind defines the data kind (Position, normal, etc...)
  95660. * @returns true if data is present
  95661. */
  95662. isVerticesDataPresent(kind: string): boolean;
  95663. /**
  95664. * Gets a list of all attached data kinds (Position, normal, etc...)
  95665. * @returns a list of string containing all kinds
  95666. */
  95667. getVerticesDataKinds(): string[];
  95668. /**
  95669. * Update index buffer
  95670. * @param indices defines the indices to store in the index buffer
  95671. * @param offset defines the offset in the target buffer where to store the data
  95672. * @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)
  95673. */
  95674. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95675. /**
  95676. * Creates a new index buffer
  95677. * @param indices defines the indices to store in the index buffer
  95678. * @param totalVertices defines the total number of vertices (could be null)
  95679. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95680. */
  95681. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95682. /**
  95683. * Return the total number of indices
  95684. * @returns the total number of indices
  95685. */
  95686. getTotalIndices(): number;
  95687. /**
  95688. * Gets the index buffer array
  95689. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95690. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95691. * @returns the index buffer array
  95692. */
  95693. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95694. /**
  95695. * Gets the index buffer
  95696. * @return the index buffer
  95697. */
  95698. getIndexBuffer(): Nullable<DataBuffer>;
  95699. /** @hidden */
  95700. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95701. /**
  95702. * Release the associated resources for a specific mesh
  95703. * @param mesh defines the source mesh
  95704. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95705. */
  95706. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95707. /**
  95708. * Apply current geometry to a given mesh
  95709. * @param mesh defines the mesh to apply geometry to
  95710. */
  95711. applyToMesh(mesh: Mesh): void;
  95712. private _updateExtend;
  95713. private _applyToMesh;
  95714. private notifyUpdate;
  95715. /**
  95716. * Load the geometry if it was flagged as delay loaded
  95717. * @param scene defines the hosting scene
  95718. * @param onLoaded defines a callback called when the geometry is loaded
  95719. */
  95720. load(scene: Scene, onLoaded?: () => void): void;
  95721. private _queueLoad;
  95722. /**
  95723. * Invert the geometry to move from a right handed system to a left handed one.
  95724. */
  95725. toLeftHanded(): void;
  95726. /** @hidden */
  95727. _resetPointsArrayCache(): void;
  95728. /** @hidden */
  95729. _generatePointsArray(): boolean;
  95730. /**
  95731. * Gets a value indicating if the geometry is disposed
  95732. * @returns true if the geometry was disposed
  95733. */
  95734. isDisposed(): boolean;
  95735. private _disposeVertexArrayObjects;
  95736. /**
  95737. * Free all associated resources
  95738. */
  95739. dispose(): void;
  95740. /**
  95741. * Clone the current geometry into a new geometry
  95742. * @param id defines the unique ID of the new geometry
  95743. * @returns a new geometry object
  95744. */
  95745. copy(id: string): Geometry;
  95746. /**
  95747. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95748. * @return a JSON representation of the current geometry data (without the vertices data)
  95749. */
  95750. serialize(): any;
  95751. private toNumberArray;
  95752. /**
  95753. * Serialize all vertices data into a JSON oject
  95754. * @returns a JSON representation of the current geometry data
  95755. */
  95756. serializeVerticeData(): any;
  95757. /**
  95758. * Extracts a clone of a mesh geometry
  95759. * @param mesh defines the source mesh
  95760. * @param id defines the unique ID of the new geometry object
  95761. * @returns the new geometry object
  95762. */
  95763. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95764. /**
  95765. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95766. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95767. * Be aware Math.random() could cause collisions, but:
  95768. * "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"
  95769. * @returns a string containing a new GUID
  95770. */
  95771. static RandomId(): string;
  95772. /** @hidden */
  95773. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95774. private static _CleanMatricesWeights;
  95775. /**
  95776. * Create a new geometry from persisted data (Using .babylon file format)
  95777. * @param parsedVertexData defines the persisted data
  95778. * @param scene defines the hosting scene
  95779. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95780. * @returns the new geometry object
  95781. */
  95782. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95783. }
  95784. }
  95785. declare module BABYLON {
  95786. /**
  95787. * Define an interface for all classes that will get and set the data on vertices
  95788. */
  95789. export interface IGetSetVerticesData {
  95790. /**
  95791. * Gets a boolean indicating if specific vertex data is present
  95792. * @param kind defines the vertex data kind to use
  95793. * @returns true is data kind is present
  95794. */
  95795. isVerticesDataPresent(kind: string): boolean;
  95796. /**
  95797. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95798. * @param kind defines the data kind (Position, normal, etc...)
  95799. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95800. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95801. * @returns a float array containing vertex data
  95802. */
  95803. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95804. /**
  95805. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95806. * @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.
  95807. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95808. * @returns the indices array or an empty array if the mesh has no geometry
  95809. */
  95810. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95811. /**
  95812. * Set specific vertex data
  95813. * @param kind defines the data kind (Position, normal, etc...)
  95814. * @param data defines the vertex data to use
  95815. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95816. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95817. */
  95818. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95819. /**
  95820. * Update a specific associated vertex buffer
  95821. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95822. * - VertexBuffer.PositionKind
  95823. * - VertexBuffer.UVKind
  95824. * - VertexBuffer.UV2Kind
  95825. * - VertexBuffer.UV3Kind
  95826. * - VertexBuffer.UV4Kind
  95827. * - VertexBuffer.UV5Kind
  95828. * - VertexBuffer.UV6Kind
  95829. * - VertexBuffer.ColorKind
  95830. * - VertexBuffer.MatricesIndicesKind
  95831. * - VertexBuffer.MatricesIndicesExtraKind
  95832. * - VertexBuffer.MatricesWeightsKind
  95833. * - VertexBuffer.MatricesWeightsExtraKind
  95834. * @param data defines the data source
  95835. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95836. * @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)
  95837. */
  95838. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95839. /**
  95840. * Creates a new index buffer
  95841. * @param indices defines the indices to store in the index buffer
  95842. * @param totalVertices defines the total number of vertices (could be null)
  95843. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95844. */
  95845. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95846. }
  95847. /**
  95848. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95849. */
  95850. export class VertexData {
  95851. /**
  95852. * Mesh side orientation : usually the external or front surface
  95853. */
  95854. static readonly FRONTSIDE: number;
  95855. /**
  95856. * Mesh side orientation : usually the internal or back surface
  95857. */
  95858. static readonly BACKSIDE: number;
  95859. /**
  95860. * Mesh side orientation : both internal and external or front and back surfaces
  95861. */
  95862. static readonly DOUBLESIDE: number;
  95863. /**
  95864. * Mesh side orientation : by default, `FRONTSIDE`
  95865. */
  95866. static readonly DEFAULTSIDE: number;
  95867. /**
  95868. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95869. */
  95870. positions: Nullable<FloatArray>;
  95871. /**
  95872. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95873. */
  95874. normals: Nullable<FloatArray>;
  95875. /**
  95876. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95877. */
  95878. tangents: Nullable<FloatArray>;
  95879. /**
  95880. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95881. */
  95882. uvs: Nullable<FloatArray>;
  95883. /**
  95884. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95885. */
  95886. uvs2: Nullable<FloatArray>;
  95887. /**
  95888. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95889. */
  95890. uvs3: Nullable<FloatArray>;
  95891. /**
  95892. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95893. */
  95894. uvs4: Nullable<FloatArray>;
  95895. /**
  95896. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95897. */
  95898. uvs5: Nullable<FloatArray>;
  95899. /**
  95900. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95901. */
  95902. uvs6: Nullable<FloatArray>;
  95903. /**
  95904. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95905. */
  95906. colors: Nullable<FloatArray>;
  95907. /**
  95908. * 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).
  95909. */
  95910. matricesIndices: Nullable<FloatArray>;
  95911. /**
  95912. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95913. */
  95914. matricesWeights: Nullable<FloatArray>;
  95915. /**
  95916. * An array extending the number of possible indices
  95917. */
  95918. matricesIndicesExtra: Nullable<FloatArray>;
  95919. /**
  95920. * An array extending the number of possible weights when the number of indices is extended
  95921. */
  95922. matricesWeightsExtra: Nullable<FloatArray>;
  95923. /**
  95924. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95925. */
  95926. indices: Nullable<IndicesArray>;
  95927. /**
  95928. * Uses the passed data array to set the set the values for the specified kind of data
  95929. * @param data a linear array of floating numbers
  95930. * @param kind the type of data that is being set, eg positions, colors etc
  95931. */
  95932. set(data: FloatArray, kind: string): void;
  95933. /**
  95934. * Associates the vertexData to the passed Mesh.
  95935. * Sets it as updatable or not (default `false`)
  95936. * @param mesh the mesh the vertexData is applied to
  95937. * @param updatable when used and having the value true allows new data to update the vertexData
  95938. * @returns the VertexData
  95939. */
  95940. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95941. /**
  95942. * Associates the vertexData to the passed Geometry.
  95943. * Sets it as updatable or not (default `false`)
  95944. * @param geometry the geometry the vertexData is applied to
  95945. * @param updatable when used and having the value true allows new data to update the vertexData
  95946. * @returns VertexData
  95947. */
  95948. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95949. /**
  95950. * Updates the associated mesh
  95951. * @param mesh the mesh to be updated
  95952. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95953. * @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
  95954. * @returns VertexData
  95955. */
  95956. updateMesh(mesh: Mesh): VertexData;
  95957. /**
  95958. * Updates the associated geometry
  95959. * @param geometry the geometry to be updated
  95960. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95961. * @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
  95962. * @returns VertexData.
  95963. */
  95964. updateGeometry(geometry: Geometry): VertexData;
  95965. private _applyTo;
  95966. private _update;
  95967. /**
  95968. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95969. * @param matrix the transforming matrix
  95970. * @returns the VertexData
  95971. */
  95972. transform(matrix: Matrix): VertexData;
  95973. /**
  95974. * Merges the passed VertexData into the current one
  95975. * @param other the VertexData to be merged into the current one
  95976. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95977. * @returns the modified VertexData
  95978. */
  95979. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95980. private _mergeElement;
  95981. private _validate;
  95982. /**
  95983. * Serializes the VertexData
  95984. * @returns a serialized object
  95985. */
  95986. serialize(): any;
  95987. /**
  95988. * Extracts the vertexData from a mesh
  95989. * @param mesh the mesh from which to extract the VertexData
  95990. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95991. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95992. * @returns the object VertexData associated to the passed mesh
  95993. */
  95994. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95995. /**
  95996. * Extracts the vertexData from the geometry
  95997. * @param geometry the geometry from which to extract the VertexData
  95998. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95999. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96000. * @returns the object VertexData associated to the passed mesh
  96001. */
  96002. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96003. private static _ExtractFrom;
  96004. /**
  96005. * Creates the VertexData for a Ribbon
  96006. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  96007. * * pathArray array of paths, each of which an array of successive Vector3
  96008. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  96009. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  96010. * * 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
  96011. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96012. * * 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)
  96013. * * 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)
  96014. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  96015. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  96016. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  96017. * @returns the VertexData of the ribbon
  96018. */
  96019. static CreateRibbon(options: {
  96020. pathArray: Vector3[][];
  96021. closeArray?: boolean;
  96022. closePath?: boolean;
  96023. offset?: number;
  96024. sideOrientation?: number;
  96025. frontUVs?: Vector4;
  96026. backUVs?: Vector4;
  96027. invertUV?: boolean;
  96028. uvs?: Vector2[];
  96029. colors?: Color4[];
  96030. }): VertexData;
  96031. /**
  96032. * Creates the VertexData for a box
  96033. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96034. * * size sets the width, height and depth of the box to the value of size, optional default 1
  96035. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  96036. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  96037. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  96038. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96039. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96041. * * 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)
  96042. * * 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)
  96043. * @returns the VertexData of the box
  96044. */
  96045. static CreateBox(options: {
  96046. size?: number;
  96047. width?: number;
  96048. height?: number;
  96049. depth?: number;
  96050. faceUV?: Vector4[];
  96051. faceColors?: Color4[];
  96052. sideOrientation?: number;
  96053. frontUVs?: Vector4;
  96054. backUVs?: Vector4;
  96055. }): VertexData;
  96056. /**
  96057. * Creates the VertexData for a tiled box
  96058. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96059. * * faceTiles sets the pattern, tile size and number of tiles for a face
  96060. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96061. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96063. * @returns the VertexData of the box
  96064. */
  96065. static CreateTiledBox(options: {
  96066. pattern?: number;
  96067. width?: number;
  96068. height?: number;
  96069. depth?: number;
  96070. tileSize?: number;
  96071. tileWidth?: number;
  96072. tileHeight?: number;
  96073. alignHorizontal?: number;
  96074. alignVertical?: number;
  96075. faceUV?: Vector4[];
  96076. faceColors?: Color4[];
  96077. sideOrientation?: number;
  96078. }): VertexData;
  96079. /**
  96080. * Creates the VertexData for a tiled plane
  96081. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96082. * * pattern a limited pattern arrangement depending on the number
  96083. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  96084. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  96085. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  96086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96087. * * 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)
  96088. * * 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)
  96089. * @returns the VertexData of the tiled plane
  96090. */
  96091. static CreateTiledPlane(options: {
  96092. pattern?: number;
  96093. tileSize?: number;
  96094. tileWidth?: number;
  96095. tileHeight?: number;
  96096. size?: number;
  96097. width?: number;
  96098. height?: number;
  96099. alignHorizontal?: number;
  96100. alignVertical?: number;
  96101. sideOrientation?: number;
  96102. frontUVs?: Vector4;
  96103. backUVs?: Vector4;
  96104. }): VertexData;
  96105. /**
  96106. * Creates the VertexData for an ellipsoid, defaults to a sphere
  96107. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96108. * * segments sets the number of horizontal strips optional, default 32
  96109. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96110. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96111. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96112. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96113. * * 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
  96114. * * 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
  96115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96116. * * 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)
  96117. * * 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)
  96118. * @returns the VertexData of the ellipsoid
  96119. */
  96120. static CreateSphere(options: {
  96121. segments?: number;
  96122. diameter?: number;
  96123. diameterX?: number;
  96124. diameterY?: number;
  96125. diameterZ?: number;
  96126. arc?: number;
  96127. slice?: number;
  96128. sideOrientation?: number;
  96129. frontUVs?: Vector4;
  96130. backUVs?: Vector4;
  96131. }): VertexData;
  96132. /**
  96133. * Creates the VertexData for a cylinder, cone or prism
  96134. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96135. * * height sets the height (y direction) of the cylinder, optional, default 2
  96136. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96137. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96138. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96139. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96140. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96141. * * 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
  96142. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96143. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96144. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96145. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96147. * * 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)
  96148. * * 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)
  96149. * @returns the VertexData of the cylinder, cone or prism
  96150. */
  96151. static CreateCylinder(options: {
  96152. height?: number;
  96153. diameterTop?: number;
  96154. diameterBottom?: number;
  96155. diameter?: number;
  96156. tessellation?: number;
  96157. subdivisions?: number;
  96158. arc?: number;
  96159. faceColors?: Color4[];
  96160. faceUV?: Vector4[];
  96161. hasRings?: boolean;
  96162. enclose?: boolean;
  96163. sideOrientation?: number;
  96164. frontUVs?: Vector4;
  96165. backUVs?: Vector4;
  96166. }): VertexData;
  96167. /**
  96168. * Creates the VertexData for a torus
  96169. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96170. * * diameter the diameter of the torus, optional default 1
  96171. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96172. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96174. * * 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)
  96175. * * 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)
  96176. * @returns the VertexData of the torus
  96177. */
  96178. static CreateTorus(options: {
  96179. diameter?: number;
  96180. thickness?: number;
  96181. tessellation?: number;
  96182. sideOrientation?: number;
  96183. frontUVs?: Vector4;
  96184. backUVs?: Vector4;
  96185. }): VertexData;
  96186. /**
  96187. * Creates the VertexData of the LineSystem
  96188. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96189. * - lines an array of lines, each line being an array of successive Vector3
  96190. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96191. * @returns the VertexData of the LineSystem
  96192. */
  96193. static CreateLineSystem(options: {
  96194. lines: Vector3[][];
  96195. colors?: Nullable<Color4[][]>;
  96196. }): VertexData;
  96197. /**
  96198. * Create the VertexData for a DashedLines
  96199. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96200. * - points an array successive Vector3
  96201. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96202. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96203. * - dashNb the intended total number of dashes, optional, default 200
  96204. * @returns the VertexData for the DashedLines
  96205. */
  96206. static CreateDashedLines(options: {
  96207. points: Vector3[];
  96208. dashSize?: number;
  96209. gapSize?: number;
  96210. dashNb?: number;
  96211. }): VertexData;
  96212. /**
  96213. * Creates the VertexData for a Ground
  96214. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96215. * - width the width (x direction) of the ground, optional, default 1
  96216. * - height the height (z direction) of the ground, optional, default 1
  96217. * - subdivisions the number of subdivisions per side, optional, default 1
  96218. * @returns the VertexData of the Ground
  96219. */
  96220. static CreateGround(options: {
  96221. width?: number;
  96222. height?: number;
  96223. subdivisions?: number;
  96224. subdivisionsX?: number;
  96225. subdivisionsY?: number;
  96226. }): VertexData;
  96227. /**
  96228. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96229. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96230. * * xmin the ground minimum X coordinate, optional, default -1
  96231. * * zmin the ground minimum Z coordinate, optional, default -1
  96232. * * xmax the ground maximum X coordinate, optional, default 1
  96233. * * zmax the ground maximum Z coordinate, optional, default 1
  96234. * * 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}
  96235. * * 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}
  96236. * @returns the VertexData of the TiledGround
  96237. */
  96238. static CreateTiledGround(options: {
  96239. xmin: number;
  96240. zmin: number;
  96241. xmax: number;
  96242. zmax: number;
  96243. subdivisions?: {
  96244. w: number;
  96245. h: number;
  96246. };
  96247. precision?: {
  96248. w: number;
  96249. h: number;
  96250. };
  96251. }): VertexData;
  96252. /**
  96253. * Creates the VertexData of the Ground designed from a heightmap
  96254. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96255. * * width the width (x direction) of the ground
  96256. * * height the height (z direction) of the ground
  96257. * * subdivisions the number of subdivisions per side
  96258. * * minHeight the minimum altitude on the ground, optional, default 0
  96259. * * maxHeight the maximum altitude on the ground, optional default 1
  96260. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96261. * * buffer the array holding the image color data
  96262. * * bufferWidth the width of image
  96263. * * bufferHeight the height of image
  96264. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96265. * @returns the VertexData of the Ground designed from a heightmap
  96266. */
  96267. static CreateGroundFromHeightMap(options: {
  96268. width: number;
  96269. height: number;
  96270. subdivisions: number;
  96271. minHeight: number;
  96272. maxHeight: number;
  96273. colorFilter: Color3;
  96274. buffer: Uint8Array;
  96275. bufferWidth: number;
  96276. bufferHeight: number;
  96277. alphaFilter: number;
  96278. }): VertexData;
  96279. /**
  96280. * Creates the VertexData for a Plane
  96281. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  96282. * * size sets the width and height of the plane to the value of size, optional default 1
  96283. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  96284. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  96285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96286. * * 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)
  96287. * * 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)
  96288. * @returns the VertexData of the box
  96289. */
  96290. static CreatePlane(options: {
  96291. size?: number;
  96292. width?: number;
  96293. height?: number;
  96294. sideOrientation?: number;
  96295. frontUVs?: Vector4;
  96296. backUVs?: Vector4;
  96297. }): VertexData;
  96298. /**
  96299. * Creates the VertexData of the Disc or regular Polygon
  96300. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  96301. * * radius the radius of the disc, optional default 0.5
  96302. * * tessellation the number of polygon sides, optional, default 64
  96303. * * 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
  96304. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96305. * * 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)
  96306. * * 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)
  96307. * @returns the VertexData of the box
  96308. */
  96309. static CreateDisc(options: {
  96310. radius?: number;
  96311. tessellation?: number;
  96312. arc?: number;
  96313. sideOrientation?: number;
  96314. frontUVs?: Vector4;
  96315. backUVs?: Vector4;
  96316. }): VertexData;
  96317. /**
  96318. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  96319. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  96320. * @param polygon a mesh built from polygonTriangulation.build()
  96321. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96322. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96323. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96324. * @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)
  96325. * @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)
  96326. * @returns the VertexData of the Polygon
  96327. */
  96328. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  96329. /**
  96330. * Creates the VertexData of the IcoSphere
  96331. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  96332. * * radius the radius of the IcoSphere, optional default 1
  96333. * * radiusX allows stretching in the x direction, optional, default radius
  96334. * * radiusY allows stretching in the y direction, optional, default radius
  96335. * * radiusZ allows stretching in the z direction, optional, default radius
  96336. * * flat when true creates a flat shaded mesh, optional, default true
  96337. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96339. * * 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)
  96340. * * 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)
  96341. * @returns the VertexData of the IcoSphere
  96342. */
  96343. static CreateIcoSphere(options: {
  96344. radius?: number;
  96345. radiusX?: number;
  96346. radiusY?: number;
  96347. radiusZ?: number;
  96348. flat?: boolean;
  96349. subdivisions?: number;
  96350. sideOrientation?: number;
  96351. frontUVs?: Vector4;
  96352. backUVs?: Vector4;
  96353. }): VertexData;
  96354. /**
  96355. * Creates the VertexData for a Polyhedron
  96356. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  96357. * * type provided types are:
  96358. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  96359. * * 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)
  96360. * * size the size of the IcoSphere, optional default 1
  96361. * * sizeX allows stretching in the x direction, optional, default size
  96362. * * sizeY allows stretching in the y direction, optional, default size
  96363. * * sizeZ allows stretching in the z direction, optional, default size
  96364. * * 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
  96365. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96366. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96367. * * flat when true creates a flat shaded mesh, optional, default true
  96368. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96370. * * 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)
  96371. * * 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)
  96372. * @returns the VertexData of the Polyhedron
  96373. */
  96374. static CreatePolyhedron(options: {
  96375. type?: number;
  96376. size?: number;
  96377. sizeX?: number;
  96378. sizeY?: number;
  96379. sizeZ?: number;
  96380. custom?: any;
  96381. faceUV?: Vector4[];
  96382. faceColors?: Color4[];
  96383. flat?: boolean;
  96384. sideOrientation?: number;
  96385. frontUVs?: Vector4;
  96386. backUVs?: Vector4;
  96387. }): VertexData;
  96388. /**
  96389. * Creates the VertexData for a TorusKnot
  96390. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  96391. * * radius the radius of the torus knot, optional, default 2
  96392. * * tube the thickness of the tube, optional, default 0.5
  96393. * * radialSegments the number of sides on each tube segments, optional, default 32
  96394. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  96395. * * p the number of windings around the z axis, optional, default 2
  96396. * * q the number of windings around the x axis, optional, default 3
  96397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96398. * * 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)
  96399. * * 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)
  96400. * @returns the VertexData of the Torus Knot
  96401. */
  96402. static CreateTorusKnot(options: {
  96403. radius?: number;
  96404. tube?: number;
  96405. radialSegments?: number;
  96406. tubularSegments?: number;
  96407. p?: number;
  96408. q?: number;
  96409. sideOrientation?: number;
  96410. frontUVs?: Vector4;
  96411. backUVs?: Vector4;
  96412. }): VertexData;
  96413. /**
  96414. * Compute normals for given positions and indices
  96415. * @param positions an array of vertex positions, [...., x, y, z, ......]
  96416. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  96417. * @param normals an array of vertex normals, [...., x, y, z, ......]
  96418. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  96419. * * facetNormals : optional array of facet normals (vector3)
  96420. * * facetPositions : optional array of facet positions (vector3)
  96421. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  96422. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  96423. * * bInfo : optional bounding info, required for facetPartitioning computation
  96424. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  96425. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  96426. * * useRightHandedSystem: optional boolean to for right handed system computation
  96427. * * depthSort : optional boolean to enable the facet depth sort computation
  96428. * * distanceTo : optional Vector3 to compute the facet depth from this location
  96429. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  96430. */
  96431. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  96432. facetNormals?: any;
  96433. facetPositions?: any;
  96434. facetPartitioning?: any;
  96435. ratio?: number;
  96436. bInfo?: any;
  96437. bbSize?: Vector3;
  96438. subDiv?: any;
  96439. useRightHandedSystem?: boolean;
  96440. depthSort?: boolean;
  96441. distanceTo?: Vector3;
  96442. depthSortedFacets?: any;
  96443. }): void;
  96444. /** @hidden */
  96445. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  96446. /**
  96447. * Applies VertexData created from the imported parameters to the geometry
  96448. * @param parsedVertexData the parsed data from an imported file
  96449. * @param geometry the geometry to apply the VertexData to
  96450. */
  96451. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  96452. }
  96453. }
  96454. declare module BABYLON {
  96455. /**
  96456. * Defines a target to use with MorphTargetManager
  96457. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96458. */
  96459. export class MorphTarget implements IAnimatable {
  96460. /** defines the name of the target */
  96461. name: string;
  96462. /**
  96463. * Gets or sets the list of animations
  96464. */
  96465. animations: Animation[];
  96466. private _scene;
  96467. private _positions;
  96468. private _normals;
  96469. private _tangents;
  96470. private _uvs;
  96471. private _influence;
  96472. private _uniqueId;
  96473. /**
  96474. * Observable raised when the influence changes
  96475. */
  96476. onInfluenceChanged: Observable<boolean>;
  96477. /** @hidden */
  96478. _onDataLayoutChanged: Observable<void>;
  96479. /**
  96480. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96481. */
  96482. get influence(): number;
  96483. set influence(influence: number);
  96484. /**
  96485. * Gets or sets the id of the morph Target
  96486. */
  96487. id: string;
  96488. private _animationPropertiesOverride;
  96489. /**
  96490. * Gets or sets the animation properties override
  96491. */
  96492. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96493. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96494. /**
  96495. * Creates a new MorphTarget
  96496. * @param name defines the name of the target
  96497. * @param influence defines the influence to use
  96498. * @param scene defines the scene the morphtarget belongs to
  96499. */
  96500. constructor(
  96501. /** defines the name of the target */
  96502. name: string, influence?: number, scene?: Nullable<Scene>);
  96503. /**
  96504. * Gets the unique ID of this manager
  96505. */
  96506. get uniqueId(): number;
  96507. /**
  96508. * Gets a boolean defining if the target contains position data
  96509. */
  96510. get hasPositions(): boolean;
  96511. /**
  96512. * Gets a boolean defining if the target contains normal data
  96513. */
  96514. get hasNormals(): boolean;
  96515. /**
  96516. * Gets a boolean defining if the target contains tangent data
  96517. */
  96518. get hasTangents(): boolean;
  96519. /**
  96520. * Gets a boolean defining if the target contains texture coordinates data
  96521. */
  96522. get hasUVs(): boolean;
  96523. /**
  96524. * Affects position data to this target
  96525. * @param data defines the position data to use
  96526. */
  96527. setPositions(data: Nullable<FloatArray>): void;
  96528. /**
  96529. * Gets the position data stored in this target
  96530. * @returns a FloatArray containing the position data (or null if not present)
  96531. */
  96532. getPositions(): Nullable<FloatArray>;
  96533. /**
  96534. * Affects normal data to this target
  96535. * @param data defines the normal data to use
  96536. */
  96537. setNormals(data: Nullable<FloatArray>): void;
  96538. /**
  96539. * Gets the normal data stored in this target
  96540. * @returns a FloatArray containing the normal data (or null if not present)
  96541. */
  96542. getNormals(): Nullable<FloatArray>;
  96543. /**
  96544. * Affects tangent data to this target
  96545. * @param data defines the tangent data to use
  96546. */
  96547. setTangents(data: Nullable<FloatArray>): void;
  96548. /**
  96549. * Gets the tangent data stored in this target
  96550. * @returns a FloatArray containing the tangent data (or null if not present)
  96551. */
  96552. getTangents(): Nullable<FloatArray>;
  96553. /**
  96554. * Affects texture coordinates data to this target
  96555. * @param data defines the texture coordinates data to use
  96556. */
  96557. setUVs(data: Nullable<FloatArray>): void;
  96558. /**
  96559. * Gets the texture coordinates data stored in this target
  96560. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96561. */
  96562. getUVs(): Nullable<FloatArray>;
  96563. /**
  96564. * Clone the current target
  96565. * @returns a new MorphTarget
  96566. */
  96567. clone(): MorphTarget;
  96568. /**
  96569. * Serializes the current target into a Serialization object
  96570. * @returns the serialized object
  96571. */
  96572. serialize(): any;
  96573. /**
  96574. * Returns the string "MorphTarget"
  96575. * @returns "MorphTarget"
  96576. */
  96577. getClassName(): string;
  96578. /**
  96579. * Creates a new target from serialized data
  96580. * @param serializationObject defines the serialized data to use
  96581. * @returns a new MorphTarget
  96582. */
  96583. static Parse(serializationObject: any): MorphTarget;
  96584. /**
  96585. * Creates a MorphTarget from mesh data
  96586. * @param mesh defines the source mesh
  96587. * @param name defines the name to use for the new target
  96588. * @param influence defines the influence to attach to the target
  96589. * @returns a new MorphTarget
  96590. */
  96591. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96592. }
  96593. }
  96594. declare module BABYLON {
  96595. /**
  96596. * This class is used to deform meshes using morphing between different targets
  96597. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96598. */
  96599. export class MorphTargetManager {
  96600. private _targets;
  96601. private _targetInfluenceChangedObservers;
  96602. private _targetDataLayoutChangedObservers;
  96603. private _activeTargets;
  96604. private _scene;
  96605. private _influences;
  96606. private _supportsNormals;
  96607. private _supportsTangents;
  96608. private _supportsUVs;
  96609. private _vertexCount;
  96610. private _uniqueId;
  96611. private _tempInfluences;
  96612. /**
  96613. * Gets or sets a boolean indicating if normals must be morphed
  96614. */
  96615. enableNormalMorphing: boolean;
  96616. /**
  96617. * Gets or sets a boolean indicating if tangents must be morphed
  96618. */
  96619. enableTangentMorphing: boolean;
  96620. /**
  96621. * Gets or sets a boolean indicating if UV must be morphed
  96622. */
  96623. enableUVMorphing: boolean;
  96624. /**
  96625. * Creates a new MorphTargetManager
  96626. * @param scene defines the current scene
  96627. */
  96628. constructor(scene?: Nullable<Scene>);
  96629. /**
  96630. * Gets the unique ID of this manager
  96631. */
  96632. get uniqueId(): number;
  96633. /**
  96634. * Gets the number of vertices handled by this manager
  96635. */
  96636. get vertexCount(): number;
  96637. /**
  96638. * Gets a boolean indicating if this manager supports morphing of normals
  96639. */
  96640. get supportsNormals(): boolean;
  96641. /**
  96642. * Gets a boolean indicating if this manager supports morphing of tangents
  96643. */
  96644. get supportsTangents(): boolean;
  96645. /**
  96646. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96647. */
  96648. get supportsUVs(): boolean;
  96649. /**
  96650. * Gets the number of targets stored in this manager
  96651. */
  96652. get numTargets(): number;
  96653. /**
  96654. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96655. */
  96656. get numInfluencers(): number;
  96657. /**
  96658. * Gets the list of influences (one per target)
  96659. */
  96660. get influences(): Float32Array;
  96661. /**
  96662. * Gets the active target at specified index. An active target is a target with an influence > 0
  96663. * @param index defines the index to check
  96664. * @returns the requested target
  96665. */
  96666. getActiveTarget(index: number): MorphTarget;
  96667. /**
  96668. * Gets the target at specified index
  96669. * @param index defines the index to check
  96670. * @returns the requested target
  96671. */
  96672. getTarget(index: number): MorphTarget;
  96673. /**
  96674. * Add a new target to this manager
  96675. * @param target defines the target to add
  96676. */
  96677. addTarget(target: MorphTarget): void;
  96678. /**
  96679. * Removes a target from the manager
  96680. * @param target defines the target to remove
  96681. */
  96682. removeTarget(target: MorphTarget): void;
  96683. /**
  96684. * Clone the current manager
  96685. * @returns a new MorphTargetManager
  96686. */
  96687. clone(): MorphTargetManager;
  96688. /**
  96689. * Serializes the current manager into a Serialization object
  96690. * @returns the serialized object
  96691. */
  96692. serialize(): any;
  96693. private _syncActiveTargets;
  96694. /**
  96695. * Syncrhonize the targets with all the meshes using this morph target manager
  96696. */
  96697. synchronize(): void;
  96698. /**
  96699. * Creates a new MorphTargetManager from serialized data
  96700. * @param serializationObject defines the serialized data
  96701. * @param scene defines the hosting scene
  96702. * @returns the new MorphTargetManager
  96703. */
  96704. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96705. }
  96706. }
  96707. declare module BABYLON {
  96708. /**
  96709. * Class used to represent a specific level of detail of a mesh
  96710. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96711. */
  96712. export class MeshLODLevel {
  96713. /** Defines the distance where this level should start being displayed */
  96714. distance: number;
  96715. /** Defines the mesh to use to render this level */
  96716. mesh: Nullable<Mesh>;
  96717. /**
  96718. * Creates a new LOD level
  96719. * @param distance defines the distance where this level should star being displayed
  96720. * @param mesh defines the mesh to use to render this level
  96721. */
  96722. constructor(
  96723. /** Defines the distance where this level should start being displayed */
  96724. distance: number,
  96725. /** Defines the mesh to use to render this level */
  96726. mesh: Nullable<Mesh>);
  96727. }
  96728. }
  96729. declare module BABYLON {
  96730. /**
  96731. * Mesh representing the gorund
  96732. */
  96733. export class GroundMesh extends Mesh {
  96734. /** If octree should be generated */
  96735. generateOctree: boolean;
  96736. private _heightQuads;
  96737. /** @hidden */
  96738. _subdivisionsX: number;
  96739. /** @hidden */
  96740. _subdivisionsY: number;
  96741. /** @hidden */
  96742. _width: number;
  96743. /** @hidden */
  96744. _height: number;
  96745. /** @hidden */
  96746. _minX: number;
  96747. /** @hidden */
  96748. _maxX: number;
  96749. /** @hidden */
  96750. _minZ: number;
  96751. /** @hidden */
  96752. _maxZ: number;
  96753. constructor(name: string, scene: Scene);
  96754. /**
  96755. * "GroundMesh"
  96756. * @returns "GroundMesh"
  96757. */
  96758. getClassName(): string;
  96759. /**
  96760. * The minimum of x and y subdivisions
  96761. */
  96762. get subdivisions(): number;
  96763. /**
  96764. * X subdivisions
  96765. */
  96766. get subdivisionsX(): number;
  96767. /**
  96768. * Y subdivisions
  96769. */
  96770. get subdivisionsY(): number;
  96771. /**
  96772. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96773. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96774. * @param chunksCount the number of subdivisions for x and y
  96775. * @param octreeBlocksSize (Default: 32)
  96776. */
  96777. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96778. /**
  96779. * Returns a height (y) value in the Worl system :
  96780. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96781. * @param x x coordinate
  96782. * @param z z coordinate
  96783. * @returns the ground y position if (x, z) are outside the ground surface.
  96784. */
  96785. getHeightAtCoordinates(x: number, z: number): number;
  96786. /**
  96787. * Returns a normalized vector (Vector3) orthogonal to the ground
  96788. * at the ground coordinates (x, z) expressed in the World system.
  96789. * @param x x coordinate
  96790. * @param z z coordinate
  96791. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96792. */
  96793. getNormalAtCoordinates(x: number, z: number): Vector3;
  96794. /**
  96795. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96796. * at the ground coordinates (x, z) expressed in the World system.
  96797. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96798. * @param x x coordinate
  96799. * @param z z coordinate
  96800. * @param ref vector to store the result
  96801. * @returns the GroundMesh.
  96802. */
  96803. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96804. /**
  96805. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96806. * if the ground has been updated.
  96807. * This can be used in the render loop.
  96808. * @returns the GroundMesh.
  96809. */
  96810. updateCoordinateHeights(): GroundMesh;
  96811. private _getFacetAt;
  96812. private _initHeightQuads;
  96813. private _computeHeightQuads;
  96814. /**
  96815. * Serializes this ground mesh
  96816. * @param serializationObject object to write serialization to
  96817. */
  96818. serialize(serializationObject: any): void;
  96819. /**
  96820. * Parses a serialized ground mesh
  96821. * @param parsedMesh the serialized mesh
  96822. * @param scene the scene to create the ground mesh in
  96823. * @returns the created ground mesh
  96824. */
  96825. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96826. }
  96827. }
  96828. declare module BABYLON {
  96829. /**
  96830. * Interface for Physics-Joint data
  96831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96832. */
  96833. export interface PhysicsJointData {
  96834. /**
  96835. * The main pivot of the joint
  96836. */
  96837. mainPivot?: Vector3;
  96838. /**
  96839. * The connected pivot of the joint
  96840. */
  96841. connectedPivot?: Vector3;
  96842. /**
  96843. * The main axis of the joint
  96844. */
  96845. mainAxis?: Vector3;
  96846. /**
  96847. * The connected axis of the joint
  96848. */
  96849. connectedAxis?: Vector3;
  96850. /**
  96851. * The collision of the joint
  96852. */
  96853. collision?: boolean;
  96854. /**
  96855. * Native Oimo/Cannon/Energy data
  96856. */
  96857. nativeParams?: any;
  96858. }
  96859. /**
  96860. * This is a holder class for the physics joint created by the physics plugin
  96861. * It holds a set of functions to control the underlying joint
  96862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96863. */
  96864. export class PhysicsJoint {
  96865. /**
  96866. * The type of the physics joint
  96867. */
  96868. type: number;
  96869. /**
  96870. * The data for the physics joint
  96871. */
  96872. jointData: PhysicsJointData;
  96873. private _physicsJoint;
  96874. protected _physicsPlugin: IPhysicsEnginePlugin;
  96875. /**
  96876. * Initializes the physics joint
  96877. * @param type The type of the physics joint
  96878. * @param jointData The data for the physics joint
  96879. */
  96880. constructor(
  96881. /**
  96882. * The type of the physics joint
  96883. */
  96884. type: number,
  96885. /**
  96886. * The data for the physics joint
  96887. */
  96888. jointData: PhysicsJointData);
  96889. /**
  96890. * Gets the physics joint
  96891. */
  96892. get physicsJoint(): any;
  96893. /**
  96894. * Sets the physics joint
  96895. */
  96896. set physicsJoint(newJoint: any);
  96897. /**
  96898. * Sets the physics plugin
  96899. */
  96900. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96901. /**
  96902. * Execute a function that is physics-plugin specific.
  96903. * @param {Function} func the function that will be executed.
  96904. * It accepts two parameters: the physics world and the physics joint
  96905. */
  96906. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96907. /**
  96908. * Distance-Joint type
  96909. */
  96910. static DistanceJoint: number;
  96911. /**
  96912. * Hinge-Joint type
  96913. */
  96914. static HingeJoint: number;
  96915. /**
  96916. * Ball-and-Socket joint type
  96917. */
  96918. static BallAndSocketJoint: number;
  96919. /**
  96920. * Wheel-Joint type
  96921. */
  96922. static WheelJoint: number;
  96923. /**
  96924. * Slider-Joint type
  96925. */
  96926. static SliderJoint: number;
  96927. /**
  96928. * Prismatic-Joint type
  96929. */
  96930. static PrismaticJoint: number;
  96931. /**
  96932. * Universal-Joint type
  96933. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96934. */
  96935. static UniversalJoint: number;
  96936. /**
  96937. * Hinge-Joint 2 type
  96938. */
  96939. static Hinge2Joint: number;
  96940. /**
  96941. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96942. */
  96943. static PointToPointJoint: number;
  96944. /**
  96945. * Spring-Joint type
  96946. */
  96947. static SpringJoint: number;
  96948. /**
  96949. * Lock-Joint type
  96950. */
  96951. static LockJoint: number;
  96952. }
  96953. /**
  96954. * A class representing a physics distance joint
  96955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96956. */
  96957. export class DistanceJoint extends PhysicsJoint {
  96958. /**
  96959. *
  96960. * @param jointData The data for the Distance-Joint
  96961. */
  96962. constructor(jointData: DistanceJointData);
  96963. /**
  96964. * Update the predefined distance.
  96965. * @param maxDistance The maximum preferred distance
  96966. * @param minDistance The minimum preferred distance
  96967. */
  96968. updateDistance(maxDistance: number, minDistance?: number): void;
  96969. }
  96970. /**
  96971. * Represents a Motor-Enabled Joint
  96972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96973. */
  96974. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96975. /**
  96976. * Initializes the Motor-Enabled Joint
  96977. * @param type The type of the joint
  96978. * @param jointData The physica joint data for the joint
  96979. */
  96980. constructor(type: number, jointData: PhysicsJointData);
  96981. /**
  96982. * Set the motor values.
  96983. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96984. * @param force the force to apply
  96985. * @param maxForce max force for this motor.
  96986. */
  96987. setMotor(force?: number, maxForce?: number): void;
  96988. /**
  96989. * Set the motor's limits.
  96990. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96991. * @param upperLimit The upper limit of the motor
  96992. * @param lowerLimit The lower limit of the motor
  96993. */
  96994. setLimit(upperLimit: number, lowerLimit?: number): void;
  96995. }
  96996. /**
  96997. * This class represents a single physics Hinge-Joint
  96998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96999. */
  97000. export class HingeJoint extends MotorEnabledJoint {
  97001. /**
  97002. * Initializes the Hinge-Joint
  97003. * @param jointData The joint data for the Hinge-Joint
  97004. */
  97005. constructor(jointData: PhysicsJointData);
  97006. /**
  97007. * Set the motor values.
  97008. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97009. * @param {number} force the force to apply
  97010. * @param {number} maxForce max force for this motor.
  97011. */
  97012. setMotor(force?: number, maxForce?: number): void;
  97013. /**
  97014. * Set the motor's limits.
  97015. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97016. * @param upperLimit The upper limit of the motor
  97017. * @param lowerLimit The lower limit of the motor
  97018. */
  97019. setLimit(upperLimit: number, lowerLimit?: number): void;
  97020. }
  97021. /**
  97022. * This class represents a dual hinge physics joint (same as wheel joint)
  97023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97024. */
  97025. export class Hinge2Joint extends MotorEnabledJoint {
  97026. /**
  97027. * Initializes the Hinge2-Joint
  97028. * @param jointData The joint data for the Hinge2-Joint
  97029. */
  97030. constructor(jointData: PhysicsJointData);
  97031. /**
  97032. * Set the motor values.
  97033. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97034. * @param {number} targetSpeed the speed the motor is to reach
  97035. * @param {number} maxForce max force for this motor.
  97036. * @param {motorIndex} the motor's index, 0 or 1.
  97037. */
  97038. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  97039. /**
  97040. * Set the motor limits.
  97041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97042. * @param {number} upperLimit the upper limit
  97043. * @param {number} lowerLimit lower limit
  97044. * @param {motorIndex} the motor's index, 0 or 1.
  97045. */
  97046. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97047. }
  97048. /**
  97049. * Interface for a motor enabled joint
  97050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97051. */
  97052. export interface IMotorEnabledJoint {
  97053. /**
  97054. * Physics joint
  97055. */
  97056. physicsJoint: any;
  97057. /**
  97058. * Sets the motor of the motor-enabled joint
  97059. * @param force The force of the motor
  97060. * @param maxForce The maximum force of the motor
  97061. * @param motorIndex The index of the motor
  97062. */
  97063. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  97064. /**
  97065. * Sets the limit of the motor
  97066. * @param upperLimit The upper limit of the motor
  97067. * @param lowerLimit The lower limit of the motor
  97068. * @param motorIndex The index of the motor
  97069. */
  97070. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97071. }
  97072. /**
  97073. * Joint data for a Distance-Joint
  97074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97075. */
  97076. export interface DistanceJointData extends PhysicsJointData {
  97077. /**
  97078. * Max distance the 2 joint objects can be apart
  97079. */
  97080. maxDistance: number;
  97081. }
  97082. /**
  97083. * Joint data from a spring joint
  97084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97085. */
  97086. export interface SpringJointData extends PhysicsJointData {
  97087. /**
  97088. * Length of the spring
  97089. */
  97090. length: number;
  97091. /**
  97092. * Stiffness of the spring
  97093. */
  97094. stiffness: number;
  97095. /**
  97096. * Damping of the spring
  97097. */
  97098. damping: number;
  97099. /** this callback will be called when applying the force to the impostors. */
  97100. forceApplicationCallback: () => void;
  97101. }
  97102. }
  97103. declare module BABYLON {
  97104. /**
  97105. * Holds the data for the raycast result
  97106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97107. */
  97108. export class PhysicsRaycastResult {
  97109. private _hasHit;
  97110. private _hitDistance;
  97111. private _hitNormalWorld;
  97112. private _hitPointWorld;
  97113. private _rayFromWorld;
  97114. private _rayToWorld;
  97115. /**
  97116. * Gets if there was a hit
  97117. */
  97118. get hasHit(): boolean;
  97119. /**
  97120. * Gets the distance from the hit
  97121. */
  97122. get hitDistance(): number;
  97123. /**
  97124. * Gets the hit normal/direction in the world
  97125. */
  97126. get hitNormalWorld(): Vector3;
  97127. /**
  97128. * Gets the hit point in the world
  97129. */
  97130. get hitPointWorld(): Vector3;
  97131. /**
  97132. * Gets the ray "start point" of the ray in the world
  97133. */
  97134. get rayFromWorld(): Vector3;
  97135. /**
  97136. * Gets the ray "end point" of the ray in the world
  97137. */
  97138. get rayToWorld(): Vector3;
  97139. /**
  97140. * Sets the hit data (normal & point in world space)
  97141. * @param hitNormalWorld defines the normal in world space
  97142. * @param hitPointWorld defines the point in world space
  97143. */
  97144. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97145. /**
  97146. * Sets the distance from the start point to the hit point
  97147. * @param distance
  97148. */
  97149. setHitDistance(distance: number): void;
  97150. /**
  97151. * Calculates the distance manually
  97152. */
  97153. calculateHitDistance(): void;
  97154. /**
  97155. * Resets all the values to default
  97156. * @param from The from point on world space
  97157. * @param to The to point on world space
  97158. */
  97159. reset(from?: Vector3, to?: Vector3): void;
  97160. }
  97161. /**
  97162. * Interface for the size containing width and height
  97163. */
  97164. interface IXYZ {
  97165. /**
  97166. * X
  97167. */
  97168. x: number;
  97169. /**
  97170. * Y
  97171. */
  97172. y: number;
  97173. /**
  97174. * Z
  97175. */
  97176. z: number;
  97177. }
  97178. }
  97179. declare module BABYLON {
  97180. /**
  97181. * Interface used to describe a physics joint
  97182. */
  97183. export interface PhysicsImpostorJoint {
  97184. /** Defines the main impostor to which the joint is linked */
  97185. mainImpostor: PhysicsImpostor;
  97186. /** Defines the impostor that is connected to the main impostor using this joint */
  97187. connectedImpostor: PhysicsImpostor;
  97188. /** Defines the joint itself */
  97189. joint: PhysicsJoint;
  97190. }
  97191. /** @hidden */
  97192. export interface IPhysicsEnginePlugin {
  97193. world: any;
  97194. name: string;
  97195. setGravity(gravity: Vector3): void;
  97196. setTimeStep(timeStep: number): void;
  97197. getTimeStep(): number;
  97198. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97199. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97200. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97201. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97202. removePhysicsBody(impostor: PhysicsImpostor): void;
  97203. generateJoint(joint: PhysicsImpostorJoint): void;
  97204. removeJoint(joint: PhysicsImpostorJoint): void;
  97205. isSupported(): boolean;
  97206. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97207. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97208. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97209. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97210. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97211. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97212. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97213. getBodyMass(impostor: PhysicsImpostor): number;
  97214. getBodyFriction(impostor: PhysicsImpostor): number;
  97215. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97216. getBodyRestitution(impostor: PhysicsImpostor): number;
  97217. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97218. getBodyPressure?(impostor: PhysicsImpostor): number;
  97219. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97220. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97221. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97222. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97223. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97224. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97225. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97226. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97227. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97228. sleepBody(impostor: PhysicsImpostor): void;
  97229. wakeUpBody(impostor: PhysicsImpostor): void;
  97230. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97231. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97232. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97233. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97234. getRadius(impostor: PhysicsImpostor): number;
  97235. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97236. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97237. dispose(): void;
  97238. }
  97239. /**
  97240. * Interface used to define a physics engine
  97241. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97242. */
  97243. export interface IPhysicsEngine {
  97244. /**
  97245. * Gets the gravity vector used by the simulation
  97246. */
  97247. gravity: Vector3;
  97248. /**
  97249. * Sets the gravity vector used by the simulation
  97250. * @param gravity defines the gravity vector to use
  97251. */
  97252. setGravity(gravity: Vector3): void;
  97253. /**
  97254. * Set the time step of the physics engine.
  97255. * Default is 1/60.
  97256. * To slow it down, enter 1/600 for example.
  97257. * To speed it up, 1/30
  97258. * @param newTimeStep the new timestep to apply to this world.
  97259. */
  97260. setTimeStep(newTimeStep: number): void;
  97261. /**
  97262. * Get the time step of the physics engine.
  97263. * @returns the current time step
  97264. */
  97265. getTimeStep(): number;
  97266. /**
  97267. * Set the sub time step of the physics engine.
  97268. * Default is 0 meaning there is no sub steps
  97269. * To increase physics resolution precision, set a small value (like 1 ms)
  97270. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97271. */
  97272. setSubTimeStep(subTimeStep: number): void;
  97273. /**
  97274. * Get the sub time step of the physics engine.
  97275. * @returns the current sub time step
  97276. */
  97277. getSubTimeStep(): number;
  97278. /**
  97279. * Release all resources
  97280. */
  97281. dispose(): void;
  97282. /**
  97283. * Gets the name of the current physics plugin
  97284. * @returns the name of the plugin
  97285. */
  97286. getPhysicsPluginName(): string;
  97287. /**
  97288. * Adding a new impostor for the impostor tracking.
  97289. * This will be done by the impostor itself.
  97290. * @param impostor the impostor to add
  97291. */
  97292. addImpostor(impostor: PhysicsImpostor): void;
  97293. /**
  97294. * Remove an impostor from the engine.
  97295. * This impostor and its mesh will not longer be updated by the physics engine.
  97296. * @param impostor the impostor to remove
  97297. */
  97298. removeImpostor(impostor: PhysicsImpostor): void;
  97299. /**
  97300. * Add a joint to the physics engine
  97301. * @param mainImpostor defines the main impostor to which the joint is added.
  97302. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  97303. * @param joint defines the joint that will connect both impostors.
  97304. */
  97305. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97306. /**
  97307. * Removes a joint from the simulation
  97308. * @param mainImpostor defines the impostor used with the joint
  97309. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  97310. * @param joint defines the joint to remove
  97311. */
  97312. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97313. /**
  97314. * Gets the current plugin used to run the simulation
  97315. * @returns current plugin
  97316. */
  97317. getPhysicsPlugin(): IPhysicsEnginePlugin;
  97318. /**
  97319. * Gets the list of physic impostors
  97320. * @returns an array of PhysicsImpostor
  97321. */
  97322. getImpostors(): Array<PhysicsImpostor>;
  97323. /**
  97324. * Gets the impostor for a physics enabled object
  97325. * @param object defines the object impersonated by the impostor
  97326. * @returns the PhysicsImpostor or null if not found
  97327. */
  97328. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97329. /**
  97330. * Gets the impostor for a physics body object
  97331. * @param body defines physics body used by the impostor
  97332. * @returns the PhysicsImpostor or null if not found
  97333. */
  97334. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  97335. /**
  97336. * Does a raycast in the physics world
  97337. * @param from when should the ray start?
  97338. * @param to when should the ray end?
  97339. * @returns PhysicsRaycastResult
  97340. */
  97341. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97342. /**
  97343. * Called by the scene. No need to call it.
  97344. * @param delta defines the timespam between frames
  97345. */
  97346. _step(delta: number): void;
  97347. }
  97348. }
  97349. declare module BABYLON {
  97350. /**
  97351. * The interface for the physics imposter parameters
  97352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97353. */
  97354. export interface PhysicsImpostorParameters {
  97355. /**
  97356. * The mass of the physics imposter
  97357. */
  97358. mass: number;
  97359. /**
  97360. * The friction of the physics imposter
  97361. */
  97362. friction?: number;
  97363. /**
  97364. * The coefficient of restitution of the physics imposter
  97365. */
  97366. restitution?: number;
  97367. /**
  97368. * The native options of the physics imposter
  97369. */
  97370. nativeOptions?: any;
  97371. /**
  97372. * Specifies if the parent should be ignored
  97373. */
  97374. ignoreParent?: boolean;
  97375. /**
  97376. * Specifies if bi-directional transformations should be disabled
  97377. */
  97378. disableBidirectionalTransformation?: boolean;
  97379. /**
  97380. * The pressure inside the physics imposter, soft object only
  97381. */
  97382. pressure?: number;
  97383. /**
  97384. * The stiffness the physics imposter, soft object only
  97385. */
  97386. stiffness?: number;
  97387. /**
  97388. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  97389. */
  97390. velocityIterations?: number;
  97391. /**
  97392. * The number of iterations used in maintaining consistent vertex positions, soft object only
  97393. */
  97394. positionIterations?: number;
  97395. /**
  97396. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  97397. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  97398. * Add to fix multiple points
  97399. */
  97400. fixedPoints?: number;
  97401. /**
  97402. * The collision margin around a soft object
  97403. */
  97404. margin?: number;
  97405. /**
  97406. * The collision margin around a soft object
  97407. */
  97408. damping?: number;
  97409. /**
  97410. * The path for a rope based on an extrusion
  97411. */
  97412. path?: any;
  97413. /**
  97414. * The shape of an extrusion used for a rope based on an extrusion
  97415. */
  97416. shape?: any;
  97417. }
  97418. /**
  97419. * Interface for a physics-enabled object
  97420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97421. */
  97422. export interface IPhysicsEnabledObject {
  97423. /**
  97424. * The position of the physics-enabled object
  97425. */
  97426. position: Vector3;
  97427. /**
  97428. * The rotation of the physics-enabled object
  97429. */
  97430. rotationQuaternion: Nullable<Quaternion>;
  97431. /**
  97432. * The scale of the physics-enabled object
  97433. */
  97434. scaling: Vector3;
  97435. /**
  97436. * The rotation of the physics-enabled object
  97437. */
  97438. rotation?: Vector3;
  97439. /**
  97440. * The parent of the physics-enabled object
  97441. */
  97442. parent?: any;
  97443. /**
  97444. * The bounding info of the physics-enabled object
  97445. * @returns The bounding info of the physics-enabled object
  97446. */
  97447. getBoundingInfo(): BoundingInfo;
  97448. /**
  97449. * Computes the world matrix
  97450. * @param force Specifies if the world matrix should be computed by force
  97451. * @returns A world matrix
  97452. */
  97453. computeWorldMatrix(force: boolean): Matrix;
  97454. /**
  97455. * Gets the world matrix
  97456. * @returns A world matrix
  97457. */
  97458. getWorldMatrix?(): Matrix;
  97459. /**
  97460. * Gets the child meshes
  97461. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  97462. * @returns An array of abstract meshes
  97463. */
  97464. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  97465. /**
  97466. * Gets the vertex data
  97467. * @param kind The type of vertex data
  97468. * @returns A nullable array of numbers, or a float32 array
  97469. */
  97470. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  97471. /**
  97472. * Gets the indices from the mesh
  97473. * @returns A nullable array of index arrays
  97474. */
  97475. getIndices?(): Nullable<IndicesArray>;
  97476. /**
  97477. * Gets the scene from the mesh
  97478. * @returns the indices array or null
  97479. */
  97480. getScene?(): Scene;
  97481. /**
  97482. * Gets the absolute position from the mesh
  97483. * @returns the absolute position
  97484. */
  97485. getAbsolutePosition(): Vector3;
  97486. /**
  97487. * Gets the absolute pivot point from the mesh
  97488. * @returns the absolute pivot point
  97489. */
  97490. getAbsolutePivotPoint(): Vector3;
  97491. /**
  97492. * Rotates the mesh
  97493. * @param axis The axis of rotation
  97494. * @param amount The amount of rotation
  97495. * @param space The space of the rotation
  97496. * @returns The rotation transform node
  97497. */
  97498. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97499. /**
  97500. * Translates the mesh
  97501. * @param axis The axis of translation
  97502. * @param distance The distance of translation
  97503. * @param space The space of the translation
  97504. * @returns The transform node
  97505. */
  97506. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97507. /**
  97508. * Sets the absolute position of the mesh
  97509. * @param absolutePosition The absolute position of the mesh
  97510. * @returns The transform node
  97511. */
  97512. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97513. /**
  97514. * Gets the class name of the mesh
  97515. * @returns The class name
  97516. */
  97517. getClassName(): string;
  97518. }
  97519. /**
  97520. * Represents a physics imposter
  97521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97522. */
  97523. export class PhysicsImpostor {
  97524. /**
  97525. * The physics-enabled object used as the physics imposter
  97526. */
  97527. object: IPhysicsEnabledObject;
  97528. /**
  97529. * The type of the physics imposter
  97530. */
  97531. type: number;
  97532. private _options;
  97533. private _scene?;
  97534. /**
  97535. * The default object size of the imposter
  97536. */
  97537. static DEFAULT_OBJECT_SIZE: Vector3;
  97538. /**
  97539. * The identity quaternion of the imposter
  97540. */
  97541. static IDENTITY_QUATERNION: Quaternion;
  97542. /** @hidden */
  97543. _pluginData: any;
  97544. private _physicsEngine;
  97545. private _physicsBody;
  97546. private _bodyUpdateRequired;
  97547. private _onBeforePhysicsStepCallbacks;
  97548. private _onAfterPhysicsStepCallbacks;
  97549. /** @hidden */
  97550. _onPhysicsCollideCallbacks: Array<{
  97551. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97552. otherImpostors: Array<PhysicsImpostor>;
  97553. }>;
  97554. private _deltaPosition;
  97555. private _deltaRotation;
  97556. private _deltaRotationConjugated;
  97557. /** @hidden */
  97558. _isFromLine: boolean;
  97559. private _parent;
  97560. private _isDisposed;
  97561. private static _tmpVecs;
  97562. private static _tmpQuat;
  97563. /**
  97564. * Specifies if the physics imposter is disposed
  97565. */
  97566. get isDisposed(): boolean;
  97567. /**
  97568. * Gets the mass of the physics imposter
  97569. */
  97570. get mass(): number;
  97571. set mass(value: number);
  97572. /**
  97573. * Gets the coefficient of friction
  97574. */
  97575. get friction(): number;
  97576. /**
  97577. * Sets the coefficient of friction
  97578. */
  97579. set friction(value: number);
  97580. /**
  97581. * Gets the coefficient of restitution
  97582. */
  97583. get restitution(): number;
  97584. /**
  97585. * Sets the coefficient of restitution
  97586. */
  97587. set restitution(value: number);
  97588. /**
  97589. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97590. */
  97591. get pressure(): number;
  97592. /**
  97593. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97594. */
  97595. set pressure(value: number);
  97596. /**
  97597. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97598. */
  97599. get stiffness(): number;
  97600. /**
  97601. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97602. */
  97603. set stiffness(value: number);
  97604. /**
  97605. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97606. */
  97607. get velocityIterations(): number;
  97608. /**
  97609. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97610. */
  97611. set velocityIterations(value: number);
  97612. /**
  97613. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97614. */
  97615. get positionIterations(): number;
  97616. /**
  97617. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97618. */
  97619. set positionIterations(value: number);
  97620. /**
  97621. * The unique id of the physics imposter
  97622. * set by the physics engine when adding this impostor to the array
  97623. */
  97624. uniqueId: number;
  97625. /**
  97626. * @hidden
  97627. */
  97628. soft: boolean;
  97629. /**
  97630. * @hidden
  97631. */
  97632. segments: number;
  97633. private _joints;
  97634. /**
  97635. * Initializes the physics imposter
  97636. * @param object The physics-enabled object used as the physics imposter
  97637. * @param type The type of the physics imposter
  97638. * @param _options The options for the physics imposter
  97639. * @param _scene The Babylon scene
  97640. */
  97641. constructor(
  97642. /**
  97643. * The physics-enabled object used as the physics imposter
  97644. */
  97645. object: IPhysicsEnabledObject,
  97646. /**
  97647. * The type of the physics imposter
  97648. */
  97649. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97650. /**
  97651. * This function will completly initialize this impostor.
  97652. * It will create a new body - but only if this mesh has no parent.
  97653. * If it has, this impostor will not be used other than to define the impostor
  97654. * of the child mesh.
  97655. * @hidden
  97656. */
  97657. _init(): void;
  97658. private _getPhysicsParent;
  97659. /**
  97660. * Should a new body be generated.
  97661. * @returns boolean specifying if body initialization is required
  97662. */
  97663. isBodyInitRequired(): boolean;
  97664. /**
  97665. * Sets the updated scaling
  97666. * @param updated Specifies if the scaling is updated
  97667. */
  97668. setScalingUpdated(): void;
  97669. /**
  97670. * Force a regeneration of this or the parent's impostor's body.
  97671. * Use under cautious - This will remove all joints already implemented.
  97672. */
  97673. forceUpdate(): void;
  97674. /**
  97675. * Gets the body that holds this impostor. Either its own, or its parent.
  97676. */
  97677. get physicsBody(): any;
  97678. /**
  97679. * Get the parent of the physics imposter
  97680. * @returns Physics imposter or null
  97681. */
  97682. get parent(): Nullable<PhysicsImpostor>;
  97683. /**
  97684. * Sets the parent of the physics imposter
  97685. */
  97686. set parent(value: Nullable<PhysicsImpostor>);
  97687. /**
  97688. * Set the physics body. Used mainly by the physics engine/plugin
  97689. */
  97690. set physicsBody(physicsBody: any);
  97691. /**
  97692. * Resets the update flags
  97693. */
  97694. resetUpdateFlags(): void;
  97695. /**
  97696. * Gets the object extend size
  97697. * @returns the object extend size
  97698. */
  97699. getObjectExtendSize(): Vector3;
  97700. /**
  97701. * Gets the object center
  97702. * @returns The object center
  97703. */
  97704. getObjectCenter(): Vector3;
  97705. /**
  97706. * Get a specific parameter from the options parameters
  97707. * @param paramName The object parameter name
  97708. * @returns The object parameter
  97709. */
  97710. getParam(paramName: string): any;
  97711. /**
  97712. * Sets a specific parameter in the options given to the physics plugin
  97713. * @param paramName The parameter name
  97714. * @param value The value of the parameter
  97715. */
  97716. setParam(paramName: string, value: number): void;
  97717. /**
  97718. * Specifically change the body's mass option. Won't recreate the physics body object
  97719. * @param mass The mass of the physics imposter
  97720. */
  97721. setMass(mass: number): void;
  97722. /**
  97723. * Gets the linear velocity
  97724. * @returns linear velocity or null
  97725. */
  97726. getLinearVelocity(): Nullable<Vector3>;
  97727. /**
  97728. * Sets the linear velocity
  97729. * @param velocity linear velocity or null
  97730. */
  97731. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97732. /**
  97733. * Gets the angular velocity
  97734. * @returns angular velocity or null
  97735. */
  97736. getAngularVelocity(): Nullable<Vector3>;
  97737. /**
  97738. * Sets the angular velocity
  97739. * @param velocity The velocity or null
  97740. */
  97741. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97742. /**
  97743. * Execute a function with the physics plugin native code
  97744. * Provide a function the will have two variables - the world object and the physics body object
  97745. * @param func The function to execute with the physics plugin native code
  97746. */
  97747. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97748. /**
  97749. * Register a function that will be executed before the physics world is stepping forward
  97750. * @param func The function to execute before the physics world is stepped forward
  97751. */
  97752. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97753. /**
  97754. * Unregister a function that will be executed before the physics world is stepping forward
  97755. * @param func The function to execute before the physics world is stepped forward
  97756. */
  97757. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97758. /**
  97759. * Register a function that will be executed after the physics step
  97760. * @param func The function to execute after physics step
  97761. */
  97762. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97763. /**
  97764. * Unregisters a function that will be executed after the physics step
  97765. * @param func The function to execute after physics step
  97766. */
  97767. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97768. /**
  97769. * register a function that will be executed when this impostor collides against a different body
  97770. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97771. * @param func Callback that is executed on collision
  97772. */
  97773. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97774. /**
  97775. * Unregisters the physics imposter on contact
  97776. * @param collideAgainst The physics object to collide against
  97777. * @param func Callback to execute on collision
  97778. */
  97779. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97780. private _tmpQuat;
  97781. private _tmpQuat2;
  97782. /**
  97783. * Get the parent rotation
  97784. * @returns The parent rotation
  97785. */
  97786. getParentsRotation(): Quaternion;
  97787. /**
  97788. * this function is executed by the physics engine.
  97789. */
  97790. beforeStep: () => void;
  97791. /**
  97792. * this function is executed by the physics engine
  97793. */
  97794. afterStep: () => void;
  97795. /**
  97796. * Legacy collision detection event support
  97797. */
  97798. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97799. /**
  97800. * event and body object due to cannon's event-based architecture.
  97801. */
  97802. onCollide: (e: {
  97803. body: any;
  97804. }) => void;
  97805. /**
  97806. * Apply a force
  97807. * @param force The force to apply
  97808. * @param contactPoint The contact point for the force
  97809. * @returns The physics imposter
  97810. */
  97811. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97812. /**
  97813. * Apply an impulse
  97814. * @param force The impulse force
  97815. * @param contactPoint The contact point for the impulse force
  97816. * @returns The physics imposter
  97817. */
  97818. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97819. /**
  97820. * A help function to create a joint
  97821. * @param otherImpostor A physics imposter used to create a joint
  97822. * @param jointType The type of joint
  97823. * @param jointData The data for the joint
  97824. * @returns The physics imposter
  97825. */
  97826. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97827. /**
  97828. * Add a joint to this impostor with a different impostor
  97829. * @param otherImpostor A physics imposter used to add a joint
  97830. * @param joint The joint to add
  97831. * @returns The physics imposter
  97832. */
  97833. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97834. /**
  97835. * Add an anchor to a cloth impostor
  97836. * @param otherImpostor rigid impostor to anchor to
  97837. * @param width ratio across width from 0 to 1
  97838. * @param height ratio up height from 0 to 1
  97839. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97840. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97841. * @returns impostor the soft imposter
  97842. */
  97843. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97844. /**
  97845. * Add a hook to a rope impostor
  97846. * @param otherImpostor rigid impostor to anchor to
  97847. * @param length ratio across rope from 0 to 1
  97848. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97849. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97850. * @returns impostor the rope imposter
  97851. */
  97852. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97853. /**
  97854. * Will keep this body still, in a sleep mode.
  97855. * @returns the physics imposter
  97856. */
  97857. sleep(): PhysicsImpostor;
  97858. /**
  97859. * Wake the body up.
  97860. * @returns The physics imposter
  97861. */
  97862. wakeUp(): PhysicsImpostor;
  97863. /**
  97864. * Clones the physics imposter
  97865. * @param newObject The physics imposter clones to this physics-enabled object
  97866. * @returns A nullable physics imposter
  97867. */
  97868. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97869. /**
  97870. * Disposes the physics imposter
  97871. */
  97872. dispose(): void;
  97873. /**
  97874. * Sets the delta position
  97875. * @param position The delta position amount
  97876. */
  97877. setDeltaPosition(position: Vector3): void;
  97878. /**
  97879. * Sets the delta rotation
  97880. * @param rotation The delta rotation amount
  97881. */
  97882. setDeltaRotation(rotation: Quaternion): void;
  97883. /**
  97884. * Gets the box size of the physics imposter and stores the result in the input parameter
  97885. * @param result Stores the box size
  97886. * @returns The physics imposter
  97887. */
  97888. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97889. /**
  97890. * Gets the radius of the physics imposter
  97891. * @returns Radius of the physics imposter
  97892. */
  97893. getRadius(): number;
  97894. /**
  97895. * Sync a bone with this impostor
  97896. * @param bone The bone to sync to the impostor.
  97897. * @param boneMesh The mesh that the bone is influencing.
  97898. * @param jointPivot The pivot of the joint / bone in local space.
  97899. * @param distToJoint Optional distance from the impostor to the joint.
  97900. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97901. */
  97902. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97903. /**
  97904. * Sync impostor to a bone
  97905. * @param bone The bone that the impostor will be synced to.
  97906. * @param boneMesh The mesh that the bone is influencing.
  97907. * @param jointPivot The pivot of the joint / bone in local space.
  97908. * @param distToJoint Optional distance from the impostor to the joint.
  97909. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97910. * @param boneAxis Optional vector3 axis the bone is aligned with
  97911. */
  97912. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97913. /**
  97914. * No-Imposter type
  97915. */
  97916. static NoImpostor: number;
  97917. /**
  97918. * Sphere-Imposter type
  97919. */
  97920. static SphereImpostor: number;
  97921. /**
  97922. * Box-Imposter type
  97923. */
  97924. static BoxImpostor: number;
  97925. /**
  97926. * Plane-Imposter type
  97927. */
  97928. static PlaneImpostor: number;
  97929. /**
  97930. * Mesh-imposter type
  97931. */
  97932. static MeshImpostor: number;
  97933. /**
  97934. * Capsule-Impostor type (Ammo.js plugin only)
  97935. */
  97936. static CapsuleImpostor: number;
  97937. /**
  97938. * Cylinder-Imposter type
  97939. */
  97940. static CylinderImpostor: number;
  97941. /**
  97942. * Particle-Imposter type
  97943. */
  97944. static ParticleImpostor: number;
  97945. /**
  97946. * Heightmap-Imposter type
  97947. */
  97948. static HeightmapImpostor: number;
  97949. /**
  97950. * ConvexHull-Impostor type (Ammo.js plugin only)
  97951. */
  97952. static ConvexHullImpostor: number;
  97953. /**
  97954. * Custom-Imposter type (Ammo.js plugin only)
  97955. */
  97956. static CustomImpostor: number;
  97957. /**
  97958. * Rope-Imposter type
  97959. */
  97960. static RopeImpostor: number;
  97961. /**
  97962. * Cloth-Imposter type
  97963. */
  97964. static ClothImpostor: number;
  97965. /**
  97966. * Softbody-Imposter type
  97967. */
  97968. static SoftbodyImpostor: number;
  97969. }
  97970. }
  97971. declare module BABYLON {
  97972. /**
  97973. * @hidden
  97974. **/
  97975. export class _CreationDataStorage {
  97976. closePath?: boolean;
  97977. closeArray?: boolean;
  97978. idx: number[];
  97979. dashSize: number;
  97980. gapSize: number;
  97981. path3D: Path3D;
  97982. pathArray: Vector3[][];
  97983. arc: number;
  97984. radius: number;
  97985. cap: number;
  97986. tessellation: number;
  97987. }
  97988. /**
  97989. * @hidden
  97990. **/
  97991. class _InstanceDataStorage {
  97992. visibleInstances: any;
  97993. batchCache: _InstancesBatch;
  97994. instancesBufferSize: number;
  97995. instancesBuffer: Nullable<Buffer>;
  97996. instancesData: Float32Array;
  97997. overridenInstanceCount: number;
  97998. isFrozen: boolean;
  97999. previousBatch: Nullable<_InstancesBatch>;
  98000. hardwareInstancedRendering: boolean;
  98001. sideOrientation: number;
  98002. manualUpdate: boolean;
  98003. }
  98004. /**
  98005. * @hidden
  98006. **/
  98007. export class _InstancesBatch {
  98008. mustReturn: boolean;
  98009. visibleInstances: Nullable<InstancedMesh[]>[];
  98010. renderSelf: boolean[];
  98011. hardwareInstancedRendering: boolean[];
  98012. }
  98013. /**
  98014. * Class used to represent renderable models
  98015. */
  98016. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  98017. /**
  98018. * Mesh side orientation : usually the external or front surface
  98019. */
  98020. static readonly FRONTSIDE: number;
  98021. /**
  98022. * Mesh side orientation : usually the internal or back surface
  98023. */
  98024. static readonly BACKSIDE: number;
  98025. /**
  98026. * Mesh side orientation : both internal and external or front and back surfaces
  98027. */
  98028. static readonly DOUBLESIDE: number;
  98029. /**
  98030. * Mesh side orientation : by default, `FRONTSIDE`
  98031. */
  98032. static readonly DEFAULTSIDE: number;
  98033. /**
  98034. * Mesh cap setting : no cap
  98035. */
  98036. static readonly NO_CAP: number;
  98037. /**
  98038. * Mesh cap setting : one cap at the beginning of the mesh
  98039. */
  98040. static readonly CAP_START: number;
  98041. /**
  98042. * Mesh cap setting : one cap at the end of the mesh
  98043. */
  98044. static readonly CAP_END: number;
  98045. /**
  98046. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  98047. */
  98048. static readonly CAP_ALL: number;
  98049. /**
  98050. * Mesh pattern setting : no flip or rotate
  98051. */
  98052. static readonly NO_FLIP: number;
  98053. /**
  98054. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  98055. */
  98056. static readonly FLIP_TILE: number;
  98057. /**
  98058. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  98059. */
  98060. static readonly ROTATE_TILE: number;
  98061. /**
  98062. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  98063. */
  98064. static readonly FLIP_ROW: number;
  98065. /**
  98066. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  98067. */
  98068. static readonly ROTATE_ROW: number;
  98069. /**
  98070. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  98071. */
  98072. static readonly FLIP_N_ROTATE_TILE: number;
  98073. /**
  98074. * Mesh pattern setting : rotate pattern and rotate
  98075. */
  98076. static readonly FLIP_N_ROTATE_ROW: number;
  98077. /**
  98078. * Mesh tile positioning : part tiles same on left/right or top/bottom
  98079. */
  98080. static readonly CENTER: number;
  98081. /**
  98082. * Mesh tile positioning : part tiles on left
  98083. */
  98084. static readonly LEFT: number;
  98085. /**
  98086. * Mesh tile positioning : part tiles on right
  98087. */
  98088. static readonly RIGHT: number;
  98089. /**
  98090. * Mesh tile positioning : part tiles on top
  98091. */
  98092. static readonly TOP: number;
  98093. /**
  98094. * Mesh tile positioning : part tiles on bottom
  98095. */
  98096. static readonly BOTTOM: number;
  98097. /**
  98098. * Gets the default side orientation.
  98099. * @param orientation the orientation to value to attempt to get
  98100. * @returns the default orientation
  98101. * @hidden
  98102. */
  98103. static _GetDefaultSideOrientation(orientation?: number): number;
  98104. private _internalMeshDataInfo;
  98105. /**
  98106. * An event triggered before rendering the mesh
  98107. */
  98108. get onBeforeRenderObservable(): Observable<Mesh>;
  98109. /**
  98110. * An event triggered before binding the mesh
  98111. */
  98112. get onBeforeBindObservable(): Observable<Mesh>;
  98113. /**
  98114. * An event triggered after rendering the mesh
  98115. */
  98116. get onAfterRenderObservable(): Observable<Mesh>;
  98117. /**
  98118. * An event triggered before drawing the mesh
  98119. */
  98120. get onBeforeDrawObservable(): Observable<Mesh>;
  98121. private _onBeforeDrawObserver;
  98122. /**
  98123. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98124. */
  98125. set onBeforeDraw(callback: () => void);
  98126. get hasInstances(): boolean;
  98127. /**
  98128. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98129. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98130. */
  98131. delayLoadState: number;
  98132. /**
  98133. * Gets the list of instances created from this mesh
  98134. * it is not supposed to be modified manually.
  98135. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98136. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98137. */
  98138. instances: InstancedMesh[];
  98139. /**
  98140. * Gets the file containing delay loading data for this mesh
  98141. */
  98142. delayLoadingFile: string;
  98143. /** @hidden */
  98144. _binaryInfo: any;
  98145. /**
  98146. * User defined function used to change how LOD level selection is done
  98147. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98148. */
  98149. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98150. /**
  98151. * Gets or sets the morph target manager
  98152. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98153. */
  98154. get morphTargetManager(): Nullable<MorphTargetManager>;
  98155. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98156. /** @hidden */
  98157. _creationDataStorage: Nullable<_CreationDataStorage>;
  98158. /** @hidden */
  98159. _geometry: Nullable<Geometry>;
  98160. /** @hidden */
  98161. _delayInfo: Array<string>;
  98162. /** @hidden */
  98163. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98164. /** @hidden */
  98165. _instanceDataStorage: _InstanceDataStorage;
  98166. private _effectiveMaterial;
  98167. /** @hidden */
  98168. _shouldGenerateFlatShading: boolean;
  98169. /** @hidden */
  98170. _originalBuilderSideOrientation: number;
  98171. /**
  98172. * Use this property to change the original side orientation defined at construction time
  98173. */
  98174. overrideMaterialSideOrientation: Nullable<number>;
  98175. /**
  98176. * Gets the source mesh (the one used to clone this one from)
  98177. */
  98178. get source(): Nullable<Mesh>;
  98179. /**
  98180. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98181. */
  98182. get isUnIndexed(): boolean;
  98183. set isUnIndexed(value: boolean);
  98184. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98185. get worldMatrixInstancedBuffer(): Float32Array;
  98186. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98187. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98188. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98189. /**
  98190. * @constructor
  98191. * @param name The value used by scene.getMeshByName() to do a lookup.
  98192. * @param scene The scene to add this mesh to.
  98193. * @param parent The parent of this mesh, if it has one
  98194. * @param source An optional Mesh from which geometry is shared, cloned.
  98195. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98196. * When false, achieved by calling a clone(), also passing False.
  98197. * This will make creation of children, recursive.
  98198. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98199. */
  98200. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98201. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98202. doNotInstantiate: boolean;
  98203. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98204. /**
  98205. * Gets the class name
  98206. * @returns the string "Mesh".
  98207. */
  98208. getClassName(): string;
  98209. /** @hidden */
  98210. get _isMesh(): boolean;
  98211. /**
  98212. * Returns a description of this mesh
  98213. * @param fullDetails define if full details about this mesh must be used
  98214. * @returns a descriptive string representing this mesh
  98215. */
  98216. toString(fullDetails?: boolean): string;
  98217. /** @hidden */
  98218. _unBindEffect(): void;
  98219. /**
  98220. * Gets a boolean indicating if this mesh has LOD
  98221. */
  98222. get hasLODLevels(): boolean;
  98223. /**
  98224. * Gets the list of MeshLODLevel associated with the current mesh
  98225. * @returns an array of MeshLODLevel
  98226. */
  98227. getLODLevels(): MeshLODLevel[];
  98228. private _sortLODLevels;
  98229. /**
  98230. * Add a mesh as LOD level triggered at the given distance.
  98231. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98232. * @param distance The distance from the center of the object to show this level
  98233. * @param mesh The mesh to be added as LOD level (can be null)
  98234. * @return This mesh (for chaining)
  98235. */
  98236. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98237. /**
  98238. * Returns the LOD level mesh at the passed distance or null if not found.
  98239. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98240. * @param distance The distance from the center of the object to show this level
  98241. * @returns a Mesh or `null`
  98242. */
  98243. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98244. /**
  98245. * Remove a mesh from the LOD array
  98246. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98247. * @param mesh defines the mesh to be removed
  98248. * @return This mesh (for chaining)
  98249. */
  98250. removeLODLevel(mesh: Mesh): Mesh;
  98251. /**
  98252. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98253. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98254. * @param camera defines the camera to use to compute distance
  98255. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98256. * @return This mesh (for chaining)
  98257. */
  98258. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98259. /**
  98260. * Gets the mesh internal Geometry object
  98261. */
  98262. get geometry(): Nullable<Geometry>;
  98263. /**
  98264. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98265. * @returns the total number of vertices
  98266. */
  98267. getTotalVertices(): number;
  98268. /**
  98269. * Returns the content of an associated vertex buffer
  98270. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98271. * - VertexBuffer.PositionKind
  98272. * - VertexBuffer.UVKind
  98273. * - VertexBuffer.UV2Kind
  98274. * - VertexBuffer.UV3Kind
  98275. * - VertexBuffer.UV4Kind
  98276. * - VertexBuffer.UV5Kind
  98277. * - VertexBuffer.UV6Kind
  98278. * - VertexBuffer.ColorKind
  98279. * - VertexBuffer.MatricesIndicesKind
  98280. * - VertexBuffer.MatricesIndicesExtraKind
  98281. * - VertexBuffer.MatricesWeightsKind
  98282. * - VertexBuffer.MatricesWeightsExtraKind
  98283. * @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
  98284. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  98285. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  98286. */
  98287. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98288. /**
  98289. * Returns the mesh VertexBuffer object from the requested `kind`
  98290. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98291. * - VertexBuffer.PositionKind
  98292. * - VertexBuffer.NormalKind
  98293. * - VertexBuffer.UVKind
  98294. * - VertexBuffer.UV2Kind
  98295. * - VertexBuffer.UV3Kind
  98296. * - VertexBuffer.UV4Kind
  98297. * - VertexBuffer.UV5Kind
  98298. * - VertexBuffer.UV6Kind
  98299. * - VertexBuffer.ColorKind
  98300. * - VertexBuffer.MatricesIndicesKind
  98301. * - VertexBuffer.MatricesIndicesExtraKind
  98302. * - VertexBuffer.MatricesWeightsKind
  98303. * - VertexBuffer.MatricesWeightsExtraKind
  98304. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  98305. */
  98306. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98307. /**
  98308. * Tests if a specific vertex buffer is associated with this mesh
  98309. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98310. * - VertexBuffer.PositionKind
  98311. * - VertexBuffer.NormalKind
  98312. * - VertexBuffer.UVKind
  98313. * - VertexBuffer.UV2Kind
  98314. * - VertexBuffer.UV3Kind
  98315. * - VertexBuffer.UV4Kind
  98316. * - VertexBuffer.UV5Kind
  98317. * - VertexBuffer.UV6Kind
  98318. * - VertexBuffer.ColorKind
  98319. * - VertexBuffer.MatricesIndicesKind
  98320. * - VertexBuffer.MatricesIndicesExtraKind
  98321. * - VertexBuffer.MatricesWeightsKind
  98322. * - VertexBuffer.MatricesWeightsExtraKind
  98323. * @returns a boolean
  98324. */
  98325. isVerticesDataPresent(kind: string): boolean;
  98326. /**
  98327. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  98328. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98329. * - VertexBuffer.PositionKind
  98330. * - VertexBuffer.UVKind
  98331. * - VertexBuffer.UV2Kind
  98332. * - VertexBuffer.UV3Kind
  98333. * - VertexBuffer.UV4Kind
  98334. * - VertexBuffer.UV5Kind
  98335. * - VertexBuffer.UV6Kind
  98336. * - VertexBuffer.ColorKind
  98337. * - VertexBuffer.MatricesIndicesKind
  98338. * - VertexBuffer.MatricesIndicesExtraKind
  98339. * - VertexBuffer.MatricesWeightsKind
  98340. * - VertexBuffer.MatricesWeightsExtraKind
  98341. * @returns a boolean
  98342. */
  98343. isVertexBufferUpdatable(kind: string): boolean;
  98344. /**
  98345. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  98346. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98347. * - VertexBuffer.PositionKind
  98348. * - VertexBuffer.NormalKind
  98349. * - VertexBuffer.UVKind
  98350. * - VertexBuffer.UV2Kind
  98351. * - VertexBuffer.UV3Kind
  98352. * - VertexBuffer.UV4Kind
  98353. * - VertexBuffer.UV5Kind
  98354. * - VertexBuffer.UV6Kind
  98355. * - VertexBuffer.ColorKind
  98356. * - VertexBuffer.MatricesIndicesKind
  98357. * - VertexBuffer.MatricesIndicesExtraKind
  98358. * - VertexBuffer.MatricesWeightsKind
  98359. * - VertexBuffer.MatricesWeightsExtraKind
  98360. * @returns an array of strings
  98361. */
  98362. getVerticesDataKinds(): string[];
  98363. /**
  98364. * Returns a positive integer : the total number of indices in this mesh geometry.
  98365. * @returns the numner of indices or zero if the mesh has no geometry.
  98366. */
  98367. getTotalIndices(): number;
  98368. /**
  98369. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98370. * @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.
  98371. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98372. * @returns the indices array or an empty array if the mesh has no geometry
  98373. */
  98374. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98375. get isBlocked(): boolean;
  98376. /**
  98377. * Determine if the current mesh is ready to be rendered
  98378. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98379. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  98380. * @returns true if all associated assets are ready (material, textures, shaders)
  98381. */
  98382. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  98383. /**
  98384. * 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.
  98385. */
  98386. get areNormalsFrozen(): boolean;
  98387. /**
  98388. * 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.
  98389. * @returns the current mesh
  98390. */
  98391. freezeNormals(): Mesh;
  98392. /**
  98393. * 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
  98394. * @returns the current mesh
  98395. */
  98396. unfreezeNormals(): Mesh;
  98397. /**
  98398. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98399. */
  98400. set overridenInstanceCount(count: number);
  98401. /** @hidden */
  98402. _preActivate(): Mesh;
  98403. /** @hidden */
  98404. _preActivateForIntermediateRendering(renderId: number): Mesh;
  98405. /** @hidden */
  98406. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  98407. /**
  98408. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98409. * This means the mesh underlying bounding box and sphere are recomputed.
  98410. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98411. * @returns the current mesh
  98412. */
  98413. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  98414. /** @hidden */
  98415. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  98416. /**
  98417. * This function will subdivide the mesh into multiple submeshes
  98418. * @param count defines the expected number of submeshes
  98419. */
  98420. subdivide(count: number): void;
  98421. /**
  98422. * Copy a FloatArray into a specific associated vertex buffer
  98423. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98424. * - VertexBuffer.PositionKind
  98425. * - VertexBuffer.UVKind
  98426. * - VertexBuffer.UV2Kind
  98427. * - VertexBuffer.UV3Kind
  98428. * - VertexBuffer.UV4Kind
  98429. * - VertexBuffer.UV5Kind
  98430. * - VertexBuffer.UV6Kind
  98431. * - VertexBuffer.ColorKind
  98432. * - VertexBuffer.MatricesIndicesKind
  98433. * - VertexBuffer.MatricesIndicesExtraKind
  98434. * - VertexBuffer.MatricesWeightsKind
  98435. * - VertexBuffer.MatricesWeightsExtraKind
  98436. * @param data defines the data source
  98437. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98438. * @param stride defines the data stride size (can be null)
  98439. * @returns the current mesh
  98440. */
  98441. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98442. /**
  98443. * Delete a vertex buffer associated with this mesh
  98444. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  98445. * - VertexBuffer.PositionKind
  98446. * - VertexBuffer.UVKind
  98447. * - VertexBuffer.UV2Kind
  98448. * - VertexBuffer.UV3Kind
  98449. * - VertexBuffer.UV4Kind
  98450. * - VertexBuffer.UV5Kind
  98451. * - VertexBuffer.UV6Kind
  98452. * - VertexBuffer.ColorKind
  98453. * - VertexBuffer.MatricesIndicesKind
  98454. * - VertexBuffer.MatricesIndicesExtraKind
  98455. * - VertexBuffer.MatricesWeightsKind
  98456. * - VertexBuffer.MatricesWeightsExtraKind
  98457. */
  98458. removeVerticesData(kind: string): void;
  98459. /**
  98460. * Flags an associated vertex buffer as updatable
  98461. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  98462. * - VertexBuffer.PositionKind
  98463. * - VertexBuffer.UVKind
  98464. * - VertexBuffer.UV2Kind
  98465. * - VertexBuffer.UV3Kind
  98466. * - VertexBuffer.UV4Kind
  98467. * - VertexBuffer.UV5Kind
  98468. * - VertexBuffer.UV6Kind
  98469. * - VertexBuffer.ColorKind
  98470. * - VertexBuffer.MatricesIndicesKind
  98471. * - VertexBuffer.MatricesIndicesExtraKind
  98472. * - VertexBuffer.MatricesWeightsKind
  98473. * - VertexBuffer.MatricesWeightsExtraKind
  98474. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98475. */
  98476. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98477. /**
  98478. * Sets the mesh global Vertex Buffer
  98479. * @param buffer defines the buffer to use
  98480. * @returns the current mesh
  98481. */
  98482. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98483. /**
  98484. * Update a specific associated vertex buffer
  98485. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98486. * - VertexBuffer.PositionKind
  98487. * - VertexBuffer.UVKind
  98488. * - VertexBuffer.UV2Kind
  98489. * - VertexBuffer.UV3Kind
  98490. * - VertexBuffer.UV4Kind
  98491. * - VertexBuffer.UV5Kind
  98492. * - VertexBuffer.UV6Kind
  98493. * - VertexBuffer.ColorKind
  98494. * - VertexBuffer.MatricesIndicesKind
  98495. * - VertexBuffer.MatricesIndicesExtraKind
  98496. * - VertexBuffer.MatricesWeightsKind
  98497. * - VertexBuffer.MatricesWeightsExtraKind
  98498. * @param data defines the data source
  98499. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98500. * @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)
  98501. * @returns the current mesh
  98502. */
  98503. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98504. /**
  98505. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98506. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98507. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98508. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98509. * @returns the current mesh
  98510. */
  98511. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98512. /**
  98513. * Creates a un-shared specific occurence of the geometry for the mesh.
  98514. * @returns the current mesh
  98515. */
  98516. makeGeometryUnique(): Mesh;
  98517. /**
  98518. * Set the index buffer of this mesh
  98519. * @param indices defines the source data
  98520. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98521. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98522. * @returns the current mesh
  98523. */
  98524. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98525. /**
  98526. * Update the current index buffer
  98527. * @param indices defines the source data
  98528. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98529. * @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)
  98530. * @returns the current mesh
  98531. */
  98532. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98533. /**
  98534. * Invert the geometry to move from a right handed system to a left handed one.
  98535. * @returns the current mesh
  98536. */
  98537. toLeftHanded(): Mesh;
  98538. /** @hidden */
  98539. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98540. /** @hidden */
  98541. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98542. /**
  98543. * Registers for this mesh a javascript function called just before the rendering process
  98544. * @param func defines the function to call before rendering this mesh
  98545. * @returns the current mesh
  98546. */
  98547. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98548. /**
  98549. * Disposes a previously registered javascript function called before the rendering
  98550. * @param func defines the function to remove
  98551. * @returns the current mesh
  98552. */
  98553. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98554. /**
  98555. * Registers for this mesh a javascript function called just after the rendering is complete
  98556. * @param func defines the function to call after rendering this mesh
  98557. * @returns the current mesh
  98558. */
  98559. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98560. /**
  98561. * Disposes a previously registered javascript function called after the rendering.
  98562. * @param func defines the function to remove
  98563. * @returns the current mesh
  98564. */
  98565. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98566. /** @hidden */
  98567. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98568. /** @hidden */
  98569. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98570. /** @hidden */
  98571. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98572. /** @hidden */
  98573. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98574. /** @hidden */
  98575. _rebuild(): void;
  98576. /** @hidden */
  98577. _freeze(): void;
  98578. /** @hidden */
  98579. _unFreeze(): void;
  98580. /**
  98581. * 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
  98582. * @param subMesh defines the subMesh to render
  98583. * @param enableAlphaMode defines if alpha mode can be changed
  98584. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98585. * @returns the current mesh
  98586. */
  98587. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98588. private _onBeforeDraw;
  98589. /**
  98590. * Renormalize the mesh and patch it up if there are no weights
  98591. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98592. * However in the case of zero weights then we set just a single influence to 1.
  98593. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98594. */
  98595. cleanMatrixWeights(): void;
  98596. private normalizeSkinFourWeights;
  98597. private normalizeSkinWeightsAndExtra;
  98598. /**
  98599. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98600. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98601. * the user know there was an issue with importing the mesh
  98602. * @returns a validation object with skinned, valid and report string
  98603. */
  98604. validateSkinning(): {
  98605. skinned: boolean;
  98606. valid: boolean;
  98607. report: string;
  98608. };
  98609. /** @hidden */
  98610. _checkDelayState(): Mesh;
  98611. private _queueLoad;
  98612. /**
  98613. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98614. * A mesh is in the frustum if its bounding box intersects the frustum
  98615. * @param frustumPlanes defines the frustum to test
  98616. * @returns true if the mesh is in the frustum planes
  98617. */
  98618. isInFrustum(frustumPlanes: Plane[]): boolean;
  98619. /**
  98620. * Sets the mesh material by the material or multiMaterial `id` property
  98621. * @param id is a string identifying the material or the multiMaterial
  98622. * @returns the current mesh
  98623. */
  98624. setMaterialByID(id: string): Mesh;
  98625. /**
  98626. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98627. * @returns an array of IAnimatable
  98628. */
  98629. getAnimatables(): IAnimatable[];
  98630. /**
  98631. * Modifies the mesh geometry according to the passed transformation matrix.
  98632. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98633. * The mesh normals are modified using the same transformation.
  98634. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98635. * @param transform defines the transform matrix to use
  98636. * @see http://doc.babylonjs.com/resources/baking_transformations
  98637. * @returns the current mesh
  98638. */
  98639. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98640. /**
  98641. * Modifies the mesh geometry according to its own current World Matrix.
  98642. * The mesh World Matrix is then reset.
  98643. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98644. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98645. * @see http://doc.babylonjs.com/resources/baking_transformations
  98646. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98647. * @returns the current mesh
  98648. */
  98649. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98650. /** @hidden */
  98651. get _positions(): Nullable<Vector3[]>;
  98652. /** @hidden */
  98653. _resetPointsArrayCache(): Mesh;
  98654. /** @hidden */
  98655. _generatePointsArray(): boolean;
  98656. /**
  98657. * Returns a new Mesh object generated from the current mesh properties.
  98658. * This method must not get confused with createInstance()
  98659. * @param name is a string, the name given to the new mesh
  98660. * @param newParent can be any Node object (default `null`)
  98661. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98662. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98663. * @returns a new mesh
  98664. */
  98665. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98666. /**
  98667. * Releases resources associated with this mesh.
  98668. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98669. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98670. */
  98671. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98672. /** @hidden */
  98673. _disposeInstanceSpecificData(): void;
  98674. /**
  98675. * Modifies the mesh geometry according to a displacement map.
  98676. * 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.
  98677. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98678. * @param url is a string, the URL from the image file is to be downloaded.
  98679. * @param minHeight is the lower limit of the displacement.
  98680. * @param maxHeight is the upper limit of the displacement.
  98681. * @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.
  98682. * @param uvOffset is an optional vector2 used to offset UV.
  98683. * @param uvScale is an optional vector2 used to scale UV.
  98684. * @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.
  98685. * @returns the Mesh.
  98686. */
  98687. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98688. /**
  98689. * Modifies the mesh geometry according to a displacementMap buffer.
  98690. * 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.
  98691. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98692. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98693. * @param heightMapWidth is the width of the buffer image.
  98694. * @param heightMapHeight is the height of the buffer image.
  98695. * @param minHeight is the lower limit of the displacement.
  98696. * @param maxHeight is the upper limit of the displacement.
  98697. * @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.
  98698. * @param uvOffset is an optional vector2 used to offset UV.
  98699. * @param uvScale is an optional vector2 used to scale UV.
  98700. * @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.
  98701. * @returns the Mesh.
  98702. */
  98703. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98704. /**
  98705. * Modify the mesh to get a flat shading rendering.
  98706. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98707. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98708. * @returns current mesh
  98709. */
  98710. convertToFlatShadedMesh(): Mesh;
  98711. /**
  98712. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98713. * In other words, more vertices, no more indices and a single bigger VBO.
  98714. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98715. * @returns current mesh
  98716. */
  98717. convertToUnIndexedMesh(): Mesh;
  98718. /**
  98719. * Inverses facet orientations.
  98720. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98721. * @param flipNormals will also inverts the normals
  98722. * @returns current mesh
  98723. */
  98724. flipFaces(flipNormals?: boolean): Mesh;
  98725. /**
  98726. * Increase the number of facets and hence vertices in a mesh
  98727. * Vertex normals are interpolated from existing vertex normals
  98728. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98729. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98730. */
  98731. increaseVertices(numberPerEdge: number): void;
  98732. /**
  98733. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98734. * This will undo any application of covertToFlatShadedMesh
  98735. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98736. */
  98737. forceSharedVertices(): void;
  98738. /** @hidden */
  98739. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98740. /** @hidden */
  98741. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98742. /**
  98743. * Creates a new InstancedMesh object from the mesh model.
  98744. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98745. * @param name defines the name of the new instance
  98746. * @returns a new InstancedMesh
  98747. */
  98748. createInstance(name: string): InstancedMesh;
  98749. /**
  98750. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98751. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98752. * @returns the current mesh
  98753. */
  98754. synchronizeInstances(): Mesh;
  98755. /**
  98756. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98757. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98758. * This should be used together with the simplification to avoid disappearing triangles.
  98759. * @param successCallback an optional success callback to be called after the optimization finished.
  98760. * @returns the current mesh
  98761. */
  98762. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98763. /**
  98764. * Serialize current mesh
  98765. * @param serializationObject defines the object which will receive the serialization data
  98766. */
  98767. serialize(serializationObject: any): void;
  98768. /** @hidden */
  98769. _syncGeometryWithMorphTargetManager(): void;
  98770. /** @hidden */
  98771. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98772. /**
  98773. * Returns a new Mesh object parsed from the source provided.
  98774. * @param parsedMesh is the source
  98775. * @param scene defines the hosting scene
  98776. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98777. * @returns a new Mesh
  98778. */
  98779. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98780. /**
  98781. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98782. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98783. * @param name defines the name of the mesh to create
  98784. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98785. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98786. * @param closePath creates a seam between the first and the last points of each path of the path array
  98787. * @param offset is taken in account only if the `pathArray` is containing a single path
  98788. * @param scene defines the hosting scene
  98789. * @param updatable defines if the mesh must be flagged as updatable
  98790. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98791. * @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)
  98792. * @returns a new Mesh
  98793. */
  98794. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98795. /**
  98796. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98797. * @param name defines the name of the mesh to create
  98798. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98799. * @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
  98800. * @param scene defines the hosting scene
  98801. * @param updatable defines if the mesh must be flagged as updatable
  98802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98803. * @returns a new Mesh
  98804. */
  98805. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98806. /**
  98807. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98808. * @param name defines the name of the mesh to create
  98809. * @param size sets the size (float) of each box side (default 1)
  98810. * @param scene defines the hosting scene
  98811. * @param updatable defines if the mesh must be flagged as updatable
  98812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98813. * @returns a new Mesh
  98814. */
  98815. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98816. /**
  98817. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98818. * @param name defines the name of the mesh to create
  98819. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98820. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98821. * @param scene defines the hosting scene
  98822. * @param updatable defines if the mesh must be flagged as updatable
  98823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98824. * @returns a new Mesh
  98825. */
  98826. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98827. /**
  98828. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98829. * @param name defines the name of the mesh to create
  98830. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98831. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98832. * @param scene defines the hosting scene
  98833. * @returns a new Mesh
  98834. */
  98835. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98836. /**
  98837. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98838. * @param name defines the name of the mesh to create
  98839. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98840. * @param diameterTop set the top cap diameter (floats, default 1)
  98841. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98842. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98843. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98844. * @param scene defines the hosting scene
  98845. * @param updatable defines if the mesh must be flagged as updatable
  98846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98847. * @returns a new Mesh
  98848. */
  98849. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98850. /**
  98851. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98852. * @param name defines the name of the mesh to create
  98853. * @param diameter sets the diameter size (float) of the torus (default 1)
  98854. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98855. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98856. * @param scene defines the hosting scene
  98857. * @param updatable defines if the mesh must be flagged as updatable
  98858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98859. * @returns a new Mesh
  98860. */
  98861. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98862. /**
  98863. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98864. * @param name defines the name of the mesh to create
  98865. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98866. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98867. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98868. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98869. * @param p the number of windings on X axis (positive integers, default 2)
  98870. * @param q the number of windings on Y axis (positive integers, default 3)
  98871. * @param scene defines the hosting scene
  98872. * @param updatable defines if the mesh must be flagged as updatable
  98873. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98874. * @returns a new Mesh
  98875. */
  98876. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98877. /**
  98878. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98879. * @param name defines the name of the mesh to create
  98880. * @param points is an array successive Vector3
  98881. * @param scene defines the hosting scene
  98882. * @param updatable defines if the mesh must be flagged as updatable
  98883. * @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).
  98884. * @returns a new Mesh
  98885. */
  98886. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98887. /**
  98888. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98889. * @param name defines the name of the mesh to create
  98890. * @param points is an array successive Vector3
  98891. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98892. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98893. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98894. * @param scene defines the hosting scene
  98895. * @param updatable defines if the mesh must be flagged as updatable
  98896. * @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)
  98897. * @returns a new Mesh
  98898. */
  98899. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98900. /**
  98901. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98902. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98903. * 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.
  98904. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98905. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98906. * Remember you can only change the shape positions, not their number when updating a polygon.
  98907. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98908. * @param name defines the name of the mesh to create
  98909. * @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
  98910. * @param scene defines the hosting scene
  98911. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98912. * @param updatable defines if the mesh must be flagged as updatable
  98913. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98914. * @param earcutInjection can be used to inject your own earcut reference
  98915. * @returns a new Mesh
  98916. */
  98917. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98918. /**
  98919. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98920. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98921. * @param name defines the name of the mesh to create
  98922. * @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
  98923. * @param depth defines the height of extrusion
  98924. * @param scene defines the hosting scene
  98925. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98926. * @param updatable defines if the mesh must be flagged as updatable
  98927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98928. * @param earcutInjection can be used to inject your own earcut reference
  98929. * @returns a new Mesh
  98930. */
  98931. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98932. /**
  98933. * Creates an extruded shape mesh.
  98934. * 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
  98935. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98936. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98937. * @param name defines the name of the mesh to create
  98938. * @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
  98939. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98940. * @param scale is the value to scale the shape
  98941. * @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
  98942. * @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
  98943. * @param scene defines the hosting scene
  98944. * @param updatable defines if the mesh must be flagged as updatable
  98945. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98946. * @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)
  98947. * @returns a new Mesh
  98948. */
  98949. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98950. /**
  98951. * Creates an custom extruded shape mesh.
  98952. * The custom extrusion is a parametric shape.
  98953. * It has no predefined shape. Its final shape will depend on the input parameters.
  98954. * Please consider using the same method from the MeshBuilder class instead
  98955. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98956. * @param name defines the name of the mesh to create
  98957. * @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
  98958. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98959. * @param scaleFunction is a custom Javascript function called on each path point
  98960. * @param rotationFunction is a custom Javascript function called on each path point
  98961. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98962. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98963. * @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
  98964. * @param scene defines the hosting scene
  98965. * @param updatable defines if the mesh must be flagged as updatable
  98966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98967. * @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)
  98968. * @returns a new Mesh
  98969. */
  98970. 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;
  98971. /**
  98972. * Creates lathe mesh.
  98973. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98974. * Please consider using the same method from the MeshBuilder class instead
  98975. * @param name defines the name of the mesh to create
  98976. * @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
  98977. * @param radius is the radius value of the lathe
  98978. * @param tessellation is the side number of the lathe.
  98979. * @param scene defines the hosting scene
  98980. * @param updatable defines if the mesh must be flagged as updatable
  98981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98982. * @returns a new Mesh
  98983. */
  98984. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98985. /**
  98986. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98987. * @param name defines the name of the mesh to create
  98988. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98989. * @param scene defines the hosting scene
  98990. * @param updatable defines if the mesh must be flagged as updatable
  98991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98992. * @returns a new Mesh
  98993. */
  98994. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98995. /**
  98996. * Creates a ground mesh.
  98997. * Please consider using the same method from the MeshBuilder class instead
  98998. * @param name defines the name of the mesh to create
  98999. * @param width set the width of the ground
  99000. * @param height set the height of the ground
  99001. * @param subdivisions sets the number of subdivisions per side
  99002. * @param scene defines the hosting scene
  99003. * @param updatable defines if the mesh must be flagged as updatable
  99004. * @returns a new Mesh
  99005. */
  99006. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  99007. /**
  99008. * Creates a tiled ground mesh.
  99009. * Please consider using the same method from the MeshBuilder class instead
  99010. * @param name defines the name of the mesh to create
  99011. * @param xmin set the ground minimum X coordinate
  99012. * @param zmin set the ground minimum Y coordinate
  99013. * @param xmax set the ground maximum X coordinate
  99014. * @param zmax set the ground maximum Z coordinate
  99015. * @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
  99016. * @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
  99017. * @param scene defines the hosting scene
  99018. * @param updatable defines if the mesh must be flagged as updatable
  99019. * @returns a new Mesh
  99020. */
  99021. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  99022. w: number;
  99023. h: number;
  99024. }, precision: {
  99025. w: number;
  99026. h: number;
  99027. }, scene: Scene, updatable?: boolean): Mesh;
  99028. /**
  99029. * Creates a ground mesh from a height map.
  99030. * Please consider using the same method from the MeshBuilder class instead
  99031. * @see http://doc.babylonjs.com/babylon101/height_map
  99032. * @param name defines the name of the mesh to create
  99033. * @param url sets the URL of the height map image resource
  99034. * @param width set the ground width size
  99035. * @param height set the ground height size
  99036. * @param subdivisions sets the number of subdivision per side
  99037. * @param minHeight is the minimum altitude on the ground
  99038. * @param maxHeight is the maximum altitude on the ground
  99039. * @param scene defines the hosting scene
  99040. * @param updatable defines if the mesh must be flagged as updatable
  99041. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  99042. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99043. * @returns a new Mesh
  99044. */
  99045. 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;
  99046. /**
  99047. * Creates a tube mesh.
  99048. * The tube is a parametric shape.
  99049. * It has no predefined shape. Its final shape will depend on the input parameters.
  99050. * Please consider using the same method from the MeshBuilder class instead
  99051. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99052. * @param name defines the name of the mesh to create
  99053. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  99054. * @param radius sets the tube radius size
  99055. * @param tessellation is the number of sides on the tubular surface
  99056. * @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
  99057. * @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
  99058. * @param scene defines the hosting scene
  99059. * @param updatable defines if the mesh must be flagged as updatable
  99060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99061. * @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)
  99062. * @returns a new Mesh
  99063. */
  99064. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  99065. (i: number, distance: number): number;
  99066. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99067. /**
  99068. * Creates a polyhedron mesh.
  99069. * Please consider using the same method from the MeshBuilder class instead.
  99070. * * 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
  99071. * * The parameter `size` (positive float, default 1) sets the polygon size
  99072. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99073. * * 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`
  99074. * * 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
  99075. * * 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)`)
  99076. * * 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
  99077. * * 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
  99078. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99079. * * If you create a double-sided mesh, you can choose what parts of 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
  99080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99081. * @param name defines the name of the mesh to create
  99082. * @param options defines the options used to create the mesh
  99083. * @param scene defines the hosting scene
  99084. * @returns a new Mesh
  99085. */
  99086. static CreatePolyhedron(name: string, options: {
  99087. type?: number;
  99088. size?: number;
  99089. sizeX?: number;
  99090. sizeY?: number;
  99091. sizeZ?: number;
  99092. custom?: any;
  99093. faceUV?: Vector4[];
  99094. faceColors?: Color4[];
  99095. updatable?: boolean;
  99096. sideOrientation?: number;
  99097. }, scene: Scene): Mesh;
  99098. /**
  99099. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  99100. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  99101. * * 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`)
  99102. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  99103. * * 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
  99104. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99105. * * If you create a double-sided mesh, you can choose what parts of 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
  99106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99107. * @param name defines the name of the mesh
  99108. * @param options defines the options used to create the mesh
  99109. * @param scene defines the hosting scene
  99110. * @returns a new Mesh
  99111. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99112. */
  99113. static CreateIcoSphere(name: string, options: {
  99114. radius?: number;
  99115. flat?: boolean;
  99116. subdivisions?: number;
  99117. sideOrientation?: number;
  99118. updatable?: boolean;
  99119. }, scene: Scene): Mesh;
  99120. /**
  99121. * Creates a decal mesh.
  99122. * Please consider using the same method from the MeshBuilder class instead.
  99123. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99124. * @param name defines the name of the mesh
  99125. * @param sourceMesh defines the mesh receiving the decal
  99126. * @param position sets the position of the decal in world coordinates
  99127. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99128. * @param size sets the decal scaling
  99129. * @param angle sets the angle to rotate the decal
  99130. * @returns a new Mesh
  99131. */
  99132. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99133. /**
  99134. * Prepare internal position array for software CPU skinning
  99135. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99136. */
  99137. setPositionsForCPUSkinning(): Float32Array;
  99138. /**
  99139. * Prepare internal normal array for software CPU skinning
  99140. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99141. */
  99142. setNormalsForCPUSkinning(): Float32Array;
  99143. /**
  99144. * Updates the vertex buffer by applying transformation from the bones
  99145. * @param skeleton defines the skeleton to apply to current mesh
  99146. * @returns the current mesh
  99147. */
  99148. applySkeleton(skeleton: Skeleton): Mesh;
  99149. /**
  99150. * 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
  99151. * @param meshes defines the list of meshes to scan
  99152. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99153. */
  99154. static MinMax(meshes: AbstractMesh[]): {
  99155. min: Vector3;
  99156. max: Vector3;
  99157. };
  99158. /**
  99159. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99160. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99161. * @returns a vector3
  99162. */
  99163. static Center(meshesOrMinMaxVector: {
  99164. min: Vector3;
  99165. max: Vector3;
  99166. } | AbstractMesh[]): Vector3;
  99167. /**
  99168. * Merge the array of meshes into a single mesh for performance reasons.
  99169. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99170. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99171. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99172. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99173. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99174. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99175. * @returns a new mesh
  99176. */
  99177. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99178. /** @hidden */
  99179. addInstance(instance: InstancedMesh): void;
  99180. /** @hidden */
  99181. removeInstance(instance: InstancedMesh): void;
  99182. }
  99183. }
  99184. declare module BABYLON {
  99185. /**
  99186. * This is the base class of all the camera used in the application.
  99187. * @see http://doc.babylonjs.com/features/cameras
  99188. */
  99189. export class Camera extends Node {
  99190. /** @hidden */
  99191. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99192. /**
  99193. * This is the default projection mode used by the cameras.
  99194. * It helps recreating a feeling of perspective and better appreciate depth.
  99195. * This is the best way to simulate real life cameras.
  99196. */
  99197. static readonly PERSPECTIVE_CAMERA: number;
  99198. /**
  99199. * This helps creating camera with an orthographic mode.
  99200. * 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.
  99201. */
  99202. static readonly ORTHOGRAPHIC_CAMERA: number;
  99203. /**
  99204. * This is the default FOV mode for perspective cameras.
  99205. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99206. */
  99207. static readonly FOVMODE_VERTICAL_FIXED: number;
  99208. /**
  99209. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99210. */
  99211. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99212. /**
  99213. * This specifies ther is no need for a camera rig.
  99214. * Basically only one eye is rendered corresponding to the camera.
  99215. */
  99216. static readonly RIG_MODE_NONE: number;
  99217. /**
  99218. * Simulates a camera Rig with one blue eye and one red eye.
  99219. * This can be use with 3d blue and red glasses.
  99220. */
  99221. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99222. /**
  99223. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99224. */
  99225. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99226. /**
  99227. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99228. */
  99229. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99230. /**
  99231. * Defines that both eyes of the camera will be rendered over under each other.
  99232. */
  99233. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99234. /**
  99235. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99236. */
  99237. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99238. /**
  99239. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99240. */
  99241. static readonly RIG_MODE_VR: number;
  99242. /**
  99243. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99244. */
  99245. static readonly RIG_MODE_WEBVR: number;
  99246. /**
  99247. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99248. */
  99249. static readonly RIG_MODE_CUSTOM: number;
  99250. /**
  99251. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99252. */
  99253. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99254. /**
  99255. * Define the input manager associated with the camera.
  99256. */
  99257. inputs: CameraInputsManager<Camera>;
  99258. /** @hidden */
  99259. _position: Vector3;
  99260. /**
  99261. * Define the current local position of the camera in the scene
  99262. */
  99263. get position(): Vector3;
  99264. set position(newPosition: Vector3);
  99265. /**
  99266. * The vector the camera should consider as up.
  99267. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99268. */
  99269. upVector: Vector3;
  99270. /**
  99271. * Define the current limit on the left side for an orthographic camera
  99272. * In scene unit
  99273. */
  99274. orthoLeft: Nullable<number>;
  99275. /**
  99276. * Define the current limit on the right side for an orthographic camera
  99277. * In scene unit
  99278. */
  99279. orthoRight: Nullable<number>;
  99280. /**
  99281. * Define the current limit on the bottom side for an orthographic camera
  99282. * In scene unit
  99283. */
  99284. orthoBottom: Nullable<number>;
  99285. /**
  99286. * Define the current limit on the top side for an orthographic camera
  99287. * In scene unit
  99288. */
  99289. orthoTop: Nullable<number>;
  99290. /**
  99291. * Field Of View is set in Radians. (default is 0.8)
  99292. */
  99293. fov: number;
  99294. /**
  99295. * Define the minimum distance the camera can see from.
  99296. * This is important to note that the depth buffer are not infinite and the closer it starts
  99297. * the more your scene might encounter depth fighting issue.
  99298. */
  99299. minZ: number;
  99300. /**
  99301. * Define the maximum distance the camera can see to.
  99302. * This is important to note that the depth buffer are not infinite and the further it end
  99303. * the more your scene might encounter depth fighting issue.
  99304. */
  99305. maxZ: number;
  99306. /**
  99307. * Define the default inertia of the camera.
  99308. * This helps giving a smooth feeling to the camera movement.
  99309. */
  99310. inertia: number;
  99311. /**
  99312. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  99313. */
  99314. mode: number;
  99315. /**
  99316. * Define whether the camera is intermediate.
  99317. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  99318. */
  99319. isIntermediate: boolean;
  99320. /**
  99321. * Define the viewport of the camera.
  99322. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  99323. */
  99324. viewport: Viewport;
  99325. /**
  99326. * Restricts the camera to viewing objects with the same layerMask.
  99327. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  99328. */
  99329. layerMask: number;
  99330. /**
  99331. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  99332. */
  99333. fovMode: number;
  99334. /**
  99335. * Rig mode of the camera.
  99336. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  99337. * This is normally controlled byt the camera themselves as internal use.
  99338. */
  99339. cameraRigMode: number;
  99340. /**
  99341. * Defines the distance between both "eyes" in case of a RIG
  99342. */
  99343. interaxialDistance: number;
  99344. /**
  99345. * Defines if stereoscopic rendering is done side by side or over under.
  99346. */
  99347. isStereoscopicSideBySide: boolean;
  99348. /**
  99349. * 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
  99350. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  99351. * else in the scene. (Eg. security camera)
  99352. *
  99353. * 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)
  99354. */
  99355. customRenderTargets: RenderTargetTexture[];
  99356. /**
  99357. * When set, the camera will render to this render target instead of the default canvas
  99358. *
  99359. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  99360. */
  99361. outputRenderTarget: Nullable<RenderTargetTexture>;
  99362. /**
  99363. * Observable triggered when the camera view matrix has changed.
  99364. */
  99365. onViewMatrixChangedObservable: Observable<Camera>;
  99366. /**
  99367. * Observable triggered when the camera Projection matrix has changed.
  99368. */
  99369. onProjectionMatrixChangedObservable: Observable<Camera>;
  99370. /**
  99371. * Observable triggered when the inputs have been processed.
  99372. */
  99373. onAfterCheckInputsObservable: Observable<Camera>;
  99374. /**
  99375. * Observable triggered when reset has been called and applied to the camera.
  99376. */
  99377. onRestoreStateObservable: Observable<Camera>;
  99378. /**
  99379. * Is this camera a part of a rig system?
  99380. */
  99381. isRigCamera: boolean;
  99382. /**
  99383. * If isRigCamera set to true this will be set with the parent camera.
  99384. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  99385. */
  99386. rigParent?: Camera;
  99387. /** @hidden */
  99388. _cameraRigParams: any;
  99389. /** @hidden */
  99390. _rigCameras: Camera[];
  99391. /** @hidden */
  99392. _rigPostProcess: Nullable<PostProcess>;
  99393. protected _webvrViewMatrix: Matrix;
  99394. /** @hidden */
  99395. _skipRendering: boolean;
  99396. /** @hidden */
  99397. _projectionMatrix: Matrix;
  99398. /** @hidden */
  99399. _postProcesses: Nullable<PostProcess>[];
  99400. /** @hidden */
  99401. _activeMeshes: SmartArray<AbstractMesh>;
  99402. protected _globalPosition: Vector3;
  99403. /** @hidden */
  99404. _computedViewMatrix: Matrix;
  99405. private _doNotComputeProjectionMatrix;
  99406. private _transformMatrix;
  99407. private _frustumPlanes;
  99408. private _refreshFrustumPlanes;
  99409. private _storedFov;
  99410. private _stateStored;
  99411. /**
  99412. * Instantiates a new camera object.
  99413. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  99414. * @see http://doc.babylonjs.com/features/cameras
  99415. * @param name Defines the name of the camera in the scene
  99416. * @param position Defines the position of the camera
  99417. * @param scene Defines the scene the camera belongs too
  99418. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  99419. */
  99420. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99421. /**
  99422. * Store current camera state (fov, position, etc..)
  99423. * @returns the camera
  99424. */
  99425. storeState(): Camera;
  99426. /**
  99427. * Restores the camera state values if it has been stored. You must call storeState() first
  99428. */
  99429. protected _restoreStateValues(): boolean;
  99430. /**
  99431. * Restored camera state. You must call storeState() first.
  99432. * @returns true if restored and false otherwise
  99433. */
  99434. restoreState(): boolean;
  99435. /**
  99436. * Gets the class name of the camera.
  99437. * @returns the class name
  99438. */
  99439. getClassName(): string;
  99440. /** @hidden */
  99441. readonly _isCamera: boolean;
  99442. /**
  99443. * Gets a string representation of the camera useful for debug purpose.
  99444. * @param fullDetails Defines that a more verboe level of logging is required
  99445. * @returns the string representation
  99446. */
  99447. toString(fullDetails?: boolean): string;
  99448. /**
  99449. * Gets the current world space position of the camera.
  99450. */
  99451. get globalPosition(): Vector3;
  99452. /**
  99453. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  99454. * @returns the active meshe list
  99455. */
  99456. getActiveMeshes(): SmartArray<AbstractMesh>;
  99457. /**
  99458. * Check whether a mesh is part of the current active mesh list of the camera
  99459. * @param mesh Defines the mesh to check
  99460. * @returns true if active, false otherwise
  99461. */
  99462. isActiveMesh(mesh: Mesh): boolean;
  99463. /**
  99464. * Is this camera ready to be used/rendered
  99465. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  99466. * @return true if the camera is ready
  99467. */
  99468. isReady(completeCheck?: boolean): boolean;
  99469. /** @hidden */
  99470. _initCache(): void;
  99471. /** @hidden */
  99472. _updateCache(ignoreParentClass?: boolean): void;
  99473. /** @hidden */
  99474. _isSynchronized(): boolean;
  99475. /** @hidden */
  99476. _isSynchronizedViewMatrix(): boolean;
  99477. /** @hidden */
  99478. _isSynchronizedProjectionMatrix(): boolean;
  99479. /**
  99480. * Attach the input controls to a specific dom element to get the input from.
  99481. * @param element Defines the element the controls should be listened from
  99482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99483. */
  99484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99485. /**
  99486. * Detach the current controls from the specified dom element.
  99487. * @param element Defines the element to stop listening the inputs from
  99488. */
  99489. detachControl(element: HTMLElement): void;
  99490. /**
  99491. * Update the camera state according to the different inputs gathered during the frame.
  99492. */
  99493. update(): void;
  99494. /** @hidden */
  99495. _checkInputs(): void;
  99496. /** @hidden */
  99497. get rigCameras(): Camera[];
  99498. /**
  99499. * Gets the post process used by the rig cameras
  99500. */
  99501. get rigPostProcess(): Nullable<PostProcess>;
  99502. /**
  99503. * Internal, gets the first post proces.
  99504. * @returns the first post process to be run on this camera.
  99505. */
  99506. _getFirstPostProcess(): Nullable<PostProcess>;
  99507. private _cascadePostProcessesToRigCams;
  99508. /**
  99509. * Attach a post process to the camera.
  99510. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99511. * @param postProcess The post process to attach to the camera
  99512. * @param insertAt The position of the post process in case several of them are in use in the scene
  99513. * @returns the position the post process has been inserted at
  99514. */
  99515. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99516. /**
  99517. * Detach a post process to the camera.
  99518. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99519. * @param postProcess The post process to detach from the camera
  99520. */
  99521. detachPostProcess(postProcess: PostProcess): void;
  99522. /**
  99523. * Gets the current world matrix of the camera
  99524. */
  99525. getWorldMatrix(): Matrix;
  99526. /** @hidden */
  99527. _getViewMatrix(): Matrix;
  99528. /**
  99529. * Gets the current view matrix of the camera.
  99530. * @param force forces the camera to recompute the matrix without looking at the cached state
  99531. * @returns the view matrix
  99532. */
  99533. getViewMatrix(force?: boolean): Matrix;
  99534. /**
  99535. * Freeze the projection matrix.
  99536. * It will prevent the cache check of the camera projection compute and can speed up perf
  99537. * if no parameter of the camera are meant to change
  99538. * @param projection Defines manually a projection if necessary
  99539. */
  99540. freezeProjectionMatrix(projection?: Matrix): void;
  99541. /**
  99542. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99543. */
  99544. unfreezeProjectionMatrix(): void;
  99545. /**
  99546. * Gets the current projection matrix of the camera.
  99547. * @param force forces the camera to recompute the matrix without looking at the cached state
  99548. * @returns the projection matrix
  99549. */
  99550. getProjectionMatrix(force?: boolean): Matrix;
  99551. /**
  99552. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99553. * @returns a Matrix
  99554. */
  99555. getTransformationMatrix(): Matrix;
  99556. private _updateFrustumPlanes;
  99557. /**
  99558. * Checks if a cullable object (mesh...) is in the camera frustum
  99559. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99560. * @param target The object to check
  99561. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99562. * @returns true if the object is in frustum otherwise false
  99563. */
  99564. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99565. /**
  99566. * Checks if a cullable object (mesh...) is in the camera frustum
  99567. * Unlike isInFrustum this cheks the full bounding box
  99568. * @param target The object to check
  99569. * @returns true if the object is in frustum otherwise false
  99570. */
  99571. isCompletelyInFrustum(target: ICullable): boolean;
  99572. /**
  99573. * Gets a ray in the forward direction from the camera.
  99574. * @param length Defines the length of the ray to create
  99575. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99576. * @param origin Defines the start point of the ray which defaults to the camera position
  99577. * @returns the forward ray
  99578. */
  99579. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99580. /**
  99581. * Releases resources associated with this node.
  99582. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99583. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99584. */
  99585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99586. /** @hidden */
  99587. _isLeftCamera: boolean;
  99588. /**
  99589. * Gets the left camera of a rig setup in case of Rigged Camera
  99590. */
  99591. get isLeftCamera(): boolean;
  99592. /** @hidden */
  99593. _isRightCamera: boolean;
  99594. /**
  99595. * Gets the right camera of a rig setup in case of Rigged Camera
  99596. */
  99597. get isRightCamera(): boolean;
  99598. /**
  99599. * Gets the left camera of a rig setup in case of Rigged Camera
  99600. */
  99601. get leftCamera(): Nullable<FreeCamera>;
  99602. /**
  99603. * Gets the right camera of a rig setup in case of Rigged Camera
  99604. */
  99605. get rightCamera(): Nullable<FreeCamera>;
  99606. /**
  99607. * Gets the left camera target of a rig setup in case of Rigged Camera
  99608. * @returns the target position
  99609. */
  99610. getLeftTarget(): Nullable<Vector3>;
  99611. /**
  99612. * Gets the right camera target of a rig setup in case of Rigged Camera
  99613. * @returns the target position
  99614. */
  99615. getRightTarget(): Nullable<Vector3>;
  99616. /**
  99617. * @hidden
  99618. */
  99619. setCameraRigMode(mode: number, rigParams: any): void;
  99620. /** @hidden */
  99621. static _setStereoscopicRigMode(camera: Camera): void;
  99622. /** @hidden */
  99623. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99624. /** @hidden */
  99625. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99626. /** @hidden */
  99627. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99628. /** @hidden */
  99629. _getVRProjectionMatrix(): Matrix;
  99630. protected _updateCameraRotationMatrix(): void;
  99631. protected _updateWebVRCameraRotationMatrix(): void;
  99632. /**
  99633. * This function MUST be overwritten by the different WebVR cameras available.
  99634. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99635. * @hidden
  99636. */
  99637. _getWebVRProjectionMatrix(): Matrix;
  99638. /**
  99639. * This function MUST be overwritten by the different WebVR cameras available.
  99640. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99641. * @hidden
  99642. */
  99643. _getWebVRViewMatrix(): Matrix;
  99644. /** @hidden */
  99645. setCameraRigParameter(name: string, value: any): void;
  99646. /**
  99647. * needs to be overridden by children so sub has required properties to be copied
  99648. * @hidden
  99649. */
  99650. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99651. /**
  99652. * May need to be overridden by children
  99653. * @hidden
  99654. */
  99655. _updateRigCameras(): void;
  99656. /** @hidden */
  99657. _setupInputs(): void;
  99658. /**
  99659. * Serialiaze the camera setup to a json represention
  99660. * @returns the JSON representation
  99661. */
  99662. serialize(): any;
  99663. /**
  99664. * Clones the current camera.
  99665. * @param name The cloned camera name
  99666. * @returns the cloned camera
  99667. */
  99668. clone(name: string): Camera;
  99669. /**
  99670. * Gets the direction of the camera relative to a given local axis.
  99671. * @param localAxis Defines the reference axis to provide a relative direction.
  99672. * @return the direction
  99673. */
  99674. getDirection(localAxis: Vector3): Vector3;
  99675. /**
  99676. * Returns the current camera absolute rotation
  99677. */
  99678. get absoluteRotation(): Quaternion;
  99679. /**
  99680. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99681. * @param localAxis Defines the reference axis to provide a relative direction.
  99682. * @param result Defines the vector to store the result in
  99683. */
  99684. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99685. /**
  99686. * Gets a camera constructor for a given camera type
  99687. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99688. * @param name The name of the camera the result will be able to instantiate
  99689. * @param scene The scene the result will construct the camera in
  99690. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99691. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99692. * @returns a factory method to construc the camera
  99693. */
  99694. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99695. /**
  99696. * Compute the world matrix of the camera.
  99697. * @returns the camera world matrix
  99698. */
  99699. computeWorldMatrix(): Matrix;
  99700. /**
  99701. * Parse a JSON and creates the camera from the parsed information
  99702. * @param parsedCamera The JSON to parse
  99703. * @param scene The scene to instantiate the camera in
  99704. * @returns the newly constructed camera
  99705. */
  99706. static Parse(parsedCamera: any, scene: Scene): Camera;
  99707. }
  99708. }
  99709. declare module BABYLON {
  99710. /**
  99711. * Class containing static functions to help procedurally build meshes
  99712. */
  99713. export class DiscBuilder {
  99714. /**
  99715. * Creates a plane polygonal mesh. By default, this is a disc
  99716. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99717. * * 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
  99718. * * 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
  99719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99722. * @param name defines the name of the mesh
  99723. * @param options defines the options used to create the mesh
  99724. * @param scene defines the hosting scene
  99725. * @returns the plane polygonal mesh
  99726. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99727. */
  99728. static CreateDisc(name: string, options: {
  99729. radius?: number;
  99730. tessellation?: number;
  99731. arc?: number;
  99732. updatable?: boolean;
  99733. sideOrientation?: number;
  99734. frontUVs?: Vector4;
  99735. backUVs?: Vector4;
  99736. }, scene?: Nullable<Scene>): Mesh;
  99737. }
  99738. }
  99739. declare module BABYLON {
  99740. /**
  99741. * This represents all the required information to add a fresnel effect on a material:
  99742. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99743. */
  99744. export class FresnelParameters {
  99745. private _isEnabled;
  99746. /**
  99747. * Define if the fresnel effect is enable or not.
  99748. */
  99749. get isEnabled(): boolean;
  99750. set isEnabled(value: boolean);
  99751. /**
  99752. * Define the color used on edges (grazing angle)
  99753. */
  99754. leftColor: Color3;
  99755. /**
  99756. * Define the color used on center
  99757. */
  99758. rightColor: Color3;
  99759. /**
  99760. * Define bias applied to computed fresnel term
  99761. */
  99762. bias: number;
  99763. /**
  99764. * Defined the power exponent applied to fresnel term
  99765. */
  99766. power: number;
  99767. /**
  99768. * Clones the current fresnel and its valuues
  99769. * @returns a clone fresnel configuration
  99770. */
  99771. clone(): FresnelParameters;
  99772. /**
  99773. * Serializes the current fresnel parameters to a JSON representation.
  99774. * @return the JSON serialization
  99775. */
  99776. serialize(): any;
  99777. /**
  99778. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99779. * @param parsedFresnelParameters Define the JSON representation
  99780. * @returns the parsed parameters
  99781. */
  99782. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99783. }
  99784. }
  99785. declare module BABYLON {
  99786. /**
  99787. * Base class of materials working in push mode in babylon JS
  99788. * @hidden
  99789. */
  99790. export class PushMaterial extends Material {
  99791. protected _activeEffect: Effect;
  99792. protected _normalMatrix: Matrix;
  99793. /**
  99794. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99795. * This means that the material can keep using a previous shader while a new one is being compiled.
  99796. * This is mostly used when shader parallel compilation is supported (true by default)
  99797. */
  99798. allowShaderHotSwapping: boolean;
  99799. constructor(name: string, scene: Scene);
  99800. getEffect(): Effect;
  99801. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99802. /**
  99803. * Binds the given world matrix to the active effect
  99804. *
  99805. * @param world the matrix to bind
  99806. */
  99807. bindOnlyWorldMatrix(world: Matrix): void;
  99808. /**
  99809. * Binds the given normal matrix to the active effect
  99810. *
  99811. * @param normalMatrix the matrix to bind
  99812. */
  99813. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99814. bind(world: Matrix, mesh?: Mesh): void;
  99815. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99816. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99817. }
  99818. }
  99819. declare module BABYLON {
  99820. /**
  99821. * This groups all the flags used to control the materials channel.
  99822. */
  99823. export class MaterialFlags {
  99824. private static _DiffuseTextureEnabled;
  99825. /**
  99826. * Are diffuse textures enabled in the application.
  99827. */
  99828. static get DiffuseTextureEnabled(): boolean;
  99829. static set DiffuseTextureEnabled(value: boolean);
  99830. private static _AmbientTextureEnabled;
  99831. /**
  99832. * Are ambient textures enabled in the application.
  99833. */
  99834. static get AmbientTextureEnabled(): boolean;
  99835. static set AmbientTextureEnabled(value: boolean);
  99836. private static _OpacityTextureEnabled;
  99837. /**
  99838. * Are opacity textures enabled in the application.
  99839. */
  99840. static get OpacityTextureEnabled(): boolean;
  99841. static set OpacityTextureEnabled(value: boolean);
  99842. private static _ReflectionTextureEnabled;
  99843. /**
  99844. * Are reflection textures enabled in the application.
  99845. */
  99846. static get ReflectionTextureEnabled(): boolean;
  99847. static set ReflectionTextureEnabled(value: boolean);
  99848. private static _EmissiveTextureEnabled;
  99849. /**
  99850. * Are emissive textures enabled in the application.
  99851. */
  99852. static get EmissiveTextureEnabled(): boolean;
  99853. static set EmissiveTextureEnabled(value: boolean);
  99854. private static _SpecularTextureEnabled;
  99855. /**
  99856. * Are specular textures enabled in the application.
  99857. */
  99858. static get SpecularTextureEnabled(): boolean;
  99859. static set SpecularTextureEnabled(value: boolean);
  99860. private static _BumpTextureEnabled;
  99861. /**
  99862. * Are bump textures enabled in the application.
  99863. */
  99864. static get BumpTextureEnabled(): boolean;
  99865. static set BumpTextureEnabled(value: boolean);
  99866. private static _LightmapTextureEnabled;
  99867. /**
  99868. * Are lightmap textures enabled in the application.
  99869. */
  99870. static get LightmapTextureEnabled(): boolean;
  99871. static set LightmapTextureEnabled(value: boolean);
  99872. private static _RefractionTextureEnabled;
  99873. /**
  99874. * Are refraction textures enabled in the application.
  99875. */
  99876. static get RefractionTextureEnabled(): boolean;
  99877. static set RefractionTextureEnabled(value: boolean);
  99878. private static _ColorGradingTextureEnabled;
  99879. /**
  99880. * Are color grading textures enabled in the application.
  99881. */
  99882. static get ColorGradingTextureEnabled(): boolean;
  99883. static set ColorGradingTextureEnabled(value: boolean);
  99884. private static _FresnelEnabled;
  99885. /**
  99886. * Are fresnels enabled in the application.
  99887. */
  99888. static get FresnelEnabled(): boolean;
  99889. static set FresnelEnabled(value: boolean);
  99890. private static _ClearCoatTextureEnabled;
  99891. /**
  99892. * Are clear coat textures enabled in the application.
  99893. */
  99894. static get ClearCoatTextureEnabled(): boolean;
  99895. static set ClearCoatTextureEnabled(value: boolean);
  99896. private static _ClearCoatBumpTextureEnabled;
  99897. /**
  99898. * Are clear coat bump textures enabled in the application.
  99899. */
  99900. static get ClearCoatBumpTextureEnabled(): boolean;
  99901. static set ClearCoatBumpTextureEnabled(value: boolean);
  99902. private static _ClearCoatTintTextureEnabled;
  99903. /**
  99904. * Are clear coat tint textures enabled in the application.
  99905. */
  99906. static get ClearCoatTintTextureEnabled(): boolean;
  99907. static set ClearCoatTintTextureEnabled(value: boolean);
  99908. private static _SheenTextureEnabled;
  99909. /**
  99910. * Are sheen textures enabled in the application.
  99911. */
  99912. static get SheenTextureEnabled(): boolean;
  99913. static set SheenTextureEnabled(value: boolean);
  99914. private static _AnisotropicTextureEnabled;
  99915. /**
  99916. * Are anisotropic textures enabled in the application.
  99917. */
  99918. static get AnisotropicTextureEnabled(): boolean;
  99919. static set AnisotropicTextureEnabled(value: boolean);
  99920. private static _ThicknessTextureEnabled;
  99921. /**
  99922. * Are thickness textures enabled in the application.
  99923. */
  99924. static get ThicknessTextureEnabled(): boolean;
  99925. static set ThicknessTextureEnabled(value: boolean);
  99926. }
  99927. }
  99928. declare module BABYLON {
  99929. /** @hidden */
  99930. export var defaultFragmentDeclaration: {
  99931. name: string;
  99932. shader: string;
  99933. };
  99934. }
  99935. declare module BABYLON {
  99936. /** @hidden */
  99937. export var defaultUboDeclaration: {
  99938. name: string;
  99939. shader: string;
  99940. };
  99941. }
  99942. declare module BABYLON {
  99943. /** @hidden */
  99944. export var lightFragmentDeclaration: {
  99945. name: string;
  99946. shader: string;
  99947. };
  99948. }
  99949. declare module BABYLON {
  99950. /** @hidden */
  99951. export var lightUboDeclaration: {
  99952. name: string;
  99953. shader: string;
  99954. };
  99955. }
  99956. declare module BABYLON {
  99957. /** @hidden */
  99958. export var lightsFragmentFunctions: {
  99959. name: string;
  99960. shader: string;
  99961. };
  99962. }
  99963. declare module BABYLON {
  99964. /** @hidden */
  99965. export var shadowsFragmentFunctions: {
  99966. name: string;
  99967. shader: string;
  99968. };
  99969. }
  99970. declare module BABYLON {
  99971. /** @hidden */
  99972. export var fresnelFunction: {
  99973. name: string;
  99974. shader: string;
  99975. };
  99976. }
  99977. declare module BABYLON {
  99978. /** @hidden */
  99979. export var reflectionFunction: {
  99980. name: string;
  99981. shader: string;
  99982. };
  99983. }
  99984. declare module BABYLON {
  99985. /** @hidden */
  99986. export var bumpFragmentFunctions: {
  99987. name: string;
  99988. shader: string;
  99989. };
  99990. }
  99991. declare module BABYLON {
  99992. /** @hidden */
  99993. export var logDepthDeclaration: {
  99994. name: string;
  99995. shader: string;
  99996. };
  99997. }
  99998. declare module BABYLON {
  99999. /** @hidden */
  100000. export var bumpFragment: {
  100001. name: string;
  100002. shader: string;
  100003. };
  100004. }
  100005. declare module BABYLON {
  100006. /** @hidden */
  100007. export var depthPrePass: {
  100008. name: string;
  100009. shader: string;
  100010. };
  100011. }
  100012. declare module BABYLON {
  100013. /** @hidden */
  100014. export var lightFragment: {
  100015. name: string;
  100016. shader: string;
  100017. };
  100018. }
  100019. declare module BABYLON {
  100020. /** @hidden */
  100021. export var logDepthFragment: {
  100022. name: string;
  100023. shader: string;
  100024. };
  100025. }
  100026. declare module BABYLON {
  100027. /** @hidden */
  100028. export var defaultPixelShader: {
  100029. name: string;
  100030. shader: string;
  100031. };
  100032. }
  100033. declare module BABYLON {
  100034. /** @hidden */
  100035. export var defaultVertexDeclaration: {
  100036. name: string;
  100037. shader: string;
  100038. };
  100039. }
  100040. declare module BABYLON {
  100041. /** @hidden */
  100042. export var bumpVertexDeclaration: {
  100043. name: string;
  100044. shader: string;
  100045. };
  100046. }
  100047. declare module BABYLON {
  100048. /** @hidden */
  100049. export var bumpVertex: {
  100050. name: string;
  100051. shader: string;
  100052. };
  100053. }
  100054. declare module BABYLON {
  100055. /** @hidden */
  100056. export var fogVertex: {
  100057. name: string;
  100058. shader: string;
  100059. };
  100060. }
  100061. declare module BABYLON {
  100062. /** @hidden */
  100063. export var shadowsVertex: {
  100064. name: string;
  100065. shader: string;
  100066. };
  100067. }
  100068. declare module BABYLON {
  100069. /** @hidden */
  100070. export var pointCloudVertex: {
  100071. name: string;
  100072. shader: string;
  100073. };
  100074. }
  100075. declare module BABYLON {
  100076. /** @hidden */
  100077. export var logDepthVertex: {
  100078. name: string;
  100079. shader: string;
  100080. };
  100081. }
  100082. declare module BABYLON {
  100083. /** @hidden */
  100084. export var defaultVertexShader: {
  100085. name: string;
  100086. shader: string;
  100087. };
  100088. }
  100089. declare module BABYLON {
  100090. /** @hidden */
  100091. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100092. MAINUV1: boolean;
  100093. MAINUV2: boolean;
  100094. DIFFUSE: boolean;
  100095. DIFFUSEDIRECTUV: number;
  100096. AMBIENT: boolean;
  100097. AMBIENTDIRECTUV: number;
  100098. OPACITY: boolean;
  100099. OPACITYDIRECTUV: number;
  100100. OPACITYRGB: boolean;
  100101. REFLECTION: boolean;
  100102. EMISSIVE: boolean;
  100103. EMISSIVEDIRECTUV: number;
  100104. SPECULAR: boolean;
  100105. SPECULARDIRECTUV: number;
  100106. BUMP: boolean;
  100107. BUMPDIRECTUV: number;
  100108. PARALLAX: boolean;
  100109. PARALLAXOCCLUSION: boolean;
  100110. SPECULAROVERALPHA: boolean;
  100111. CLIPPLANE: boolean;
  100112. CLIPPLANE2: boolean;
  100113. CLIPPLANE3: boolean;
  100114. CLIPPLANE4: boolean;
  100115. CLIPPLANE5: boolean;
  100116. CLIPPLANE6: boolean;
  100117. ALPHATEST: boolean;
  100118. DEPTHPREPASS: boolean;
  100119. ALPHAFROMDIFFUSE: boolean;
  100120. POINTSIZE: boolean;
  100121. FOG: boolean;
  100122. SPECULARTERM: boolean;
  100123. DIFFUSEFRESNEL: boolean;
  100124. OPACITYFRESNEL: boolean;
  100125. REFLECTIONFRESNEL: boolean;
  100126. REFRACTIONFRESNEL: boolean;
  100127. EMISSIVEFRESNEL: boolean;
  100128. FRESNEL: boolean;
  100129. NORMAL: boolean;
  100130. UV1: boolean;
  100131. UV2: boolean;
  100132. VERTEXCOLOR: boolean;
  100133. VERTEXALPHA: boolean;
  100134. NUM_BONE_INFLUENCERS: number;
  100135. BonesPerMesh: number;
  100136. BONETEXTURE: boolean;
  100137. INSTANCES: boolean;
  100138. GLOSSINESS: boolean;
  100139. ROUGHNESS: boolean;
  100140. EMISSIVEASILLUMINATION: boolean;
  100141. LINKEMISSIVEWITHDIFFUSE: boolean;
  100142. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100143. LIGHTMAP: boolean;
  100144. LIGHTMAPDIRECTUV: number;
  100145. OBJECTSPACE_NORMALMAP: boolean;
  100146. USELIGHTMAPASSHADOWMAP: boolean;
  100147. REFLECTIONMAP_3D: boolean;
  100148. REFLECTIONMAP_SPHERICAL: boolean;
  100149. REFLECTIONMAP_PLANAR: boolean;
  100150. REFLECTIONMAP_CUBIC: boolean;
  100151. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100152. REFLECTIONMAP_PROJECTION: boolean;
  100153. REFLECTIONMAP_SKYBOX: boolean;
  100154. REFLECTIONMAP_EXPLICIT: boolean;
  100155. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100156. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100157. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100158. INVERTCUBICMAP: boolean;
  100159. LOGARITHMICDEPTH: boolean;
  100160. REFRACTION: boolean;
  100161. REFRACTIONMAP_3D: boolean;
  100162. REFLECTIONOVERALPHA: boolean;
  100163. TWOSIDEDLIGHTING: boolean;
  100164. SHADOWFLOAT: boolean;
  100165. MORPHTARGETS: boolean;
  100166. MORPHTARGETS_NORMAL: boolean;
  100167. MORPHTARGETS_TANGENT: boolean;
  100168. MORPHTARGETS_UV: boolean;
  100169. NUM_MORPH_INFLUENCERS: number;
  100170. NONUNIFORMSCALING: boolean;
  100171. PREMULTIPLYALPHA: boolean;
  100172. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100173. ALPHABLEND: boolean;
  100174. IMAGEPROCESSING: boolean;
  100175. VIGNETTE: boolean;
  100176. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100177. VIGNETTEBLENDMODEOPAQUE: boolean;
  100178. TONEMAPPING: boolean;
  100179. TONEMAPPING_ACES: boolean;
  100180. CONTRAST: boolean;
  100181. COLORCURVES: boolean;
  100182. COLORGRADING: boolean;
  100183. COLORGRADING3D: boolean;
  100184. SAMPLER3DGREENDEPTH: boolean;
  100185. SAMPLER3DBGRMAP: boolean;
  100186. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100187. MULTIVIEW: boolean;
  100188. /**
  100189. * If the reflection texture on this material is in linear color space
  100190. * @hidden
  100191. */
  100192. IS_REFLECTION_LINEAR: boolean;
  100193. /**
  100194. * If the refraction texture on this material is in linear color space
  100195. * @hidden
  100196. */
  100197. IS_REFRACTION_LINEAR: boolean;
  100198. EXPOSURE: boolean;
  100199. constructor();
  100200. setReflectionMode(modeToEnable: string): void;
  100201. }
  100202. /**
  100203. * This is the default material used in Babylon. It is the best trade off between quality
  100204. * and performances.
  100205. * @see http://doc.babylonjs.com/babylon101/materials
  100206. */
  100207. export class StandardMaterial extends PushMaterial {
  100208. private _diffuseTexture;
  100209. /**
  100210. * The basic texture of the material as viewed under a light.
  100211. */
  100212. diffuseTexture: Nullable<BaseTexture>;
  100213. private _ambientTexture;
  100214. /**
  100215. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100216. */
  100217. ambientTexture: Nullable<BaseTexture>;
  100218. private _opacityTexture;
  100219. /**
  100220. * Define the transparency of the material from a texture.
  100221. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100222. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100223. */
  100224. opacityTexture: Nullable<BaseTexture>;
  100225. private _reflectionTexture;
  100226. /**
  100227. * Define the texture used to display the reflection.
  100228. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100229. */
  100230. reflectionTexture: Nullable<BaseTexture>;
  100231. private _emissiveTexture;
  100232. /**
  100233. * Define texture of the material as if self lit.
  100234. * This will be mixed in the final result even in the absence of light.
  100235. */
  100236. emissiveTexture: Nullable<BaseTexture>;
  100237. private _specularTexture;
  100238. /**
  100239. * Define how the color and intensity of the highlight given by the light in the material.
  100240. */
  100241. specularTexture: Nullable<BaseTexture>;
  100242. private _bumpTexture;
  100243. /**
  100244. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100245. * 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.
  100246. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  100247. */
  100248. bumpTexture: Nullable<BaseTexture>;
  100249. private _lightmapTexture;
  100250. /**
  100251. * Complex lighting can be computationally expensive to compute at runtime.
  100252. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100253. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  100254. */
  100255. lightmapTexture: Nullable<BaseTexture>;
  100256. private _refractionTexture;
  100257. /**
  100258. * Define the texture used to display the refraction.
  100259. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100260. */
  100261. refractionTexture: Nullable<BaseTexture>;
  100262. /**
  100263. * The color of the material lit by the environmental background lighting.
  100264. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100265. */
  100266. ambientColor: Color3;
  100267. /**
  100268. * The basic color of the material as viewed under a light.
  100269. */
  100270. diffuseColor: Color3;
  100271. /**
  100272. * Define how the color and intensity of the highlight given by the light in the material.
  100273. */
  100274. specularColor: Color3;
  100275. /**
  100276. * Define the color of the material as if self lit.
  100277. * This will be mixed in the final result even in the absence of light.
  100278. */
  100279. emissiveColor: Color3;
  100280. /**
  100281. * Defines how sharp are the highlights in the material.
  100282. * The bigger the value the sharper giving a more glossy feeling to the result.
  100283. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100284. */
  100285. specularPower: number;
  100286. private _useAlphaFromDiffuseTexture;
  100287. /**
  100288. * Does the transparency come from the diffuse texture alpha channel.
  100289. */
  100290. useAlphaFromDiffuseTexture: boolean;
  100291. private _useEmissiveAsIllumination;
  100292. /**
  100293. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100294. */
  100295. useEmissiveAsIllumination: boolean;
  100296. private _linkEmissiveWithDiffuse;
  100297. /**
  100298. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100299. * the emissive level when the final color is close to one.
  100300. */
  100301. linkEmissiveWithDiffuse: boolean;
  100302. private _useSpecularOverAlpha;
  100303. /**
  100304. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100305. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100306. */
  100307. useSpecularOverAlpha: boolean;
  100308. private _useReflectionOverAlpha;
  100309. /**
  100310. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100311. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100312. */
  100313. useReflectionOverAlpha: boolean;
  100314. private _disableLighting;
  100315. /**
  100316. * Does lights from the scene impacts this material.
  100317. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100318. */
  100319. disableLighting: boolean;
  100320. private _useObjectSpaceNormalMap;
  100321. /**
  100322. * Allows using an object space normal map (instead of tangent space).
  100323. */
  100324. useObjectSpaceNormalMap: boolean;
  100325. private _useParallax;
  100326. /**
  100327. * Is parallax enabled or not.
  100328. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100329. */
  100330. useParallax: boolean;
  100331. private _useParallaxOcclusion;
  100332. /**
  100333. * Is parallax occlusion enabled or not.
  100334. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100335. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100336. */
  100337. useParallaxOcclusion: boolean;
  100338. /**
  100339. * 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.
  100340. */
  100341. parallaxScaleBias: number;
  100342. private _roughness;
  100343. /**
  100344. * Helps to define how blurry the reflections should appears in the material.
  100345. */
  100346. roughness: number;
  100347. /**
  100348. * In case of refraction, define the value of the index of refraction.
  100349. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100350. */
  100351. indexOfRefraction: number;
  100352. /**
  100353. * Invert the refraction texture alongside the y axis.
  100354. * It can be useful with procedural textures or probe for instance.
  100355. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100356. */
  100357. invertRefractionY: boolean;
  100358. /**
  100359. * Defines the alpha limits in alpha test mode.
  100360. */
  100361. alphaCutOff: number;
  100362. private _useLightmapAsShadowmap;
  100363. /**
  100364. * In case of light mapping, define whether the map contains light or shadow informations.
  100365. */
  100366. useLightmapAsShadowmap: boolean;
  100367. private _diffuseFresnelParameters;
  100368. /**
  100369. * Define the diffuse fresnel parameters of the material.
  100370. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100371. */
  100372. diffuseFresnelParameters: FresnelParameters;
  100373. private _opacityFresnelParameters;
  100374. /**
  100375. * Define the opacity fresnel parameters of the material.
  100376. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100377. */
  100378. opacityFresnelParameters: FresnelParameters;
  100379. private _reflectionFresnelParameters;
  100380. /**
  100381. * Define the reflection fresnel parameters of the material.
  100382. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100383. */
  100384. reflectionFresnelParameters: FresnelParameters;
  100385. private _refractionFresnelParameters;
  100386. /**
  100387. * Define the refraction fresnel parameters of the material.
  100388. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100389. */
  100390. refractionFresnelParameters: FresnelParameters;
  100391. private _emissiveFresnelParameters;
  100392. /**
  100393. * Define the emissive fresnel parameters of the material.
  100394. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100395. */
  100396. emissiveFresnelParameters: FresnelParameters;
  100397. private _useReflectionFresnelFromSpecular;
  100398. /**
  100399. * If true automatically deducts the fresnels values from the material specularity.
  100400. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100401. */
  100402. useReflectionFresnelFromSpecular: boolean;
  100403. private _useGlossinessFromSpecularMapAlpha;
  100404. /**
  100405. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100406. */
  100407. useGlossinessFromSpecularMapAlpha: boolean;
  100408. private _maxSimultaneousLights;
  100409. /**
  100410. * Defines the maximum number of lights that can be used in the material
  100411. */
  100412. maxSimultaneousLights: number;
  100413. private _invertNormalMapX;
  100414. /**
  100415. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100416. */
  100417. invertNormalMapX: boolean;
  100418. private _invertNormalMapY;
  100419. /**
  100420. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100421. */
  100422. invertNormalMapY: boolean;
  100423. private _twoSidedLighting;
  100424. /**
  100425. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100426. */
  100427. twoSidedLighting: boolean;
  100428. /**
  100429. * Default configuration related to image processing available in the standard Material.
  100430. */
  100431. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100432. /**
  100433. * Gets the image processing configuration used either in this material.
  100434. */
  100435. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100436. /**
  100437. * Sets the Default image processing configuration used either in the this material.
  100438. *
  100439. * If sets to null, the scene one is in use.
  100440. */
  100441. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100442. /**
  100443. * Keep track of the image processing observer to allow dispose and replace.
  100444. */
  100445. private _imageProcessingObserver;
  100446. /**
  100447. * Attaches a new image processing configuration to the Standard Material.
  100448. * @param configuration
  100449. */
  100450. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100451. /**
  100452. * Gets wether the color curves effect is enabled.
  100453. */
  100454. get cameraColorCurvesEnabled(): boolean;
  100455. /**
  100456. * Sets wether the color curves effect is enabled.
  100457. */
  100458. set cameraColorCurvesEnabled(value: boolean);
  100459. /**
  100460. * Gets wether the color grading effect is enabled.
  100461. */
  100462. get cameraColorGradingEnabled(): boolean;
  100463. /**
  100464. * Gets wether the color grading effect is enabled.
  100465. */
  100466. set cameraColorGradingEnabled(value: boolean);
  100467. /**
  100468. * Gets wether tonemapping is enabled or not.
  100469. */
  100470. get cameraToneMappingEnabled(): boolean;
  100471. /**
  100472. * Sets wether tonemapping is enabled or not
  100473. */
  100474. set cameraToneMappingEnabled(value: boolean);
  100475. /**
  100476. * The camera exposure used on this material.
  100477. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100478. * This corresponds to a photographic exposure.
  100479. */
  100480. get cameraExposure(): number;
  100481. /**
  100482. * The camera exposure used on this material.
  100483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100484. * This corresponds to a photographic exposure.
  100485. */
  100486. set cameraExposure(value: number);
  100487. /**
  100488. * Gets The camera contrast used on this material.
  100489. */
  100490. get cameraContrast(): number;
  100491. /**
  100492. * Sets The camera contrast used on this material.
  100493. */
  100494. set cameraContrast(value: number);
  100495. /**
  100496. * Gets the Color Grading 2D Lookup Texture.
  100497. */
  100498. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100499. /**
  100500. * Sets the Color Grading 2D Lookup Texture.
  100501. */
  100502. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100503. /**
  100504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100506. * 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;
  100507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100508. */
  100509. get cameraColorCurves(): Nullable<ColorCurves>;
  100510. /**
  100511. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100512. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100513. * 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;
  100514. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100515. */
  100516. set cameraColorCurves(value: Nullable<ColorCurves>);
  100517. /**
  100518. * Custom callback helping to override the default shader used in the material.
  100519. */
  100520. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100521. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100522. protected _worldViewProjectionMatrix: Matrix;
  100523. protected _globalAmbientColor: Color3;
  100524. protected _useLogarithmicDepth: boolean;
  100525. protected _rebuildInParallel: boolean;
  100526. /**
  100527. * Instantiates a new standard material.
  100528. * This is the default material used in Babylon. It is the best trade off between quality
  100529. * and performances.
  100530. * @see http://doc.babylonjs.com/babylon101/materials
  100531. * @param name Define the name of the material in the scene
  100532. * @param scene Define the scene the material belong to
  100533. */
  100534. constructor(name: string, scene: Scene);
  100535. /**
  100536. * Gets a boolean indicating that current material needs to register RTT
  100537. */
  100538. get hasRenderTargetTextures(): boolean;
  100539. /**
  100540. * Gets the current class name of the material e.g. "StandardMaterial"
  100541. * Mainly use in serialization.
  100542. * @returns the class name
  100543. */
  100544. getClassName(): string;
  100545. /**
  100546. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100547. * You can try switching to logarithmic depth.
  100548. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100549. */
  100550. get useLogarithmicDepth(): boolean;
  100551. set useLogarithmicDepth(value: boolean);
  100552. /**
  100553. * Specifies if the material will require alpha blending
  100554. * @returns a boolean specifying if alpha blending is needed
  100555. */
  100556. needAlphaBlending(): boolean;
  100557. /**
  100558. * Specifies if this material should be rendered in alpha test mode
  100559. * @returns a boolean specifying if an alpha test is needed.
  100560. */
  100561. needAlphaTesting(): boolean;
  100562. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100563. /**
  100564. * Get the texture used for alpha test purpose.
  100565. * @returns the diffuse texture in case of the standard material.
  100566. */
  100567. getAlphaTestTexture(): Nullable<BaseTexture>;
  100568. /**
  100569. * Get if the submesh is ready to be used and all its information available.
  100570. * Child classes can use it to update shaders
  100571. * @param mesh defines the mesh to check
  100572. * @param subMesh defines which submesh to check
  100573. * @param useInstances specifies that instances should be used
  100574. * @returns a boolean indicating that the submesh is ready or not
  100575. */
  100576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100577. /**
  100578. * Builds the material UBO layouts.
  100579. * Used internally during the effect preparation.
  100580. */
  100581. buildUniformLayout(): void;
  100582. /**
  100583. * Unbinds the material from the mesh
  100584. */
  100585. unbind(): void;
  100586. /**
  100587. * Binds the submesh to this material by preparing the effect and shader to draw
  100588. * @param world defines the world transformation matrix
  100589. * @param mesh defines the mesh containing the submesh
  100590. * @param subMesh defines the submesh to bind the material to
  100591. */
  100592. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100593. /**
  100594. * Get the list of animatables in the material.
  100595. * @returns the list of animatables object used in the material
  100596. */
  100597. getAnimatables(): IAnimatable[];
  100598. /**
  100599. * Gets the active textures from the material
  100600. * @returns an array of textures
  100601. */
  100602. getActiveTextures(): BaseTexture[];
  100603. /**
  100604. * Specifies if the material uses a texture
  100605. * @param texture defines the texture to check against the material
  100606. * @returns a boolean specifying if the material uses the texture
  100607. */
  100608. hasTexture(texture: BaseTexture): boolean;
  100609. /**
  100610. * Disposes the material
  100611. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100612. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100613. */
  100614. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100615. /**
  100616. * Makes a duplicate of the material, and gives it a new name
  100617. * @param name defines the new name for the duplicated material
  100618. * @returns the cloned material
  100619. */
  100620. clone(name: string): StandardMaterial;
  100621. /**
  100622. * Serializes this material in a JSON representation
  100623. * @returns the serialized material object
  100624. */
  100625. serialize(): any;
  100626. /**
  100627. * Creates a standard material from parsed material data
  100628. * @param source defines the JSON representation of the material
  100629. * @param scene defines the hosting scene
  100630. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100631. * @returns a new standard material
  100632. */
  100633. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100634. /**
  100635. * Are diffuse textures enabled in the application.
  100636. */
  100637. static get DiffuseTextureEnabled(): boolean;
  100638. static set DiffuseTextureEnabled(value: boolean);
  100639. /**
  100640. * Are ambient textures enabled in the application.
  100641. */
  100642. static get AmbientTextureEnabled(): boolean;
  100643. static set AmbientTextureEnabled(value: boolean);
  100644. /**
  100645. * Are opacity textures enabled in the application.
  100646. */
  100647. static get OpacityTextureEnabled(): boolean;
  100648. static set OpacityTextureEnabled(value: boolean);
  100649. /**
  100650. * Are reflection textures enabled in the application.
  100651. */
  100652. static get ReflectionTextureEnabled(): boolean;
  100653. static set ReflectionTextureEnabled(value: boolean);
  100654. /**
  100655. * Are emissive textures enabled in the application.
  100656. */
  100657. static get EmissiveTextureEnabled(): boolean;
  100658. static set EmissiveTextureEnabled(value: boolean);
  100659. /**
  100660. * Are specular textures enabled in the application.
  100661. */
  100662. static get SpecularTextureEnabled(): boolean;
  100663. static set SpecularTextureEnabled(value: boolean);
  100664. /**
  100665. * Are bump textures enabled in the application.
  100666. */
  100667. static get BumpTextureEnabled(): boolean;
  100668. static set BumpTextureEnabled(value: boolean);
  100669. /**
  100670. * Are lightmap textures enabled in the application.
  100671. */
  100672. static get LightmapTextureEnabled(): boolean;
  100673. static set LightmapTextureEnabled(value: boolean);
  100674. /**
  100675. * Are refraction textures enabled in the application.
  100676. */
  100677. static get RefractionTextureEnabled(): boolean;
  100678. static set RefractionTextureEnabled(value: boolean);
  100679. /**
  100680. * Are color grading textures enabled in the application.
  100681. */
  100682. static get ColorGradingTextureEnabled(): boolean;
  100683. static set ColorGradingTextureEnabled(value: boolean);
  100684. /**
  100685. * Are fresnels enabled in the application.
  100686. */
  100687. static get FresnelEnabled(): boolean;
  100688. static set FresnelEnabled(value: boolean);
  100689. }
  100690. }
  100691. declare module BABYLON {
  100692. /**
  100693. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100694. *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.
  100695. * The SPS is also a particle system. It provides some methods to manage the particles.
  100696. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100697. *
  100698. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100699. */
  100700. export class SolidParticleSystem implements IDisposable {
  100701. /**
  100702. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100703. * Example : var p = SPS.particles[i];
  100704. */
  100705. particles: SolidParticle[];
  100706. /**
  100707. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100708. */
  100709. nbParticles: number;
  100710. /**
  100711. * If the particles must ever face the camera (default false). Useful for planar particles.
  100712. */
  100713. billboard: boolean;
  100714. /**
  100715. * Recompute normals when adding a shape
  100716. */
  100717. recomputeNormals: boolean;
  100718. /**
  100719. * This a counter ofr your own usage. It's not set by any SPS functions.
  100720. */
  100721. counter: number;
  100722. /**
  100723. * The SPS name. This name is also given to the underlying mesh.
  100724. */
  100725. name: string;
  100726. /**
  100727. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100728. */
  100729. mesh: Mesh;
  100730. /**
  100731. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100732. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100733. */
  100734. vars: any;
  100735. /**
  100736. * This array is populated when the SPS is set as 'pickable'.
  100737. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100738. * Each element of this array is an object `{idx: int, faceId: int}`.
  100739. * `idx` is the picked particle index in the `SPS.particles` array
  100740. * `faceId` is the picked face index counted within this particle.
  100741. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  100742. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  100743. * Use the method SPS.pickedParticle(pickingInfo) instead.
  100744. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100745. */
  100746. pickedParticles: {
  100747. idx: number;
  100748. faceId: number;
  100749. }[];
  100750. /**
  100751. * This array is populated when the SPS is set as 'pickable'
  100752. * Each key of this array is a submesh index.
  100753. * Each element of this array is a second array defined like this :
  100754. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  100755. * Each element of this second array is an object `{idx: int, faceId: int}`.
  100756. * `idx` is the picked particle index in the `SPS.particles` array
  100757. * `faceId` is the picked face index counted within this particle.
  100758. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  100759. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100760. */
  100761. pickedBySubMesh: {
  100762. idx: number;
  100763. faceId: number;
  100764. }[][];
  100765. /**
  100766. * This array is populated when `enableDepthSort` is set to true.
  100767. * Each element of this array is an instance of the class DepthSortedParticle.
  100768. */
  100769. depthSortedParticles: DepthSortedParticle[];
  100770. /**
  100771. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100772. * @hidden
  100773. */
  100774. _bSphereOnly: boolean;
  100775. /**
  100776. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100777. * @hidden
  100778. */
  100779. _bSphereRadiusFactor: number;
  100780. private _scene;
  100781. private _positions;
  100782. private _indices;
  100783. private _normals;
  100784. private _colors;
  100785. private _uvs;
  100786. private _indices32;
  100787. private _positions32;
  100788. private _normals32;
  100789. private _fixedNormal32;
  100790. private _colors32;
  100791. private _uvs32;
  100792. private _index;
  100793. private _updatable;
  100794. private _pickable;
  100795. private _isVisibilityBoxLocked;
  100796. private _alwaysVisible;
  100797. private _depthSort;
  100798. private _expandable;
  100799. private _shapeCounter;
  100800. private _copy;
  100801. private _color;
  100802. private _computeParticleColor;
  100803. private _computeParticleTexture;
  100804. private _computeParticleRotation;
  100805. private _computeParticleVertex;
  100806. private _computeBoundingBox;
  100807. private _depthSortParticles;
  100808. private _camera;
  100809. private _mustUnrotateFixedNormals;
  100810. private _particlesIntersect;
  100811. private _needs32Bits;
  100812. private _isNotBuilt;
  100813. private _lastParticleId;
  100814. private _idxOfId;
  100815. private _multimaterialEnabled;
  100816. private _useModelMaterial;
  100817. private _indicesByMaterial;
  100818. private _materialIndexes;
  100819. private _depthSortFunction;
  100820. private _materialSortFunction;
  100821. private _materials;
  100822. private _multimaterial;
  100823. private _materialIndexesById;
  100824. private _defaultMaterial;
  100825. private _autoUpdateSubMeshes;
  100826. /**
  100827. * Creates a SPS (Solid Particle System) object.
  100828. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100829. * @param scene (Scene) is the scene in which the SPS is added.
  100830. * @param options defines the options of the sps e.g.
  100831. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100832. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100833. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100834. * * 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.
  100835. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100836. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100837. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100838. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100839. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100840. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100841. */
  100842. constructor(name: string, scene: Scene, options?: {
  100843. updatable?: boolean;
  100844. isPickable?: boolean;
  100845. enableDepthSort?: boolean;
  100846. particleIntersection?: boolean;
  100847. boundingSphereOnly?: boolean;
  100848. bSphereRadiusFactor?: number;
  100849. expandable?: boolean;
  100850. useModelMaterial?: boolean;
  100851. enableMultiMaterial?: boolean;
  100852. });
  100853. /**
  100854. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100855. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100856. * @returns the created mesh
  100857. */
  100858. buildMesh(): Mesh;
  100859. /**
  100860. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100861. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100862. * Thus the particles generated from `digest()` have their property `position` set yet.
  100863. * @param mesh ( Mesh ) is the mesh to be digested
  100864. * @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
  100865. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100866. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100867. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100868. * @returns the current SPS
  100869. */
  100870. digest(mesh: Mesh, options?: {
  100871. facetNb?: number;
  100872. number?: number;
  100873. delta?: number;
  100874. storage?: [];
  100875. }): SolidParticleSystem;
  100876. /**
  100877. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100878. * @hidden
  100879. */
  100880. private _unrotateFixedNormals;
  100881. /**
  100882. * Resets the temporary working copy particle
  100883. * @hidden
  100884. */
  100885. private _resetCopy;
  100886. /**
  100887. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100888. * @param p the current index in the positions array to be updated
  100889. * @param ind the current index in the indices array
  100890. * @param shape a Vector3 array, the shape geometry
  100891. * @param positions the positions array to be updated
  100892. * @param meshInd the shape indices array
  100893. * @param indices the indices array to be updated
  100894. * @param meshUV the shape uv array
  100895. * @param uvs the uv array to be updated
  100896. * @param meshCol the shape color array
  100897. * @param colors the color array to be updated
  100898. * @param meshNor the shape normals array
  100899. * @param normals the normals array to be updated
  100900. * @param idx the particle index
  100901. * @param idxInShape the particle index in its shape
  100902. * @param options the addShape() method passed options
  100903. * @model the particle model
  100904. * @hidden
  100905. */
  100906. private _meshBuilder;
  100907. /**
  100908. * Returns a shape Vector3 array from positions float array
  100909. * @param positions float array
  100910. * @returns a vector3 array
  100911. * @hidden
  100912. */
  100913. private _posToShape;
  100914. /**
  100915. * Returns a shapeUV array from a float uvs (array deep copy)
  100916. * @param uvs as a float array
  100917. * @returns a shapeUV array
  100918. * @hidden
  100919. */
  100920. private _uvsToShapeUV;
  100921. /**
  100922. * Adds a new particle object in the particles array
  100923. * @param idx particle index in particles array
  100924. * @param id particle id
  100925. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100926. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100927. * @param model particle ModelShape object
  100928. * @param shapeId model shape identifier
  100929. * @param idxInShape index of the particle in the current model
  100930. * @param bInfo model bounding info object
  100931. * @param storage target storage array, if any
  100932. * @hidden
  100933. */
  100934. private _addParticle;
  100935. /**
  100936. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100937. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100938. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100939. * @param nb (positive integer) the number of particles to be created from this model
  100940. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100941. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100942. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100943. * @returns the number of shapes in the system
  100944. */
  100945. addShape(mesh: Mesh, nb: number, options?: {
  100946. positionFunction?: any;
  100947. vertexFunction?: any;
  100948. storage?: [];
  100949. }): number;
  100950. /**
  100951. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100952. * @hidden
  100953. */
  100954. private _rebuildParticle;
  100955. /**
  100956. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100957. * @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.
  100958. * @returns the SPS.
  100959. */
  100960. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100961. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100962. * Returns an array with the removed particles.
  100963. * 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.
  100964. * The SPS can't be empty so at least one particle needs to remain in place.
  100965. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100966. * @param start index of the first particle to remove
  100967. * @param end index of the last particle to remove (included)
  100968. * @returns an array populated with the removed particles
  100969. */
  100970. removeParticles(start: number, end: number): SolidParticle[];
  100971. /**
  100972. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100973. * @param solidParticleArray an array populated with Solid Particles objects
  100974. * @returns the SPS
  100975. */
  100976. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100977. /**
  100978. * Creates a new particle and modifies the SPS mesh geometry :
  100979. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100980. * - calls _addParticle() to populate the particle array
  100981. * factorized code from addShape() and insertParticlesFromArray()
  100982. * @param idx particle index in the particles array
  100983. * @param i particle index in its shape
  100984. * @param modelShape particle ModelShape object
  100985. * @param shape shape vertex array
  100986. * @param meshInd shape indices array
  100987. * @param meshUV shape uv array
  100988. * @param meshCol shape color array
  100989. * @param meshNor shape normals array
  100990. * @param bbInfo shape bounding info
  100991. * @param storage target particle storage
  100992. * @options addShape() passed options
  100993. * @hidden
  100994. */
  100995. private _insertNewParticle;
  100996. /**
  100997. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100998. * This method calls `updateParticle()` for each particle of the SPS.
  100999. * For an animated SPS, it is usually called within the render loop.
  101000. * 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.
  101001. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  101002. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  101003. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  101004. * @returns the SPS.
  101005. */
  101006. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  101007. /**
  101008. * Disposes the SPS.
  101009. */
  101010. dispose(): void;
  101011. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  101012. * idx is the particle index in the SPS
  101013. * faceId is the picked face index counted within this particle.
  101014. * Returns null if the pickInfo can't identify a picked particle.
  101015. * @param pickingInfo (PickingInfo object)
  101016. * @returns {idx: number, faceId: number} or null
  101017. */
  101018. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  101019. idx: number;
  101020. faceId: number;
  101021. }>;
  101022. /**
  101023. * Returns a SolidParticle object from its identifier : particle.id
  101024. * @param id (integer) the particle Id
  101025. * @returns the searched particle or null if not found in the SPS.
  101026. */
  101027. getParticleById(id: number): Nullable<SolidParticle>;
  101028. /**
  101029. * Returns a new array populated with the particles having the passed shapeId.
  101030. * @param shapeId (integer) the shape identifier
  101031. * @returns a new solid particle array
  101032. */
  101033. getParticlesByShapeId(shapeId: number): SolidParticle[];
  101034. /**
  101035. * Populates the passed array "ref" with the particles having the passed shapeId.
  101036. * @param shapeId the shape identifier
  101037. * @returns the SPS
  101038. * @param ref
  101039. */
  101040. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  101041. /**
  101042. * Computes the required SubMeshes according the materials assigned to the particles.
  101043. * @returns the solid particle system.
  101044. * Does nothing if called before the SPS mesh is built.
  101045. */
  101046. computeSubMeshes(): SolidParticleSystem;
  101047. /**
  101048. * Sorts the solid particles by material when MultiMaterial is enabled.
  101049. * Updates the indices32 array.
  101050. * Updates the indicesByMaterial array.
  101051. * Updates the mesh indices array.
  101052. * @returns the SPS
  101053. * @hidden
  101054. */
  101055. private _sortParticlesByMaterial;
  101056. /**
  101057. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  101058. * @hidden
  101059. */
  101060. private _setMaterialIndexesById;
  101061. /**
  101062. * Returns an array with unique values of Materials from the passed array
  101063. * @param array the material array to be checked and filtered
  101064. * @hidden
  101065. */
  101066. private _filterUniqueMaterialId;
  101067. /**
  101068. * Sets a new Standard Material as _defaultMaterial if not already set.
  101069. * @hidden
  101070. */
  101071. private _setDefaultMaterial;
  101072. /**
  101073. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  101074. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101075. * @returns the SPS.
  101076. */
  101077. refreshVisibleSize(): SolidParticleSystem;
  101078. /**
  101079. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  101080. * @param size the size (float) of the visibility box
  101081. * note : this doesn't lock the SPS mesh bounding box.
  101082. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101083. */
  101084. setVisibilityBox(size: number): void;
  101085. /**
  101086. * Gets whether the SPS as always visible or not
  101087. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101088. */
  101089. get isAlwaysVisible(): boolean;
  101090. /**
  101091. * Sets the SPS as always visible or not
  101092. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101093. */
  101094. set isAlwaysVisible(val: boolean);
  101095. /**
  101096. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101097. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101098. */
  101099. set isVisibilityBoxLocked(val: boolean);
  101100. /**
  101101. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101102. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101103. */
  101104. get isVisibilityBoxLocked(): boolean;
  101105. /**
  101106. * Tells to `setParticles()` to compute the particle rotations or not.
  101107. * Default value : true. The SPS is faster when it's set to false.
  101108. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101109. */
  101110. set computeParticleRotation(val: boolean);
  101111. /**
  101112. * Tells to `setParticles()` to compute the particle colors or not.
  101113. * Default value : true. The SPS is faster when it's set to false.
  101114. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101115. */
  101116. set computeParticleColor(val: boolean);
  101117. set computeParticleTexture(val: boolean);
  101118. /**
  101119. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101120. * Default value : false. The SPS is faster when it's set to false.
  101121. * Note : the particle custom vertex positions aren't stored values.
  101122. */
  101123. set computeParticleVertex(val: boolean);
  101124. /**
  101125. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101126. */
  101127. set computeBoundingBox(val: boolean);
  101128. /**
  101129. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101130. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101131. * Default : `true`
  101132. */
  101133. set depthSortParticles(val: boolean);
  101134. /**
  101135. * Gets if `setParticles()` computes the particle rotations or not.
  101136. * Default value : true. The SPS is faster when it's set to false.
  101137. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101138. */
  101139. get computeParticleRotation(): boolean;
  101140. /**
  101141. * Gets if `setParticles()` computes the particle colors or not.
  101142. * Default value : true. The SPS is faster when it's set to false.
  101143. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101144. */
  101145. get computeParticleColor(): boolean;
  101146. /**
  101147. * Gets if `setParticles()` computes the particle textures or not.
  101148. * Default value : true. The SPS is faster when it's set to false.
  101149. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101150. */
  101151. get computeParticleTexture(): boolean;
  101152. /**
  101153. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101154. * Default value : false. The SPS is faster when it's set to false.
  101155. * Note : the particle custom vertex positions aren't stored values.
  101156. */
  101157. get computeParticleVertex(): boolean;
  101158. /**
  101159. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101160. */
  101161. get computeBoundingBox(): boolean;
  101162. /**
  101163. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101164. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101165. * Default : `true`
  101166. */
  101167. get depthSortParticles(): boolean;
  101168. /**
  101169. * Gets if the SPS is created as expandable at construction time.
  101170. * Default : `false`
  101171. */
  101172. get expandable(): boolean;
  101173. /**
  101174. * Gets if the SPS supports the Multi Materials
  101175. */
  101176. get multimaterialEnabled(): boolean;
  101177. /**
  101178. * Gets if the SPS uses the model materials for its own multimaterial.
  101179. */
  101180. get useModelMaterial(): boolean;
  101181. /**
  101182. * The SPS used material array.
  101183. */
  101184. get materials(): Material[];
  101185. /**
  101186. * Sets the SPS MultiMaterial from the passed materials.
  101187. * Note : the passed array is internally copied and not used then by reference.
  101188. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101189. */
  101190. setMultiMaterial(materials: Material[]): void;
  101191. /**
  101192. * The SPS computed multimaterial object
  101193. */
  101194. get multimaterial(): MultiMaterial;
  101195. set multimaterial(mm: MultiMaterial);
  101196. /**
  101197. * If the subMeshes must be updated on the next call to setParticles()
  101198. */
  101199. get autoUpdateSubMeshes(): boolean;
  101200. set autoUpdateSubMeshes(val: boolean);
  101201. /**
  101202. * This function does nothing. It may be overwritten to set all the particle first values.
  101203. * The SPS doesn't call this function, you may have to call it by your own.
  101204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101205. */
  101206. initParticles(): void;
  101207. /**
  101208. * This function does nothing. It may be overwritten to recycle a particle.
  101209. * The SPS doesn't call this function, you may have to call it by your own.
  101210. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101211. * @param particle The particle to recycle
  101212. * @returns the recycled particle
  101213. */
  101214. recycleParticle(particle: SolidParticle): SolidParticle;
  101215. /**
  101216. * Updates a particle : this function should be overwritten by the user.
  101217. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  101218. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101219. * @example : just set a particle position or velocity and recycle conditions
  101220. * @param particle The particle to update
  101221. * @returns the updated particle
  101222. */
  101223. updateParticle(particle: SolidParticle): SolidParticle;
  101224. /**
  101225. * Updates a vertex of a particle : it can be overwritten by the user.
  101226. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  101227. * @param particle the current particle
  101228. * @param vertex the current index of the current particle
  101229. * @param pt the index of the current vertex in the particle shape
  101230. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  101231. * @example : just set a vertex particle position
  101232. * @returns the updated vertex
  101233. */
  101234. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  101235. /**
  101236. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  101237. * This does nothing and may be overwritten by the user.
  101238. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101239. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101240. * @param update the boolean update value actually passed to setParticles()
  101241. */
  101242. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  101243. /**
  101244. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  101245. * This will be passed three parameters.
  101246. * This does nothing and may be overwritten by the user.
  101247. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101248. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101249. * @param update the boolean update value actually passed to setParticles()
  101250. */
  101251. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  101252. }
  101253. }
  101254. declare module BABYLON {
  101255. /**
  101256. * Represents one particle of a solid particle system.
  101257. */
  101258. export class SolidParticle {
  101259. /**
  101260. * particle global index
  101261. */
  101262. idx: number;
  101263. /**
  101264. * particle identifier
  101265. */
  101266. id: number;
  101267. /**
  101268. * The color of the particle
  101269. */
  101270. color: Nullable<Color4>;
  101271. /**
  101272. * The world space position of the particle.
  101273. */
  101274. position: Vector3;
  101275. /**
  101276. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  101277. */
  101278. rotation: Vector3;
  101279. /**
  101280. * The world space rotation quaternion of the particle.
  101281. */
  101282. rotationQuaternion: Nullable<Quaternion>;
  101283. /**
  101284. * The scaling of the particle.
  101285. */
  101286. scaling: Vector3;
  101287. /**
  101288. * The uvs of the particle.
  101289. */
  101290. uvs: Vector4;
  101291. /**
  101292. * The current speed of the particle.
  101293. */
  101294. velocity: Vector3;
  101295. /**
  101296. * The pivot point in the particle local space.
  101297. */
  101298. pivot: Vector3;
  101299. /**
  101300. * Must the particle be translated from its pivot point in its local space ?
  101301. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  101302. * Default : false
  101303. */
  101304. translateFromPivot: boolean;
  101305. /**
  101306. * Is the particle active or not ?
  101307. */
  101308. alive: boolean;
  101309. /**
  101310. * Is the particle visible or not ?
  101311. */
  101312. isVisible: boolean;
  101313. /**
  101314. * Index of this particle in the global "positions" array (Internal use)
  101315. * @hidden
  101316. */
  101317. _pos: number;
  101318. /**
  101319. * @hidden Index of this particle in the global "indices" array (Internal use)
  101320. */
  101321. _ind: number;
  101322. /**
  101323. * @hidden ModelShape of this particle (Internal use)
  101324. */
  101325. _model: ModelShape;
  101326. /**
  101327. * ModelShape id of this particle
  101328. */
  101329. shapeId: number;
  101330. /**
  101331. * Index of the particle in its shape id
  101332. */
  101333. idxInShape: number;
  101334. /**
  101335. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  101336. */
  101337. _modelBoundingInfo: BoundingInfo;
  101338. /**
  101339. * @hidden Particle BoundingInfo object (Internal use)
  101340. */
  101341. _boundingInfo: BoundingInfo;
  101342. /**
  101343. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  101344. */
  101345. _sps: SolidParticleSystem;
  101346. /**
  101347. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  101348. */
  101349. _stillInvisible: boolean;
  101350. /**
  101351. * @hidden Last computed particle rotation matrix
  101352. */
  101353. _rotationMatrix: number[];
  101354. /**
  101355. * Parent particle Id, if any.
  101356. * Default null.
  101357. */
  101358. parentId: Nullable<number>;
  101359. /**
  101360. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  101361. */
  101362. materialIndex: Nullable<number>;
  101363. /**
  101364. * Custom object or properties.
  101365. */
  101366. props: Nullable<any>;
  101367. /**
  101368. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  101369. * The possible values are :
  101370. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101371. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101372. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101373. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101374. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101375. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  101376. * */
  101377. cullingStrategy: number;
  101378. /**
  101379. * @hidden Internal global position in the SPS.
  101380. */
  101381. _globalPosition: Vector3;
  101382. /**
  101383. * Creates a Solid Particle object.
  101384. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  101385. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  101386. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  101387. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  101388. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  101389. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  101390. * @param shapeId (integer) is the model shape identifier in the SPS.
  101391. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  101392. * @param sps defines the sps it is associated to
  101393. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  101394. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  101395. */
  101396. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  101397. /**
  101398. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  101399. * @param target the particle target
  101400. * @returns the current particle
  101401. */
  101402. copyToRef(target: SolidParticle): SolidParticle;
  101403. /**
  101404. * Legacy support, changed scale to scaling
  101405. */
  101406. get scale(): Vector3;
  101407. /**
  101408. * Legacy support, changed scale to scaling
  101409. */
  101410. set scale(scale: Vector3);
  101411. /**
  101412. * Legacy support, changed quaternion to rotationQuaternion
  101413. */
  101414. get quaternion(): Nullable<Quaternion>;
  101415. /**
  101416. * Legacy support, changed quaternion to rotationQuaternion
  101417. */
  101418. set quaternion(q: Nullable<Quaternion>);
  101419. /**
  101420. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  101421. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  101422. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  101423. * @returns true if it intersects
  101424. */
  101425. intersectsMesh(target: Mesh | SolidParticle): boolean;
  101426. /**
  101427. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  101428. * A particle is in the frustum if its bounding box intersects the frustum
  101429. * @param frustumPlanes defines the frustum to test
  101430. * @returns true if the particle is in the frustum planes
  101431. */
  101432. isInFrustum(frustumPlanes: Plane[]): boolean;
  101433. /**
  101434. * get the rotation matrix of the particle
  101435. * @hidden
  101436. */
  101437. getRotationMatrix(m: Matrix): void;
  101438. }
  101439. /**
  101440. * Represents the shape of the model used by one particle of a solid particle system.
  101441. * SPS internal tool, don't use it manually.
  101442. */
  101443. export class ModelShape {
  101444. /**
  101445. * The shape id
  101446. * @hidden
  101447. */
  101448. shapeID: number;
  101449. /**
  101450. * flat array of model positions (internal use)
  101451. * @hidden
  101452. */
  101453. _shape: Vector3[];
  101454. /**
  101455. * flat array of model UVs (internal use)
  101456. * @hidden
  101457. */
  101458. _shapeUV: number[];
  101459. /**
  101460. * color array of the model
  101461. * @hidden
  101462. */
  101463. _shapeColors: number[];
  101464. /**
  101465. * indices array of the model
  101466. * @hidden
  101467. */
  101468. _indices: number[];
  101469. /**
  101470. * normals array of the model
  101471. * @hidden
  101472. */
  101473. _normals: number[];
  101474. /**
  101475. * length of the shape in the model indices array (internal use)
  101476. * @hidden
  101477. */
  101478. _indicesLength: number;
  101479. /**
  101480. * Custom position function (internal use)
  101481. * @hidden
  101482. */
  101483. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  101484. /**
  101485. * Custom vertex function (internal use)
  101486. * @hidden
  101487. */
  101488. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  101489. /**
  101490. * Model material (internal use)
  101491. * @hidden
  101492. */
  101493. _material: Nullable<Material>;
  101494. /**
  101495. * 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.
  101496. * SPS internal tool, don't use it manually.
  101497. * @hidden
  101498. */
  101499. 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>);
  101500. }
  101501. /**
  101502. * Represents a Depth Sorted Particle in the solid particle system.
  101503. * @hidden
  101504. */
  101505. export class DepthSortedParticle {
  101506. /**
  101507. * Particle index
  101508. */
  101509. idx: number;
  101510. /**
  101511. * Index of the particle in the "indices" array
  101512. */
  101513. ind: number;
  101514. /**
  101515. * Length of the particle shape in the "indices" array
  101516. */
  101517. indicesLength: number;
  101518. /**
  101519. * Squared distance from the particle to the camera
  101520. */
  101521. sqDistance: number;
  101522. /**
  101523. * Material index when used with MultiMaterials
  101524. */
  101525. materialIndex: number;
  101526. /**
  101527. * Creates a new sorted particle
  101528. * @param materialIndex
  101529. */
  101530. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  101531. }
  101532. }
  101533. declare module BABYLON {
  101534. /**
  101535. * @hidden
  101536. */
  101537. export class _MeshCollisionData {
  101538. _checkCollisions: boolean;
  101539. _collisionMask: number;
  101540. _collisionGroup: number;
  101541. _collider: Nullable<Collider>;
  101542. _oldPositionForCollisions: Vector3;
  101543. _diffPositionForCollisions: Vector3;
  101544. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101545. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101546. }
  101547. }
  101548. declare module BABYLON {
  101549. /** @hidden */
  101550. class _FacetDataStorage {
  101551. facetPositions: Vector3[];
  101552. facetNormals: Vector3[];
  101553. facetPartitioning: number[][];
  101554. facetNb: number;
  101555. partitioningSubdivisions: number;
  101556. partitioningBBoxRatio: number;
  101557. facetDataEnabled: boolean;
  101558. facetParameters: any;
  101559. bbSize: Vector3;
  101560. subDiv: {
  101561. max: number;
  101562. X: number;
  101563. Y: number;
  101564. Z: number;
  101565. };
  101566. facetDepthSort: boolean;
  101567. facetDepthSortEnabled: boolean;
  101568. depthSortedIndices: IndicesArray;
  101569. depthSortedFacets: {
  101570. ind: number;
  101571. sqDistance: number;
  101572. }[];
  101573. facetDepthSortFunction: (f1: {
  101574. ind: number;
  101575. sqDistance: number;
  101576. }, f2: {
  101577. ind: number;
  101578. sqDistance: number;
  101579. }) => number;
  101580. facetDepthSortFrom: Vector3;
  101581. facetDepthSortOrigin: Vector3;
  101582. invertedMatrix: Matrix;
  101583. }
  101584. /**
  101585. * @hidden
  101586. **/
  101587. class _InternalAbstractMeshDataInfo {
  101588. _hasVertexAlpha: boolean;
  101589. _useVertexColors: boolean;
  101590. _numBoneInfluencers: number;
  101591. _applyFog: boolean;
  101592. _receiveShadows: boolean;
  101593. _facetData: _FacetDataStorage;
  101594. _visibility: number;
  101595. _skeleton: Nullable<Skeleton>;
  101596. _layerMask: number;
  101597. _computeBonesUsingShaders: boolean;
  101598. _isActive: boolean;
  101599. _onlyForInstances: boolean;
  101600. _isActiveIntermediate: boolean;
  101601. _onlyForInstancesIntermediate: boolean;
  101602. _actAsRegularMesh: boolean;
  101603. }
  101604. /**
  101605. * Class used to store all common mesh properties
  101606. */
  101607. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101608. /** No occlusion */
  101609. static OCCLUSION_TYPE_NONE: number;
  101610. /** Occlusion set to optimisitic */
  101611. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101612. /** Occlusion set to strict */
  101613. static OCCLUSION_TYPE_STRICT: number;
  101614. /** Use an accurante occlusion algorithm */
  101615. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101616. /** Use a conservative occlusion algorithm */
  101617. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101618. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101619. * Test order :
  101620. * Is the bounding sphere outside the frustum ?
  101621. * If not, are the bounding box vertices outside the frustum ?
  101622. * It not, then the cullable object is in the frustum.
  101623. */
  101624. static readonly CULLINGSTRATEGY_STANDARD: number;
  101625. /** Culling strategy : Bounding Sphere Only.
  101626. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101627. * It's also less accurate than the standard because some not visible objects can still be selected.
  101628. * Test : is the bounding sphere outside the frustum ?
  101629. * If not, then the cullable object is in the frustum.
  101630. */
  101631. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101632. /** Culling strategy : Optimistic Inclusion.
  101633. * This in an inclusion test first, then the standard exclusion test.
  101634. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101635. * 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.
  101636. * Anyway, it's as accurate as the standard strategy.
  101637. * Test :
  101638. * Is the cullable object bounding sphere center in the frustum ?
  101639. * If not, apply the default culling strategy.
  101640. */
  101641. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101642. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101643. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101644. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101645. * 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.
  101646. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101647. * Test :
  101648. * Is the cullable object bounding sphere center in the frustum ?
  101649. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101650. */
  101651. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101652. /**
  101653. * No billboard
  101654. */
  101655. static get BILLBOARDMODE_NONE(): number;
  101656. /** Billboard on X axis */
  101657. static get BILLBOARDMODE_X(): number;
  101658. /** Billboard on Y axis */
  101659. static get BILLBOARDMODE_Y(): number;
  101660. /** Billboard on Z axis */
  101661. static get BILLBOARDMODE_Z(): number;
  101662. /** Billboard on all axes */
  101663. static get BILLBOARDMODE_ALL(): number;
  101664. /** Billboard on using position instead of orientation */
  101665. static get BILLBOARDMODE_USE_POSITION(): number;
  101666. /** @hidden */
  101667. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101668. /**
  101669. * The culling strategy to use to check whether the mesh must be rendered or not.
  101670. * This value can be changed at any time and will be used on the next render mesh selection.
  101671. * The possible values are :
  101672. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101673. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101674. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101675. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101676. * Please read each static variable documentation to get details about the culling process.
  101677. * */
  101678. cullingStrategy: number;
  101679. /**
  101680. * Gets the number of facets in the mesh
  101681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101682. */
  101683. get facetNb(): number;
  101684. /**
  101685. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101686. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101687. */
  101688. get partitioningSubdivisions(): number;
  101689. set partitioningSubdivisions(nb: number);
  101690. /**
  101691. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101692. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101694. */
  101695. get partitioningBBoxRatio(): number;
  101696. set partitioningBBoxRatio(ratio: number);
  101697. /**
  101698. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101699. * Works only for updatable meshes.
  101700. * Doesn't work with multi-materials
  101701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101702. */
  101703. get mustDepthSortFacets(): boolean;
  101704. set mustDepthSortFacets(sort: boolean);
  101705. /**
  101706. * The location (Vector3) where the facet depth sort must be computed from.
  101707. * By default, the active camera position.
  101708. * Used only when facet depth sort is enabled
  101709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101710. */
  101711. get facetDepthSortFrom(): Vector3;
  101712. set facetDepthSortFrom(location: Vector3);
  101713. /**
  101714. * gets a boolean indicating if facetData is enabled
  101715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101716. */
  101717. get isFacetDataEnabled(): boolean;
  101718. /** @hidden */
  101719. _updateNonUniformScalingState(value: boolean): boolean;
  101720. /**
  101721. * An event triggered when this mesh collides with another one
  101722. */
  101723. onCollideObservable: Observable<AbstractMesh>;
  101724. /** Set a function to call when this mesh collides with another one */
  101725. set onCollide(callback: () => void);
  101726. /**
  101727. * An event triggered when the collision's position changes
  101728. */
  101729. onCollisionPositionChangeObservable: Observable<Vector3>;
  101730. /** Set a function to call when the collision's position changes */
  101731. set onCollisionPositionChange(callback: () => void);
  101732. /**
  101733. * An event triggered when material is changed
  101734. */
  101735. onMaterialChangedObservable: Observable<AbstractMesh>;
  101736. /**
  101737. * Gets or sets the orientation for POV movement & rotation
  101738. */
  101739. definedFacingForward: boolean;
  101740. /** @hidden */
  101741. _occlusionQuery: Nullable<WebGLQuery>;
  101742. /** @hidden */
  101743. _renderingGroup: Nullable<RenderingGroup>;
  101744. /**
  101745. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101746. */
  101747. get visibility(): number;
  101748. /**
  101749. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101750. */
  101751. set visibility(value: number);
  101752. /** Gets or sets the alpha index used to sort transparent meshes
  101753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101754. */
  101755. alphaIndex: number;
  101756. /**
  101757. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101758. */
  101759. isVisible: boolean;
  101760. /**
  101761. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101762. */
  101763. isPickable: boolean;
  101764. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101765. showSubMeshesBoundingBox: boolean;
  101766. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101767. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101768. */
  101769. isBlocker: boolean;
  101770. /**
  101771. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101772. */
  101773. enablePointerMoveEvents: boolean;
  101774. /**
  101775. * Specifies the rendering group id for this mesh (0 by default)
  101776. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101777. */
  101778. renderingGroupId: number;
  101779. private _material;
  101780. /** Gets or sets current material */
  101781. get material(): Nullable<Material>;
  101782. set material(value: Nullable<Material>);
  101783. /**
  101784. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101785. * @see http://doc.babylonjs.com/babylon101/shadows
  101786. */
  101787. get receiveShadows(): boolean;
  101788. set receiveShadows(value: boolean);
  101789. /** Defines color to use when rendering outline */
  101790. outlineColor: Color3;
  101791. /** Define width to use when rendering outline */
  101792. outlineWidth: number;
  101793. /** Defines color to use when rendering overlay */
  101794. overlayColor: Color3;
  101795. /** Defines alpha to use when rendering overlay */
  101796. overlayAlpha: number;
  101797. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101798. get hasVertexAlpha(): boolean;
  101799. set hasVertexAlpha(value: boolean);
  101800. /** 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) */
  101801. get useVertexColors(): boolean;
  101802. set useVertexColors(value: boolean);
  101803. /**
  101804. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101805. */
  101806. get computeBonesUsingShaders(): boolean;
  101807. set computeBonesUsingShaders(value: boolean);
  101808. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101809. get numBoneInfluencers(): number;
  101810. set numBoneInfluencers(value: number);
  101811. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101812. get applyFog(): boolean;
  101813. set applyFog(value: boolean);
  101814. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101815. useOctreeForRenderingSelection: boolean;
  101816. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101817. useOctreeForPicking: boolean;
  101818. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101819. useOctreeForCollisions: boolean;
  101820. /**
  101821. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101822. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101823. */
  101824. get layerMask(): number;
  101825. set layerMask(value: number);
  101826. /**
  101827. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101828. */
  101829. alwaysSelectAsActiveMesh: boolean;
  101830. /**
  101831. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101832. */
  101833. doNotSyncBoundingInfo: boolean;
  101834. /**
  101835. * Gets or sets the current action manager
  101836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101837. */
  101838. actionManager: Nullable<AbstractActionManager>;
  101839. private _meshCollisionData;
  101840. /**
  101841. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101842. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101843. */
  101844. ellipsoid: Vector3;
  101845. /**
  101846. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101847. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101848. */
  101849. ellipsoidOffset: Vector3;
  101850. /**
  101851. * Gets or sets a collision mask used to mask collisions (default is -1).
  101852. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101853. */
  101854. get collisionMask(): number;
  101855. set collisionMask(mask: number);
  101856. /**
  101857. * Gets or sets the current collision group mask (-1 by default).
  101858. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101859. */
  101860. get collisionGroup(): number;
  101861. set collisionGroup(mask: number);
  101862. /**
  101863. * Defines edge width used when edgesRenderer is enabled
  101864. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101865. */
  101866. edgesWidth: number;
  101867. /**
  101868. * Defines edge color used when edgesRenderer is enabled
  101869. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101870. */
  101871. edgesColor: Color4;
  101872. /** @hidden */
  101873. _edgesRenderer: Nullable<IEdgesRenderer>;
  101874. /** @hidden */
  101875. _masterMesh: Nullable<AbstractMesh>;
  101876. /** @hidden */
  101877. _boundingInfo: Nullable<BoundingInfo>;
  101878. /** @hidden */
  101879. _renderId: number;
  101880. /**
  101881. * Gets or sets the list of subMeshes
  101882. * @see http://doc.babylonjs.com/how_to/multi_materials
  101883. */
  101884. subMeshes: SubMesh[];
  101885. /** @hidden */
  101886. _intersectionsInProgress: AbstractMesh[];
  101887. /** @hidden */
  101888. _unIndexed: boolean;
  101889. /** @hidden */
  101890. _lightSources: Light[];
  101891. /** Gets the list of lights affecting that mesh */
  101892. get lightSources(): Light[];
  101893. /** @hidden */
  101894. get _positions(): Nullable<Vector3[]>;
  101895. /** @hidden */
  101896. _waitingData: {
  101897. lods: Nullable<any>;
  101898. actions: Nullable<any>;
  101899. freezeWorldMatrix: Nullable<boolean>;
  101900. };
  101901. /** @hidden */
  101902. _bonesTransformMatrices: Nullable<Float32Array>;
  101903. /** @hidden */
  101904. _transformMatrixTexture: Nullable<RawTexture>;
  101905. /**
  101906. * Gets or sets a skeleton to apply skining transformations
  101907. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101908. */
  101909. set skeleton(value: Nullable<Skeleton>);
  101910. get skeleton(): Nullable<Skeleton>;
  101911. /**
  101912. * An event triggered when the mesh is rebuilt.
  101913. */
  101914. onRebuildObservable: Observable<AbstractMesh>;
  101915. /**
  101916. * Creates a new AbstractMesh
  101917. * @param name defines the name of the mesh
  101918. * @param scene defines the hosting scene
  101919. */
  101920. constructor(name: string, scene?: Nullable<Scene>);
  101921. /**
  101922. * Returns the string "AbstractMesh"
  101923. * @returns "AbstractMesh"
  101924. */
  101925. getClassName(): string;
  101926. /**
  101927. * Gets a string representation of the current mesh
  101928. * @param fullDetails defines a boolean indicating if full details must be included
  101929. * @returns a string representation of the current mesh
  101930. */
  101931. toString(fullDetails?: boolean): string;
  101932. /**
  101933. * @hidden
  101934. */
  101935. protected _getEffectiveParent(): Nullable<Node>;
  101936. /** @hidden */
  101937. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101938. /** @hidden */
  101939. _rebuild(): void;
  101940. /** @hidden */
  101941. _resyncLightSources(): void;
  101942. /** @hidden */
  101943. _resyncLightSource(light: Light): void;
  101944. /** @hidden */
  101945. _unBindEffect(): void;
  101946. /** @hidden */
  101947. _removeLightSource(light: Light, dispose: boolean): void;
  101948. private _markSubMeshesAsDirty;
  101949. /** @hidden */
  101950. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101951. /** @hidden */
  101952. _markSubMeshesAsAttributesDirty(): void;
  101953. /** @hidden */
  101954. _markSubMeshesAsMiscDirty(): void;
  101955. /**
  101956. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101957. */
  101958. get scaling(): Vector3;
  101959. set scaling(newScaling: Vector3);
  101960. /**
  101961. * Returns true if the mesh is blocked. Implemented by child classes
  101962. */
  101963. get isBlocked(): boolean;
  101964. /**
  101965. * Returns the mesh itself by default. Implemented by child classes
  101966. * @param camera defines the camera to use to pick the right LOD level
  101967. * @returns the currentAbstractMesh
  101968. */
  101969. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101970. /**
  101971. * Returns 0 by default. Implemented by child classes
  101972. * @returns an integer
  101973. */
  101974. getTotalVertices(): number;
  101975. /**
  101976. * Returns a positive integer : the total number of indices in this mesh geometry.
  101977. * @returns the numner of indices or zero if the mesh has no geometry.
  101978. */
  101979. getTotalIndices(): number;
  101980. /**
  101981. * Returns null by default. Implemented by child classes
  101982. * @returns null
  101983. */
  101984. getIndices(): Nullable<IndicesArray>;
  101985. /**
  101986. * Returns the array of the requested vertex data kind. Implemented by child classes
  101987. * @param kind defines the vertex data kind to use
  101988. * @returns null
  101989. */
  101990. getVerticesData(kind: string): Nullable<FloatArray>;
  101991. /**
  101992. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101993. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101994. * Note that a new underlying VertexBuffer object is created each call.
  101995. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101996. * @param kind defines vertex data kind:
  101997. * * VertexBuffer.PositionKind
  101998. * * VertexBuffer.UVKind
  101999. * * VertexBuffer.UV2Kind
  102000. * * VertexBuffer.UV3Kind
  102001. * * VertexBuffer.UV4Kind
  102002. * * VertexBuffer.UV5Kind
  102003. * * VertexBuffer.UV6Kind
  102004. * * VertexBuffer.ColorKind
  102005. * * VertexBuffer.MatricesIndicesKind
  102006. * * VertexBuffer.MatricesIndicesExtraKind
  102007. * * VertexBuffer.MatricesWeightsKind
  102008. * * VertexBuffer.MatricesWeightsExtraKind
  102009. * @param data defines the data source
  102010. * @param updatable defines if the data must be flagged as updatable (or static)
  102011. * @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
  102012. * @returns the current mesh
  102013. */
  102014. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  102015. /**
  102016. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  102017. * If the mesh has no geometry, it is simply returned as it is.
  102018. * @param kind defines vertex data kind:
  102019. * * VertexBuffer.PositionKind
  102020. * * VertexBuffer.UVKind
  102021. * * VertexBuffer.UV2Kind
  102022. * * VertexBuffer.UV3Kind
  102023. * * VertexBuffer.UV4Kind
  102024. * * VertexBuffer.UV5Kind
  102025. * * VertexBuffer.UV6Kind
  102026. * * VertexBuffer.ColorKind
  102027. * * VertexBuffer.MatricesIndicesKind
  102028. * * VertexBuffer.MatricesIndicesExtraKind
  102029. * * VertexBuffer.MatricesWeightsKind
  102030. * * VertexBuffer.MatricesWeightsExtraKind
  102031. * @param data defines the data source
  102032. * @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
  102033. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  102034. * @returns the current mesh
  102035. */
  102036. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  102037. /**
  102038. * Sets the mesh indices,
  102039. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  102040. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  102041. * @param totalVertices Defines the total number of vertices
  102042. * @returns the current mesh
  102043. */
  102044. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  102045. /**
  102046. * Gets a boolean indicating if specific vertex data is present
  102047. * @param kind defines the vertex data kind to use
  102048. * @returns true is data kind is present
  102049. */
  102050. isVerticesDataPresent(kind: string): boolean;
  102051. /**
  102052. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  102053. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  102054. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  102055. * @returns a BoundingInfo
  102056. */
  102057. getBoundingInfo(): BoundingInfo;
  102058. /**
  102059. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  102060. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  102061. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  102062. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  102063. * @returns the current mesh
  102064. */
  102065. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  102066. /**
  102067. * Overwrite the current bounding info
  102068. * @param boundingInfo defines the new bounding info
  102069. * @returns the current mesh
  102070. */
  102071. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  102072. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  102073. get useBones(): boolean;
  102074. /** @hidden */
  102075. _preActivate(): void;
  102076. /** @hidden */
  102077. _preActivateForIntermediateRendering(renderId: number): void;
  102078. /** @hidden */
  102079. _activate(renderId: number, intermediateRendering: boolean): boolean;
  102080. /** @hidden */
  102081. _postActivate(): void;
  102082. /** @hidden */
  102083. _freeze(): void;
  102084. /** @hidden */
  102085. _unFreeze(): void;
  102086. /**
  102087. * Gets the current world matrix
  102088. * @returns a Matrix
  102089. */
  102090. getWorldMatrix(): Matrix;
  102091. /** @hidden */
  102092. _getWorldMatrixDeterminant(): number;
  102093. /**
  102094. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  102095. */
  102096. get isAnInstance(): boolean;
  102097. /**
  102098. * Gets a boolean indicating if this mesh has instances
  102099. */
  102100. get hasInstances(): boolean;
  102101. /**
  102102. * Perform relative position change from the point of view of behind the front of the mesh.
  102103. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102104. * Supports definition of mesh facing forward or backward
  102105. * @param amountRight defines the distance on the right axis
  102106. * @param amountUp defines the distance on the up axis
  102107. * @param amountForward defines the distance on the forward axis
  102108. * @returns the current mesh
  102109. */
  102110. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102111. /**
  102112. * Calculate relative position change from the point of view of behind the front of the mesh.
  102113. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102114. * Supports definition of mesh facing forward or backward
  102115. * @param amountRight defines the distance on the right axis
  102116. * @param amountUp defines the distance on the up axis
  102117. * @param amountForward defines the distance on the forward axis
  102118. * @returns the new displacement vector
  102119. */
  102120. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102121. /**
  102122. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102123. * Supports definition of mesh facing forward or backward
  102124. * @param flipBack defines the flip
  102125. * @param twirlClockwise defines the twirl
  102126. * @param tiltRight defines the tilt
  102127. * @returns the current mesh
  102128. */
  102129. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102130. /**
  102131. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102132. * Supports definition of mesh facing forward or backward.
  102133. * @param flipBack defines the flip
  102134. * @param twirlClockwise defines the twirl
  102135. * @param tiltRight defines the tilt
  102136. * @returns the new rotation vector
  102137. */
  102138. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102139. /**
  102140. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102141. * This means the mesh underlying bounding box and sphere are recomputed.
  102142. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102143. * @returns the current mesh
  102144. */
  102145. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102146. /** @hidden */
  102147. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102148. /** @hidden */
  102149. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102150. /** @hidden */
  102151. _updateBoundingInfo(): AbstractMesh;
  102152. /** @hidden */
  102153. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102154. /** @hidden */
  102155. protected _afterComputeWorldMatrix(): void;
  102156. /** @hidden */
  102157. get _effectiveMesh(): AbstractMesh;
  102158. /**
  102159. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102160. * A mesh is in the frustum if its bounding box intersects the frustum
  102161. * @param frustumPlanes defines the frustum to test
  102162. * @returns true if the mesh is in the frustum planes
  102163. */
  102164. isInFrustum(frustumPlanes: Plane[]): boolean;
  102165. /**
  102166. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102167. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102168. * @param frustumPlanes defines the frustum to test
  102169. * @returns true if the mesh is completely in the frustum planes
  102170. */
  102171. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102172. /**
  102173. * True if the mesh intersects another mesh or a SolidParticle object
  102174. * @param mesh defines a target mesh or SolidParticle to test
  102175. * @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)
  102176. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102177. * @returns true if there is an intersection
  102178. */
  102179. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102180. /**
  102181. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102182. * @param point defines the point to test
  102183. * @returns true if there is an intersection
  102184. */
  102185. intersectsPoint(point: Vector3): boolean;
  102186. /**
  102187. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102188. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102189. */
  102190. get checkCollisions(): boolean;
  102191. set checkCollisions(collisionEnabled: boolean);
  102192. /**
  102193. * Gets Collider object used to compute collisions (not physics)
  102194. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102195. */
  102196. get collider(): Nullable<Collider>;
  102197. /**
  102198. * Move the mesh using collision engine
  102199. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102200. * @param displacement defines the requested displacement vector
  102201. * @returns the current mesh
  102202. */
  102203. moveWithCollisions(displacement: Vector3): AbstractMesh;
  102204. private _onCollisionPositionChange;
  102205. /** @hidden */
  102206. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  102207. /** @hidden */
  102208. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  102209. /** @hidden */
  102210. _checkCollision(collider: Collider): AbstractMesh;
  102211. /** @hidden */
  102212. _generatePointsArray(): boolean;
  102213. /**
  102214. * Checks if the passed Ray intersects with the mesh
  102215. * @param ray defines the ray to use
  102216. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  102217. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102218. * @returns the picking info
  102219. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  102220. */
  102221. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  102222. /**
  102223. * Clones the current mesh
  102224. * @param name defines the mesh name
  102225. * @param newParent defines the new mesh parent
  102226. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  102227. * @returns the new mesh
  102228. */
  102229. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  102230. /**
  102231. * Disposes all the submeshes of the current meshnp
  102232. * @returns the current mesh
  102233. */
  102234. releaseSubMeshes(): AbstractMesh;
  102235. /**
  102236. * Releases resources associated with this abstract mesh.
  102237. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102238. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102239. */
  102240. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102241. /**
  102242. * Adds the passed mesh as a child to the current mesh
  102243. * @param mesh defines the child mesh
  102244. * @returns the current mesh
  102245. */
  102246. addChild(mesh: AbstractMesh): AbstractMesh;
  102247. /**
  102248. * Removes the passed mesh from the current mesh children list
  102249. * @param mesh defines the child mesh
  102250. * @returns the current mesh
  102251. */
  102252. removeChild(mesh: AbstractMesh): AbstractMesh;
  102253. /** @hidden */
  102254. private _initFacetData;
  102255. /**
  102256. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  102257. * This method can be called within the render loop.
  102258. * 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
  102259. * @returns the current mesh
  102260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102261. */
  102262. updateFacetData(): AbstractMesh;
  102263. /**
  102264. * Returns the facetLocalNormals array.
  102265. * The normals are expressed in the mesh local spac
  102266. * @returns an array of Vector3
  102267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102268. */
  102269. getFacetLocalNormals(): Vector3[];
  102270. /**
  102271. * Returns the facetLocalPositions array.
  102272. * The facet positions are expressed in the mesh local space
  102273. * @returns an array of Vector3
  102274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102275. */
  102276. getFacetLocalPositions(): Vector3[];
  102277. /**
  102278. * Returns the facetLocalPartioning array
  102279. * @returns an array of array of numbers
  102280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102281. */
  102282. getFacetLocalPartitioning(): number[][];
  102283. /**
  102284. * Returns the i-th facet position in the world system.
  102285. * This method allocates a new Vector3 per call
  102286. * @param i defines the facet index
  102287. * @returns a new Vector3
  102288. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102289. */
  102290. getFacetPosition(i: number): Vector3;
  102291. /**
  102292. * Sets the reference Vector3 with the i-th facet position in the world system
  102293. * @param i defines the facet index
  102294. * @param ref defines the target vector
  102295. * @returns the current mesh
  102296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102297. */
  102298. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  102299. /**
  102300. * Returns the i-th facet normal in the world system.
  102301. * This method allocates a new Vector3 per call
  102302. * @param i defines the facet index
  102303. * @returns a new Vector3
  102304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102305. */
  102306. getFacetNormal(i: number): Vector3;
  102307. /**
  102308. * Sets the reference Vector3 with the i-th facet normal in the world system
  102309. * @param i defines the facet index
  102310. * @param ref defines the target vector
  102311. * @returns the current mesh
  102312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102313. */
  102314. getFacetNormalToRef(i: number, ref: Vector3): this;
  102315. /**
  102316. * 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)
  102317. * @param x defines x coordinate
  102318. * @param y defines y coordinate
  102319. * @param z defines z coordinate
  102320. * @returns the array of facet indexes
  102321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102322. */
  102323. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  102324. /**
  102325. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  102326. * @param projected sets as the (x,y,z) world projection on the facet
  102327. * @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
  102328. * @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
  102329. * @param x defines x coordinate
  102330. * @param y defines y coordinate
  102331. * @param z defines z coordinate
  102332. * @returns the face index if found (or null instead)
  102333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102334. */
  102335. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102336. /**
  102337. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  102338. * @param projected sets as the (x,y,z) local projection on the facet
  102339. * @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
  102340. * @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
  102341. * @param x defines x coordinate
  102342. * @param y defines y coordinate
  102343. * @param z defines z coordinate
  102344. * @returns the face index if found (or null instead)
  102345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102346. */
  102347. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102348. /**
  102349. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  102350. * @returns the parameters
  102351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102352. */
  102353. getFacetDataParameters(): any;
  102354. /**
  102355. * Disables the feature FacetData and frees the related memory
  102356. * @returns the current mesh
  102357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102358. */
  102359. disableFacetData(): AbstractMesh;
  102360. /**
  102361. * Updates the AbstractMesh indices array
  102362. * @param indices defines the data source
  102363. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  102364. * @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)
  102365. * @returns the current mesh
  102366. */
  102367. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  102368. /**
  102369. * Creates new normals data for the mesh
  102370. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  102371. * @returns the current mesh
  102372. */
  102373. createNormals(updatable: boolean): AbstractMesh;
  102374. /**
  102375. * Align the mesh with a normal
  102376. * @param normal defines the normal to use
  102377. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  102378. * @returns the current mesh
  102379. */
  102380. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  102381. /** @hidden */
  102382. _checkOcclusionQuery(): boolean;
  102383. /**
  102384. * Disables the mesh edge rendering mode
  102385. * @returns the currentAbstractMesh
  102386. */
  102387. disableEdgesRendering(): AbstractMesh;
  102388. /**
  102389. * Enables the edge rendering mode on the mesh.
  102390. * This mode makes the mesh edges visible
  102391. * @param epsilon defines the maximal distance between two angles to detect a face
  102392. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  102393. * @returns the currentAbstractMesh
  102394. * @see https://www.babylonjs-playground.com/#19O9TU#0
  102395. */
  102396. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  102397. }
  102398. }
  102399. declare module BABYLON {
  102400. /**
  102401. * Interface used to define ActionEvent
  102402. */
  102403. export interface IActionEvent {
  102404. /** The mesh or sprite that triggered the action */
  102405. source: any;
  102406. /** The X mouse cursor position at the time of the event */
  102407. pointerX: number;
  102408. /** The Y mouse cursor position at the time of the event */
  102409. pointerY: number;
  102410. /** The mesh that is currently pointed at (can be null) */
  102411. meshUnderPointer: Nullable<AbstractMesh>;
  102412. /** the original (browser) event that triggered the ActionEvent */
  102413. sourceEvent?: any;
  102414. /** additional data for the event */
  102415. additionalData?: any;
  102416. }
  102417. /**
  102418. * ActionEvent is the event being sent when an action is triggered.
  102419. */
  102420. export class ActionEvent implements IActionEvent {
  102421. /** The mesh or sprite that triggered the action */
  102422. source: any;
  102423. /** The X mouse cursor position at the time of the event */
  102424. pointerX: number;
  102425. /** The Y mouse cursor position at the time of the event */
  102426. pointerY: number;
  102427. /** The mesh that is currently pointed at (can be null) */
  102428. meshUnderPointer: Nullable<AbstractMesh>;
  102429. /** the original (browser) event that triggered the ActionEvent */
  102430. sourceEvent?: any;
  102431. /** additional data for the event */
  102432. additionalData?: any;
  102433. /**
  102434. * Creates a new ActionEvent
  102435. * @param source The mesh or sprite that triggered the action
  102436. * @param pointerX The X mouse cursor position at the time of the event
  102437. * @param pointerY The Y mouse cursor position at the time of the event
  102438. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  102439. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  102440. * @param additionalData additional data for the event
  102441. */
  102442. constructor(
  102443. /** The mesh or sprite that triggered the action */
  102444. source: any,
  102445. /** The X mouse cursor position at the time of the event */
  102446. pointerX: number,
  102447. /** The Y mouse cursor position at the time of the event */
  102448. pointerY: number,
  102449. /** The mesh that is currently pointed at (can be null) */
  102450. meshUnderPointer: Nullable<AbstractMesh>,
  102451. /** the original (browser) event that triggered the ActionEvent */
  102452. sourceEvent?: any,
  102453. /** additional data for the event */
  102454. additionalData?: any);
  102455. /**
  102456. * Helper function to auto-create an ActionEvent from a source mesh.
  102457. * @param source The source mesh that triggered the event
  102458. * @param evt The original (browser) event
  102459. * @param additionalData additional data for the event
  102460. * @returns the new ActionEvent
  102461. */
  102462. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  102463. /**
  102464. * Helper function to auto-create an ActionEvent from a source sprite
  102465. * @param source The source sprite that triggered the event
  102466. * @param scene Scene associated with the sprite
  102467. * @param evt The original (browser) event
  102468. * @param additionalData additional data for the event
  102469. * @returns the new ActionEvent
  102470. */
  102471. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  102472. /**
  102473. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  102474. * @param scene the scene where the event occurred
  102475. * @param evt The original (browser) event
  102476. * @returns the new ActionEvent
  102477. */
  102478. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  102479. /**
  102480. * Helper function to auto-create an ActionEvent from a primitive
  102481. * @param prim defines the target primitive
  102482. * @param pointerPos defines the pointer position
  102483. * @param evt The original (browser) event
  102484. * @param additionalData additional data for the event
  102485. * @returns the new ActionEvent
  102486. */
  102487. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  102488. }
  102489. }
  102490. declare module BABYLON {
  102491. /**
  102492. * Abstract class used to decouple action Manager from scene and meshes.
  102493. * Do not instantiate.
  102494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102495. */
  102496. export abstract class AbstractActionManager implements IDisposable {
  102497. /** Gets the list of active triggers */
  102498. static Triggers: {
  102499. [key: string]: number;
  102500. };
  102501. /** Gets the cursor to use when hovering items */
  102502. hoverCursor: string;
  102503. /** Gets the list of actions */
  102504. actions: IAction[];
  102505. /**
  102506. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  102507. */
  102508. isRecursive: boolean;
  102509. /**
  102510. * Releases all associated resources
  102511. */
  102512. abstract dispose(): void;
  102513. /**
  102514. * Does this action manager has pointer triggers
  102515. */
  102516. abstract get hasPointerTriggers(): boolean;
  102517. /**
  102518. * Does this action manager has pick triggers
  102519. */
  102520. abstract get hasPickTriggers(): boolean;
  102521. /**
  102522. * Process a specific trigger
  102523. * @param trigger defines the trigger to process
  102524. * @param evt defines the event details to be processed
  102525. */
  102526. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102527. /**
  102528. * Does this action manager handles actions of any of the given triggers
  102529. * @param triggers defines the triggers to be tested
  102530. * @return a boolean indicating whether one (or more) of the triggers is handled
  102531. */
  102532. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102533. /**
  102534. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102535. * speed.
  102536. * @param triggerA defines the trigger to be tested
  102537. * @param triggerB defines the trigger to be tested
  102538. * @return a boolean indicating whether one (or more) of the triggers is handled
  102539. */
  102540. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102541. /**
  102542. * Does this action manager handles actions of a given trigger
  102543. * @param trigger defines the trigger to be tested
  102544. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102545. * @return whether the trigger is handled
  102546. */
  102547. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102548. /**
  102549. * Serialize this manager to a JSON object
  102550. * @param name defines the property name to store this manager
  102551. * @returns a JSON representation of this manager
  102552. */
  102553. abstract serialize(name: string): any;
  102554. /**
  102555. * Registers an action to this action manager
  102556. * @param action defines the action to be registered
  102557. * @return the action amended (prepared) after registration
  102558. */
  102559. abstract registerAction(action: IAction): Nullable<IAction>;
  102560. /**
  102561. * Unregisters an action to this action manager
  102562. * @param action defines the action to be unregistered
  102563. * @return a boolean indicating whether the action has been unregistered
  102564. */
  102565. abstract unregisterAction(action: IAction): Boolean;
  102566. /**
  102567. * Does exist one action manager with at least one trigger
  102568. **/
  102569. static get HasTriggers(): boolean;
  102570. /**
  102571. * Does exist one action manager with at least one pick trigger
  102572. **/
  102573. static get HasPickTriggers(): boolean;
  102574. /**
  102575. * Does exist one action manager that handles actions of a given trigger
  102576. * @param trigger defines the trigger to be tested
  102577. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102578. **/
  102579. static HasSpecificTrigger(trigger: number): boolean;
  102580. }
  102581. }
  102582. declare module BABYLON {
  102583. /**
  102584. * Defines how a node can be built from a string name.
  102585. */
  102586. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102587. /**
  102588. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102589. */
  102590. export class Node implements IBehaviorAware<Node> {
  102591. /** @hidden */
  102592. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102593. private static _NodeConstructors;
  102594. /**
  102595. * Add a new node constructor
  102596. * @param type defines the type name of the node to construct
  102597. * @param constructorFunc defines the constructor function
  102598. */
  102599. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102600. /**
  102601. * Returns a node constructor based on type name
  102602. * @param type defines the type name
  102603. * @param name defines the new node name
  102604. * @param scene defines the hosting scene
  102605. * @param options defines optional options to transmit to constructors
  102606. * @returns the new constructor or null
  102607. */
  102608. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102609. /**
  102610. * Gets or sets the name of the node
  102611. */
  102612. name: string;
  102613. /**
  102614. * Gets or sets the id of the node
  102615. */
  102616. id: string;
  102617. /**
  102618. * Gets or sets the unique id of the node
  102619. */
  102620. uniqueId: number;
  102621. /**
  102622. * Gets or sets a string used to store user defined state for the node
  102623. */
  102624. state: string;
  102625. /**
  102626. * Gets or sets an object used to store user defined information for the node
  102627. */
  102628. metadata: any;
  102629. /**
  102630. * For internal use only. Please do not use.
  102631. */
  102632. reservedDataStore: any;
  102633. /**
  102634. * List of inspectable custom properties (used by the Inspector)
  102635. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102636. */
  102637. inspectableCustomProperties: IInspectable[];
  102638. private _doNotSerialize;
  102639. /**
  102640. * Gets or sets a boolean used to define if the node must be serialized
  102641. */
  102642. get doNotSerialize(): boolean;
  102643. set doNotSerialize(value: boolean);
  102644. /** @hidden */
  102645. _isDisposed: boolean;
  102646. /**
  102647. * Gets a list of Animations associated with the node
  102648. */
  102649. animations: Animation[];
  102650. protected _ranges: {
  102651. [name: string]: Nullable<AnimationRange>;
  102652. };
  102653. /**
  102654. * Callback raised when the node is ready to be used
  102655. */
  102656. onReady: Nullable<(node: Node) => void>;
  102657. private _isEnabled;
  102658. private _isParentEnabled;
  102659. private _isReady;
  102660. /** @hidden */
  102661. _currentRenderId: number;
  102662. private _parentUpdateId;
  102663. /** @hidden */
  102664. _childUpdateId: number;
  102665. /** @hidden */
  102666. _waitingParentId: Nullable<string>;
  102667. /** @hidden */
  102668. _scene: Scene;
  102669. /** @hidden */
  102670. _cache: any;
  102671. private _parentNode;
  102672. private _children;
  102673. /** @hidden */
  102674. _worldMatrix: Matrix;
  102675. /** @hidden */
  102676. _worldMatrixDeterminant: number;
  102677. /** @hidden */
  102678. _worldMatrixDeterminantIsDirty: boolean;
  102679. /** @hidden */
  102680. private _sceneRootNodesIndex;
  102681. /**
  102682. * Gets a boolean indicating if the node has been disposed
  102683. * @returns true if the node was disposed
  102684. */
  102685. isDisposed(): boolean;
  102686. /**
  102687. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102688. * @see https://doc.babylonjs.com/how_to/parenting
  102689. */
  102690. set parent(parent: Nullable<Node>);
  102691. get parent(): Nullable<Node>;
  102692. /** @hidden */
  102693. _addToSceneRootNodes(): void;
  102694. /** @hidden */
  102695. _removeFromSceneRootNodes(): void;
  102696. private _animationPropertiesOverride;
  102697. /**
  102698. * Gets or sets the animation properties override
  102699. */
  102700. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102701. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102702. /**
  102703. * Gets a string idenfifying the name of the class
  102704. * @returns "Node" string
  102705. */
  102706. getClassName(): string;
  102707. /** @hidden */
  102708. readonly _isNode: boolean;
  102709. /**
  102710. * An event triggered when the mesh is disposed
  102711. */
  102712. onDisposeObservable: Observable<Node>;
  102713. private _onDisposeObserver;
  102714. /**
  102715. * Sets a callback that will be raised when the node will be disposed
  102716. */
  102717. set onDispose(callback: () => void);
  102718. /**
  102719. * Creates a new Node
  102720. * @param name the name and id to be given to this node
  102721. * @param scene the scene this node will be added to
  102722. */
  102723. constructor(name: string, scene?: Nullable<Scene>);
  102724. /**
  102725. * Gets the scene of the node
  102726. * @returns a scene
  102727. */
  102728. getScene(): Scene;
  102729. /**
  102730. * Gets the engine of the node
  102731. * @returns a Engine
  102732. */
  102733. getEngine(): Engine;
  102734. private _behaviors;
  102735. /**
  102736. * Attach a behavior to the node
  102737. * @see http://doc.babylonjs.com/features/behaviour
  102738. * @param behavior defines the behavior to attach
  102739. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102740. * @returns the current Node
  102741. */
  102742. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102743. /**
  102744. * Remove an attached behavior
  102745. * @see http://doc.babylonjs.com/features/behaviour
  102746. * @param behavior defines the behavior to attach
  102747. * @returns the current Node
  102748. */
  102749. removeBehavior(behavior: Behavior<Node>): Node;
  102750. /**
  102751. * Gets the list of attached behaviors
  102752. * @see http://doc.babylonjs.com/features/behaviour
  102753. */
  102754. get behaviors(): Behavior<Node>[];
  102755. /**
  102756. * Gets an attached behavior by name
  102757. * @param name defines the name of the behavior to look for
  102758. * @see http://doc.babylonjs.com/features/behaviour
  102759. * @returns null if behavior was not found else the requested behavior
  102760. */
  102761. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102762. /**
  102763. * Returns the latest update of the World matrix
  102764. * @returns a Matrix
  102765. */
  102766. getWorldMatrix(): Matrix;
  102767. /** @hidden */
  102768. _getWorldMatrixDeterminant(): number;
  102769. /**
  102770. * Returns directly the latest state of the mesh World matrix.
  102771. * A Matrix is returned.
  102772. */
  102773. get worldMatrixFromCache(): Matrix;
  102774. /** @hidden */
  102775. _initCache(): void;
  102776. /** @hidden */
  102777. updateCache(force?: boolean): void;
  102778. /** @hidden */
  102779. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102780. /** @hidden */
  102781. _updateCache(ignoreParentClass?: boolean): void;
  102782. /** @hidden */
  102783. _isSynchronized(): boolean;
  102784. /** @hidden */
  102785. _markSyncedWithParent(): void;
  102786. /** @hidden */
  102787. isSynchronizedWithParent(): boolean;
  102788. /** @hidden */
  102789. isSynchronized(): boolean;
  102790. /**
  102791. * Is this node ready to be used/rendered
  102792. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102793. * @return true if the node is ready
  102794. */
  102795. isReady(completeCheck?: boolean): boolean;
  102796. /**
  102797. * Is this node enabled?
  102798. * 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
  102799. * @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
  102800. * @return whether this node (and its parent) is enabled
  102801. */
  102802. isEnabled(checkAncestors?: boolean): boolean;
  102803. /** @hidden */
  102804. protected _syncParentEnabledState(): void;
  102805. /**
  102806. * Set the enabled state of this node
  102807. * @param value defines the new enabled state
  102808. */
  102809. setEnabled(value: boolean): void;
  102810. /**
  102811. * Is this node a descendant of the given node?
  102812. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102813. * @param ancestor defines the parent node to inspect
  102814. * @returns a boolean indicating if this node is a descendant of the given node
  102815. */
  102816. isDescendantOf(ancestor: Node): boolean;
  102817. /** @hidden */
  102818. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102819. /**
  102820. * Will return all nodes that have this node as ascendant
  102821. * @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
  102822. * @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
  102823. * @return all children nodes of all types
  102824. */
  102825. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102826. /**
  102827. * Get all child-meshes of this node
  102828. * @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)
  102829. * @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
  102830. * @returns an array of AbstractMesh
  102831. */
  102832. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102833. /**
  102834. * Get all direct children of this node
  102835. * @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
  102836. * @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)
  102837. * @returns an array of Node
  102838. */
  102839. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102840. /** @hidden */
  102841. _setReady(state: boolean): void;
  102842. /**
  102843. * Get an animation by name
  102844. * @param name defines the name of the animation to look for
  102845. * @returns null if not found else the requested animation
  102846. */
  102847. getAnimationByName(name: string): Nullable<Animation>;
  102848. /**
  102849. * Creates an animation range for this node
  102850. * @param name defines the name of the range
  102851. * @param from defines the starting key
  102852. * @param to defines the end key
  102853. */
  102854. createAnimationRange(name: string, from: number, to: number): void;
  102855. /**
  102856. * Delete a specific animation range
  102857. * @param name defines the name of the range to delete
  102858. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102859. */
  102860. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102861. /**
  102862. * Get an animation range by name
  102863. * @param name defines the name of the animation range to look for
  102864. * @returns null if not found else the requested animation range
  102865. */
  102866. getAnimationRange(name: string): Nullable<AnimationRange>;
  102867. /**
  102868. * Gets the list of all animation ranges defined on this node
  102869. * @returns an array
  102870. */
  102871. getAnimationRanges(): Nullable<AnimationRange>[];
  102872. /**
  102873. * Will start the animation sequence
  102874. * @param name defines the range frames for animation sequence
  102875. * @param loop defines if the animation should loop (false by default)
  102876. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102877. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102878. * @returns the object created for this animation. If range does not exist, it will return null
  102879. */
  102880. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102881. /**
  102882. * Serialize animation ranges into a JSON compatible object
  102883. * @returns serialization object
  102884. */
  102885. serializeAnimationRanges(): any;
  102886. /**
  102887. * Computes the world matrix of the node
  102888. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102889. * @returns the world matrix
  102890. */
  102891. computeWorldMatrix(force?: boolean): Matrix;
  102892. /**
  102893. * Releases resources associated with this node.
  102894. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102895. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102896. */
  102897. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102898. /**
  102899. * Parse animation range data from a serialization object and store them into a given node
  102900. * @param node defines where to store the animation ranges
  102901. * @param parsedNode defines the serialization object to read data from
  102902. * @param scene defines the hosting scene
  102903. */
  102904. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102905. /**
  102906. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102907. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102908. * @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
  102909. * @returns the new bounding vectors
  102910. */
  102911. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102912. min: Vector3;
  102913. max: Vector3;
  102914. };
  102915. }
  102916. }
  102917. declare module BABYLON {
  102918. /**
  102919. * @hidden
  102920. */
  102921. export class _IAnimationState {
  102922. key: number;
  102923. repeatCount: number;
  102924. workValue?: any;
  102925. loopMode?: number;
  102926. offsetValue?: any;
  102927. highLimitValue?: any;
  102928. }
  102929. /**
  102930. * Class used to store any kind of animation
  102931. */
  102932. export class Animation {
  102933. /**Name of the animation */
  102934. name: string;
  102935. /**Property to animate */
  102936. targetProperty: string;
  102937. /**The frames per second of the animation */
  102938. framePerSecond: number;
  102939. /**The data type of the animation */
  102940. dataType: number;
  102941. /**The loop mode of the animation */
  102942. loopMode?: number | undefined;
  102943. /**Specifies if blending should be enabled */
  102944. enableBlending?: boolean | undefined;
  102945. /**
  102946. * Use matrix interpolation instead of using direct key value when animating matrices
  102947. */
  102948. static AllowMatricesInterpolation: boolean;
  102949. /**
  102950. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102951. */
  102952. static AllowMatrixDecomposeForInterpolation: boolean;
  102953. /**
  102954. * Stores the key frames of the animation
  102955. */
  102956. private _keys;
  102957. /**
  102958. * Stores the easing function of the animation
  102959. */
  102960. private _easingFunction;
  102961. /**
  102962. * @hidden Internal use only
  102963. */
  102964. _runtimeAnimations: RuntimeAnimation[];
  102965. /**
  102966. * The set of event that will be linked to this animation
  102967. */
  102968. private _events;
  102969. /**
  102970. * Stores an array of target property paths
  102971. */
  102972. targetPropertyPath: string[];
  102973. /**
  102974. * Stores the blending speed of the animation
  102975. */
  102976. blendingSpeed: number;
  102977. /**
  102978. * Stores the animation ranges for the animation
  102979. */
  102980. private _ranges;
  102981. /**
  102982. * @hidden Internal use
  102983. */
  102984. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102985. /**
  102986. * Sets up an animation
  102987. * @param property The property to animate
  102988. * @param animationType The animation type to apply
  102989. * @param framePerSecond The frames per second of the animation
  102990. * @param easingFunction The easing function used in the animation
  102991. * @returns The created animation
  102992. */
  102993. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102994. /**
  102995. * Create and start an animation on a node
  102996. * @param name defines the name of the global animation that will be run on all nodes
  102997. * @param node defines the root node where the animation will take place
  102998. * @param targetProperty defines property to animate
  102999. * @param framePerSecond defines the number of frame per second yo use
  103000. * @param totalFrame defines the number of frames in total
  103001. * @param from defines the initial value
  103002. * @param to defines the final value
  103003. * @param loopMode defines which loop mode you want to use (off by default)
  103004. * @param easingFunction defines the easing function to use (linear by default)
  103005. * @param onAnimationEnd defines the callback to call when animation end
  103006. * @returns the animatable created for this animation
  103007. */
  103008. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103009. /**
  103010. * Create and start an animation on a node and its descendants
  103011. * @param name defines the name of the global animation that will be run on all nodes
  103012. * @param node defines the root node where the animation will take place
  103013. * @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
  103014. * @param targetProperty defines property to animate
  103015. * @param framePerSecond defines the number of frame per second to use
  103016. * @param totalFrame defines the number of frames in total
  103017. * @param from defines the initial value
  103018. * @param to defines the final value
  103019. * @param loopMode defines which loop mode you want to use (off by default)
  103020. * @param easingFunction defines the easing function to use (linear by default)
  103021. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  103022. * @returns the list of animatables created for all nodes
  103023. * @example https://www.babylonjs-playground.com/#MH0VLI
  103024. */
  103025. 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[]>;
  103026. /**
  103027. * Creates a new animation, merges it with the existing animations and starts it
  103028. * @param name Name of the animation
  103029. * @param node Node which contains the scene that begins the animations
  103030. * @param targetProperty Specifies which property to animate
  103031. * @param framePerSecond The frames per second of the animation
  103032. * @param totalFrame The total number of frames
  103033. * @param from The frame at the beginning of the animation
  103034. * @param to The frame at the end of the animation
  103035. * @param loopMode Specifies the loop mode of the animation
  103036. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  103037. * @param onAnimationEnd Callback to run once the animation is complete
  103038. * @returns Nullable animation
  103039. */
  103040. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103041. /**
  103042. * Transition property of an host to the target Value
  103043. * @param property The property to transition
  103044. * @param targetValue The target Value of the property
  103045. * @param host The object where the property to animate belongs
  103046. * @param scene Scene used to run the animation
  103047. * @param frameRate Framerate (in frame/s) to use
  103048. * @param transition The transition type we want to use
  103049. * @param duration The duration of the animation, in milliseconds
  103050. * @param onAnimationEnd Callback trigger at the end of the animation
  103051. * @returns Nullable animation
  103052. */
  103053. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  103054. /**
  103055. * Return the array of runtime animations currently using this animation
  103056. */
  103057. get runtimeAnimations(): RuntimeAnimation[];
  103058. /**
  103059. * Specifies if any of the runtime animations are currently running
  103060. */
  103061. get hasRunningRuntimeAnimations(): boolean;
  103062. /**
  103063. * Initializes the animation
  103064. * @param name Name of the animation
  103065. * @param targetProperty Property to animate
  103066. * @param framePerSecond The frames per second of the animation
  103067. * @param dataType The data type of the animation
  103068. * @param loopMode The loop mode of the animation
  103069. * @param enableBlending Specifies if blending should be enabled
  103070. */
  103071. constructor(
  103072. /**Name of the animation */
  103073. name: string,
  103074. /**Property to animate */
  103075. targetProperty: string,
  103076. /**The frames per second of the animation */
  103077. framePerSecond: number,
  103078. /**The data type of the animation */
  103079. dataType: number,
  103080. /**The loop mode of the animation */
  103081. loopMode?: number | undefined,
  103082. /**Specifies if blending should be enabled */
  103083. enableBlending?: boolean | undefined);
  103084. /**
  103085. * Converts the animation to a string
  103086. * @param fullDetails support for multiple levels of logging within scene loading
  103087. * @returns String form of the animation
  103088. */
  103089. toString(fullDetails?: boolean): string;
  103090. /**
  103091. * Add an event to this animation
  103092. * @param event Event to add
  103093. */
  103094. addEvent(event: AnimationEvent): void;
  103095. /**
  103096. * Remove all events found at the given frame
  103097. * @param frame The frame to remove events from
  103098. */
  103099. removeEvents(frame: number): void;
  103100. /**
  103101. * Retrieves all the events from the animation
  103102. * @returns Events from the animation
  103103. */
  103104. getEvents(): AnimationEvent[];
  103105. /**
  103106. * Creates an animation range
  103107. * @param name Name of the animation range
  103108. * @param from Starting frame of the animation range
  103109. * @param to Ending frame of the animation
  103110. */
  103111. createRange(name: string, from: number, to: number): void;
  103112. /**
  103113. * Deletes an animation range by name
  103114. * @param name Name of the animation range to delete
  103115. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103116. */
  103117. deleteRange(name: string, deleteFrames?: boolean): void;
  103118. /**
  103119. * Gets the animation range by name, or null if not defined
  103120. * @param name Name of the animation range
  103121. * @returns Nullable animation range
  103122. */
  103123. getRange(name: string): Nullable<AnimationRange>;
  103124. /**
  103125. * Gets the key frames from the animation
  103126. * @returns The key frames of the animation
  103127. */
  103128. getKeys(): Array<IAnimationKey>;
  103129. /**
  103130. * Gets the highest frame rate of the animation
  103131. * @returns Highest frame rate of the animation
  103132. */
  103133. getHighestFrame(): number;
  103134. /**
  103135. * Gets the easing function of the animation
  103136. * @returns Easing function of the animation
  103137. */
  103138. getEasingFunction(): IEasingFunction;
  103139. /**
  103140. * Sets the easing function of the animation
  103141. * @param easingFunction A custom mathematical formula for animation
  103142. */
  103143. setEasingFunction(easingFunction: EasingFunction): void;
  103144. /**
  103145. * Interpolates a scalar linearly
  103146. * @param startValue Start value of the animation curve
  103147. * @param endValue End value of the animation curve
  103148. * @param gradient Scalar amount to interpolate
  103149. * @returns Interpolated scalar value
  103150. */
  103151. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103152. /**
  103153. * Interpolates a scalar cubically
  103154. * @param startValue Start value of the animation curve
  103155. * @param outTangent End tangent of the animation
  103156. * @param endValue End value of the animation curve
  103157. * @param inTangent Start tangent of the animation curve
  103158. * @param gradient Scalar amount to interpolate
  103159. * @returns Interpolated scalar value
  103160. */
  103161. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103162. /**
  103163. * Interpolates a quaternion using a spherical linear interpolation
  103164. * @param startValue Start value of the animation curve
  103165. * @param endValue End value of the animation curve
  103166. * @param gradient Scalar amount to interpolate
  103167. * @returns Interpolated quaternion value
  103168. */
  103169. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103170. /**
  103171. * Interpolates a quaternion cubically
  103172. * @param startValue Start value of the animation curve
  103173. * @param outTangent End tangent of the animation curve
  103174. * @param endValue End value of the animation curve
  103175. * @param inTangent Start tangent of the animation curve
  103176. * @param gradient Scalar amount to interpolate
  103177. * @returns Interpolated quaternion value
  103178. */
  103179. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103180. /**
  103181. * Interpolates a Vector3 linearl
  103182. * @param startValue Start value of the animation curve
  103183. * @param endValue End value of the animation curve
  103184. * @param gradient Scalar amount to interpolate
  103185. * @returns Interpolated scalar value
  103186. */
  103187. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103188. /**
  103189. * Interpolates a Vector3 cubically
  103190. * @param startValue Start value of the animation curve
  103191. * @param outTangent End tangent of the animation
  103192. * @param endValue End value of the animation curve
  103193. * @param inTangent Start tangent of the animation curve
  103194. * @param gradient Scalar amount to interpolate
  103195. * @returns InterpolatedVector3 value
  103196. */
  103197. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  103198. /**
  103199. * Interpolates a Vector2 linearly
  103200. * @param startValue Start value of the animation curve
  103201. * @param endValue End value of the animation curve
  103202. * @param gradient Scalar amount to interpolate
  103203. * @returns Interpolated Vector2 value
  103204. */
  103205. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  103206. /**
  103207. * Interpolates a Vector2 cubically
  103208. * @param startValue Start value of the animation curve
  103209. * @param outTangent End tangent of the animation
  103210. * @param endValue End value of the animation curve
  103211. * @param inTangent Start tangent of the animation curve
  103212. * @param gradient Scalar amount to interpolate
  103213. * @returns Interpolated Vector2 value
  103214. */
  103215. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  103216. /**
  103217. * Interpolates a size linearly
  103218. * @param startValue Start value of the animation curve
  103219. * @param endValue End value of the animation curve
  103220. * @param gradient Scalar amount to interpolate
  103221. * @returns Interpolated Size value
  103222. */
  103223. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  103224. /**
  103225. * Interpolates a Color3 linearly
  103226. * @param startValue Start value of the animation curve
  103227. * @param endValue End value of the animation curve
  103228. * @param gradient Scalar amount to interpolate
  103229. * @returns Interpolated Color3 value
  103230. */
  103231. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  103232. /**
  103233. * Interpolates a Color4 linearly
  103234. * @param startValue Start value of the animation curve
  103235. * @param endValue End value of the animation curve
  103236. * @param gradient Scalar amount to interpolate
  103237. * @returns Interpolated Color3 value
  103238. */
  103239. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  103240. /**
  103241. * @hidden Internal use only
  103242. */
  103243. _getKeyValue(value: any): any;
  103244. /**
  103245. * @hidden Internal use only
  103246. */
  103247. _interpolate(currentFrame: number, state: _IAnimationState): any;
  103248. /**
  103249. * Defines the function to use to interpolate matrices
  103250. * @param startValue defines the start matrix
  103251. * @param endValue defines the end matrix
  103252. * @param gradient defines the gradient between both matrices
  103253. * @param result defines an optional target matrix where to store the interpolation
  103254. * @returns the interpolated matrix
  103255. */
  103256. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  103257. /**
  103258. * Makes a copy of the animation
  103259. * @returns Cloned animation
  103260. */
  103261. clone(): Animation;
  103262. /**
  103263. * Sets the key frames of the animation
  103264. * @param values The animation key frames to set
  103265. */
  103266. setKeys(values: Array<IAnimationKey>): void;
  103267. /**
  103268. * Serializes the animation to an object
  103269. * @returns Serialized object
  103270. */
  103271. serialize(): any;
  103272. /**
  103273. * Float animation type
  103274. */
  103275. static readonly ANIMATIONTYPE_FLOAT: number;
  103276. /**
  103277. * Vector3 animation type
  103278. */
  103279. static readonly ANIMATIONTYPE_VECTOR3: number;
  103280. /**
  103281. * Quaternion animation type
  103282. */
  103283. static readonly ANIMATIONTYPE_QUATERNION: number;
  103284. /**
  103285. * Matrix animation type
  103286. */
  103287. static readonly ANIMATIONTYPE_MATRIX: number;
  103288. /**
  103289. * Color3 animation type
  103290. */
  103291. static readonly ANIMATIONTYPE_COLOR3: number;
  103292. /**
  103293. * Color3 animation type
  103294. */
  103295. static readonly ANIMATIONTYPE_COLOR4: number;
  103296. /**
  103297. * Vector2 animation type
  103298. */
  103299. static readonly ANIMATIONTYPE_VECTOR2: number;
  103300. /**
  103301. * Size animation type
  103302. */
  103303. static readonly ANIMATIONTYPE_SIZE: number;
  103304. /**
  103305. * Relative Loop Mode
  103306. */
  103307. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  103308. /**
  103309. * Cycle Loop Mode
  103310. */
  103311. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  103312. /**
  103313. * Constant Loop Mode
  103314. */
  103315. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  103316. /** @hidden */
  103317. static _UniversalLerp(left: any, right: any, amount: number): any;
  103318. /**
  103319. * Parses an animation object and creates an animation
  103320. * @param parsedAnimation Parsed animation object
  103321. * @returns Animation object
  103322. */
  103323. static Parse(parsedAnimation: any): Animation;
  103324. /**
  103325. * Appends the serialized animations from the source animations
  103326. * @param source Source containing the animations
  103327. * @param destination Target to store the animations
  103328. */
  103329. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103330. }
  103331. }
  103332. declare module BABYLON {
  103333. /**
  103334. * Interface containing an array of animations
  103335. */
  103336. export interface IAnimatable {
  103337. /**
  103338. * Array of animations
  103339. */
  103340. animations: Nullable<Array<Animation>>;
  103341. }
  103342. }
  103343. declare module BABYLON {
  103344. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  103345. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103346. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103347. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103348. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103349. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103350. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103351. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103352. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103353. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103354. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103355. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103356. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103357. /**
  103358. * Decorator used to define property that can be serialized as reference to a camera
  103359. * @param sourceName defines the name of the property to decorate
  103360. */
  103361. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103362. /**
  103363. * Class used to help serialization objects
  103364. */
  103365. export class SerializationHelper {
  103366. /** @hidden */
  103367. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  103368. /** @hidden */
  103369. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  103370. /** @hidden */
  103371. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  103372. /** @hidden */
  103373. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  103374. /**
  103375. * Appends the serialized animations from the source animations
  103376. * @param source Source containing the animations
  103377. * @param destination Target to store the animations
  103378. */
  103379. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103380. /**
  103381. * Static function used to serialized a specific entity
  103382. * @param entity defines the entity to serialize
  103383. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  103384. * @returns a JSON compatible object representing the serialization of the entity
  103385. */
  103386. static Serialize<T>(entity: T, serializationObject?: any): any;
  103387. /**
  103388. * Creates a new entity from a serialization data object
  103389. * @param creationFunction defines a function used to instanciated the new entity
  103390. * @param source defines the source serialization data
  103391. * @param scene defines the hosting scene
  103392. * @param rootUrl defines the root url for resources
  103393. * @returns a new entity
  103394. */
  103395. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  103396. /**
  103397. * Clones an object
  103398. * @param creationFunction defines the function used to instanciate the new object
  103399. * @param source defines the source object
  103400. * @returns the cloned object
  103401. */
  103402. static Clone<T>(creationFunction: () => T, source: T): T;
  103403. /**
  103404. * Instanciates a new object based on a source one (some data will be shared between both object)
  103405. * @param creationFunction defines the function used to instanciate the new object
  103406. * @param source defines the source object
  103407. * @returns the new object
  103408. */
  103409. static Instanciate<T>(creationFunction: () => T, source: T): T;
  103410. }
  103411. }
  103412. declare module BABYLON {
  103413. /**
  103414. * Class used to manipulate GUIDs
  103415. */
  103416. export class GUID {
  103417. /**
  103418. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103419. * Be aware Math.random() could cause collisions, but:
  103420. * "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"
  103421. * @returns a pseudo random id
  103422. */
  103423. static RandomId(): string;
  103424. }
  103425. }
  103426. declare module BABYLON {
  103427. /**
  103428. * Base class of all the textures in babylon.
  103429. * It groups all the common properties the materials, post process, lights... might need
  103430. * in order to make a correct use of the texture.
  103431. */
  103432. export class BaseTexture implements IAnimatable {
  103433. /**
  103434. * Default anisotropic filtering level for the application.
  103435. * It is set to 4 as a good tradeoff between perf and quality.
  103436. */
  103437. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  103438. /**
  103439. * Gets or sets the unique id of the texture
  103440. */
  103441. uniqueId: number;
  103442. /**
  103443. * Define the name of the texture.
  103444. */
  103445. name: string;
  103446. /**
  103447. * Gets or sets an object used to store user defined information.
  103448. */
  103449. metadata: any;
  103450. /**
  103451. * For internal use only. Please do not use.
  103452. */
  103453. reservedDataStore: any;
  103454. private _hasAlpha;
  103455. /**
  103456. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  103457. */
  103458. set hasAlpha(value: boolean);
  103459. get hasAlpha(): boolean;
  103460. /**
  103461. * Defines if the alpha value should be determined via the rgb values.
  103462. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  103463. */
  103464. getAlphaFromRGB: boolean;
  103465. /**
  103466. * Intensity or strength of the texture.
  103467. * It is commonly used by materials to fine tune the intensity of the texture
  103468. */
  103469. level: number;
  103470. /**
  103471. * Define the UV chanel to use starting from 0 and defaulting to 0.
  103472. * This is part of the texture as textures usually maps to one uv set.
  103473. */
  103474. coordinatesIndex: number;
  103475. private _coordinatesMode;
  103476. /**
  103477. * How a texture is mapped.
  103478. *
  103479. * | Value | Type | Description |
  103480. * | ----- | ----------------------------------- | ----------- |
  103481. * | 0 | EXPLICIT_MODE | |
  103482. * | 1 | SPHERICAL_MODE | |
  103483. * | 2 | PLANAR_MODE | |
  103484. * | 3 | CUBIC_MODE | |
  103485. * | 4 | PROJECTION_MODE | |
  103486. * | 5 | SKYBOX_MODE | |
  103487. * | 6 | INVCUBIC_MODE | |
  103488. * | 7 | EQUIRECTANGULAR_MODE | |
  103489. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  103490. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  103491. */
  103492. set coordinatesMode(value: number);
  103493. get coordinatesMode(): number;
  103494. /**
  103495. * | Value | Type | Description |
  103496. * | ----- | ------------------ | ----------- |
  103497. * | 0 | CLAMP_ADDRESSMODE | |
  103498. * | 1 | WRAP_ADDRESSMODE | |
  103499. * | 2 | MIRROR_ADDRESSMODE | |
  103500. */
  103501. wrapU: number;
  103502. /**
  103503. * | Value | Type | Description |
  103504. * | ----- | ------------------ | ----------- |
  103505. * | 0 | CLAMP_ADDRESSMODE | |
  103506. * | 1 | WRAP_ADDRESSMODE | |
  103507. * | 2 | MIRROR_ADDRESSMODE | |
  103508. */
  103509. wrapV: number;
  103510. /**
  103511. * | Value | Type | Description |
  103512. * | ----- | ------------------ | ----------- |
  103513. * | 0 | CLAMP_ADDRESSMODE | |
  103514. * | 1 | WRAP_ADDRESSMODE | |
  103515. * | 2 | MIRROR_ADDRESSMODE | |
  103516. */
  103517. wrapR: number;
  103518. /**
  103519. * With compliant hardware and browser (supporting anisotropic filtering)
  103520. * this defines the level of anisotropic filtering in the texture.
  103521. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  103522. */
  103523. anisotropicFilteringLevel: number;
  103524. /**
  103525. * Define if the texture is a cube texture or if false a 2d texture.
  103526. */
  103527. get isCube(): boolean;
  103528. set isCube(value: boolean);
  103529. /**
  103530. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103531. */
  103532. get is3D(): boolean;
  103533. set is3D(value: boolean);
  103534. /**
  103535. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103536. */
  103537. get is2DArray(): boolean;
  103538. set is2DArray(value: boolean);
  103539. /**
  103540. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103541. * HDR texture are usually stored in linear space.
  103542. * This only impacts the PBR and Background materials
  103543. */
  103544. gammaSpace: boolean;
  103545. /**
  103546. * Gets or sets whether or not the texture contains RGBD data.
  103547. */
  103548. get isRGBD(): boolean;
  103549. set isRGBD(value: boolean);
  103550. /**
  103551. * Is Z inverted in the texture (useful in a cube texture).
  103552. */
  103553. invertZ: boolean;
  103554. /**
  103555. * Are mip maps generated for this texture or not.
  103556. */
  103557. get noMipmap(): boolean;
  103558. /**
  103559. * @hidden
  103560. */
  103561. lodLevelInAlpha: boolean;
  103562. /**
  103563. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103564. */
  103565. get lodGenerationOffset(): number;
  103566. set lodGenerationOffset(value: number);
  103567. /**
  103568. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103569. */
  103570. get lodGenerationScale(): number;
  103571. set lodGenerationScale(value: number);
  103572. /**
  103573. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103574. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103575. * average roughness values.
  103576. */
  103577. get linearSpecularLOD(): boolean;
  103578. set linearSpecularLOD(value: boolean);
  103579. /**
  103580. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103581. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103582. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103583. */
  103584. get irradianceTexture(): Nullable<BaseTexture>;
  103585. set irradianceTexture(value: Nullable<BaseTexture>);
  103586. /**
  103587. * Define if the texture is a render target.
  103588. */
  103589. isRenderTarget: boolean;
  103590. /**
  103591. * Define the unique id of the texture in the scene.
  103592. */
  103593. get uid(): string;
  103594. /**
  103595. * Return a string representation of the texture.
  103596. * @returns the texture as a string
  103597. */
  103598. toString(): string;
  103599. /**
  103600. * Get the class name of the texture.
  103601. * @returns "BaseTexture"
  103602. */
  103603. getClassName(): string;
  103604. /**
  103605. * Define the list of animation attached to the texture.
  103606. */
  103607. animations: Animation[];
  103608. /**
  103609. * An event triggered when the texture is disposed.
  103610. */
  103611. onDisposeObservable: Observable<BaseTexture>;
  103612. private _onDisposeObserver;
  103613. /**
  103614. * Callback triggered when the texture has been disposed.
  103615. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103616. */
  103617. set onDispose(callback: () => void);
  103618. /**
  103619. * Define the current state of the loading sequence when in delayed load mode.
  103620. */
  103621. delayLoadState: number;
  103622. private _scene;
  103623. /** @hidden */
  103624. _texture: Nullable<InternalTexture>;
  103625. private _uid;
  103626. /**
  103627. * Define if the texture is preventinga material to render or not.
  103628. * If not and the texture is not ready, the engine will use a default black texture instead.
  103629. */
  103630. get isBlocking(): boolean;
  103631. /**
  103632. * Instantiates a new BaseTexture.
  103633. * Base class of all the textures in babylon.
  103634. * It groups all the common properties the materials, post process, lights... might need
  103635. * in order to make a correct use of the texture.
  103636. * @param scene Define the scene the texture blongs to
  103637. */
  103638. constructor(scene: Nullable<Scene>);
  103639. /**
  103640. * Get the scene the texture belongs to.
  103641. * @returns the scene or null if undefined
  103642. */
  103643. getScene(): Nullable<Scene>;
  103644. /**
  103645. * Get the texture transform matrix used to offset tile the texture for istance.
  103646. * @returns the transformation matrix
  103647. */
  103648. getTextureMatrix(): Matrix;
  103649. /**
  103650. * Get the texture reflection matrix used to rotate/transform the reflection.
  103651. * @returns the reflection matrix
  103652. */
  103653. getReflectionTextureMatrix(): Matrix;
  103654. /**
  103655. * Get the underlying lower level texture from Babylon.
  103656. * @returns the insternal texture
  103657. */
  103658. getInternalTexture(): Nullable<InternalTexture>;
  103659. /**
  103660. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103661. * @returns true if ready or not blocking
  103662. */
  103663. isReadyOrNotBlocking(): boolean;
  103664. /**
  103665. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103666. * @returns true if fully ready
  103667. */
  103668. isReady(): boolean;
  103669. private _cachedSize;
  103670. /**
  103671. * Get the size of the texture.
  103672. * @returns the texture size.
  103673. */
  103674. getSize(): ISize;
  103675. /**
  103676. * Get the base size of the texture.
  103677. * It can be different from the size if the texture has been resized for POT for instance
  103678. * @returns the base size
  103679. */
  103680. getBaseSize(): ISize;
  103681. /**
  103682. * Update the sampling mode of the texture.
  103683. * Default is Trilinear mode.
  103684. *
  103685. * | Value | Type | Description |
  103686. * | ----- | ------------------ | ----------- |
  103687. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103688. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103689. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103690. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103691. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103692. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103693. * | 7 | NEAREST_LINEAR | |
  103694. * | 8 | NEAREST_NEAREST | |
  103695. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103696. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103697. * | 11 | LINEAR_LINEAR | |
  103698. * | 12 | LINEAR_NEAREST | |
  103699. *
  103700. * > _mag_: magnification filter (close to the viewer)
  103701. * > _min_: minification filter (far from the viewer)
  103702. * > _mip_: filter used between mip map levels
  103703. *@param samplingMode Define the new sampling mode of the texture
  103704. */
  103705. updateSamplingMode(samplingMode: number): void;
  103706. /**
  103707. * Scales the texture if is `canRescale()`
  103708. * @param ratio the resize factor we want to use to rescale
  103709. */
  103710. scale(ratio: number): void;
  103711. /**
  103712. * Get if the texture can rescale.
  103713. */
  103714. get canRescale(): boolean;
  103715. /** @hidden */
  103716. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103717. /** @hidden */
  103718. _rebuild(): void;
  103719. /**
  103720. * Triggers the load sequence in delayed load mode.
  103721. */
  103722. delayLoad(): void;
  103723. /**
  103724. * Clones the texture.
  103725. * @returns the cloned texture
  103726. */
  103727. clone(): Nullable<BaseTexture>;
  103728. /**
  103729. * Get the texture underlying type (INT, FLOAT...)
  103730. */
  103731. get textureType(): number;
  103732. /**
  103733. * Get the texture underlying format (RGB, RGBA...)
  103734. */
  103735. get textureFormat(): number;
  103736. /**
  103737. * Indicates that textures need to be re-calculated for all materials
  103738. */
  103739. protected _markAllSubMeshesAsTexturesDirty(): void;
  103740. /**
  103741. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103742. * This will returns an RGBA array buffer containing either in values (0-255) or
  103743. * float values (0-1) depending of the underlying buffer type.
  103744. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103745. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103746. * @param buffer defines a user defined buffer to fill with data (can be null)
  103747. * @returns The Array buffer containing the pixels data.
  103748. */
  103749. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103750. /**
  103751. * Release and destroy the underlying lower level texture aka internalTexture.
  103752. */
  103753. releaseInternalTexture(): void;
  103754. /** @hidden */
  103755. get _lodTextureHigh(): Nullable<BaseTexture>;
  103756. /** @hidden */
  103757. get _lodTextureMid(): Nullable<BaseTexture>;
  103758. /** @hidden */
  103759. get _lodTextureLow(): Nullable<BaseTexture>;
  103760. /**
  103761. * Dispose the texture and release its associated resources.
  103762. */
  103763. dispose(): void;
  103764. /**
  103765. * Serialize the texture into a JSON representation that can be parsed later on.
  103766. * @returns the JSON representation of the texture
  103767. */
  103768. serialize(): any;
  103769. /**
  103770. * Helper function to be called back once a list of texture contains only ready textures.
  103771. * @param textures Define the list of textures to wait for
  103772. * @param callback Define the callback triggered once the entire list will be ready
  103773. */
  103774. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103775. }
  103776. }
  103777. declare module BABYLON {
  103778. /**
  103779. * Options to be used when creating an effect.
  103780. */
  103781. export interface IEffectCreationOptions {
  103782. /**
  103783. * Atrributes that will be used in the shader.
  103784. */
  103785. attributes: string[];
  103786. /**
  103787. * Uniform varible names that will be set in the shader.
  103788. */
  103789. uniformsNames: string[];
  103790. /**
  103791. * Uniform buffer variable names that will be set in the shader.
  103792. */
  103793. uniformBuffersNames: string[];
  103794. /**
  103795. * Sampler texture variable names that will be set in the shader.
  103796. */
  103797. samplers: string[];
  103798. /**
  103799. * Define statements that will be set in the shader.
  103800. */
  103801. defines: any;
  103802. /**
  103803. * Possible fallbacks for this effect to improve performance when needed.
  103804. */
  103805. fallbacks: Nullable<IEffectFallbacks>;
  103806. /**
  103807. * Callback that will be called when the shader is compiled.
  103808. */
  103809. onCompiled: Nullable<(effect: Effect) => void>;
  103810. /**
  103811. * Callback that will be called if an error occurs during shader compilation.
  103812. */
  103813. onError: Nullable<(effect: Effect, errors: string) => void>;
  103814. /**
  103815. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103816. */
  103817. indexParameters?: any;
  103818. /**
  103819. * Max number of lights that can be used in the shader.
  103820. */
  103821. maxSimultaneousLights?: number;
  103822. /**
  103823. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103824. */
  103825. transformFeedbackVaryings?: Nullable<string[]>;
  103826. }
  103827. /**
  103828. * Effect containing vertex and fragment shader that can be executed on an object.
  103829. */
  103830. export class Effect implements IDisposable {
  103831. /**
  103832. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103833. */
  103834. static ShadersRepository: string;
  103835. /**
  103836. * Enable logging of the shader code when a compilation error occurs
  103837. */
  103838. static LogShaderCodeOnCompilationError: boolean;
  103839. /**
  103840. * Name of the effect.
  103841. */
  103842. name: any;
  103843. /**
  103844. * String container all the define statements that should be set on the shader.
  103845. */
  103846. defines: string;
  103847. /**
  103848. * Callback that will be called when the shader is compiled.
  103849. */
  103850. onCompiled: Nullable<(effect: Effect) => void>;
  103851. /**
  103852. * Callback that will be called if an error occurs during shader compilation.
  103853. */
  103854. onError: Nullable<(effect: Effect, errors: string) => void>;
  103855. /**
  103856. * Callback that will be called when effect is bound.
  103857. */
  103858. onBind: Nullable<(effect: Effect) => void>;
  103859. /**
  103860. * Unique ID of the effect.
  103861. */
  103862. uniqueId: number;
  103863. /**
  103864. * Observable that will be called when the shader is compiled.
  103865. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103866. */
  103867. onCompileObservable: Observable<Effect>;
  103868. /**
  103869. * Observable that will be called if an error occurs during shader compilation.
  103870. */
  103871. onErrorObservable: Observable<Effect>;
  103872. /** @hidden */
  103873. _onBindObservable: Nullable<Observable<Effect>>;
  103874. /**
  103875. * @hidden
  103876. * Specifies if the effect was previously ready
  103877. */
  103878. _wasPreviouslyReady: boolean;
  103879. /**
  103880. * Observable that will be called when effect is bound.
  103881. */
  103882. get onBindObservable(): Observable<Effect>;
  103883. /** @hidden */
  103884. _bonesComputationForcedToCPU: boolean;
  103885. private static _uniqueIdSeed;
  103886. private _engine;
  103887. private _uniformBuffersNames;
  103888. private _uniformsNames;
  103889. private _samplerList;
  103890. private _samplers;
  103891. private _isReady;
  103892. private _compilationError;
  103893. private _allFallbacksProcessed;
  103894. private _attributesNames;
  103895. private _attributes;
  103896. private _attributeLocationByName;
  103897. private _uniforms;
  103898. /**
  103899. * Key for the effect.
  103900. * @hidden
  103901. */
  103902. _key: string;
  103903. private _indexParameters;
  103904. private _fallbacks;
  103905. private _vertexSourceCode;
  103906. private _fragmentSourceCode;
  103907. private _vertexSourceCodeOverride;
  103908. private _fragmentSourceCodeOverride;
  103909. private _transformFeedbackVaryings;
  103910. /**
  103911. * Compiled shader to webGL program.
  103912. * @hidden
  103913. */
  103914. _pipelineContext: Nullable<IPipelineContext>;
  103915. private _valueCache;
  103916. private static _baseCache;
  103917. /**
  103918. * Instantiates an effect.
  103919. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103920. * @param baseName Name of the effect.
  103921. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103922. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103923. * @param samplers List of sampler variables that will be passed to the shader.
  103924. * @param engine Engine to be used to render the effect
  103925. * @param defines Define statements to be added to the shader.
  103926. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103927. * @param onCompiled Callback that will be called when the shader is compiled.
  103928. * @param onError Callback that will be called if an error occurs during shader compilation.
  103929. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103930. */
  103931. 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);
  103932. private _useFinalCode;
  103933. /**
  103934. * Unique key for this effect
  103935. */
  103936. get key(): string;
  103937. /**
  103938. * If the effect has been compiled and prepared.
  103939. * @returns if the effect is compiled and prepared.
  103940. */
  103941. isReady(): boolean;
  103942. private _isReadyInternal;
  103943. /**
  103944. * The engine the effect was initialized with.
  103945. * @returns the engine.
  103946. */
  103947. getEngine(): Engine;
  103948. /**
  103949. * The pipeline context for this effect
  103950. * @returns the associated pipeline context
  103951. */
  103952. getPipelineContext(): Nullable<IPipelineContext>;
  103953. /**
  103954. * The set of names of attribute variables for the shader.
  103955. * @returns An array of attribute names.
  103956. */
  103957. getAttributesNames(): string[];
  103958. /**
  103959. * Returns the attribute at the given index.
  103960. * @param index The index of the attribute.
  103961. * @returns The location of the attribute.
  103962. */
  103963. getAttributeLocation(index: number): number;
  103964. /**
  103965. * Returns the attribute based on the name of the variable.
  103966. * @param name of the attribute to look up.
  103967. * @returns the attribute location.
  103968. */
  103969. getAttributeLocationByName(name: string): number;
  103970. /**
  103971. * The number of attributes.
  103972. * @returns the numnber of attributes.
  103973. */
  103974. getAttributesCount(): number;
  103975. /**
  103976. * Gets the index of a uniform variable.
  103977. * @param uniformName of the uniform to look up.
  103978. * @returns the index.
  103979. */
  103980. getUniformIndex(uniformName: string): number;
  103981. /**
  103982. * Returns the attribute based on the name of the variable.
  103983. * @param uniformName of the uniform to look up.
  103984. * @returns the location of the uniform.
  103985. */
  103986. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103987. /**
  103988. * Returns an array of sampler variable names
  103989. * @returns The array of sampler variable neames.
  103990. */
  103991. getSamplers(): string[];
  103992. /**
  103993. * The error from the last compilation.
  103994. * @returns the error string.
  103995. */
  103996. getCompilationError(): string;
  103997. /**
  103998. * Gets a boolean indicating that all fallbacks were used during compilation
  103999. * @returns true if all fallbacks were used
  104000. */
  104001. allFallbacksProcessed(): boolean;
  104002. /**
  104003. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  104004. * @param func The callback to be used.
  104005. */
  104006. executeWhenCompiled(func: (effect: Effect) => void): void;
  104007. private _checkIsReady;
  104008. private _loadShader;
  104009. /**
  104010. * Recompiles the webGL program
  104011. * @param vertexSourceCode The source code for the vertex shader.
  104012. * @param fragmentSourceCode The source code for the fragment shader.
  104013. * @param onCompiled Callback called when completed.
  104014. * @param onError Callback called on error.
  104015. * @hidden
  104016. */
  104017. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  104018. /**
  104019. * Prepares the effect
  104020. * @hidden
  104021. */
  104022. _prepareEffect(): void;
  104023. private _getShaderCodeAndErrorLine;
  104024. private _processCompilationErrors;
  104025. /**
  104026. * Checks if the effect is supported. (Must be called after compilation)
  104027. */
  104028. get isSupported(): boolean;
  104029. /**
  104030. * Binds a texture to the engine to be used as output of the shader.
  104031. * @param channel Name of the output variable.
  104032. * @param texture Texture to bind.
  104033. * @hidden
  104034. */
  104035. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  104036. /**
  104037. * Sets a texture on the engine to be used in the shader.
  104038. * @param channel Name of the sampler variable.
  104039. * @param texture Texture to set.
  104040. */
  104041. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  104042. /**
  104043. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  104044. * @param channel Name of the sampler variable.
  104045. * @param texture Texture to set.
  104046. */
  104047. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  104048. /**
  104049. * Sets an array of textures on the engine to be used in the shader.
  104050. * @param channel Name of the variable.
  104051. * @param textures Textures to set.
  104052. */
  104053. setTextureArray(channel: string, textures: BaseTexture[]): void;
  104054. /**
  104055. * 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)
  104056. * @param channel Name of the sampler variable.
  104057. * @param postProcess Post process to get the input texture from.
  104058. */
  104059. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  104060. /**
  104061. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  104062. * 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)
  104063. * @param channel Name of the sampler variable.
  104064. * @param postProcess Post process to get the output texture from.
  104065. */
  104066. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  104067. /** @hidden */
  104068. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  104069. /** @hidden */
  104070. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  104071. /** @hidden */
  104072. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  104073. /** @hidden */
  104074. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  104075. /**
  104076. * Binds a buffer to a uniform.
  104077. * @param buffer Buffer to bind.
  104078. * @param name Name of the uniform variable to bind to.
  104079. */
  104080. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  104081. /**
  104082. * Binds block to a uniform.
  104083. * @param blockName Name of the block to bind.
  104084. * @param index Index to bind.
  104085. */
  104086. bindUniformBlock(blockName: string, index: number): void;
  104087. /**
  104088. * Sets an interger value on a uniform variable.
  104089. * @param uniformName Name of the variable.
  104090. * @param value Value to be set.
  104091. * @returns this effect.
  104092. */
  104093. setInt(uniformName: string, value: number): Effect;
  104094. /**
  104095. * Sets an int array on a uniform variable.
  104096. * @param uniformName Name of the variable.
  104097. * @param array array to be set.
  104098. * @returns this effect.
  104099. */
  104100. setIntArray(uniformName: string, array: Int32Array): Effect;
  104101. /**
  104102. * 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)
  104103. * @param uniformName Name of the variable.
  104104. * @param array array to be set.
  104105. * @returns this effect.
  104106. */
  104107. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104108. /**
  104109. * 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)
  104110. * @param uniformName Name of the variable.
  104111. * @param array array to be set.
  104112. * @returns this effect.
  104113. */
  104114. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104115. /**
  104116. * 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)
  104117. * @param uniformName Name of the variable.
  104118. * @param array array to be set.
  104119. * @returns this effect.
  104120. */
  104121. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104122. /**
  104123. * Sets an float array on a uniform variable.
  104124. * @param uniformName Name of the variable.
  104125. * @param array array to be set.
  104126. * @returns this effect.
  104127. */
  104128. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104129. /**
  104130. * 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)
  104131. * @param uniformName Name of the variable.
  104132. * @param array array to be set.
  104133. * @returns this effect.
  104134. */
  104135. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104136. /**
  104137. * 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)
  104138. * @param uniformName Name of the variable.
  104139. * @param array array to be set.
  104140. * @returns this effect.
  104141. */
  104142. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104143. /**
  104144. * 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)
  104145. * @param uniformName Name of the variable.
  104146. * @param array array to be set.
  104147. * @returns this effect.
  104148. */
  104149. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104150. /**
  104151. * Sets an array on a uniform variable.
  104152. * @param uniformName Name of the variable.
  104153. * @param array array to be set.
  104154. * @returns this effect.
  104155. */
  104156. setArray(uniformName: string, array: number[]): Effect;
  104157. /**
  104158. * 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)
  104159. * @param uniformName Name of the variable.
  104160. * @param array array to be set.
  104161. * @returns this effect.
  104162. */
  104163. setArray2(uniformName: string, array: number[]): Effect;
  104164. /**
  104165. * 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)
  104166. * @param uniformName Name of the variable.
  104167. * @param array array to be set.
  104168. * @returns this effect.
  104169. */
  104170. setArray3(uniformName: string, array: number[]): Effect;
  104171. /**
  104172. * 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)
  104173. * @param uniformName Name of the variable.
  104174. * @param array array to be set.
  104175. * @returns this effect.
  104176. */
  104177. setArray4(uniformName: string, array: number[]): Effect;
  104178. /**
  104179. * Sets matrices on a uniform variable.
  104180. * @param uniformName Name of the variable.
  104181. * @param matrices matrices to be set.
  104182. * @returns this effect.
  104183. */
  104184. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104185. /**
  104186. * Sets matrix on a uniform variable.
  104187. * @param uniformName Name of the variable.
  104188. * @param matrix matrix to be set.
  104189. * @returns this effect.
  104190. */
  104191. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  104192. /**
  104193. * 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)
  104194. * @param uniformName Name of the variable.
  104195. * @param matrix matrix to be set.
  104196. * @returns this effect.
  104197. */
  104198. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  104199. /**
  104200. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  104201. * @param uniformName Name of the variable.
  104202. * @param matrix matrix to be set.
  104203. * @returns this effect.
  104204. */
  104205. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  104206. /**
  104207. * Sets a float on a uniform variable.
  104208. * @param uniformName Name of the variable.
  104209. * @param value value to be set.
  104210. * @returns this effect.
  104211. */
  104212. setFloat(uniformName: string, value: number): Effect;
  104213. /**
  104214. * Sets a boolean on a uniform variable.
  104215. * @param uniformName Name of the variable.
  104216. * @param bool value to be set.
  104217. * @returns this effect.
  104218. */
  104219. setBool(uniformName: string, bool: boolean): Effect;
  104220. /**
  104221. * Sets a Vector2 on a uniform variable.
  104222. * @param uniformName Name of the variable.
  104223. * @param vector2 vector2 to be set.
  104224. * @returns this effect.
  104225. */
  104226. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  104227. /**
  104228. * Sets a float2 on a uniform variable.
  104229. * @param uniformName Name of the variable.
  104230. * @param x First float in float2.
  104231. * @param y Second float in float2.
  104232. * @returns this effect.
  104233. */
  104234. setFloat2(uniformName: string, x: number, y: number): Effect;
  104235. /**
  104236. * Sets a Vector3 on a uniform variable.
  104237. * @param uniformName Name of the variable.
  104238. * @param vector3 Value to be set.
  104239. * @returns this effect.
  104240. */
  104241. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  104242. /**
  104243. * Sets a float3 on a uniform variable.
  104244. * @param uniformName Name of the variable.
  104245. * @param x First float in float3.
  104246. * @param y Second float in float3.
  104247. * @param z Third float in float3.
  104248. * @returns this effect.
  104249. */
  104250. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  104251. /**
  104252. * Sets a Vector4 on a uniform variable.
  104253. * @param uniformName Name of the variable.
  104254. * @param vector4 Value to be set.
  104255. * @returns this effect.
  104256. */
  104257. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  104258. /**
  104259. * Sets a float4 on a uniform variable.
  104260. * @param uniformName Name of the variable.
  104261. * @param x First float in float4.
  104262. * @param y Second float in float4.
  104263. * @param z Third float in float4.
  104264. * @param w Fourth float in float4.
  104265. * @returns this effect.
  104266. */
  104267. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  104268. /**
  104269. * Sets a Color3 on a uniform variable.
  104270. * @param uniformName Name of the variable.
  104271. * @param color3 Value to be set.
  104272. * @returns this effect.
  104273. */
  104274. setColor3(uniformName: string, color3: IColor3Like): Effect;
  104275. /**
  104276. * Sets a Color4 on a uniform variable.
  104277. * @param uniformName Name of the variable.
  104278. * @param color3 Value to be set.
  104279. * @param alpha Alpha value to be set.
  104280. * @returns this effect.
  104281. */
  104282. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  104283. /**
  104284. * Sets a Color4 on a uniform variable
  104285. * @param uniformName defines the name of the variable
  104286. * @param color4 defines the value to be set
  104287. * @returns this effect.
  104288. */
  104289. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  104290. /** Release all associated resources */
  104291. dispose(): void;
  104292. /**
  104293. * This function will add a new shader to the shader store
  104294. * @param name the name of the shader
  104295. * @param pixelShader optional pixel shader content
  104296. * @param vertexShader optional vertex shader content
  104297. */
  104298. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  104299. /**
  104300. * Store of each shader (The can be looked up using effect.key)
  104301. */
  104302. static ShadersStore: {
  104303. [key: string]: string;
  104304. };
  104305. /**
  104306. * Store of each included file for a shader (The can be looked up using effect.key)
  104307. */
  104308. static IncludesShadersStore: {
  104309. [key: string]: string;
  104310. };
  104311. /**
  104312. * Resets the cache of effects.
  104313. */
  104314. static ResetCache(): void;
  104315. }
  104316. }
  104317. declare module BABYLON {
  104318. /**
  104319. * Interface used to describe the capabilities of the engine relatively to the current browser
  104320. */
  104321. export interface EngineCapabilities {
  104322. /** Maximum textures units per fragment shader */
  104323. maxTexturesImageUnits: number;
  104324. /** Maximum texture units per vertex shader */
  104325. maxVertexTextureImageUnits: number;
  104326. /** Maximum textures units in the entire pipeline */
  104327. maxCombinedTexturesImageUnits: number;
  104328. /** Maximum texture size */
  104329. maxTextureSize: number;
  104330. /** Maximum texture samples */
  104331. maxSamples?: number;
  104332. /** Maximum cube texture size */
  104333. maxCubemapTextureSize: number;
  104334. /** Maximum render texture size */
  104335. maxRenderTextureSize: number;
  104336. /** Maximum number of vertex attributes */
  104337. maxVertexAttribs: number;
  104338. /** Maximum number of varyings */
  104339. maxVaryingVectors: number;
  104340. /** Maximum number of uniforms per vertex shader */
  104341. maxVertexUniformVectors: number;
  104342. /** Maximum number of uniforms per fragment shader */
  104343. maxFragmentUniformVectors: number;
  104344. /** Defines if standard derivates (dx/dy) are supported */
  104345. standardDerivatives: boolean;
  104346. /** Defines if s3tc texture compression is supported */
  104347. s3tc?: WEBGL_compressed_texture_s3tc;
  104348. /** Defines if pvrtc texture compression is supported */
  104349. pvrtc: any;
  104350. /** Defines if etc1 texture compression is supported */
  104351. etc1: any;
  104352. /** Defines if etc2 texture compression is supported */
  104353. etc2: any;
  104354. /** Defines if astc texture compression is supported */
  104355. astc: any;
  104356. /** Defines if float textures are supported */
  104357. textureFloat: boolean;
  104358. /** Defines if vertex array objects are supported */
  104359. vertexArrayObject: boolean;
  104360. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  104361. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  104362. /** Gets the maximum level of anisotropy supported */
  104363. maxAnisotropy: number;
  104364. /** Defines if instancing is supported */
  104365. instancedArrays: boolean;
  104366. /** Defines if 32 bits indices are supported */
  104367. uintIndices: boolean;
  104368. /** Defines if high precision shaders are supported */
  104369. highPrecisionShaderSupported: boolean;
  104370. /** Defines if depth reading in the fragment shader is supported */
  104371. fragmentDepthSupported: boolean;
  104372. /** Defines if float texture linear filtering is supported*/
  104373. textureFloatLinearFiltering: boolean;
  104374. /** Defines if rendering to float textures is supported */
  104375. textureFloatRender: boolean;
  104376. /** Defines if half float textures are supported*/
  104377. textureHalfFloat: boolean;
  104378. /** Defines if half float texture linear filtering is supported*/
  104379. textureHalfFloatLinearFiltering: boolean;
  104380. /** Defines if rendering to half float textures is supported */
  104381. textureHalfFloatRender: boolean;
  104382. /** Defines if textureLOD shader command is supported */
  104383. textureLOD: boolean;
  104384. /** Defines if draw buffers extension is supported */
  104385. drawBuffersExtension: boolean;
  104386. /** Defines if depth textures are supported */
  104387. depthTextureExtension: boolean;
  104388. /** Defines if float color buffer are supported */
  104389. colorBufferFloat: boolean;
  104390. /** Gets disjoint timer query extension (null if not supported) */
  104391. timerQuery?: EXT_disjoint_timer_query;
  104392. /** Defines if timestamp can be used with timer query */
  104393. canUseTimestampForTimerQuery: boolean;
  104394. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  104395. multiview?: any;
  104396. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  104397. oculusMultiview?: any;
  104398. /** Function used to let the system compiles shaders in background */
  104399. parallelShaderCompile?: {
  104400. COMPLETION_STATUS_KHR: number;
  104401. };
  104402. /** Max number of texture samples for MSAA */
  104403. maxMSAASamples: number;
  104404. /** Defines if the blend min max extension is supported */
  104405. blendMinMax: boolean;
  104406. }
  104407. }
  104408. declare module BABYLON {
  104409. /**
  104410. * @hidden
  104411. **/
  104412. export class DepthCullingState {
  104413. private _isDepthTestDirty;
  104414. private _isDepthMaskDirty;
  104415. private _isDepthFuncDirty;
  104416. private _isCullFaceDirty;
  104417. private _isCullDirty;
  104418. private _isZOffsetDirty;
  104419. private _isFrontFaceDirty;
  104420. private _depthTest;
  104421. private _depthMask;
  104422. private _depthFunc;
  104423. private _cull;
  104424. private _cullFace;
  104425. private _zOffset;
  104426. private _frontFace;
  104427. /**
  104428. * Initializes the state.
  104429. */
  104430. constructor();
  104431. get isDirty(): boolean;
  104432. get zOffset(): number;
  104433. set zOffset(value: number);
  104434. get cullFace(): Nullable<number>;
  104435. set cullFace(value: Nullable<number>);
  104436. get cull(): Nullable<boolean>;
  104437. set cull(value: Nullable<boolean>);
  104438. get depthFunc(): Nullable<number>;
  104439. set depthFunc(value: Nullable<number>);
  104440. get depthMask(): boolean;
  104441. set depthMask(value: boolean);
  104442. get depthTest(): boolean;
  104443. set depthTest(value: boolean);
  104444. get frontFace(): Nullable<number>;
  104445. set frontFace(value: Nullable<number>);
  104446. reset(): void;
  104447. apply(gl: WebGLRenderingContext): void;
  104448. }
  104449. }
  104450. declare module BABYLON {
  104451. /**
  104452. * @hidden
  104453. **/
  104454. export class StencilState {
  104455. /** 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 */
  104456. static readonly ALWAYS: number;
  104457. /** Passed to stencilOperation to specify that stencil value must be kept */
  104458. static readonly KEEP: number;
  104459. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104460. static readonly REPLACE: number;
  104461. private _isStencilTestDirty;
  104462. private _isStencilMaskDirty;
  104463. private _isStencilFuncDirty;
  104464. private _isStencilOpDirty;
  104465. private _stencilTest;
  104466. private _stencilMask;
  104467. private _stencilFunc;
  104468. private _stencilFuncRef;
  104469. private _stencilFuncMask;
  104470. private _stencilOpStencilFail;
  104471. private _stencilOpDepthFail;
  104472. private _stencilOpStencilDepthPass;
  104473. get isDirty(): boolean;
  104474. get stencilFunc(): number;
  104475. set stencilFunc(value: number);
  104476. get stencilFuncRef(): number;
  104477. set stencilFuncRef(value: number);
  104478. get stencilFuncMask(): number;
  104479. set stencilFuncMask(value: number);
  104480. get stencilOpStencilFail(): number;
  104481. set stencilOpStencilFail(value: number);
  104482. get stencilOpDepthFail(): number;
  104483. set stencilOpDepthFail(value: number);
  104484. get stencilOpStencilDepthPass(): number;
  104485. set stencilOpStencilDepthPass(value: number);
  104486. get stencilMask(): number;
  104487. set stencilMask(value: number);
  104488. get stencilTest(): boolean;
  104489. set stencilTest(value: boolean);
  104490. constructor();
  104491. reset(): void;
  104492. apply(gl: WebGLRenderingContext): void;
  104493. }
  104494. }
  104495. declare module BABYLON {
  104496. /**
  104497. * @hidden
  104498. **/
  104499. export class AlphaState {
  104500. private _isAlphaBlendDirty;
  104501. private _isBlendFunctionParametersDirty;
  104502. private _isBlendEquationParametersDirty;
  104503. private _isBlendConstantsDirty;
  104504. private _alphaBlend;
  104505. private _blendFunctionParameters;
  104506. private _blendEquationParameters;
  104507. private _blendConstants;
  104508. /**
  104509. * Initializes the state.
  104510. */
  104511. constructor();
  104512. get isDirty(): boolean;
  104513. get alphaBlend(): boolean;
  104514. set alphaBlend(value: boolean);
  104515. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  104516. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  104517. setAlphaEquationParameters(rgb: number, alpha: number): void;
  104518. reset(): void;
  104519. apply(gl: WebGLRenderingContext): void;
  104520. }
  104521. }
  104522. declare module BABYLON {
  104523. /** @hidden */
  104524. export class WebGL2ShaderProcessor implements IShaderProcessor {
  104525. attributeProcessor(attribute: string): string;
  104526. varyingProcessor(varying: string, isFragment: boolean): string;
  104527. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  104528. }
  104529. }
  104530. declare module BABYLON {
  104531. /**
  104532. * Interface for attribute information associated with buffer instanciation
  104533. */
  104534. export interface InstancingAttributeInfo {
  104535. /**
  104536. * Name of the GLSL attribute
  104537. * if attribute index is not specified, this is used to retrieve the index from the effect
  104538. */
  104539. attributeName: string;
  104540. /**
  104541. * Index/offset of the attribute in the vertex shader
  104542. * if not specified, this will be computes from the name.
  104543. */
  104544. index?: number;
  104545. /**
  104546. * size of the attribute, 1, 2, 3 or 4
  104547. */
  104548. attributeSize: number;
  104549. /**
  104550. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104551. */
  104552. offset: number;
  104553. /**
  104554. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104555. * default to 1
  104556. */
  104557. divisor?: number;
  104558. /**
  104559. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104560. * default is FLOAT
  104561. */
  104562. attributeType?: number;
  104563. /**
  104564. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104565. */
  104566. normalized?: boolean;
  104567. }
  104568. }
  104569. declare module BABYLON {
  104570. interface ThinEngine {
  104571. /**
  104572. * Update a video texture
  104573. * @param texture defines the texture to update
  104574. * @param video defines the video element to use
  104575. * @param invertY defines if data must be stored with Y axis inverted
  104576. */
  104577. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104578. }
  104579. }
  104580. declare module BABYLON {
  104581. /**
  104582. * Settings for finer control over video usage
  104583. */
  104584. export interface VideoTextureSettings {
  104585. /**
  104586. * Applies `autoplay` to video, if specified
  104587. */
  104588. autoPlay?: boolean;
  104589. /**
  104590. * Applies `loop` to video, if specified
  104591. */
  104592. loop?: boolean;
  104593. /**
  104594. * Automatically updates internal texture from video at every frame in the render loop
  104595. */
  104596. autoUpdateTexture: boolean;
  104597. /**
  104598. * Image src displayed during the video loading or until the user interacts with the video.
  104599. */
  104600. poster?: string;
  104601. }
  104602. /**
  104603. * If you want to display a video in your scene, this is the special texture for that.
  104604. * This special texture works similar to other textures, with the exception of a few parameters.
  104605. * @see https://doc.babylonjs.com/how_to/video_texture
  104606. */
  104607. export class VideoTexture extends Texture {
  104608. /**
  104609. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104610. */
  104611. readonly autoUpdateTexture: boolean;
  104612. /**
  104613. * The video instance used by the texture internally
  104614. */
  104615. readonly video: HTMLVideoElement;
  104616. private _onUserActionRequestedObservable;
  104617. /**
  104618. * Event triggerd when a dom action is required by the user to play the video.
  104619. * This happens due to recent changes in browser policies preventing video to auto start.
  104620. */
  104621. get onUserActionRequestedObservable(): Observable<Texture>;
  104622. private _generateMipMaps;
  104623. private _engine;
  104624. private _stillImageCaptured;
  104625. private _displayingPosterTexture;
  104626. private _settings;
  104627. private _createInternalTextureOnEvent;
  104628. private _frameId;
  104629. private _currentSrc;
  104630. /**
  104631. * Creates a video texture.
  104632. * If you want to display a video in your scene, this is the special texture for that.
  104633. * This special texture works similar to other textures, with the exception of a few parameters.
  104634. * @see https://doc.babylonjs.com/how_to/video_texture
  104635. * @param name optional name, will detect from video source, if not defined
  104636. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104637. * @param scene is obviously the current scene.
  104638. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104639. * @param invertY is false by default but can be used to invert video on Y axis
  104640. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104641. * @param settings allows finer control over video usage
  104642. */
  104643. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104644. private _getName;
  104645. private _getVideo;
  104646. private _createInternalTexture;
  104647. private reset;
  104648. /**
  104649. * @hidden Internal method to initiate `update`.
  104650. */
  104651. _rebuild(): void;
  104652. /**
  104653. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104654. */
  104655. update(): void;
  104656. /**
  104657. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104658. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104659. */
  104660. updateTexture(isVisible: boolean): void;
  104661. protected _updateInternalTexture: () => void;
  104662. /**
  104663. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104664. * @param url New url.
  104665. */
  104666. updateURL(url: string): void;
  104667. /**
  104668. * Clones the texture.
  104669. * @returns the cloned texture
  104670. */
  104671. clone(): VideoTexture;
  104672. /**
  104673. * Dispose the texture and release its associated resources.
  104674. */
  104675. dispose(): void;
  104676. /**
  104677. * Creates a video texture straight from a stream.
  104678. * @param scene Define the scene the texture should be created in
  104679. * @param stream Define the stream the texture should be created from
  104680. * @returns The created video texture as a promise
  104681. */
  104682. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104683. /**
  104684. * Creates a video texture straight from your WebCam video feed.
  104685. * @param scene Define the scene the texture should be created in
  104686. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104687. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104688. * @returns The created video texture as a promise
  104689. */
  104690. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104691. minWidth: number;
  104692. maxWidth: number;
  104693. minHeight: number;
  104694. maxHeight: number;
  104695. deviceId: string;
  104696. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104697. /**
  104698. * Creates a video texture straight from your WebCam video feed.
  104699. * @param scene Define the scene the texture should be created in
  104700. * @param onReady Define a callback to triggered once the texture will be ready
  104701. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104702. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104703. */
  104704. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104705. minWidth: number;
  104706. maxWidth: number;
  104707. minHeight: number;
  104708. maxHeight: number;
  104709. deviceId: string;
  104710. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104711. }
  104712. }
  104713. declare module BABYLON {
  104714. /**
  104715. * Defines the interface used by objects working like Scene
  104716. * @hidden
  104717. */
  104718. export interface ISceneLike {
  104719. _addPendingData(data: any): void;
  104720. _removePendingData(data: any): void;
  104721. offlineProvider: IOfflineProvider;
  104722. }
  104723. /** Interface defining initialization parameters for Engine class */
  104724. export interface EngineOptions extends WebGLContextAttributes {
  104725. /**
  104726. * Defines if the engine should no exceed a specified device ratio
  104727. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104728. */
  104729. limitDeviceRatio?: number;
  104730. /**
  104731. * Defines if webvr should be enabled automatically
  104732. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104733. */
  104734. autoEnableWebVR?: boolean;
  104735. /**
  104736. * Defines if webgl2 should be turned off even if supported
  104737. * @see http://doc.babylonjs.com/features/webgl2
  104738. */
  104739. disableWebGL2Support?: boolean;
  104740. /**
  104741. * Defines if webaudio should be initialized as well
  104742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104743. */
  104744. audioEngine?: boolean;
  104745. /**
  104746. * Defines if animations should run using a deterministic lock step
  104747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104748. */
  104749. deterministicLockstep?: boolean;
  104750. /** Defines the maximum steps to use with deterministic lock step mode */
  104751. lockstepMaxSteps?: number;
  104752. /** Defines the seconds between each deterministic lock step */
  104753. timeStep?: number;
  104754. /**
  104755. * Defines that engine should ignore context lost events
  104756. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104757. */
  104758. doNotHandleContextLost?: boolean;
  104759. /**
  104760. * Defines that engine should ignore modifying touch action attribute and style
  104761. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104762. */
  104763. doNotHandleTouchAction?: boolean;
  104764. /**
  104765. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104766. */
  104767. useHighPrecisionFloats?: boolean;
  104768. }
  104769. /**
  104770. * The base engine class (root of all engines)
  104771. */
  104772. export class ThinEngine {
  104773. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104774. static ExceptionList: ({
  104775. key: string;
  104776. capture: string;
  104777. captureConstraint: number;
  104778. targets: string[];
  104779. } | {
  104780. key: string;
  104781. capture: null;
  104782. captureConstraint: null;
  104783. targets: string[];
  104784. })[];
  104785. /** @hidden */
  104786. static _TextureLoaders: IInternalTextureLoader[];
  104787. /**
  104788. * Returns the current npm package of the sdk
  104789. */
  104790. static get NpmPackage(): string;
  104791. /**
  104792. * Returns the current version of the framework
  104793. */
  104794. static get Version(): string;
  104795. /**
  104796. * Returns a string describing the current engine
  104797. */
  104798. get description(): string;
  104799. /**
  104800. * Gets or sets the epsilon value used by collision engine
  104801. */
  104802. static CollisionsEpsilon: number;
  104803. /**
  104804. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104805. */
  104806. static get ShadersRepository(): string;
  104807. static set ShadersRepository(value: string);
  104808. /** @hidden */
  104809. _shaderProcessor: IShaderProcessor;
  104810. /**
  104811. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104812. */
  104813. forcePOTTextures: boolean;
  104814. /**
  104815. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104816. */
  104817. isFullscreen: boolean;
  104818. /**
  104819. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104820. */
  104821. cullBackFaces: boolean;
  104822. /**
  104823. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104824. */
  104825. renderEvenInBackground: boolean;
  104826. /**
  104827. * Gets or sets a boolean indicating that cache can be kept between frames
  104828. */
  104829. preventCacheWipeBetweenFrames: boolean;
  104830. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104831. validateShaderPrograms: boolean;
  104832. /**
  104833. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104834. * This can provide greater z depth for distant objects.
  104835. */
  104836. useReverseDepthBuffer: boolean;
  104837. /**
  104838. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104839. */
  104840. disableUniformBuffers: boolean;
  104841. /** @hidden */
  104842. _uniformBuffers: UniformBuffer[];
  104843. /**
  104844. * Gets a boolean indicating that the engine supports uniform buffers
  104845. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104846. */
  104847. get supportsUniformBuffers(): boolean;
  104848. /** @hidden */
  104849. _gl: WebGLRenderingContext;
  104850. /** @hidden */
  104851. _webGLVersion: number;
  104852. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104853. protected _windowIsBackground: boolean;
  104854. protected _creationOptions: EngineOptions;
  104855. protected _highPrecisionShadersAllowed: boolean;
  104856. /** @hidden */
  104857. get _shouldUseHighPrecisionShader(): boolean;
  104858. /**
  104859. * Gets a boolean indicating that only power of 2 textures are supported
  104860. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104861. */
  104862. get needPOTTextures(): boolean;
  104863. /** @hidden */
  104864. _badOS: boolean;
  104865. /** @hidden */
  104866. _badDesktopOS: boolean;
  104867. private _hardwareScalingLevel;
  104868. /** @hidden */
  104869. _caps: EngineCapabilities;
  104870. private _isStencilEnable;
  104871. private _glVersion;
  104872. private _glRenderer;
  104873. private _glVendor;
  104874. /** @hidden */
  104875. _videoTextureSupported: boolean;
  104876. protected _renderingQueueLaunched: boolean;
  104877. protected _activeRenderLoops: (() => void)[];
  104878. /**
  104879. * Observable signaled when a context lost event is raised
  104880. */
  104881. onContextLostObservable: Observable<ThinEngine>;
  104882. /**
  104883. * Observable signaled when a context restored event is raised
  104884. */
  104885. onContextRestoredObservable: Observable<ThinEngine>;
  104886. private _onContextLost;
  104887. private _onContextRestored;
  104888. protected _contextWasLost: boolean;
  104889. /** @hidden */
  104890. _doNotHandleContextLost: boolean;
  104891. /**
  104892. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104894. */
  104895. get doNotHandleContextLost(): boolean;
  104896. set doNotHandleContextLost(value: boolean);
  104897. /**
  104898. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104899. */
  104900. disableVertexArrayObjects: boolean;
  104901. /** @hidden */
  104902. protected _colorWrite: boolean;
  104903. /** @hidden */
  104904. protected _colorWriteChanged: boolean;
  104905. /** @hidden */
  104906. protected _depthCullingState: DepthCullingState;
  104907. /** @hidden */
  104908. protected _stencilState: StencilState;
  104909. /** @hidden */
  104910. _alphaState: AlphaState;
  104911. /** @hidden */
  104912. _alphaMode: number;
  104913. /** @hidden */
  104914. _alphaEquation: number;
  104915. /** @hidden */
  104916. _internalTexturesCache: InternalTexture[];
  104917. /** @hidden */
  104918. protected _activeChannel: number;
  104919. private _currentTextureChannel;
  104920. /** @hidden */
  104921. protected _boundTexturesCache: {
  104922. [key: string]: Nullable<InternalTexture>;
  104923. };
  104924. /** @hidden */
  104925. protected _currentEffect: Nullable<Effect>;
  104926. /** @hidden */
  104927. protected _currentProgram: Nullable<WebGLProgram>;
  104928. private _compiledEffects;
  104929. private _vertexAttribArraysEnabled;
  104930. /** @hidden */
  104931. protected _cachedViewport: Nullable<IViewportLike>;
  104932. private _cachedVertexArrayObject;
  104933. /** @hidden */
  104934. protected _cachedVertexBuffers: any;
  104935. /** @hidden */
  104936. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104937. /** @hidden */
  104938. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104939. /** @hidden */
  104940. _currentRenderTarget: Nullable<InternalTexture>;
  104941. private _uintIndicesCurrentlySet;
  104942. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104943. /** @hidden */
  104944. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104945. private _currentBufferPointers;
  104946. private _currentInstanceLocations;
  104947. private _currentInstanceBuffers;
  104948. private _textureUnits;
  104949. /** @hidden */
  104950. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104951. /** @hidden */
  104952. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104953. /** @hidden */
  104954. _boundRenderFunction: any;
  104955. private _vaoRecordInProgress;
  104956. private _mustWipeVertexAttributes;
  104957. private _emptyTexture;
  104958. private _emptyCubeTexture;
  104959. private _emptyTexture3D;
  104960. private _emptyTexture2DArray;
  104961. /** @hidden */
  104962. _frameHandler: number;
  104963. private _nextFreeTextureSlots;
  104964. private _maxSimultaneousTextures;
  104965. private _activeRequests;
  104966. /** @hidden */
  104967. _transformTextureUrl: Nullable<(url: string) => string>;
  104968. protected get _supportsHardwareTextureRescaling(): boolean;
  104969. private _framebufferDimensionsObject;
  104970. /**
  104971. * sets the object from which width and height will be taken from when getting render width and height
  104972. * Will fallback to the gl object
  104973. * @param dimensions the framebuffer width and height that will be used.
  104974. */
  104975. set framebufferDimensionsObject(dimensions: Nullable<{
  104976. framebufferWidth: number;
  104977. framebufferHeight: number;
  104978. }>);
  104979. /**
  104980. * Gets the current viewport
  104981. */
  104982. get currentViewport(): Nullable<IViewportLike>;
  104983. /**
  104984. * Gets the default empty texture
  104985. */
  104986. get emptyTexture(): InternalTexture;
  104987. /**
  104988. * Gets the default empty 3D texture
  104989. */
  104990. get emptyTexture3D(): InternalTexture;
  104991. /**
  104992. * Gets the default empty 2D array texture
  104993. */
  104994. get emptyTexture2DArray(): InternalTexture;
  104995. /**
  104996. * Gets the default empty cube texture
  104997. */
  104998. get emptyCubeTexture(): InternalTexture;
  104999. /**
  105000. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  105001. */
  105002. readonly premultipliedAlpha: boolean;
  105003. /**
  105004. * Observable event triggered before each texture is initialized
  105005. */
  105006. onBeforeTextureInitObservable: Observable<Texture>;
  105007. /**
  105008. * Creates a new engine
  105009. * @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
  105010. * @param antialias defines enable antialiasing (default: false)
  105011. * @param options defines further options to be sent to the getContext() function
  105012. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105013. */
  105014. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105015. private _rebuildInternalTextures;
  105016. private _rebuildEffects;
  105017. /**
  105018. * Gets a boolean indicating if all created effects are ready
  105019. * @returns true if all effects are ready
  105020. */
  105021. areAllEffectsReady(): boolean;
  105022. protected _rebuildBuffers(): void;
  105023. protected _initGLContext(): void;
  105024. /**
  105025. * Gets version of the current webGL context
  105026. */
  105027. get webGLVersion(): number;
  105028. /**
  105029. * Gets a string idenfifying the name of the class
  105030. * @returns "Engine" string
  105031. */
  105032. getClassName(): string;
  105033. /**
  105034. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  105035. */
  105036. get isStencilEnable(): boolean;
  105037. /** @hidden */
  105038. _prepareWorkingCanvas(): void;
  105039. /**
  105040. * Reset the texture cache to empty state
  105041. */
  105042. resetTextureCache(): void;
  105043. /**
  105044. * Gets an object containing information about the current webGL context
  105045. * @returns an object containing the vender, the renderer and the version of the current webGL context
  105046. */
  105047. getGlInfo(): {
  105048. vendor: string;
  105049. renderer: string;
  105050. version: string;
  105051. };
  105052. /**
  105053. * Defines the hardware scaling level.
  105054. * By default the hardware scaling level is computed from the window device ratio.
  105055. * 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.
  105056. * @param level defines the level to use
  105057. */
  105058. setHardwareScalingLevel(level: number): void;
  105059. /**
  105060. * Gets the current hardware scaling level.
  105061. * By default the hardware scaling level is computed from the window device ratio.
  105062. * 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.
  105063. * @returns a number indicating the current hardware scaling level
  105064. */
  105065. getHardwareScalingLevel(): number;
  105066. /**
  105067. * Gets the list of loaded textures
  105068. * @returns an array containing all loaded textures
  105069. */
  105070. getLoadedTexturesCache(): InternalTexture[];
  105071. /**
  105072. * Gets the object containing all engine capabilities
  105073. * @returns the EngineCapabilities object
  105074. */
  105075. getCaps(): EngineCapabilities;
  105076. /**
  105077. * stop executing a render loop function and remove it from the execution array
  105078. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  105079. */
  105080. stopRenderLoop(renderFunction?: () => void): void;
  105081. /** @hidden */
  105082. _renderLoop(): void;
  105083. /**
  105084. * Gets the HTML canvas attached with the current webGL context
  105085. * @returns a HTML canvas
  105086. */
  105087. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  105088. /**
  105089. * Gets host window
  105090. * @returns the host window object
  105091. */
  105092. getHostWindow(): Nullable<Window>;
  105093. /**
  105094. * Gets the current render width
  105095. * @param useScreen defines if screen size must be used (or the current render target if any)
  105096. * @returns a number defining the current render width
  105097. */
  105098. getRenderWidth(useScreen?: boolean): number;
  105099. /**
  105100. * Gets the current render height
  105101. * @param useScreen defines if screen size must be used (or the current render target if any)
  105102. * @returns a number defining the current render height
  105103. */
  105104. getRenderHeight(useScreen?: boolean): number;
  105105. /**
  105106. * Can be used to override the current requestAnimationFrame requester.
  105107. * @hidden
  105108. */
  105109. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105110. /**
  105111. * Register and execute a render loop. The engine can have more than one render function
  105112. * @param renderFunction defines the function to continuously execute
  105113. */
  105114. runRenderLoop(renderFunction: () => void): void;
  105115. /**
  105116. * Clear the current render buffer or the current render target (if any is set up)
  105117. * @param color defines the color to use
  105118. * @param backBuffer defines if the back buffer must be cleared
  105119. * @param depth defines if the depth buffer must be cleared
  105120. * @param stencil defines if the stencil buffer must be cleared
  105121. */
  105122. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105123. private _viewportCached;
  105124. /** @hidden */
  105125. _viewport(x: number, y: number, width: number, height: number): void;
  105126. /**
  105127. * Set the WebGL's viewport
  105128. * @param viewport defines the viewport element to be used
  105129. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105130. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105131. */
  105132. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105133. /**
  105134. * Begin a new frame
  105135. */
  105136. beginFrame(): void;
  105137. /**
  105138. * Enf the current frame
  105139. */
  105140. endFrame(): void;
  105141. /**
  105142. * Resize the view according to the canvas' size
  105143. */
  105144. resize(): void;
  105145. /**
  105146. * Force a specific size of the canvas
  105147. * @param width defines the new canvas' width
  105148. * @param height defines the new canvas' height
  105149. */
  105150. setSize(width: number, height: number): void;
  105151. /**
  105152. * Binds the frame buffer to the specified texture.
  105153. * @param texture The texture to render to or null for the default canvas
  105154. * @param faceIndex The face of the texture to render to in case of cube texture
  105155. * @param requiredWidth The width of the target to render to
  105156. * @param requiredHeight The height of the target to render to
  105157. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105158. * @param lodLevel defines the lod level to bind to the frame buffer
  105159. * @param layer defines the 2d array index to bind to frame buffer to
  105160. */
  105161. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105162. /** @hidden */
  105163. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105164. /**
  105165. * Unbind the current render target texture from the webGL context
  105166. * @param texture defines the render target texture to unbind
  105167. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105168. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105169. */
  105170. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105171. /**
  105172. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105173. */
  105174. flushFramebuffer(): void;
  105175. /**
  105176. * Unbind the current render target and bind the default framebuffer
  105177. */
  105178. restoreDefaultFramebuffer(): void;
  105179. /** @hidden */
  105180. protected _resetVertexBufferBinding(): void;
  105181. /**
  105182. * Creates a vertex buffer
  105183. * @param data the data for the vertex buffer
  105184. * @returns the new WebGL static buffer
  105185. */
  105186. createVertexBuffer(data: DataArray): DataBuffer;
  105187. private _createVertexBuffer;
  105188. /**
  105189. * Creates a dynamic vertex buffer
  105190. * @param data the data for the dynamic vertex buffer
  105191. * @returns the new WebGL dynamic buffer
  105192. */
  105193. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  105194. protected _resetIndexBufferBinding(): void;
  105195. /**
  105196. * Creates a new index buffer
  105197. * @param indices defines the content of the index buffer
  105198. * @param updatable defines if the index buffer must be updatable
  105199. * @returns a new webGL buffer
  105200. */
  105201. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  105202. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  105203. /**
  105204. * Bind a webGL buffer to the webGL context
  105205. * @param buffer defines the buffer to bind
  105206. */
  105207. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  105208. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  105209. private bindBuffer;
  105210. /**
  105211. * update the bound buffer with the given data
  105212. * @param data defines the data to update
  105213. */
  105214. updateArrayBuffer(data: Float32Array): void;
  105215. private _vertexAttribPointer;
  105216. /** @hidden */
  105217. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  105218. private _bindVertexBuffersAttributes;
  105219. /**
  105220. * Records a vertex array object
  105221. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  105222. * @param vertexBuffers defines the list of vertex buffers to store
  105223. * @param indexBuffer defines the index buffer to store
  105224. * @param effect defines the effect to store
  105225. * @returns the new vertex array object
  105226. */
  105227. recordVertexArrayObject(vertexBuffers: {
  105228. [key: string]: VertexBuffer;
  105229. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  105230. /**
  105231. * Bind a specific vertex array object
  105232. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  105233. * @param vertexArrayObject defines the vertex array object to bind
  105234. * @param indexBuffer defines the index buffer to bind
  105235. */
  105236. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  105237. /**
  105238. * Bind webGl buffers directly to the webGL context
  105239. * @param vertexBuffer defines the vertex buffer to bind
  105240. * @param indexBuffer defines the index buffer to bind
  105241. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  105242. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  105243. * @param effect defines the effect associated with the vertex buffer
  105244. */
  105245. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  105246. private _unbindVertexArrayObject;
  105247. /**
  105248. * Bind a list of vertex buffers to the webGL context
  105249. * @param vertexBuffers defines the list of vertex buffers to bind
  105250. * @param indexBuffer defines the index buffer to bind
  105251. * @param effect defines the effect associated with the vertex buffers
  105252. */
  105253. bindBuffers(vertexBuffers: {
  105254. [key: string]: Nullable<VertexBuffer>;
  105255. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  105256. /**
  105257. * Unbind all instance attributes
  105258. */
  105259. unbindInstanceAttributes(): void;
  105260. /**
  105261. * Release and free the memory of a vertex array object
  105262. * @param vao defines the vertex array object to delete
  105263. */
  105264. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  105265. /** @hidden */
  105266. _releaseBuffer(buffer: DataBuffer): boolean;
  105267. protected _deleteBuffer(buffer: DataBuffer): void;
  105268. /**
  105269. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  105270. * @param instancesBuffer defines the webGL buffer to update and bind
  105271. * @param data defines the data to store in the buffer
  105272. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  105273. */
  105274. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  105275. /**
  105276. * Bind the content of a webGL buffer used with instantiation
  105277. * @param instancesBuffer defines the webGL buffer to bind
  105278. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  105279. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  105280. */
  105281. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  105282. /**
  105283. * Disable the instance attribute corresponding to the name in parameter
  105284. * @param name defines the name of the attribute to disable
  105285. */
  105286. disableInstanceAttributeByName(name: string): void;
  105287. /**
  105288. * Disable the instance attribute corresponding to the location in parameter
  105289. * @param attributeLocation defines the attribute location of the attribute to disable
  105290. */
  105291. disableInstanceAttribute(attributeLocation: number): void;
  105292. /**
  105293. * Disable the attribute corresponding to the location in parameter
  105294. * @param attributeLocation defines the attribute location of the attribute to disable
  105295. */
  105296. disableAttributeByIndex(attributeLocation: number): void;
  105297. /**
  105298. * Send a draw order
  105299. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  105300. * @param indexStart defines the starting index
  105301. * @param indexCount defines the number of index to draw
  105302. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105303. */
  105304. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  105305. /**
  105306. * Draw a list of points
  105307. * @param verticesStart defines the index of first vertex to draw
  105308. * @param verticesCount defines the count of vertices to draw
  105309. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105310. */
  105311. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105312. /**
  105313. * Draw a list of unindexed primitives
  105314. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  105315. * @param verticesStart defines the index of first vertex to draw
  105316. * @param verticesCount defines the count of vertices to draw
  105317. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105318. */
  105319. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105320. /**
  105321. * Draw a list of indexed primitives
  105322. * @param fillMode defines the primitive to use
  105323. * @param indexStart defines the starting index
  105324. * @param indexCount defines the number of index to draw
  105325. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105326. */
  105327. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  105328. /**
  105329. * Draw a list of unindexed primitives
  105330. * @param fillMode defines the primitive to use
  105331. * @param verticesStart defines the index of first vertex to draw
  105332. * @param verticesCount defines the count of vertices to draw
  105333. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105334. */
  105335. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105336. private _drawMode;
  105337. /** @hidden */
  105338. protected _reportDrawCall(): void;
  105339. /** @hidden */
  105340. _releaseEffect(effect: Effect): void;
  105341. /** @hidden */
  105342. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  105343. /**
  105344. * Create a new effect (used to store vertex/fragment shaders)
  105345. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  105346. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  105347. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  105348. * @param samplers defines an array of string used to represent textures
  105349. * @param defines defines the string containing the defines to use to compile the shaders
  105350. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105351. * @param onCompiled defines a function to call when the effect creation is successful
  105352. * @param onError defines a function to call when the effect creation has failed
  105353. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  105354. * @returns the new Effect
  105355. */
  105356. 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;
  105357. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  105358. private _compileShader;
  105359. private _compileRawShader;
  105360. /** @hidden */
  105361. _getShaderSource(shader: WebGLShader): Nullable<string>;
  105362. /**
  105363. * Directly creates a webGL program
  105364. * @param pipelineContext defines the pipeline context to attach to
  105365. * @param vertexCode defines the vertex shader code to use
  105366. * @param fragmentCode defines the fragment shader code to use
  105367. * @param context defines the webGL context to use (if not set, the current one will be used)
  105368. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105369. * @returns the new webGL program
  105370. */
  105371. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105372. /**
  105373. * Creates a webGL program
  105374. * @param pipelineContext defines the pipeline context to attach to
  105375. * @param vertexCode defines the vertex shader code to use
  105376. * @param fragmentCode defines the fragment shader code to use
  105377. * @param defines defines the string containing the defines to use to compile the shaders
  105378. * @param context defines the webGL context to use (if not set, the current one will be used)
  105379. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105380. * @returns the new webGL program
  105381. */
  105382. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105383. /**
  105384. * Creates a new pipeline context
  105385. * @returns the new pipeline
  105386. */
  105387. createPipelineContext(): IPipelineContext;
  105388. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105389. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  105390. /** @hidden */
  105391. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  105392. /** @hidden */
  105393. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  105394. /** @hidden */
  105395. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  105396. /**
  105397. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  105398. * @param pipelineContext defines the pipeline context to use
  105399. * @param uniformsNames defines the list of uniform names
  105400. * @returns an array of webGL uniform locations
  105401. */
  105402. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  105403. /**
  105404. * Gets the lsit of active attributes for a given webGL program
  105405. * @param pipelineContext defines the pipeline context to use
  105406. * @param attributesNames defines the list of attribute names to get
  105407. * @returns an array of indices indicating the offset of each attribute
  105408. */
  105409. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  105410. /**
  105411. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  105412. * @param effect defines the effect to activate
  105413. */
  105414. enableEffect(effect: Nullable<Effect>): void;
  105415. /**
  105416. * Set the value of an uniform to a number (int)
  105417. * @param uniform defines the webGL uniform location where to store the value
  105418. * @param value defines the int number to store
  105419. */
  105420. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105421. /**
  105422. * Set the value of an uniform to an array of int32
  105423. * @param uniform defines the webGL uniform location where to store the value
  105424. * @param array defines the array of int32 to store
  105425. */
  105426. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105427. /**
  105428. * Set the value of an uniform to an array of int32 (stored as vec2)
  105429. * @param uniform defines the webGL uniform location where to store the value
  105430. * @param array defines the array of int32 to store
  105431. */
  105432. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105433. /**
  105434. * Set the value of an uniform to an array of int32 (stored as vec3)
  105435. * @param uniform defines the webGL uniform location where to store the value
  105436. * @param array defines the array of int32 to store
  105437. */
  105438. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105439. /**
  105440. * Set the value of an uniform to an array of int32 (stored as vec4)
  105441. * @param uniform defines the webGL uniform location where to store the value
  105442. * @param array defines the array of int32 to store
  105443. */
  105444. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105445. /**
  105446. * Set the value of an uniform to an array of number
  105447. * @param uniform defines the webGL uniform location where to store the value
  105448. * @param array defines the array of number to store
  105449. */
  105450. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105451. /**
  105452. * Set the value of an uniform to an array of number (stored as vec2)
  105453. * @param uniform defines the webGL uniform location where to store the value
  105454. * @param array defines the array of number to store
  105455. */
  105456. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105457. /**
  105458. * Set the value of an uniform to an array of number (stored as vec3)
  105459. * @param uniform defines the webGL uniform location where to store the value
  105460. * @param array defines the array of number to store
  105461. */
  105462. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105463. /**
  105464. * Set the value of an uniform to an array of number (stored as vec4)
  105465. * @param uniform defines the webGL uniform location where to store the value
  105466. * @param array defines the array of number to store
  105467. */
  105468. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105469. /**
  105470. * Set the value of an uniform to an array of float32 (stored as matrices)
  105471. * @param uniform defines the webGL uniform location where to store the value
  105472. * @param matrices defines the array of float32 to store
  105473. */
  105474. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  105475. /**
  105476. * Set the value of an uniform to a matrix (3x3)
  105477. * @param uniform defines the webGL uniform location where to store the value
  105478. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  105479. */
  105480. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105481. /**
  105482. * Set the value of an uniform to a matrix (2x2)
  105483. * @param uniform defines the webGL uniform location where to store the value
  105484. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  105485. */
  105486. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105487. /**
  105488. * Set the value of an uniform to a number (float)
  105489. * @param uniform defines the webGL uniform location where to store the value
  105490. * @param value defines the float number to store
  105491. */
  105492. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105493. /**
  105494. * Set the value of an uniform to a vec2
  105495. * @param uniform defines the webGL uniform location where to store the value
  105496. * @param x defines the 1st component of the value
  105497. * @param y defines the 2nd component of the value
  105498. */
  105499. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  105500. /**
  105501. * Set the value of an uniform to a vec3
  105502. * @param uniform defines the webGL uniform location where to store the value
  105503. * @param x defines the 1st component of the value
  105504. * @param y defines the 2nd component of the value
  105505. * @param z defines the 3rd component of the value
  105506. */
  105507. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  105508. /**
  105509. * Set the value of an uniform to a vec4
  105510. * @param uniform defines the webGL uniform location where to store the value
  105511. * @param x defines the 1st component of the value
  105512. * @param y defines the 2nd component of the value
  105513. * @param z defines the 3rd component of the value
  105514. * @param w defines the 4th component of the value
  105515. */
  105516. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  105517. /**
  105518. * Apply all cached states (depth, culling, stencil and alpha)
  105519. */
  105520. applyStates(): void;
  105521. /**
  105522. * Enable or disable color writing
  105523. * @param enable defines the state to set
  105524. */
  105525. setColorWrite(enable: boolean): void;
  105526. /**
  105527. * Gets a boolean indicating if color writing is enabled
  105528. * @returns the current color writing state
  105529. */
  105530. getColorWrite(): boolean;
  105531. /**
  105532. * Gets the depth culling state manager
  105533. */
  105534. get depthCullingState(): DepthCullingState;
  105535. /**
  105536. * Gets the alpha state manager
  105537. */
  105538. get alphaState(): AlphaState;
  105539. /**
  105540. * Gets the stencil state manager
  105541. */
  105542. get stencilState(): StencilState;
  105543. /**
  105544. * Clears the list of texture accessible through engine.
  105545. * This can help preventing texture load conflict due to name collision.
  105546. */
  105547. clearInternalTexturesCache(): void;
  105548. /**
  105549. * Force the entire cache to be cleared
  105550. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105551. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105552. */
  105553. wipeCaches(bruteForce?: boolean): void;
  105554. /** @hidden */
  105555. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105556. min: number;
  105557. mag: number;
  105558. };
  105559. /** @hidden */
  105560. _createTexture(): WebGLTexture;
  105561. /**
  105562. * Usually called from Texture.ts.
  105563. * Passed information to create a WebGLTexture
  105564. * @param url defines a value which contains one of the following:
  105565. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105566. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105567. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105569. * @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)
  105570. * @param scene needed for loading to the correct scene
  105571. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105572. * @param onLoad optional callback to be called upon successful completion
  105573. * @param onError optional callback to be called upon failure
  105574. * @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
  105575. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105576. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105577. * @param forcedExtension defines the extension to use to pick the right loader
  105578. * @param mimeType defines an optional mime type
  105579. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105580. */
  105581. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  105582. /**
  105583. * Loads an image as an HTMLImageElement.
  105584. * @param input url string, ArrayBuffer, or Blob to load
  105585. * @param onLoad callback called when the image successfully loads
  105586. * @param onError callback called when the image fails to load
  105587. * @param offlineProvider offline provider for caching
  105588. * @param mimeType optional mime type
  105589. * @returns the HTMLImageElement of the loaded image
  105590. * @hidden
  105591. */
  105592. 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>;
  105593. /**
  105594. * @hidden
  105595. */
  105596. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105597. /**
  105598. * Creates a raw texture
  105599. * @param data defines the data to store in the texture
  105600. * @param width defines the width of the texture
  105601. * @param height defines the height of the texture
  105602. * @param format defines the format of the data
  105603. * @param generateMipMaps defines if the engine should generate the mip levels
  105604. * @param invertY defines if data must be stored with Y axis inverted
  105605. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105606. * @param compression defines the compression used (null by default)
  105607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105608. * @returns the raw texture inside an InternalTexture
  105609. */
  105610. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105611. /**
  105612. * Creates a new raw cube texture
  105613. * @param data defines the array of data to use to create each face
  105614. * @param size defines the size of the textures
  105615. * @param format defines the format of the data
  105616. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105617. * @param generateMipMaps defines if the engine should generate the mip levels
  105618. * @param invertY defines if data must be stored with Y axis inverted
  105619. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105620. * @param compression defines the compression used (null by default)
  105621. * @returns the cube texture as an InternalTexture
  105622. */
  105623. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105624. /**
  105625. * Creates a new raw 3D texture
  105626. * @param data defines the data used to create the texture
  105627. * @param width defines the width of the texture
  105628. * @param height defines the height of the texture
  105629. * @param depth defines the depth of the texture
  105630. * @param format defines the format of the texture
  105631. * @param generateMipMaps defines if the engine must generate mip levels
  105632. * @param invertY defines if data must be stored with Y axis inverted
  105633. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105634. * @param compression defines the compressed used (can be null)
  105635. * @param textureType defines the compressed used (can be null)
  105636. * @returns a new raw 3D texture (stored in an InternalTexture)
  105637. */
  105638. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105639. /**
  105640. * Creates a new raw 2D array texture
  105641. * @param data defines the data used to create the texture
  105642. * @param width defines the width of the texture
  105643. * @param height defines the height of the texture
  105644. * @param depth defines the number of layers of the texture
  105645. * @param format defines the format of the texture
  105646. * @param generateMipMaps defines if the engine must generate mip levels
  105647. * @param invertY defines if data must be stored with Y axis inverted
  105648. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105649. * @param compression defines the compressed used (can be null)
  105650. * @param textureType defines the compressed used (can be null)
  105651. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105652. */
  105653. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105654. private _unpackFlipYCached;
  105655. /**
  105656. * In case you are sharing the context with other applications, it might
  105657. * be interested to not cache the unpack flip y state to ensure a consistent
  105658. * value would be set.
  105659. */
  105660. enableUnpackFlipYCached: boolean;
  105661. /** @hidden */
  105662. _unpackFlipY(value: boolean): void;
  105663. /** @hidden */
  105664. _getUnpackAlignement(): number;
  105665. private _getTextureTarget;
  105666. /**
  105667. * Update the sampling mode of a given texture
  105668. * @param samplingMode defines the required sampling mode
  105669. * @param texture defines the texture to update
  105670. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105671. */
  105672. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105673. /**
  105674. * Update the sampling mode of a given texture
  105675. * @param texture defines the texture to update
  105676. * @param wrapU defines the texture wrap mode of the u coordinates
  105677. * @param wrapV defines the texture wrap mode of the v coordinates
  105678. * @param wrapR defines the texture wrap mode of the r coordinates
  105679. */
  105680. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105681. /** @hidden */
  105682. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105683. width: number;
  105684. height: number;
  105685. layers?: number;
  105686. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105687. /** @hidden */
  105688. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105689. /** @hidden */
  105690. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105691. /**
  105692. * Update a portion of an internal texture
  105693. * @param texture defines the texture to update
  105694. * @param imageData defines the data to store into the texture
  105695. * @param xOffset defines the x coordinates of the update rectangle
  105696. * @param yOffset defines the y coordinates of the update rectangle
  105697. * @param width defines the width of the update rectangle
  105698. * @param height defines the height of the update rectangle
  105699. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105700. * @param lod defines the lod level to update (0 by default)
  105701. */
  105702. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105703. /** @hidden */
  105704. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105705. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105706. private _prepareWebGLTexture;
  105707. /** @hidden */
  105708. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105709. private _getDepthStencilBuffer;
  105710. /** @hidden */
  105711. _releaseFramebufferObjects(texture: InternalTexture): void;
  105712. /** @hidden */
  105713. _releaseTexture(texture: InternalTexture): void;
  105714. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105715. protected _setProgram(program: WebGLProgram): void;
  105716. protected _boundUniforms: {
  105717. [key: number]: WebGLUniformLocation;
  105718. };
  105719. /**
  105720. * Binds an effect to the webGL context
  105721. * @param effect defines the effect to bind
  105722. */
  105723. bindSamplers(effect: Effect): void;
  105724. private _activateCurrentTexture;
  105725. /** @hidden */
  105726. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105727. /** @hidden */
  105728. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105729. /**
  105730. * Unbind all textures from the webGL context
  105731. */
  105732. unbindAllTextures(): void;
  105733. /**
  105734. * Sets a texture to the according uniform.
  105735. * @param channel The texture channel
  105736. * @param uniform The uniform to set
  105737. * @param texture The texture to apply
  105738. */
  105739. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105740. private _bindSamplerUniformToChannel;
  105741. private _getTextureWrapMode;
  105742. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105743. /**
  105744. * Sets an array of texture to the webGL context
  105745. * @param channel defines the channel where the texture array must be set
  105746. * @param uniform defines the associated uniform location
  105747. * @param textures defines the array of textures to bind
  105748. */
  105749. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105750. /** @hidden */
  105751. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105752. private _setTextureParameterFloat;
  105753. private _setTextureParameterInteger;
  105754. /**
  105755. * Unbind all vertex attributes from the webGL context
  105756. */
  105757. unbindAllAttributes(): void;
  105758. /**
  105759. * 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
  105760. */
  105761. releaseEffects(): void;
  105762. /**
  105763. * Dispose and release all associated resources
  105764. */
  105765. dispose(): void;
  105766. /**
  105767. * Attach a new callback raised when context lost event is fired
  105768. * @param callback defines the callback to call
  105769. */
  105770. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105771. /**
  105772. * Attach a new callback raised when context restored event is fired
  105773. * @param callback defines the callback to call
  105774. */
  105775. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105776. /**
  105777. * Get the current error code of the webGL context
  105778. * @returns the error code
  105779. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105780. */
  105781. getError(): number;
  105782. private _canRenderToFloatFramebuffer;
  105783. private _canRenderToHalfFloatFramebuffer;
  105784. private _canRenderToFramebuffer;
  105785. /** @hidden */
  105786. _getWebGLTextureType(type: number): number;
  105787. /** @hidden */
  105788. _getInternalFormat(format: number): number;
  105789. /** @hidden */
  105790. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105791. /** @hidden */
  105792. _getRGBAMultiSampleBufferFormat(type: number): number;
  105793. /** @hidden */
  105794. _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;
  105795. /**
  105796. * Loads a file from a url
  105797. * @param url url to load
  105798. * @param onSuccess callback called when the file successfully loads
  105799. * @param onProgress callback called while file is loading (if the server supports this mode)
  105800. * @param offlineProvider defines the offline provider for caching
  105801. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105802. * @param onError callback called when the file fails to load
  105803. * @returns a file request object
  105804. * @hidden
  105805. */
  105806. 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;
  105807. /**
  105808. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105809. * @param x defines the x coordinate of the rectangle where pixels must be read
  105810. * @param y defines the y coordinate of the rectangle where pixels must be read
  105811. * @param width defines the width of the rectangle where pixels must be read
  105812. * @param height defines the height of the rectangle where pixels must be read
  105813. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105814. * @returns a Uint8Array containing RGBA colors
  105815. */
  105816. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105817. private static _isSupported;
  105818. /**
  105819. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105820. * @returns true if the engine can be created
  105821. * @ignorenaming
  105822. */
  105823. static isSupported(): boolean;
  105824. /**
  105825. * Find the next highest power of two.
  105826. * @param x Number to start search from.
  105827. * @return Next highest power of two.
  105828. */
  105829. static CeilingPOT(x: number): number;
  105830. /**
  105831. * Find the next lowest power of two.
  105832. * @param x Number to start search from.
  105833. * @return Next lowest power of two.
  105834. */
  105835. static FloorPOT(x: number): number;
  105836. /**
  105837. * Find the nearest power of two.
  105838. * @param x Number to start search from.
  105839. * @return Next nearest power of two.
  105840. */
  105841. static NearestPOT(x: number): number;
  105842. /**
  105843. * Get the closest exponent of two
  105844. * @param value defines the value to approximate
  105845. * @param max defines the maximum value to return
  105846. * @param mode defines how to define the closest value
  105847. * @returns closest exponent of two of the given value
  105848. */
  105849. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105850. /**
  105851. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105852. * @param func - the function to be called
  105853. * @param requester - the object that will request the next frame. Falls back to window.
  105854. * @returns frame number
  105855. */
  105856. static QueueNewFrame(func: () => void, requester?: any): number;
  105857. /**
  105858. * Gets host document
  105859. * @returns the host document object
  105860. */
  105861. getHostDocument(): Nullable<Document>;
  105862. }
  105863. }
  105864. declare module BABYLON {
  105865. /**
  105866. * Class representing spherical harmonics coefficients to the 3rd degree
  105867. */
  105868. export class SphericalHarmonics {
  105869. /**
  105870. * Defines whether or not the harmonics have been prescaled for rendering.
  105871. */
  105872. preScaled: boolean;
  105873. /**
  105874. * The l0,0 coefficients of the spherical harmonics
  105875. */
  105876. l00: Vector3;
  105877. /**
  105878. * The l1,-1 coefficients of the spherical harmonics
  105879. */
  105880. l1_1: Vector3;
  105881. /**
  105882. * The l1,0 coefficients of the spherical harmonics
  105883. */
  105884. l10: Vector3;
  105885. /**
  105886. * The l1,1 coefficients of the spherical harmonics
  105887. */
  105888. l11: Vector3;
  105889. /**
  105890. * The l2,-2 coefficients of the spherical harmonics
  105891. */
  105892. l2_2: Vector3;
  105893. /**
  105894. * The l2,-1 coefficients of the spherical harmonics
  105895. */
  105896. l2_1: Vector3;
  105897. /**
  105898. * The l2,0 coefficients of the spherical harmonics
  105899. */
  105900. l20: Vector3;
  105901. /**
  105902. * The l2,1 coefficients of the spherical harmonics
  105903. */
  105904. l21: Vector3;
  105905. /**
  105906. * The l2,2 coefficients of the spherical harmonics
  105907. */
  105908. l22: Vector3;
  105909. /**
  105910. * Adds a light to the spherical harmonics
  105911. * @param direction the direction of the light
  105912. * @param color the color of the light
  105913. * @param deltaSolidAngle the delta solid angle of the light
  105914. */
  105915. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105916. /**
  105917. * Scales the spherical harmonics by the given amount
  105918. * @param scale the amount to scale
  105919. */
  105920. scaleInPlace(scale: number): void;
  105921. /**
  105922. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105923. *
  105924. * ```
  105925. * E_lm = A_l * L_lm
  105926. * ```
  105927. *
  105928. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105929. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105930. * the scaling factors are given in equation 9.
  105931. */
  105932. convertIncidentRadianceToIrradiance(): void;
  105933. /**
  105934. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105935. *
  105936. * ```
  105937. * L = (1/pi) * E * rho
  105938. * ```
  105939. *
  105940. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105941. */
  105942. convertIrradianceToLambertianRadiance(): void;
  105943. /**
  105944. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105945. * required operations at run time.
  105946. *
  105947. * This is simply done by scaling back the SH with Ylm constants parameter.
  105948. * The trigonometric part being applied by the shader at run time.
  105949. */
  105950. preScaleForRendering(): void;
  105951. /**
  105952. * Constructs a spherical harmonics from an array.
  105953. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105954. * @returns the spherical harmonics
  105955. */
  105956. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105957. /**
  105958. * Gets the spherical harmonics from polynomial
  105959. * @param polynomial the spherical polynomial
  105960. * @returns the spherical harmonics
  105961. */
  105962. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105963. }
  105964. /**
  105965. * Class representing spherical polynomial coefficients to the 3rd degree
  105966. */
  105967. export class SphericalPolynomial {
  105968. private _harmonics;
  105969. /**
  105970. * The spherical harmonics used to create the polynomials.
  105971. */
  105972. get preScaledHarmonics(): SphericalHarmonics;
  105973. /**
  105974. * The x coefficients of the spherical polynomial
  105975. */
  105976. x: Vector3;
  105977. /**
  105978. * The y coefficients of the spherical polynomial
  105979. */
  105980. y: Vector3;
  105981. /**
  105982. * The z coefficients of the spherical polynomial
  105983. */
  105984. z: Vector3;
  105985. /**
  105986. * The xx coefficients of the spherical polynomial
  105987. */
  105988. xx: Vector3;
  105989. /**
  105990. * The yy coefficients of the spherical polynomial
  105991. */
  105992. yy: Vector3;
  105993. /**
  105994. * The zz coefficients of the spherical polynomial
  105995. */
  105996. zz: Vector3;
  105997. /**
  105998. * The xy coefficients of the spherical polynomial
  105999. */
  106000. xy: Vector3;
  106001. /**
  106002. * The yz coefficients of the spherical polynomial
  106003. */
  106004. yz: Vector3;
  106005. /**
  106006. * The zx coefficients of the spherical polynomial
  106007. */
  106008. zx: Vector3;
  106009. /**
  106010. * Adds an ambient color to the spherical polynomial
  106011. * @param color the color to add
  106012. */
  106013. addAmbient(color: Color3): void;
  106014. /**
  106015. * Scales the spherical polynomial by the given amount
  106016. * @param scale the amount to scale
  106017. */
  106018. scaleInPlace(scale: number): void;
  106019. /**
  106020. * Gets the spherical polynomial from harmonics
  106021. * @param harmonics the spherical harmonics
  106022. * @returns the spherical polynomial
  106023. */
  106024. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106025. /**
  106026. * Constructs a spherical polynomial from an array.
  106027. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106028. * @returns the spherical polynomial
  106029. */
  106030. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106031. }
  106032. }
  106033. declare module BABYLON {
  106034. /**
  106035. * Defines the source of the internal texture
  106036. */
  106037. export enum InternalTextureSource {
  106038. /**
  106039. * The source of the texture data is unknown
  106040. */
  106041. Unknown = 0,
  106042. /**
  106043. * Texture data comes from an URL
  106044. */
  106045. Url = 1,
  106046. /**
  106047. * Texture data is only used for temporary storage
  106048. */
  106049. Temp = 2,
  106050. /**
  106051. * Texture data comes from raw data (ArrayBuffer)
  106052. */
  106053. Raw = 3,
  106054. /**
  106055. * Texture content is dynamic (video or dynamic texture)
  106056. */
  106057. Dynamic = 4,
  106058. /**
  106059. * Texture content is generated by rendering to it
  106060. */
  106061. RenderTarget = 5,
  106062. /**
  106063. * Texture content is part of a multi render target process
  106064. */
  106065. MultiRenderTarget = 6,
  106066. /**
  106067. * Texture data comes from a cube data file
  106068. */
  106069. Cube = 7,
  106070. /**
  106071. * Texture data comes from a raw cube data
  106072. */
  106073. CubeRaw = 8,
  106074. /**
  106075. * Texture data come from a prefiltered cube data file
  106076. */
  106077. CubePrefiltered = 9,
  106078. /**
  106079. * Texture content is raw 3D data
  106080. */
  106081. Raw3D = 10,
  106082. /**
  106083. * Texture content is raw 2D array data
  106084. */
  106085. Raw2DArray = 11,
  106086. /**
  106087. * Texture content is a depth texture
  106088. */
  106089. Depth = 12,
  106090. /**
  106091. * Texture data comes from a raw cube data encoded with RGBD
  106092. */
  106093. CubeRawRGBD = 13
  106094. }
  106095. /**
  106096. * Class used to store data associated with WebGL texture data for the engine
  106097. * This class should not be used directly
  106098. */
  106099. export class InternalTexture {
  106100. /** @hidden */
  106101. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  106102. /**
  106103. * Defines if the texture is ready
  106104. */
  106105. isReady: boolean;
  106106. /**
  106107. * Defines if the texture is a cube texture
  106108. */
  106109. isCube: boolean;
  106110. /**
  106111. * Defines if the texture contains 3D data
  106112. */
  106113. is3D: boolean;
  106114. /**
  106115. * Defines if the texture contains 2D array data
  106116. */
  106117. is2DArray: boolean;
  106118. /**
  106119. * Defines if the texture contains multiview data
  106120. */
  106121. isMultiview: boolean;
  106122. /**
  106123. * Gets the URL used to load this texture
  106124. */
  106125. url: string;
  106126. /**
  106127. * Gets the sampling mode of the texture
  106128. */
  106129. samplingMode: number;
  106130. /**
  106131. * Gets a boolean indicating if the texture needs mipmaps generation
  106132. */
  106133. generateMipMaps: boolean;
  106134. /**
  106135. * Gets the number of samples used by the texture (WebGL2+ only)
  106136. */
  106137. samples: number;
  106138. /**
  106139. * Gets the type of the texture (int, float...)
  106140. */
  106141. type: number;
  106142. /**
  106143. * Gets the format of the texture (RGB, RGBA...)
  106144. */
  106145. format: number;
  106146. /**
  106147. * Observable called when the texture is loaded
  106148. */
  106149. onLoadedObservable: Observable<InternalTexture>;
  106150. /**
  106151. * Gets the width of the texture
  106152. */
  106153. width: number;
  106154. /**
  106155. * Gets the height of the texture
  106156. */
  106157. height: number;
  106158. /**
  106159. * Gets the depth of the texture
  106160. */
  106161. depth: number;
  106162. /**
  106163. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106164. */
  106165. baseWidth: number;
  106166. /**
  106167. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106168. */
  106169. baseHeight: number;
  106170. /**
  106171. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106172. */
  106173. baseDepth: number;
  106174. /**
  106175. * Gets a boolean indicating if the texture is inverted on Y axis
  106176. */
  106177. invertY: boolean;
  106178. /** @hidden */
  106179. _invertVScale: boolean;
  106180. /** @hidden */
  106181. _associatedChannel: number;
  106182. /** @hidden */
  106183. _source: InternalTextureSource;
  106184. /** @hidden */
  106185. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106186. /** @hidden */
  106187. _bufferView: Nullable<ArrayBufferView>;
  106188. /** @hidden */
  106189. _bufferViewArray: Nullable<ArrayBufferView[]>;
  106190. /** @hidden */
  106191. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  106192. /** @hidden */
  106193. _size: number;
  106194. /** @hidden */
  106195. _extension: string;
  106196. /** @hidden */
  106197. _files: Nullable<string[]>;
  106198. /** @hidden */
  106199. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  106200. /** @hidden */
  106201. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  106202. /** @hidden */
  106203. _framebuffer: Nullable<WebGLFramebuffer>;
  106204. /** @hidden */
  106205. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  106206. /** @hidden */
  106207. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  106208. /** @hidden */
  106209. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  106210. /** @hidden */
  106211. _attachments: Nullable<number[]>;
  106212. /** @hidden */
  106213. _cachedCoordinatesMode: Nullable<number>;
  106214. /** @hidden */
  106215. _cachedWrapU: Nullable<number>;
  106216. /** @hidden */
  106217. _cachedWrapV: Nullable<number>;
  106218. /** @hidden */
  106219. _cachedWrapR: Nullable<number>;
  106220. /** @hidden */
  106221. _cachedAnisotropicFilteringLevel: Nullable<number>;
  106222. /** @hidden */
  106223. _isDisabled: boolean;
  106224. /** @hidden */
  106225. _compression: Nullable<string>;
  106226. /** @hidden */
  106227. _generateStencilBuffer: boolean;
  106228. /** @hidden */
  106229. _generateDepthBuffer: boolean;
  106230. /** @hidden */
  106231. _comparisonFunction: number;
  106232. /** @hidden */
  106233. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  106234. /** @hidden */
  106235. _lodGenerationScale: number;
  106236. /** @hidden */
  106237. _lodGenerationOffset: number;
  106238. /** @hidden */
  106239. _depthStencilTexture: Nullable<InternalTexture>;
  106240. /** @hidden */
  106241. _colorTextureArray: Nullable<WebGLTexture>;
  106242. /** @hidden */
  106243. _depthStencilTextureArray: Nullable<WebGLTexture>;
  106244. /** @hidden */
  106245. _lodTextureHigh: Nullable<BaseTexture>;
  106246. /** @hidden */
  106247. _lodTextureMid: Nullable<BaseTexture>;
  106248. /** @hidden */
  106249. _lodTextureLow: Nullable<BaseTexture>;
  106250. /** @hidden */
  106251. _isRGBD: boolean;
  106252. /** @hidden */
  106253. _linearSpecularLOD: boolean;
  106254. /** @hidden */
  106255. _irradianceTexture: Nullable<BaseTexture>;
  106256. /** @hidden */
  106257. _webGLTexture: Nullable<WebGLTexture>;
  106258. /** @hidden */
  106259. _references: number;
  106260. private _engine;
  106261. /**
  106262. * Gets the Engine the texture belongs to.
  106263. * @returns The babylon engine
  106264. */
  106265. getEngine(): ThinEngine;
  106266. /**
  106267. * Gets the data source type of the texture
  106268. */
  106269. get source(): InternalTextureSource;
  106270. /**
  106271. * Creates a new InternalTexture
  106272. * @param engine defines the engine to use
  106273. * @param source defines the type of data that will be used
  106274. * @param delayAllocation if the texture allocation should be delayed (default: false)
  106275. */
  106276. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  106277. /**
  106278. * Increments the number of references (ie. the number of Texture that point to it)
  106279. */
  106280. incrementReferences(): void;
  106281. /**
  106282. * Change the size of the texture (not the size of the content)
  106283. * @param width defines the new width
  106284. * @param height defines the new height
  106285. * @param depth defines the new depth (1 by default)
  106286. */
  106287. updateSize(width: int, height: int, depth?: int): void;
  106288. /** @hidden */
  106289. _rebuild(): void;
  106290. /** @hidden */
  106291. _swapAndDie(target: InternalTexture): void;
  106292. /**
  106293. * Dispose the current allocated resources
  106294. */
  106295. dispose(): void;
  106296. }
  106297. }
  106298. declare module BABYLON {
  106299. /**
  106300. * Class used to work with sound analyzer using fast fourier transform (FFT)
  106301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106302. */
  106303. export class Analyser {
  106304. /**
  106305. * Gets or sets the smoothing
  106306. * @ignorenaming
  106307. */
  106308. SMOOTHING: number;
  106309. /**
  106310. * Gets or sets the FFT table size
  106311. * @ignorenaming
  106312. */
  106313. FFT_SIZE: number;
  106314. /**
  106315. * Gets or sets the bar graph amplitude
  106316. * @ignorenaming
  106317. */
  106318. BARGRAPHAMPLITUDE: number;
  106319. /**
  106320. * Gets or sets the position of the debug canvas
  106321. * @ignorenaming
  106322. */
  106323. DEBUGCANVASPOS: {
  106324. x: number;
  106325. y: number;
  106326. };
  106327. /**
  106328. * Gets or sets the debug canvas size
  106329. * @ignorenaming
  106330. */
  106331. DEBUGCANVASSIZE: {
  106332. width: number;
  106333. height: number;
  106334. };
  106335. private _byteFreqs;
  106336. private _byteTime;
  106337. private _floatFreqs;
  106338. private _webAudioAnalyser;
  106339. private _debugCanvas;
  106340. private _debugCanvasContext;
  106341. private _scene;
  106342. private _registerFunc;
  106343. private _audioEngine;
  106344. /**
  106345. * Creates a new analyser
  106346. * @param scene defines hosting scene
  106347. */
  106348. constructor(scene: Scene);
  106349. /**
  106350. * Get the number of data values you will have to play with for the visualization
  106351. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  106352. * @returns a number
  106353. */
  106354. getFrequencyBinCount(): number;
  106355. /**
  106356. * Gets the current frequency data as a byte array
  106357. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106358. * @returns a Uint8Array
  106359. */
  106360. getByteFrequencyData(): Uint8Array;
  106361. /**
  106362. * Gets the current waveform as a byte array
  106363. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  106364. * @returns a Uint8Array
  106365. */
  106366. getByteTimeDomainData(): Uint8Array;
  106367. /**
  106368. * Gets the current frequency data as a float array
  106369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106370. * @returns a Float32Array
  106371. */
  106372. getFloatFrequencyData(): Float32Array;
  106373. /**
  106374. * Renders the debug canvas
  106375. */
  106376. drawDebugCanvas(): void;
  106377. /**
  106378. * Stops rendering the debug canvas and removes it
  106379. */
  106380. stopDebugCanvas(): void;
  106381. /**
  106382. * Connects two audio nodes
  106383. * @param inputAudioNode defines first node to connect
  106384. * @param outputAudioNode defines second node to connect
  106385. */
  106386. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  106387. /**
  106388. * Releases all associated resources
  106389. */
  106390. dispose(): void;
  106391. }
  106392. }
  106393. declare module BABYLON {
  106394. /**
  106395. * This represents an audio engine and it is responsible
  106396. * to play, synchronize and analyse sounds throughout the application.
  106397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106398. */
  106399. export interface IAudioEngine extends IDisposable {
  106400. /**
  106401. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106402. */
  106403. readonly canUseWebAudio: boolean;
  106404. /**
  106405. * Gets the current AudioContext if available.
  106406. */
  106407. readonly audioContext: Nullable<AudioContext>;
  106408. /**
  106409. * The master gain node defines the global audio volume of your audio engine.
  106410. */
  106411. readonly masterGain: GainNode;
  106412. /**
  106413. * Gets whether or not mp3 are supported by your browser.
  106414. */
  106415. readonly isMP3supported: boolean;
  106416. /**
  106417. * Gets whether or not ogg are supported by your browser.
  106418. */
  106419. readonly isOGGsupported: boolean;
  106420. /**
  106421. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106422. * @ignoreNaming
  106423. */
  106424. WarnedWebAudioUnsupported: boolean;
  106425. /**
  106426. * Defines if the audio engine relies on a custom unlocked button.
  106427. * In this case, the embedded button will not be displayed.
  106428. */
  106429. useCustomUnlockedButton: boolean;
  106430. /**
  106431. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  106432. */
  106433. readonly unlocked: boolean;
  106434. /**
  106435. * Event raised when audio has been unlocked on the browser.
  106436. */
  106437. onAudioUnlockedObservable: Observable<AudioEngine>;
  106438. /**
  106439. * Event raised when audio has been locked on the browser.
  106440. */
  106441. onAudioLockedObservable: Observable<AudioEngine>;
  106442. /**
  106443. * Flags the audio engine in Locked state.
  106444. * This happens due to new browser policies preventing audio to autoplay.
  106445. */
  106446. lock(): void;
  106447. /**
  106448. * Unlocks the audio engine once a user action has been done on the dom.
  106449. * This is helpful to resume play once browser policies have been satisfied.
  106450. */
  106451. unlock(): void;
  106452. /**
  106453. * Gets the global volume sets on the master gain.
  106454. * @returns the global volume if set or -1 otherwise
  106455. */
  106456. getGlobalVolume(): number;
  106457. /**
  106458. * Sets the global volume of your experience (sets on the master gain).
  106459. * @param newVolume Defines the new global volume of the application
  106460. */
  106461. setGlobalVolume(newVolume: number): void;
  106462. /**
  106463. * Connect the audio engine to an audio analyser allowing some amazing
  106464. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106466. * @param analyser The analyser to connect to the engine
  106467. */
  106468. connectToAnalyser(analyser: Analyser): void;
  106469. }
  106470. /**
  106471. * This represents the default audio engine used in babylon.
  106472. * It is responsible to play, synchronize and analyse sounds throughout the application.
  106473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106474. */
  106475. export class AudioEngine implements IAudioEngine {
  106476. private _audioContext;
  106477. private _audioContextInitialized;
  106478. private _muteButton;
  106479. private _hostElement;
  106480. /**
  106481. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106482. */
  106483. canUseWebAudio: boolean;
  106484. /**
  106485. * The master gain node defines the global audio volume of your audio engine.
  106486. */
  106487. masterGain: GainNode;
  106488. /**
  106489. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106490. * @ignoreNaming
  106491. */
  106492. WarnedWebAudioUnsupported: boolean;
  106493. /**
  106494. * Gets whether or not mp3 are supported by your browser.
  106495. */
  106496. isMP3supported: boolean;
  106497. /**
  106498. * Gets whether or not ogg are supported by your browser.
  106499. */
  106500. isOGGsupported: boolean;
  106501. /**
  106502. * Gets whether audio has been unlocked on the device.
  106503. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  106504. * a user interaction has happened.
  106505. */
  106506. unlocked: boolean;
  106507. /**
  106508. * Defines if the audio engine relies on a custom unlocked button.
  106509. * In this case, the embedded button will not be displayed.
  106510. */
  106511. useCustomUnlockedButton: boolean;
  106512. /**
  106513. * Event raised when audio has been unlocked on the browser.
  106514. */
  106515. onAudioUnlockedObservable: Observable<AudioEngine>;
  106516. /**
  106517. * Event raised when audio has been locked on the browser.
  106518. */
  106519. onAudioLockedObservable: Observable<AudioEngine>;
  106520. /**
  106521. * Gets the current AudioContext if available.
  106522. */
  106523. get audioContext(): Nullable<AudioContext>;
  106524. private _connectedAnalyser;
  106525. /**
  106526. * Instantiates a new audio engine.
  106527. *
  106528. * There should be only one per page as some browsers restrict the number
  106529. * of audio contexts you can create.
  106530. * @param hostElement defines the host element where to display the mute icon if necessary
  106531. */
  106532. constructor(hostElement?: Nullable<HTMLElement>);
  106533. /**
  106534. * Flags the audio engine in Locked state.
  106535. * This happens due to new browser policies preventing audio to autoplay.
  106536. */
  106537. lock(): void;
  106538. /**
  106539. * Unlocks the audio engine once a user action has been done on the dom.
  106540. * This is helpful to resume play once browser policies have been satisfied.
  106541. */
  106542. unlock(): void;
  106543. private _resumeAudioContext;
  106544. private _initializeAudioContext;
  106545. private _tryToRun;
  106546. private _triggerRunningState;
  106547. private _triggerSuspendedState;
  106548. private _displayMuteButton;
  106549. private _moveButtonToTopLeft;
  106550. private _onResize;
  106551. private _hideMuteButton;
  106552. /**
  106553. * Destroy and release the resources associated with the audio ccontext.
  106554. */
  106555. dispose(): void;
  106556. /**
  106557. * Gets the global volume sets on the master gain.
  106558. * @returns the global volume if set or -1 otherwise
  106559. */
  106560. getGlobalVolume(): number;
  106561. /**
  106562. * Sets the global volume of your experience (sets on the master gain).
  106563. * @param newVolume Defines the new global volume of the application
  106564. */
  106565. setGlobalVolume(newVolume: number): void;
  106566. /**
  106567. * Connect the audio engine to an audio analyser allowing some amazing
  106568. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106570. * @param analyser The analyser to connect to the engine
  106571. */
  106572. connectToAnalyser(analyser: Analyser): void;
  106573. }
  106574. }
  106575. declare module BABYLON {
  106576. /**
  106577. * Interface used to present a loading screen while loading a scene
  106578. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106579. */
  106580. export interface ILoadingScreen {
  106581. /**
  106582. * Function called to display the loading screen
  106583. */
  106584. displayLoadingUI: () => void;
  106585. /**
  106586. * Function called to hide the loading screen
  106587. */
  106588. hideLoadingUI: () => void;
  106589. /**
  106590. * Gets or sets the color to use for the background
  106591. */
  106592. loadingUIBackgroundColor: string;
  106593. /**
  106594. * Gets or sets the text to display while loading
  106595. */
  106596. loadingUIText: string;
  106597. }
  106598. /**
  106599. * Class used for the default loading screen
  106600. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106601. */
  106602. export class DefaultLoadingScreen implements ILoadingScreen {
  106603. private _renderingCanvas;
  106604. private _loadingText;
  106605. private _loadingDivBackgroundColor;
  106606. private _loadingDiv;
  106607. private _loadingTextDiv;
  106608. /** Gets or sets the logo url to use for the default loading screen */
  106609. static DefaultLogoUrl: string;
  106610. /** Gets or sets the spinner url to use for the default loading screen */
  106611. static DefaultSpinnerUrl: string;
  106612. /**
  106613. * Creates a new default loading screen
  106614. * @param _renderingCanvas defines the canvas used to render the scene
  106615. * @param _loadingText defines the default text to display
  106616. * @param _loadingDivBackgroundColor defines the default background color
  106617. */
  106618. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106619. /**
  106620. * Function called to display the loading screen
  106621. */
  106622. displayLoadingUI(): void;
  106623. /**
  106624. * Function called to hide the loading screen
  106625. */
  106626. hideLoadingUI(): void;
  106627. /**
  106628. * Gets or sets the text to display while loading
  106629. */
  106630. set loadingUIText(text: string);
  106631. get loadingUIText(): string;
  106632. /**
  106633. * Gets or sets the color to use for the background
  106634. */
  106635. get loadingUIBackgroundColor(): string;
  106636. set loadingUIBackgroundColor(color: string);
  106637. private _resizeLoadingUI;
  106638. }
  106639. }
  106640. declare module BABYLON {
  106641. /**
  106642. * Interface for any object that can request an animation frame
  106643. */
  106644. export interface ICustomAnimationFrameRequester {
  106645. /**
  106646. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106647. */
  106648. renderFunction?: Function;
  106649. /**
  106650. * Called to request the next frame to render to
  106651. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106652. */
  106653. requestAnimationFrame: Function;
  106654. /**
  106655. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106656. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106657. */
  106658. requestID?: number;
  106659. }
  106660. }
  106661. declare module BABYLON {
  106662. /**
  106663. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106664. */
  106665. export class PerformanceMonitor {
  106666. private _enabled;
  106667. private _rollingFrameTime;
  106668. private _lastFrameTimeMs;
  106669. /**
  106670. * constructor
  106671. * @param frameSampleSize The number of samples required to saturate the sliding window
  106672. */
  106673. constructor(frameSampleSize?: number);
  106674. /**
  106675. * Samples current frame
  106676. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106677. */
  106678. sampleFrame(timeMs?: number): void;
  106679. /**
  106680. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106681. */
  106682. get averageFrameTime(): number;
  106683. /**
  106684. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106685. */
  106686. get averageFrameTimeVariance(): number;
  106687. /**
  106688. * Returns the frame time of the most recent frame
  106689. */
  106690. get instantaneousFrameTime(): number;
  106691. /**
  106692. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106693. */
  106694. get averageFPS(): number;
  106695. /**
  106696. * Returns the average framerate in frames per second using the most recent frame time
  106697. */
  106698. get instantaneousFPS(): number;
  106699. /**
  106700. * Returns true if enough samples have been taken to completely fill the sliding window
  106701. */
  106702. get isSaturated(): boolean;
  106703. /**
  106704. * Enables contributions to the sliding window sample set
  106705. */
  106706. enable(): void;
  106707. /**
  106708. * Disables contributions to the sliding window sample set
  106709. * Samples will not be interpolated over the disabled period
  106710. */
  106711. disable(): void;
  106712. /**
  106713. * Returns true if sampling is enabled
  106714. */
  106715. get isEnabled(): boolean;
  106716. /**
  106717. * Resets performance monitor
  106718. */
  106719. reset(): void;
  106720. }
  106721. /**
  106722. * RollingAverage
  106723. *
  106724. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106725. */
  106726. export class RollingAverage {
  106727. /**
  106728. * Current average
  106729. */
  106730. average: number;
  106731. /**
  106732. * Current variance
  106733. */
  106734. variance: number;
  106735. protected _samples: Array<number>;
  106736. protected _sampleCount: number;
  106737. protected _pos: number;
  106738. protected _m2: number;
  106739. /**
  106740. * constructor
  106741. * @param length The number of samples required to saturate the sliding window
  106742. */
  106743. constructor(length: number);
  106744. /**
  106745. * Adds a sample to the sample set
  106746. * @param v The sample value
  106747. */
  106748. add(v: number): void;
  106749. /**
  106750. * Returns previously added values or null if outside of history or outside the sliding window domain
  106751. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106752. * @return Value previously recorded with add() or null if outside of range
  106753. */
  106754. history(i: number): number;
  106755. /**
  106756. * Returns true if enough samples have been taken to completely fill the sliding window
  106757. * @return true if sample-set saturated
  106758. */
  106759. isSaturated(): boolean;
  106760. /**
  106761. * Resets the rolling average (equivalent to 0 samples taken so far)
  106762. */
  106763. reset(): void;
  106764. /**
  106765. * Wraps a value around the sample range boundaries
  106766. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106767. * @return Wrapped position in sample range
  106768. */
  106769. protected _wrapPosition(i: number): number;
  106770. }
  106771. }
  106772. declare module BABYLON {
  106773. /**
  106774. * This class is used to track a performance counter which is number based.
  106775. * The user has access to many properties which give statistics of different nature.
  106776. *
  106777. * The implementer can track two kinds of Performance Counter: time and count.
  106778. * 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.
  106779. * 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.
  106780. */
  106781. export class PerfCounter {
  106782. /**
  106783. * Gets or sets a global boolean to turn on and off all the counters
  106784. */
  106785. static Enabled: boolean;
  106786. /**
  106787. * Returns the smallest value ever
  106788. */
  106789. get min(): number;
  106790. /**
  106791. * Returns the biggest value ever
  106792. */
  106793. get max(): number;
  106794. /**
  106795. * Returns the average value since the performance counter is running
  106796. */
  106797. get average(): number;
  106798. /**
  106799. * Returns the average value of the last second the counter was monitored
  106800. */
  106801. get lastSecAverage(): number;
  106802. /**
  106803. * Returns the current value
  106804. */
  106805. get current(): number;
  106806. /**
  106807. * Gets the accumulated total
  106808. */
  106809. get total(): number;
  106810. /**
  106811. * Gets the total value count
  106812. */
  106813. get count(): number;
  106814. /**
  106815. * Creates a new counter
  106816. */
  106817. constructor();
  106818. /**
  106819. * Call this method to start monitoring a new frame.
  106820. * 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.
  106821. */
  106822. fetchNewFrame(): void;
  106823. /**
  106824. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106825. * @param newCount the count value to add to the monitored count
  106826. * @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.
  106827. */
  106828. addCount(newCount: number, fetchResult: boolean): void;
  106829. /**
  106830. * Start monitoring this performance counter
  106831. */
  106832. beginMonitoring(): void;
  106833. /**
  106834. * Compute the time lapsed since the previous beginMonitoring() call.
  106835. * @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
  106836. */
  106837. endMonitoring(newFrame?: boolean): void;
  106838. private _fetchResult;
  106839. private _startMonitoringTime;
  106840. private _min;
  106841. private _max;
  106842. private _average;
  106843. private _current;
  106844. private _totalValueCount;
  106845. private _totalAccumulated;
  106846. private _lastSecAverage;
  106847. private _lastSecAccumulated;
  106848. private _lastSecTime;
  106849. private _lastSecValueCount;
  106850. }
  106851. }
  106852. declare module BABYLON {
  106853. interface ThinEngine {
  106854. /**
  106855. * Sets alpha constants used by some alpha blending modes
  106856. * @param r defines the red component
  106857. * @param g defines the green component
  106858. * @param b defines the blue component
  106859. * @param a defines the alpha component
  106860. */
  106861. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106862. /**
  106863. * Sets the current alpha mode
  106864. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106865. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106866. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106867. */
  106868. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106869. /**
  106870. * Gets the current alpha mode
  106871. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106872. * @returns the current alpha mode
  106873. */
  106874. getAlphaMode(): number;
  106875. /**
  106876. * Sets the current alpha equation
  106877. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106878. */
  106879. setAlphaEquation(equation: number): void;
  106880. /**
  106881. * Gets the current alpha equation.
  106882. * @returns the current alpha equation
  106883. */
  106884. getAlphaEquation(): number;
  106885. }
  106886. }
  106887. declare module BABYLON {
  106888. /**
  106889. * Defines the interface used by display changed events
  106890. */
  106891. export interface IDisplayChangedEventArgs {
  106892. /** Gets the vrDisplay object (if any) */
  106893. vrDisplay: Nullable<any>;
  106894. /** Gets a boolean indicating if webVR is supported */
  106895. vrSupported: boolean;
  106896. }
  106897. /**
  106898. * Defines the interface used by objects containing a viewport (like a camera)
  106899. */
  106900. interface IViewportOwnerLike {
  106901. /**
  106902. * Gets or sets the viewport
  106903. */
  106904. viewport: IViewportLike;
  106905. }
  106906. /**
  106907. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106908. */
  106909. export class Engine extends ThinEngine {
  106910. /** Defines that alpha blending is disabled */
  106911. static readonly ALPHA_DISABLE: number;
  106912. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106913. static readonly ALPHA_ADD: number;
  106914. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106915. static readonly ALPHA_COMBINE: number;
  106916. /** Defines that alpha blending to DEST - SRC * DEST */
  106917. static readonly ALPHA_SUBTRACT: number;
  106918. /** Defines that alpha blending to SRC * DEST */
  106919. static readonly ALPHA_MULTIPLY: number;
  106920. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106921. static readonly ALPHA_MAXIMIZED: number;
  106922. /** Defines that alpha blending to SRC + DEST */
  106923. static readonly ALPHA_ONEONE: number;
  106924. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106925. static readonly ALPHA_PREMULTIPLIED: number;
  106926. /**
  106927. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106928. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106929. */
  106930. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106931. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106932. static readonly ALPHA_INTERPOLATE: number;
  106933. /**
  106934. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106935. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106936. */
  106937. static readonly ALPHA_SCREENMODE: number;
  106938. /** Defines that the ressource is not delayed*/
  106939. static readonly DELAYLOADSTATE_NONE: number;
  106940. /** Defines that the ressource was successfully delay loaded */
  106941. static readonly DELAYLOADSTATE_LOADED: number;
  106942. /** Defines that the ressource is currently delay loading */
  106943. static readonly DELAYLOADSTATE_LOADING: number;
  106944. /** Defines that the ressource is delayed and has not started loading */
  106945. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106946. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106947. static readonly NEVER: number;
  106948. /** 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 */
  106949. static readonly ALWAYS: number;
  106950. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106951. static readonly LESS: number;
  106952. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106953. static readonly EQUAL: number;
  106954. /** 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 */
  106955. static readonly LEQUAL: number;
  106956. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106957. static readonly GREATER: number;
  106958. /** 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 */
  106959. static readonly GEQUAL: number;
  106960. /** 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 */
  106961. static readonly NOTEQUAL: number;
  106962. /** Passed to stencilOperation to specify that stencil value must be kept */
  106963. static readonly KEEP: number;
  106964. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106965. static readonly REPLACE: number;
  106966. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106967. static readonly INCR: number;
  106968. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106969. static readonly DECR: number;
  106970. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106971. static readonly INVERT: number;
  106972. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106973. static readonly INCR_WRAP: number;
  106974. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106975. static readonly DECR_WRAP: number;
  106976. /** Texture is not repeating outside of 0..1 UVs */
  106977. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106978. /** Texture is repeating outside of 0..1 UVs */
  106979. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106980. /** Texture is repeating and mirrored */
  106981. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106982. /** ALPHA */
  106983. static readonly TEXTUREFORMAT_ALPHA: number;
  106984. /** LUMINANCE */
  106985. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106986. /** LUMINANCE_ALPHA */
  106987. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106988. /** RGB */
  106989. static readonly TEXTUREFORMAT_RGB: number;
  106990. /** RGBA */
  106991. static readonly TEXTUREFORMAT_RGBA: number;
  106992. /** RED */
  106993. static readonly TEXTUREFORMAT_RED: number;
  106994. /** RED (2nd reference) */
  106995. static readonly TEXTUREFORMAT_R: number;
  106996. /** RG */
  106997. static readonly TEXTUREFORMAT_RG: number;
  106998. /** RED_INTEGER */
  106999. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  107000. /** RED_INTEGER (2nd reference) */
  107001. static readonly TEXTUREFORMAT_R_INTEGER: number;
  107002. /** RG_INTEGER */
  107003. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  107004. /** RGB_INTEGER */
  107005. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  107006. /** RGBA_INTEGER */
  107007. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  107008. /** UNSIGNED_BYTE */
  107009. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  107010. /** UNSIGNED_BYTE (2nd reference) */
  107011. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  107012. /** FLOAT */
  107013. static readonly TEXTURETYPE_FLOAT: number;
  107014. /** HALF_FLOAT */
  107015. static readonly TEXTURETYPE_HALF_FLOAT: number;
  107016. /** BYTE */
  107017. static readonly TEXTURETYPE_BYTE: number;
  107018. /** SHORT */
  107019. static readonly TEXTURETYPE_SHORT: number;
  107020. /** UNSIGNED_SHORT */
  107021. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  107022. /** INT */
  107023. static readonly TEXTURETYPE_INT: number;
  107024. /** UNSIGNED_INT */
  107025. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  107026. /** UNSIGNED_SHORT_4_4_4_4 */
  107027. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  107028. /** UNSIGNED_SHORT_5_5_5_1 */
  107029. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  107030. /** UNSIGNED_SHORT_5_6_5 */
  107031. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  107032. /** UNSIGNED_INT_2_10_10_10_REV */
  107033. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  107034. /** UNSIGNED_INT_24_8 */
  107035. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  107036. /** UNSIGNED_INT_10F_11F_11F_REV */
  107037. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  107038. /** UNSIGNED_INT_5_9_9_9_REV */
  107039. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  107040. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  107041. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  107042. /** nearest is mag = nearest and min = nearest and mip = linear */
  107043. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  107044. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107045. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  107046. /** Trilinear is mag = linear and min = linear and mip = linear */
  107047. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  107048. /** nearest is mag = nearest and min = nearest and mip = linear */
  107049. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  107050. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107051. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  107052. /** Trilinear is mag = linear and min = linear and mip = linear */
  107053. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  107054. /** mag = nearest and min = nearest and mip = nearest */
  107055. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  107056. /** mag = nearest and min = linear and mip = nearest */
  107057. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  107058. /** mag = nearest and min = linear and mip = linear */
  107059. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  107060. /** mag = nearest and min = linear and mip = none */
  107061. static readonly TEXTURE_NEAREST_LINEAR: number;
  107062. /** mag = nearest and min = nearest and mip = none */
  107063. static readonly TEXTURE_NEAREST_NEAREST: number;
  107064. /** mag = linear and min = nearest and mip = nearest */
  107065. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  107066. /** mag = linear and min = nearest and mip = linear */
  107067. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  107068. /** mag = linear and min = linear and mip = none */
  107069. static readonly TEXTURE_LINEAR_LINEAR: number;
  107070. /** mag = linear and min = nearest and mip = none */
  107071. static readonly TEXTURE_LINEAR_NEAREST: number;
  107072. /** Explicit coordinates mode */
  107073. static readonly TEXTURE_EXPLICIT_MODE: number;
  107074. /** Spherical coordinates mode */
  107075. static readonly TEXTURE_SPHERICAL_MODE: number;
  107076. /** Planar coordinates mode */
  107077. static readonly TEXTURE_PLANAR_MODE: number;
  107078. /** Cubic coordinates mode */
  107079. static readonly TEXTURE_CUBIC_MODE: number;
  107080. /** Projection coordinates mode */
  107081. static readonly TEXTURE_PROJECTION_MODE: number;
  107082. /** Skybox coordinates mode */
  107083. static readonly TEXTURE_SKYBOX_MODE: number;
  107084. /** Inverse Cubic coordinates mode */
  107085. static readonly TEXTURE_INVCUBIC_MODE: number;
  107086. /** Equirectangular coordinates mode */
  107087. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  107088. /** Equirectangular Fixed coordinates mode */
  107089. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  107090. /** Equirectangular Fixed Mirrored coordinates mode */
  107091. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  107092. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  107093. static readonly SCALEMODE_FLOOR: number;
  107094. /** Defines that texture rescaling will look for the nearest power of 2 size */
  107095. static readonly SCALEMODE_NEAREST: number;
  107096. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  107097. static readonly SCALEMODE_CEILING: number;
  107098. /**
  107099. * Returns the current npm package of the sdk
  107100. */
  107101. static get NpmPackage(): string;
  107102. /**
  107103. * Returns the current version of the framework
  107104. */
  107105. static get Version(): string;
  107106. /** Gets the list of created engines */
  107107. static get Instances(): Engine[];
  107108. /**
  107109. * Gets the latest created engine
  107110. */
  107111. static get LastCreatedEngine(): Nullable<Engine>;
  107112. /**
  107113. * Gets the latest created scene
  107114. */
  107115. static get LastCreatedScene(): Nullable<Scene>;
  107116. /**
  107117. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107118. * @param flag defines which part of the materials must be marked as dirty
  107119. * @param predicate defines a predicate used to filter which materials should be affected
  107120. */
  107121. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107122. /**
  107123. * Method called to create the default loading screen.
  107124. * This can be overriden in your own app.
  107125. * @param canvas The rendering canvas element
  107126. * @returns The loading screen
  107127. */
  107128. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107129. /**
  107130. * Method called to create the default rescale post process on each engine.
  107131. */
  107132. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107133. /**
  107134. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107135. **/
  107136. enableOfflineSupport: boolean;
  107137. /**
  107138. * 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)
  107139. **/
  107140. disableManifestCheck: boolean;
  107141. /**
  107142. * Gets the list of created scenes
  107143. */
  107144. scenes: Scene[];
  107145. /**
  107146. * Event raised when a new scene is created
  107147. */
  107148. onNewSceneAddedObservable: Observable<Scene>;
  107149. /**
  107150. * Gets the list of created postprocesses
  107151. */
  107152. postProcesses: PostProcess[];
  107153. /**
  107154. * Gets a boolean indicating if the pointer is currently locked
  107155. */
  107156. isPointerLock: boolean;
  107157. /**
  107158. * Observable event triggered each time the rendering canvas is resized
  107159. */
  107160. onResizeObservable: Observable<Engine>;
  107161. /**
  107162. * Observable event triggered each time the canvas loses focus
  107163. */
  107164. onCanvasBlurObservable: Observable<Engine>;
  107165. /**
  107166. * Observable event triggered each time the canvas gains focus
  107167. */
  107168. onCanvasFocusObservable: Observable<Engine>;
  107169. /**
  107170. * Observable event triggered each time the canvas receives pointerout event
  107171. */
  107172. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107173. /**
  107174. * Observable raised when the engine begins a new frame
  107175. */
  107176. onBeginFrameObservable: Observable<Engine>;
  107177. /**
  107178. * If set, will be used to request the next animation frame for the render loop
  107179. */
  107180. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107181. /**
  107182. * Observable raised when the engine ends the current frame
  107183. */
  107184. onEndFrameObservable: Observable<Engine>;
  107185. /**
  107186. * Observable raised when the engine is about to compile a shader
  107187. */
  107188. onBeforeShaderCompilationObservable: Observable<Engine>;
  107189. /**
  107190. * Observable raised when the engine has jsut compiled a shader
  107191. */
  107192. onAfterShaderCompilationObservable: Observable<Engine>;
  107193. /**
  107194. * Gets the audio engine
  107195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107196. * @ignorenaming
  107197. */
  107198. static audioEngine: IAudioEngine;
  107199. /**
  107200. * Default AudioEngine factory responsible of creating the Audio Engine.
  107201. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  107202. */
  107203. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  107204. /**
  107205. * Default offline support factory responsible of creating a tool used to store data locally.
  107206. * By default, this will create a Database object if the workload has been embedded.
  107207. */
  107208. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  107209. private _loadingScreen;
  107210. private _pointerLockRequested;
  107211. private _dummyFramebuffer;
  107212. private _rescalePostProcess;
  107213. private _deterministicLockstep;
  107214. private _lockstepMaxSteps;
  107215. private _timeStep;
  107216. protected get _supportsHardwareTextureRescaling(): boolean;
  107217. private _fps;
  107218. private _deltaTime;
  107219. /** @hidden */
  107220. _drawCalls: PerfCounter;
  107221. /** 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 */
  107222. canvasTabIndex: number;
  107223. /**
  107224. * Turn this value on if you want to pause FPS computation when in background
  107225. */
  107226. disablePerformanceMonitorInBackground: boolean;
  107227. private _performanceMonitor;
  107228. /**
  107229. * Gets the performance monitor attached to this engine
  107230. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  107231. */
  107232. get performanceMonitor(): PerformanceMonitor;
  107233. private _onFocus;
  107234. private _onBlur;
  107235. private _onCanvasPointerOut;
  107236. private _onCanvasBlur;
  107237. private _onCanvasFocus;
  107238. private _onFullscreenChange;
  107239. private _onPointerLockChange;
  107240. /**
  107241. * Gets the HTML element used to attach event listeners
  107242. * @returns a HTML element
  107243. */
  107244. getInputElement(): Nullable<HTMLElement>;
  107245. /**
  107246. * Creates a new engine
  107247. * @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
  107248. * @param antialias defines enable antialiasing (default: false)
  107249. * @param options defines further options to be sent to the getContext() function
  107250. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107251. */
  107252. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107253. /**
  107254. * Gets current aspect ratio
  107255. * @param viewportOwner defines the camera to use to get the aspect ratio
  107256. * @param useScreen defines if screen size must be used (or the current render target if any)
  107257. * @returns a number defining the aspect ratio
  107258. */
  107259. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  107260. /**
  107261. * Gets current screen aspect ratio
  107262. * @returns a number defining the aspect ratio
  107263. */
  107264. getScreenAspectRatio(): number;
  107265. /**
  107266. * Gets the client rect of the HTML canvas attached with the current webGL context
  107267. * @returns a client rectanglee
  107268. */
  107269. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  107270. /**
  107271. * Gets the client rect of the HTML element used for events
  107272. * @returns a client rectanglee
  107273. */
  107274. getInputElementClientRect(): Nullable<ClientRect>;
  107275. /**
  107276. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  107277. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107278. * @returns true if engine is in deterministic lock step mode
  107279. */
  107280. isDeterministicLockStep(): boolean;
  107281. /**
  107282. * Gets the max steps when engine is running in deterministic lock step
  107283. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107284. * @returns the max steps
  107285. */
  107286. getLockstepMaxSteps(): number;
  107287. /**
  107288. * Returns the time in ms between steps when using deterministic lock step.
  107289. * @returns time step in (ms)
  107290. */
  107291. getTimeStep(): number;
  107292. /**
  107293. * Force the mipmap generation for the given render target texture
  107294. * @param texture defines the render target texture to use
  107295. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  107296. */
  107297. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  107298. /** States */
  107299. /**
  107300. * Set various states to the webGL context
  107301. * @param culling defines backface culling state
  107302. * @param zOffset defines the value to apply to zOffset (0 by default)
  107303. * @param force defines if states must be applied even if cache is up to date
  107304. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  107305. */
  107306. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107307. /**
  107308. * Set the z offset to apply to current rendering
  107309. * @param value defines the offset to apply
  107310. */
  107311. setZOffset(value: number): void;
  107312. /**
  107313. * Gets the current value of the zOffset
  107314. * @returns the current zOffset state
  107315. */
  107316. getZOffset(): number;
  107317. /**
  107318. * Enable or disable depth buffering
  107319. * @param enable defines the state to set
  107320. */
  107321. setDepthBuffer(enable: boolean): void;
  107322. /**
  107323. * Gets a boolean indicating if depth writing is enabled
  107324. * @returns the current depth writing state
  107325. */
  107326. getDepthWrite(): boolean;
  107327. /**
  107328. * Enable or disable depth writing
  107329. * @param enable defines the state to set
  107330. */
  107331. setDepthWrite(enable: boolean): void;
  107332. /**
  107333. * Gets a boolean indicating if stencil buffer is enabled
  107334. * @returns the current stencil buffer state
  107335. */
  107336. getStencilBuffer(): boolean;
  107337. /**
  107338. * Enable or disable the stencil buffer
  107339. * @param enable defines if the stencil buffer must be enabled or disabled
  107340. */
  107341. setStencilBuffer(enable: boolean): void;
  107342. /**
  107343. * Gets the current stencil mask
  107344. * @returns a number defining the new stencil mask to use
  107345. */
  107346. getStencilMask(): number;
  107347. /**
  107348. * Sets the current stencil mask
  107349. * @param mask defines the new stencil mask to use
  107350. */
  107351. setStencilMask(mask: number): void;
  107352. /**
  107353. * Gets the current stencil function
  107354. * @returns a number defining the stencil function to use
  107355. */
  107356. getStencilFunction(): number;
  107357. /**
  107358. * Gets the current stencil reference value
  107359. * @returns a number defining the stencil reference value to use
  107360. */
  107361. getStencilFunctionReference(): number;
  107362. /**
  107363. * Gets the current stencil mask
  107364. * @returns a number defining the stencil mask to use
  107365. */
  107366. getStencilFunctionMask(): number;
  107367. /**
  107368. * Sets the current stencil function
  107369. * @param stencilFunc defines the new stencil function to use
  107370. */
  107371. setStencilFunction(stencilFunc: number): void;
  107372. /**
  107373. * Sets the current stencil reference
  107374. * @param reference defines the new stencil reference to use
  107375. */
  107376. setStencilFunctionReference(reference: number): void;
  107377. /**
  107378. * Sets the current stencil mask
  107379. * @param mask defines the new stencil mask to use
  107380. */
  107381. setStencilFunctionMask(mask: number): void;
  107382. /**
  107383. * Gets the current stencil operation when stencil fails
  107384. * @returns a number defining stencil operation to use when stencil fails
  107385. */
  107386. getStencilOperationFail(): number;
  107387. /**
  107388. * Gets the current stencil operation when depth fails
  107389. * @returns a number defining stencil operation to use when depth fails
  107390. */
  107391. getStencilOperationDepthFail(): number;
  107392. /**
  107393. * Gets the current stencil operation when stencil passes
  107394. * @returns a number defining stencil operation to use when stencil passes
  107395. */
  107396. getStencilOperationPass(): number;
  107397. /**
  107398. * Sets the stencil operation to use when stencil fails
  107399. * @param operation defines the stencil operation to use when stencil fails
  107400. */
  107401. setStencilOperationFail(operation: number): void;
  107402. /**
  107403. * Sets the stencil operation to use when depth fails
  107404. * @param operation defines the stencil operation to use when depth fails
  107405. */
  107406. setStencilOperationDepthFail(operation: number): void;
  107407. /**
  107408. * Sets the stencil operation to use when stencil passes
  107409. * @param operation defines the stencil operation to use when stencil passes
  107410. */
  107411. setStencilOperationPass(operation: number): void;
  107412. /**
  107413. * Sets a boolean indicating if the dithering state is enabled or disabled
  107414. * @param value defines the dithering state
  107415. */
  107416. setDitheringState(value: boolean): void;
  107417. /**
  107418. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  107419. * @param value defines the rasterizer state
  107420. */
  107421. setRasterizerState(value: boolean): void;
  107422. /**
  107423. * Gets the current depth function
  107424. * @returns a number defining the depth function
  107425. */
  107426. getDepthFunction(): Nullable<number>;
  107427. /**
  107428. * Sets the current depth function
  107429. * @param depthFunc defines the function to use
  107430. */
  107431. setDepthFunction(depthFunc: number): void;
  107432. /**
  107433. * Sets the current depth function to GREATER
  107434. */
  107435. setDepthFunctionToGreater(): void;
  107436. /**
  107437. * Sets the current depth function to GEQUAL
  107438. */
  107439. setDepthFunctionToGreaterOrEqual(): void;
  107440. /**
  107441. * Sets the current depth function to LESS
  107442. */
  107443. setDepthFunctionToLess(): void;
  107444. /**
  107445. * Sets the current depth function to LEQUAL
  107446. */
  107447. setDepthFunctionToLessOrEqual(): void;
  107448. private _cachedStencilBuffer;
  107449. private _cachedStencilFunction;
  107450. private _cachedStencilMask;
  107451. private _cachedStencilOperationPass;
  107452. private _cachedStencilOperationFail;
  107453. private _cachedStencilOperationDepthFail;
  107454. private _cachedStencilReference;
  107455. /**
  107456. * Caches the the state of the stencil buffer
  107457. */
  107458. cacheStencilState(): void;
  107459. /**
  107460. * Restores the state of the stencil buffer
  107461. */
  107462. restoreStencilState(): void;
  107463. /**
  107464. * Directly set the WebGL Viewport
  107465. * @param x defines the x coordinate of the viewport (in screen space)
  107466. * @param y defines the y coordinate of the viewport (in screen space)
  107467. * @param width defines the width of the viewport (in screen space)
  107468. * @param height defines the height of the viewport (in screen space)
  107469. * @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
  107470. */
  107471. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  107472. /**
  107473. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  107474. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107475. * @param y defines the y-coordinate of the corner of the clear rectangle
  107476. * @param width defines the width of the clear rectangle
  107477. * @param height defines the height of the clear rectangle
  107478. * @param clearColor defines the clear color
  107479. */
  107480. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  107481. /**
  107482. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  107483. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107484. * @param y defines the y-coordinate of the corner of the clear rectangle
  107485. * @param width defines the width of the clear rectangle
  107486. * @param height defines the height of the clear rectangle
  107487. */
  107488. enableScissor(x: number, y: number, width: number, height: number): void;
  107489. /**
  107490. * Disable previously set scissor test rectangle
  107491. */
  107492. disableScissor(): void;
  107493. protected _reportDrawCall(): void;
  107494. /**
  107495. * Initializes a webVR display and starts listening to display change events
  107496. * The onVRDisplayChangedObservable will be notified upon these changes
  107497. * @returns The onVRDisplayChangedObservable
  107498. */
  107499. initWebVR(): Observable<IDisplayChangedEventArgs>;
  107500. /** @hidden */
  107501. _prepareVRComponent(): void;
  107502. /** @hidden */
  107503. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  107504. /** @hidden */
  107505. _submitVRFrame(): void;
  107506. /**
  107507. * Call this function to leave webVR mode
  107508. * Will do nothing if webVR is not supported or if there is no webVR device
  107509. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107510. */
  107511. disableVR(): void;
  107512. /**
  107513. * Gets a boolean indicating that the system is in VR mode and is presenting
  107514. * @returns true if VR mode is engaged
  107515. */
  107516. isVRPresenting(): boolean;
  107517. /** @hidden */
  107518. _requestVRFrame(): void;
  107519. /** @hidden */
  107520. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107521. /**
  107522. * Gets the source code of the vertex shader associated with a specific webGL program
  107523. * @param program defines the program to use
  107524. * @returns a string containing the source code of the vertex shader associated with the program
  107525. */
  107526. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  107527. /**
  107528. * Gets the source code of the fragment shader associated with a specific webGL program
  107529. * @param program defines the program to use
  107530. * @returns a string containing the source code of the fragment shader associated with the program
  107531. */
  107532. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  107533. /**
  107534. * Sets a depth stencil texture from a render target to the according uniform.
  107535. * @param channel The texture channel
  107536. * @param uniform The uniform to set
  107537. * @param texture The render target texture containing the depth stencil texture to apply
  107538. */
  107539. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107540. /**
  107541. * Sets a texture to the webGL context from a postprocess
  107542. * @param channel defines the channel to use
  107543. * @param postProcess defines the source postprocess
  107544. */
  107545. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107546. /**
  107547. * Binds the output of the passed in post process to the texture channel specified
  107548. * @param channel The channel the texture should be bound to
  107549. * @param postProcess The post process which's output should be bound
  107550. */
  107551. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107552. /** @hidden */
  107553. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107554. protected _rebuildBuffers(): void;
  107555. /** @hidden */
  107556. _renderFrame(): void;
  107557. _renderLoop(): void;
  107558. /** @hidden */
  107559. _renderViews(): boolean;
  107560. /**
  107561. * Toggle full screen mode
  107562. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107563. */
  107564. switchFullscreen(requestPointerLock: boolean): void;
  107565. /**
  107566. * Enters full screen mode
  107567. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107568. */
  107569. enterFullscreen(requestPointerLock: boolean): void;
  107570. /**
  107571. * Exits full screen mode
  107572. */
  107573. exitFullscreen(): void;
  107574. /**
  107575. * Enters Pointerlock mode
  107576. */
  107577. enterPointerlock(): void;
  107578. /**
  107579. * Exits Pointerlock mode
  107580. */
  107581. exitPointerlock(): void;
  107582. /**
  107583. * Begin a new frame
  107584. */
  107585. beginFrame(): void;
  107586. /**
  107587. * Enf the current frame
  107588. */
  107589. endFrame(): void;
  107590. resize(): void;
  107591. /**
  107592. * Force a specific size of the canvas
  107593. * @param width defines the new canvas' width
  107594. * @param height defines the new canvas' height
  107595. */
  107596. setSize(width: number, height: number): void;
  107597. /**
  107598. * Updates a dynamic vertex buffer.
  107599. * @param vertexBuffer the vertex buffer to update
  107600. * @param data the data used to update the vertex buffer
  107601. * @param byteOffset the byte offset of the data
  107602. * @param byteLength the byte length of the data
  107603. */
  107604. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107605. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107606. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107607. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107608. _releaseTexture(texture: InternalTexture): void;
  107609. /**
  107610. * @hidden
  107611. * Rescales a texture
  107612. * @param source input texutre
  107613. * @param destination destination texture
  107614. * @param scene scene to use to render the resize
  107615. * @param internalFormat format to use when resizing
  107616. * @param onComplete callback to be called when resize has completed
  107617. */
  107618. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107619. /**
  107620. * Gets the current framerate
  107621. * @returns a number representing the framerate
  107622. */
  107623. getFps(): number;
  107624. /**
  107625. * Gets the time spent between current and previous frame
  107626. * @returns a number representing the delta time in ms
  107627. */
  107628. getDeltaTime(): number;
  107629. private _measureFps;
  107630. /** @hidden */
  107631. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107632. /**
  107633. * Update a dynamic index buffer
  107634. * @param indexBuffer defines the target index buffer
  107635. * @param indices defines the data to update
  107636. * @param offset defines the offset in the target index buffer where update should start
  107637. */
  107638. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107639. /**
  107640. * Updates the sample count of a render target texture
  107641. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107642. * @param texture defines the texture to update
  107643. * @param samples defines the sample count to set
  107644. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107645. */
  107646. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107647. /**
  107648. * Updates a depth texture Comparison Mode and Function.
  107649. * If the comparison Function is equal to 0, the mode will be set to none.
  107650. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107651. * @param texture The texture to set the comparison function for
  107652. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107653. */
  107654. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107655. /**
  107656. * Creates a webGL buffer to use with instanciation
  107657. * @param capacity defines the size of the buffer
  107658. * @returns the webGL buffer
  107659. */
  107660. createInstancesBuffer(capacity: number): DataBuffer;
  107661. /**
  107662. * Delete a webGL buffer used with instanciation
  107663. * @param buffer defines the webGL buffer to delete
  107664. */
  107665. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107666. private _clientWaitAsync;
  107667. /** @hidden */
  107668. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107669. /** @hidden */
  107670. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107671. dispose(): void;
  107672. private _disableTouchAction;
  107673. /**
  107674. * Display the loading screen
  107675. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107676. */
  107677. displayLoadingUI(): void;
  107678. /**
  107679. * Hide the loading screen
  107680. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107681. */
  107682. hideLoadingUI(): void;
  107683. /**
  107684. * Gets the current loading screen object
  107685. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107686. */
  107687. get loadingScreen(): ILoadingScreen;
  107688. /**
  107689. * Sets the current loading screen object
  107690. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107691. */
  107692. set loadingScreen(loadingScreen: ILoadingScreen);
  107693. /**
  107694. * Sets the current loading screen text
  107695. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107696. */
  107697. set loadingUIText(text: string);
  107698. /**
  107699. * Sets the current loading screen background color
  107700. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107701. */
  107702. set loadingUIBackgroundColor(color: string);
  107703. /** Pointerlock and fullscreen */
  107704. /**
  107705. * Ask the browser to promote the current element to pointerlock mode
  107706. * @param element defines the DOM element to promote
  107707. */
  107708. static _RequestPointerlock(element: HTMLElement): void;
  107709. /**
  107710. * Asks the browser to exit pointerlock mode
  107711. */
  107712. static _ExitPointerlock(): void;
  107713. /**
  107714. * Ask the browser to promote the current element to fullscreen rendering mode
  107715. * @param element defines the DOM element to promote
  107716. */
  107717. static _RequestFullscreen(element: HTMLElement): void;
  107718. /**
  107719. * Asks the browser to exit fullscreen mode
  107720. */
  107721. static _ExitFullscreen(): void;
  107722. }
  107723. }
  107724. declare module BABYLON {
  107725. /**
  107726. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107727. * during the life time of the application.
  107728. */
  107729. export class EngineStore {
  107730. /** Gets the list of created engines */
  107731. static Instances: Engine[];
  107732. /** @hidden */
  107733. static _LastCreatedScene: Nullable<Scene>;
  107734. /**
  107735. * Gets the latest created engine
  107736. */
  107737. static get LastCreatedEngine(): Nullable<Engine>;
  107738. /**
  107739. * Gets the latest created scene
  107740. */
  107741. static get LastCreatedScene(): Nullable<Scene>;
  107742. /**
  107743. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107744. * @ignorenaming
  107745. */
  107746. static UseFallbackTexture: boolean;
  107747. /**
  107748. * Texture content used if a texture cannot loaded
  107749. * @ignorenaming
  107750. */
  107751. static FallbackTexture: string;
  107752. }
  107753. }
  107754. declare module BABYLON {
  107755. /**
  107756. * Helper class that provides a small promise polyfill
  107757. */
  107758. export class PromisePolyfill {
  107759. /**
  107760. * Static function used to check if the polyfill is required
  107761. * If this is the case then the function will inject the polyfill to window.Promise
  107762. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107763. */
  107764. static Apply(force?: boolean): void;
  107765. }
  107766. }
  107767. declare module BABYLON {
  107768. /**
  107769. * Interface for screenshot methods with describe argument called `size` as object with options
  107770. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107771. */
  107772. export interface IScreenshotSize {
  107773. /**
  107774. * number in pixels for canvas height
  107775. */
  107776. height?: number;
  107777. /**
  107778. * multiplier allowing render at a higher or lower resolution
  107779. * If value is defined then height and width will be ignored and taken from camera
  107780. */
  107781. precision?: number;
  107782. /**
  107783. * number in pixels for canvas width
  107784. */
  107785. width?: number;
  107786. }
  107787. }
  107788. declare module BABYLON {
  107789. interface IColor4Like {
  107790. r: float;
  107791. g: float;
  107792. b: float;
  107793. a: float;
  107794. }
  107795. /**
  107796. * Class containing a set of static utilities functions
  107797. */
  107798. export class Tools {
  107799. /**
  107800. * Gets or sets the base URL to use to load assets
  107801. */
  107802. static get BaseUrl(): string;
  107803. static set BaseUrl(value: string);
  107804. /**
  107805. * Enable/Disable Custom HTTP Request Headers globally.
  107806. * default = false
  107807. * @see CustomRequestHeaders
  107808. */
  107809. static UseCustomRequestHeaders: boolean;
  107810. /**
  107811. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107812. * i.e. when loading files, where the server/service expects an Authorization header
  107813. */
  107814. static CustomRequestHeaders: {
  107815. [key: string]: string;
  107816. };
  107817. /**
  107818. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107819. */
  107820. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107821. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107822. /**
  107823. * Default behaviour for cors in the application.
  107824. * It can be a string if the expected behavior is identical in the entire app.
  107825. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107826. */
  107827. static get CorsBehavior(): string | ((url: string | string[]) => string);
  107828. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  107829. /**
  107830. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107831. * @ignorenaming
  107832. */
  107833. static get UseFallbackTexture(): boolean;
  107834. static set UseFallbackTexture(value: boolean);
  107835. /**
  107836. * Use this object to register external classes like custom textures or material
  107837. * to allow the laoders to instantiate them
  107838. */
  107839. static get RegisteredExternalClasses(): {
  107840. [key: string]: Object;
  107841. };
  107842. static set RegisteredExternalClasses(classes: {
  107843. [key: string]: Object;
  107844. });
  107845. /**
  107846. * Texture content used if a texture cannot loaded
  107847. * @ignorenaming
  107848. */
  107849. static get fallbackTexture(): string;
  107850. static set fallbackTexture(value: string);
  107851. /**
  107852. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107853. * @param u defines the coordinate on X axis
  107854. * @param v defines the coordinate on Y axis
  107855. * @param width defines the width of the source data
  107856. * @param height defines the height of the source data
  107857. * @param pixels defines the source byte array
  107858. * @param color defines the output color
  107859. */
  107860. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107861. /**
  107862. * Interpolates between a and b via alpha
  107863. * @param a The lower value (returned when alpha = 0)
  107864. * @param b The upper value (returned when alpha = 1)
  107865. * @param alpha The interpolation-factor
  107866. * @return The mixed value
  107867. */
  107868. static Mix(a: number, b: number, alpha: number): number;
  107869. /**
  107870. * Tries to instantiate a new object from a given class name
  107871. * @param className defines the class name to instantiate
  107872. * @returns the new object or null if the system was not able to do the instantiation
  107873. */
  107874. static Instantiate(className: string): any;
  107875. /**
  107876. * Provides a slice function that will work even on IE
  107877. * @param data defines the array to slice
  107878. * @param start defines the start of the data (optional)
  107879. * @param end defines the end of the data (optional)
  107880. * @returns the new sliced array
  107881. */
  107882. static Slice<T>(data: T, start?: number, end?: number): T;
  107883. /**
  107884. * Polyfill for setImmediate
  107885. * @param action defines the action to execute after the current execution block
  107886. */
  107887. static SetImmediate(action: () => void): void;
  107888. /**
  107889. * Function indicating if a number is an exponent of 2
  107890. * @param value defines the value to test
  107891. * @returns true if the value is an exponent of 2
  107892. */
  107893. static IsExponentOfTwo(value: number): boolean;
  107894. private static _tmpFloatArray;
  107895. /**
  107896. * Returns the nearest 32-bit single precision float representation of a Number
  107897. * @param value A Number. If the parameter is of a different type, it will get converted
  107898. * to a number or to NaN if it cannot be converted
  107899. * @returns number
  107900. */
  107901. static FloatRound(value: number): number;
  107902. /**
  107903. * Extracts the filename from a path
  107904. * @param path defines the path to use
  107905. * @returns the filename
  107906. */
  107907. static GetFilename(path: string): string;
  107908. /**
  107909. * Extracts the "folder" part of a path (everything before the filename).
  107910. * @param uri The URI to extract the info from
  107911. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107912. * @returns The "folder" part of the path
  107913. */
  107914. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107915. /**
  107916. * Extracts text content from a DOM element hierarchy
  107917. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107918. */
  107919. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107920. /**
  107921. * Convert an angle in radians to degrees
  107922. * @param angle defines the angle to convert
  107923. * @returns the angle in degrees
  107924. */
  107925. static ToDegrees(angle: number): number;
  107926. /**
  107927. * Convert an angle in degrees to radians
  107928. * @param angle defines the angle to convert
  107929. * @returns the angle in radians
  107930. */
  107931. static ToRadians(angle: number): number;
  107932. /**
  107933. * Returns an array if obj is not an array
  107934. * @param obj defines the object to evaluate as an array
  107935. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107936. * @returns either obj directly if obj is an array or a new array containing obj
  107937. */
  107938. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107939. /**
  107940. * Gets the pointer prefix to use
  107941. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107942. */
  107943. static GetPointerPrefix(): string;
  107944. /**
  107945. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107946. * @param url define the url we are trying
  107947. * @param element define the dom element where to configure the cors policy
  107948. */
  107949. static SetCorsBehavior(url: string | string[], element: {
  107950. crossOrigin: string | null;
  107951. }): void;
  107952. /**
  107953. * Removes unwanted characters from an url
  107954. * @param url defines the url to clean
  107955. * @returns the cleaned url
  107956. */
  107957. static CleanUrl(url: string): string;
  107958. /**
  107959. * Gets or sets a function used to pre-process url before using them to load assets
  107960. */
  107961. static get PreprocessUrl(): (url: string) => string;
  107962. static set PreprocessUrl(processor: (url: string) => string);
  107963. /**
  107964. * Loads an image as an HTMLImageElement.
  107965. * @param input url string, ArrayBuffer, or Blob to load
  107966. * @param onLoad callback called when the image successfully loads
  107967. * @param onError callback called when the image fails to load
  107968. * @param offlineProvider offline provider for caching
  107969. * @param mimeType optional mime type
  107970. * @returns the HTMLImageElement of the loaded image
  107971. */
  107972. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107973. /**
  107974. * Loads a file from a url
  107975. * @param url url string, ArrayBuffer, or Blob to load
  107976. * @param onSuccess callback called when the file successfully loads
  107977. * @param onProgress callback called while file is loading (if the server supports this mode)
  107978. * @param offlineProvider defines the offline provider for caching
  107979. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107980. * @param onError callback called when the file fails to load
  107981. * @returns a file request object
  107982. */
  107983. 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;
  107984. /**
  107985. * Loads a file from a url
  107986. * @param url the file url to load
  107987. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107988. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107989. */
  107990. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107991. /**
  107992. * Load a script (identified by an url). When the url returns, the
  107993. * content of this file is added into a new script element, attached to the DOM (body element)
  107994. * @param scriptUrl defines the url of the script to laod
  107995. * @param onSuccess defines the callback called when the script is loaded
  107996. * @param onError defines the callback to call if an error occurs
  107997. * @param scriptId defines the id of the script element
  107998. */
  107999. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  108000. /**
  108001. * Load an asynchronous script (identified by an url). When the url returns, the
  108002. * content of this file is added into a new script element, attached to the DOM (body element)
  108003. * @param scriptUrl defines the url of the script to laod
  108004. * @param scriptId defines the id of the script element
  108005. * @returns a promise request object
  108006. */
  108007. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  108008. /**
  108009. * Loads a file from a blob
  108010. * @param fileToLoad defines the blob to use
  108011. * @param callback defines the callback to call when data is loaded
  108012. * @param progressCallback defines the callback to call during loading process
  108013. * @returns a file request object
  108014. */
  108015. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  108016. /**
  108017. * Reads a file from a File object
  108018. * @param file defines the file to load
  108019. * @param onSuccess defines the callback to call when data is loaded
  108020. * @param onProgress defines the callback to call during loading process
  108021. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  108022. * @param onError defines the callback to call when an error occurs
  108023. * @returns a file request object
  108024. */
  108025. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108026. /**
  108027. * Creates a data url from a given string content
  108028. * @param content defines the content to convert
  108029. * @returns the new data url link
  108030. */
  108031. static FileAsURL(content: string): string;
  108032. /**
  108033. * Format the given number to a specific decimal format
  108034. * @param value defines the number to format
  108035. * @param decimals defines the number of decimals to use
  108036. * @returns the formatted string
  108037. */
  108038. static Format(value: number, decimals?: number): string;
  108039. /**
  108040. * Tries to copy an object by duplicating every property
  108041. * @param source defines the source object
  108042. * @param destination defines the target object
  108043. * @param doNotCopyList defines a list of properties to avoid
  108044. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  108045. */
  108046. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  108047. /**
  108048. * Gets a boolean indicating if the given object has no own property
  108049. * @param obj defines the object to test
  108050. * @returns true if object has no own property
  108051. */
  108052. static IsEmpty(obj: any): boolean;
  108053. /**
  108054. * Function used to register events at window level
  108055. * @param windowElement defines the Window object to use
  108056. * @param events defines the events to register
  108057. */
  108058. static RegisterTopRootEvents(windowElement: Window, events: {
  108059. name: string;
  108060. handler: Nullable<(e: FocusEvent) => any>;
  108061. }[]): void;
  108062. /**
  108063. * Function used to unregister events from window level
  108064. * @param windowElement defines the Window object to use
  108065. * @param events defines the events to unregister
  108066. */
  108067. static UnregisterTopRootEvents(windowElement: Window, events: {
  108068. name: string;
  108069. handler: Nullable<(e: FocusEvent) => any>;
  108070. }[]): void;
  108071. /**
  108072. * @ignore
  108073. */
  108074. static _ScreenshotCanvas: HTMLCanvasElement;
  108075. /**
  108076. * Dumps the current bound framebuffer
  108077. * @param width defines the rendering width
  108078. * @param height defines the rendering height
  108079. * @param engine defines the hosting engine
  108080. * @param successCallback defines the callback triggered once the data are available
  108081. * @param mimeType defines the mime type of the result
  108082. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  108083. */
  108084. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108085. /**
  108086. * Converts the canvas data to blob.
  108087. * This acts as a polyfill for browsers not supporting the to blob function.
  108088. * @param canvas Defines the canvas to extract the data from
  108089. * @param successCallback Defines the callback triggered once the data are available
  108090. * @param mimeType Defines the mime type of the result
  108091. */
  108092. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  108093. /**
  108094. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  108095. * @param successCallback defines the callback triggered once the data are available
  108096. * @param mimeType defines the mime type of the result
  108097. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  108098. */
  108099. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108100. /**
  108101. * Downloads a blob in the browser
  108102. * @param blob defines the blob to download
  108103. * @param fileName defines the name of the downloaded file
  108104. */
  108105. static Download(blob: Blob, fileName: string): void;
  108106. /**
  108107. * Captures a screenshot of the current rendering
  108108. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108109. * @param engine defines the rendering engine
  108110. * @param camera defines the source camera
  108111. * @param size This parameter can be set to a single number or to an object with the
  108112. * following (optional) properties: precision, width, height. If a single number is passed,
  108113. * it will be used for both width and height. If an object is passed, the screenshot size
  108114. * will be derived from the parameters. The precision property is a multiplier allowing
  108115. * rendering at a higher or lower resolution
  108116. * @param successCallback defines the callback receives a single parameter which contains the
  108117. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108118. * src parameter of an <img> to display it
  108119. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108120. * Check your browser for supported MIME types
  108121. */
  108122. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  108123. /**
  108124. * Captures a screenshot of the current rendering
  108125. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108126. * @param engine defines the rendering engine
  108127. * @param camera defines the source camera
  108128. * @param size This parameter can be set to a single number or to an object with the
  108129. * following (optional) properties: precision, width, height. If a single number is passed,
  108130. * it will be used for both width and height. If an object is passed, the screenshot size
  108131. * will be derived from the parameters. The precision property is a multiplier allowing
  108132. * rendering at a higher or lower resolution
  108133. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108134. * Check your browser for supported MIME types
  108135. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108136. * to the src parameter of an <img> to display it
  108137. */
  108138. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108139. /**
  108140. * Generates an image screenshot from the specified camera.
  108141. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108142. * @param engine The engine to use for rendering
  108143. * @param camera The camera to use for rendering
  108144. * @param size This parameter can be set to a single number or to an object with the
  108145. * following (optional) properties: precision, width, height. If a single number is passed,
  108146. * it will be used for both width and height. If an object is passed, the screenshot size
  108147. * will be derived from the parameters. The precision property is a multiplier allowing
  108148. * rendering at a higher or lower resolution
  108149. * @param successCallback The callback receives a single parameter which contains the
  108150. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108151. * src parameter of an <img> to display it
  108152. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108153. * Check your browser for supported MIME types
  108154. * @param samples Texture samples (default: 1)
  108155. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108156. * @param fileName A name for for the downloaded file.
  108157. */
  108158. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108159. /**
  108160. * Generates an image screenshot from the specified camera.
  108161. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108162. * @param engine The engine to use for rendering
  108163. * @param camera The camera to use for rendering
  108164. * @param size This parameter can be set to a single number or to an object with the
  108165. * following (optional) properties: precision, width, height. If a single number is passed,
  108166. * it will be used for both width and height. If an object is passed, the screenshot size
  108167. * will be derived from the parameters. The precision property is a multiplier allowing
  108168. * rendering at a higher or lower resolution
  108169. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108170. * Check your browser for supported MIME types
  108171. * @param samples Texture samples (default: 1)
  108172. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108173. * @param fileName A name for for the downloaded file.
  108174. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108175. * to the src parameter of an <img> to display it
  108176. */
  108177. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108178. /**
  108179. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108180. * Be aware Math.random() could cause collisions, but:
  108181. * "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"
  108182. * @returns a pseudo random id
  108183. */
  108184. static RandomId(): string;
  108185. /**
  108186. * Test if the given uri is a base64 string
  108187. * @param uri The uri to test
  108188. * @return True if the uri is a base64 string or false otherwise
  108189. */
  108190. static IsBase64(uri: string): boolean;
  108191. /**
  108192. * Decode the given base64 uri.
  108193. * @param uri The uri to decode
  108194. * @return The decoded base64 data.
  108195. */
  108196. static DecodeBase64(uri: string): ArrayBuffer;
  108197. /**
  108198. * Gets the absolute url.
  108199. * @param url the input url
  108200. * @return the absolute url
  108201. */
  108202. static GetAbsoluteUrl(url: string): string;
  108203. /**
  108204. * No log
  108205. */
  108206. static readonly NoneLogLevel: number;
  108207. /**
  108208. * Only message logs
  108209. */
  108210. static readonly MessageLogLevel: number;
  108211. /**
  108212. * Only warning logs
  108213. */
  108214. static readonly WarningLogLevel: number;
  108215. /**
  108216. * Only error logs
  108217. */
  108218. static readonly ErrorLogLevel: number;
  108219. /**
  108220. * All logs
  108221. */
  108222. static readonly AllLogLevel: number;
  108223. /**
  108224. * Gets a value indicating the number of loading errors
  108225. * @ignorenaming
  108226. */
  108227. static get errorsCount(): number;
  108228. /**
  108229. * Callback called when a new log is added
  108230. */
  108231. static OnNewCacheEntry: (entry: string) => void;
  108232. /**
  108233. * Log a message to the console
  108234. * @param message defines the message to log
  108235. */
  108236. static Log(message: string): void;
  108237. /**
  108238. * Write a warning message to the console
  108239. * @param message defines the message to log
  108240. */
  108241. static Warn(message: string): void;
  108242. /**
  108243. * Write an error message to the console
  108244. * @param message defines the message to log
  108245. */
  108246. static Error(message: string): void;
  108247. /**
  108248. * Gets current log cache (list of logs)
  108249. */
  108250. static get LogCache(): string;
  108251. /**
  108252. * Clears the log cache
  108253. */
  108254. static ClearLogCache(): void;
  108255. /**
  108256. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  108257. */
  108258. static set LogLevels(level: number);
  108259. /**
  108260. * Checks if the window object exists
  108261. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  108262. */
  108263. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  108264. /**
  108265. * No performance log
  108266. */
  108267. static readonly PerformanceNoneLogLevel: number;
  108268. /**
  108269. * Use user marks to log performance
  108270. */
  108271. static readonly PerformanceUserMarkLogLevel: number;
  108272. /**
  108273. * Log performance to the console
  108274. */
  108275. static readonly PerformanceConsoleLogLevel: number;
  108276. private static _performance;
  108277. /**
  108278. * Sets the current performance log level
  108279. */
  108280. static set PerformanceLogLevel(level: number);
  108281. private static _StartPerformanceCounterDisabled;
  108282. private static _EndPerformanceCounterDisabled;
  108283. private static _StartUserMark;
  108284. private static _EndUserMark;
  108285. private static _StartPerformanceConsole;
  108286. private static _EndPerformanceConsole;
  108287. /**
  108288. * Starts a performance counter
  108289. */
  108290. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  108291. /**
  108292. * Ends a specific performance coutner
  108293. */
  108294. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  108295. /**
  108296. * Gets either window.performance.now() if supported or Date.now() else
  108297. */
  108298. static get Now(): number;
  108299. /**
  108300. * This method will return the name of the class used to create the instance of the given object.
  108301. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  108302. * @param object the object to get the class name from
  108303. * @param isType defines if the object is actually a type
  108304. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  108305. */
  108306. static GetClassName(object: any, isType?: boolean): string;
  108307. /**
  108308. * Gets the first element of an array satisfying a given predicate
  108309. * @param array defines the array to browse
  108310. * @param predicate defines the predicate to use
  108311. * @returns null if not found or the element
  108312. */
  108313. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  108314. /**
  108315. * This method will return the name of the full name of the class, including its owning module (if any).
  108316. * 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).
  108317. * @param object the object to get the class name from
  108318. * @param isType defines if the object is actually a type
  108319. * @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.
  108320. * @ignorenaming
  108321. */
  108322. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  108323. /**
  108324. * Returns a promise that resolves after the given amount of time.
  108325. * @param delay Number of milliseconds to delay
  108326. * @returns Promise that resolves after the given amount of time
  108327. */
  108328. static DelayAsync(delay: number): Promise<void>;
  108329. /**
  108330. * Utility function to detect if the current user agent is Safari
  108331. * @returns whether or not the current user agent is safari
  108332. */
  108333. static IsSafari(): boolean;
  108334. }
  108335. /**
  108336. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  108337. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  108338. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  108339. * @param name The name of the class, case should be preserved
  108340. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  108341. */
  108342. export function className(name: string, module?: string): (target: Object) => void;
  108343. /**
  108344. * An implementation of a loop for asynchronous functions.
  108345. */
  108346. export class AsyncLoop {
  108347. /**
  108348. * Defines the number of iterations for the loop
  108349. */
  108350. iterations: number;
  108351. /**
  108352. * Defines the current index of the loop.
  108353. */
  108354. index: number;
  108355. private _done;
  108356. private _fn;
  108357. private _successCallback;
  108358. /**
  108359. * Constructor.
  108360. * @param iterations the number of iterations.
  108361. * @param func the function to run each iteration
  108362. * @param successCallback the callback that will be called upon succesful execution
  108363. * @param offset starting offset.
  108364. */
  108365. constructor(
  108366. /**
  108367. * Defines the number of iterations for the loop
  108368. */
  108369. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  108370. /**
  108371. * Execute the next iteration. Must be called after the last iteration was finished.
  108372. */
  108373. executeNext(): void;
  108374. /**
  108375. * Break the loop and run the success callback.
  108376. */
  108377. breakLoop(): void;
  108378. /**
  108379. * Create and run an async loop.
  108380. * @param iterations the number of iterations.
  108381. * @param fn the function to run each iteration
  108382. * @param successCallback the callback that will be called upon succesful execution
  108383. * @param offset starting offset.
  108384. * @returns the created async loop object
  108385. */
  108386. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  108387. /**
  108388. * A for-loop that will run a given number of iterations synchronous and the rest async.
  108389. * @param iterations total number of iterations
  108390. * @param syncedIterations number of synchronous iterations in each async iteration.
  108391. * @param fn the function to call each iteration.
  108392. * @param callback a success call back that will be called when iterating stops.
  108393. * @param breakFunction a break condition (optional)
  108394. * @param timeout timeout settings for the setTimeout function. default - 0.
  108395. * @returns the created async loop object
  108396. */
  108397. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  108398. }
  108399. }
  108400. declare module BABYLON {
  108401. /**
  108402. * This class implement a typical dictionary using a string as key and the generic type T as value.
  108403. * The underlying implementation relies on an associative array to ensure the best performances.
  108404. * The value can be anything including 'null' but except 'undefined'
  108405. */
  108406. export class StringDictionary<T> {
  108407. /**
  108408. * This will clear this dictionary and copy the content from the 'source' one.
  108409. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  108410. * @param source the dictionary to take the content from and copy to this dictionary
  108411. */
  108412. copyFrom(source: StringDictionary<T>): void;
  108413. /**
  108414. * Get a value based from its key
  108415. * @param key the given key to get the matching value from
  108416. * @return the value if found, otherwise undefined is returned
  108417. */
  108418. get(key: string): T | undefined;
  108419. /**
  108420. * Get a value from its key or add it if it doesn't exist.
  108421. * This method will ensure you that a given key/data will be present in the dictionary.
  108422. * @param key the given key to get the matching value from
  108423. * @param factory the factory that will create the value if the key is not present in the dictionary.
  108424. * The factory will only be invoked if there's no data for the given key.
  108425. * @return the value corresponding to the key.
  108426. */
  108427. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  108428. /**
  108429. * Get a value from its key if present in the dictionary otherwise add it
  108430. * @param key the key to get the value from
  108431. * @param val if there's no such key/value pair in the dictionary add it with this value
  108432. * @return the value corresponding to the key
  108433. */
  108434. getOrAdd(key: string, val: T): T;
  108435. /**
  108436. * Check if there's a given key in the dictionary
  108437. * @param key the key to check for
  108438. * @return true if the key is present, false otherwise
  108439. */
  108440. contains(key: string): boolean;
  108441. /**
  108442. * Add a new key and its corresponding value
  108443. * @param key the key to add
  108444. * @param value the value corresponding to the key
  108445. * @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
  108446. */
  108447. add(key: string, value: T): boolean;
  108448. /**
  108449. * Update a specific value associated to a key
  108450. * @param key defines the key to use
  108451. * @param value defines the value to store
  108452. * @returns true if the value was updated (or false if the key was not found)
  108453. */
  108454. set(key: string, value: T): boolean;
  108455. /**
  108456. * Get the element of the given key and remove it from the dictionary
  108457. * @param key defines the key to search
  108458. * @returns the value associated with the key or null if not found
  108459. */
  108460. getAndRemove(key: string): Nullable<T>;
  108461. /**
  108462. * Remove a key/value from the dictionary.
  108463. * @param key the key to remove
  108464. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  108465. */
  108466. remove(key: string): boolean;
  108467. /**
  108468. * Clear the whole content of the dictionary
  108469. */
  108470. clear(): void;
  108471. /**
  108472. * Gets the current count
  108473. */
  108474. get count(): number;
  108475. /**
  108476. * Execute a callback on each key/val of the dictionary.
  108477. * Note that you can remove any element in this dictionary in the callback implementation
  108478. * @param callback the callback to execute on a given key/value pair
  108479. */
  108480. forEach(callback: (key: string, val: T) => void): void;
  108481. /**
  108482. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  108483. * If the callback returns null or undefined the method will iterate to the next key/value pair
  108484. * Note that you can remove any element in this dictionary in the callback implementation
  108485. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  108486. * @returns the first item
  108487. */
  108488. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  108489. private _count;
  108490. private _data;
  108491. }
  108492. }
  108493. declare module BABYLON {
  108494. /** @hidden */
  108495. export interface ICollisionCoordinator {
  108496. createCollider(): Collider;
  108497. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108498. init(scene: Scene): void;
  108499. }
  108500. /** @hidden */
  108501. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  108502. private _scene;
  108503. private _scaledPosition;
  108504. private _scaledVelocity;
  108505. private _finalPosition;
  108506. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108507. createCollider(): Collider;
  108508. init(scene: Scene): void;
  108509. private _collideWithWorld;
  108510. }
  108511. }
  108512. declare module BABYLON {
  108513. /**
  108514. * Class used to manage all inputs for the scene.
  108515. */
  108516. export class InputManager {
  108517. /** The distance in pixel that you have to move to prevent some events */
  108518. static DragMovementThreshold: number;
  108519. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108520. static LongPressDelay: number;
  108521. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108522. static DoubleClickDelay: number;
  108523. /** If you need to check double click without raising a single click at first click, enable this flag */
  108524. static ExclusiveDoubleClickMode: boolean;
  108525. private _wheelEventName;
  108526. private _onPointerMove;
  108527. private _onPointerDown;
  108528. private _onPointerUp;
  108529. private _initClickEvent;
  108530. private _initActionManager;
  108531. private _delayedSimpleClick;
  108532. private _delayedSimpleClickTimeout;
  108533. private _previousDelayedSimpleClickTimeout;
  108534. private _meshPickProceed;
  108535. private _previousButtonPressed;
  108536. private _currentPickResult;
  108537. private _previousPickResult;
  108538. private _totalPointersPressed;
  108539. private _doubleClickOccured;
  108540. private _pointerOverMesh;
  108541. private _pickedDownMesh;
  108542. private _pickedUpMesh;
  108543. private _pointerX;
  108544. private _pointerY;
  108545. private _unTranslatedPointerX;
  108546. private _unTranslatedPointerY;
  108547. private _startingPointerPosition;
  108548. private _previousStartingPointerPosition;
  108549. private _startingPointerTime;
  108550. private _previousStartingPointerTime;
  108551. private _pointerCaptures;
  108552. private _onKeyDown;
  108553. private _onKeyUp;
  108554. private _onCanvasFocusObserver;
  108555. private _onCanvasBlurObserver;
  108556. private _scene;
  108557. /**
  108558. * Creates a new InputManager
  108559. * @param scene defines the hosting scene
  108560. */
  108561. constructor(scene: Scene);
  108562. /**
  108563. * Gets the mesh that is currently under the pointer
  108564. */
  108565. get meshUnderPointer(): Nullable<AbstractMesh>;
  108566. /**
  108567. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108568. */
  108569. get unTranslatedPointer(): Vector2;
  108570. /**
  108571. * Gets or sets the current on-screen X position of the pointer
  108572. */
  108573. get pointerX(): number;
  108574. set pointerX(value: number);
  108575. /**
  108576. * Gets or sets the current on-screen Y position of the pointer
  108577. */
  108578. get pointerY(): number;
  108579. set pointerY(value: number);
  108580. private _updatePointerPosition;
  108581. private _processPointerMove;
  108582. private _setRayOnPointerInfo;
  108583. private _checkPrePointerObservable;
  108584. /**
  108585. * Use this method to simulate a pointer move on a mesh
  108586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108589. */
  108590. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108591. /**
  108592. * Use this method to simulate a pointer down on a mesh
  108593. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108594. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108595. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108596. */
  108597. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108598. private _processPointerDown;
  108599. /** @hidden */
  108600. _isPointerSwiping(): boolean;
  108601. /**
  108602. * Use this method to simulate a pointer up on a mesh
  108603. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108604. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108605. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108606. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108607. */
  108608. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108609. private _processPointerUp;
  108610. /**
  108611. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108612. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108613. * @returns true if the pointer was captured
  108614. */
  108615. isPointerCaptured(pointerId?: number): boolean;
  108616. /**
  108617. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108618. * @param attachUp defines if you want to attach events to pointerup
  108619. * @param attachDown defines if you want to attach events to pointerdown
  108620. * @param attachMove defines if you want to attach events to pointermove
  108621. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108622. */
  108623. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108624. /**
  108625. * Detaches all event handlers
  108626. */
  108627. detachControl(): void;
  108628. /**
  108629. * Force the value of meshUnderPointer
  108630. * @param mesh defines the mesh to use
  108631. */
  108632. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108633. /**
  108634. * Gets the mesh under the pointer
  108635. * @returns a Mesh or null if no mesh is under the pointer
  108636. */
  108637. getPointerOverMesh(): Nullable<AbstractMesh>;
  108638. }
  108639. }
  108640. declare module BABYLON {
  108641. /**
  108642. * Helper class used to generate session unique ID
  108643. */
  108644. export class UniqueIdGenerator {
  108645. private static _UniqueIdCounter;
  108646. /**
  108647. * Gets an unique (relatively to the current scene) Id
  108648. */
  108649. static get UniqueId(): number;
  108650. }
  108651. }
  108652. declare module BABYLON {
  108653. /**
  108654. * This class defines the direct association between an animation and a target
  108655. */
  108656. export class TargetedAnimation {
  108657. /**
  108658. * Animation to perform
  108659. */
  108660. animation: Animation;
  108661. /**
  108662. * Target to animate
  108663. */
  108664. target: any;
  108665. /**
  108666. * Serialize the object
  108667. * @returns the JSON object representing the current entity
  108668. */
  108669. serialize(): any;
  108670. }
  108671. /**
  108672. * Use this class to create coordinated animations on multiple targets
  108673. */
  108674. export class AnimationGroup implements IDisposable {
  108675. /** The name of the animation group */
  108676. name: string;
  108677. private _scene;
  108678. private _targetedAnimations;
  108679. private _animatables;
  108680. private _from;
  108681. private _to;
  108682. private _isStarted;
  108683. private _isPaused;
  108684. private _speedRatio;
  108685. private _loopAnimation;
  108686. /**
  108687. * Gets or sets the unique id of the node
  108688. */
  108689. uniqueId: number;
  108690. /**
  108691. * This observable will notify when one animation have ended
  108692. */
  108693. onAnimationEndObservable: Observable<TargetedAnimation>;
  108694. /**
  108695. * Observer raised when one animation loops
  108696. */
  108697. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108698. /**
  108699. * Observer raised when all animations have looped
  108700. */
  108701. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108702. /**
  108703. * This observable will notify when all animations have ended.
  108704. */
  108705. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108706. /**
  108707. * This observable will notify when all animations have paused.
  108708. */
  108709. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108710. /**
  108711. * This observable will notify when all animations are playing.
  108712. */
  108713. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108714. /**
  108715. * Gets the first frame
  108716. */
  108717. get from(): number;
  108718. /**
  108719. * Gets the last frame
  108720. */
  108721. get to(): number;
  108722. /**
  108723. * Define if the animations are started
  108724. */
  108725. get isStarted(): boolean;
  108726. /**
  108727. * Gets a value indicating that the current group is playing
  108728. */
  108729. get isPlaying(): boolean;
  108730. /**
  108731. * Gets or sets the speed ratio to use for all animations
  108732. */
  108733. get speedRatio(): number;
  108734. /**
  108735. * Gets or sets the speed ratio to use for all animations
  108736. */
  108737. set speedRatio(value: number);
  108738. /**
  108739. * Gets or sets if all animations should loop or not
  108740. */
  108741. get loopAnimation(): boolean;
  108742. set loopAnimation(value: boolean);
  108743. /**
  108744. * Gets the targeted animations for this animation group
  108745. */
  108746. get targetedAnimations(): Array<TargetedAnimation>;
  108747. /**
  108748. * returning the list of animatables controlled by this animation group.
  108749. */
  108750. get animatables(): Array<Animatable>;
  108751. /**
  108752. * Instantiates a new Animation Group.
  108753. * This helps managing several animations at once.
  108754. * @see http://doc.babylonjs.com/how_to/group
  108755. * @param name Defines the name of the group
  108756. * @param scene Defines the scene the group belongs to
  108757. */
  108758. constructor(
  108759. /** The name of the animation group */
  108760. name: string, scene?: Nullable<Scene>);
  108761. /**
  108762. * Add an animation (with its target) in the group
  108763. * @param animation defines the animation we want to add
  108764. * @param target defines the target of the animation
  108765. * @returns the TargetedAnimation object
  108766. */
  108767. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108768. /**
  108769. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108770. * It can add constant keys at begin or end
  108771. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108772. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108773. * @returns the animation group
  108774. */
  108775. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108776. private _animationLoopCount;
  108777. private _animationLoopFlags;
  108778. private _processLoop;
  108779. /**
  108780. * Start all animations on given targets
  108781. * @param loop defines if animations must loop
  108782. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108783. * @param from defines the from key (optional)
  108784. * @param to defines the to key (optional)
  108785. * @returns the current animation group
  108786. */
  108787. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108788. /**
  108789. * Pause all animations
  108790. * @returns the animation group
  108791. */
  108792. pause(): AnimationGroup;
  108793. /**
  108794. * Play all animations to initial state
  108795. * This function will start() the animations if they were not started or will restart() them if they were paused
  108796. * @param loop defines if animations must loop
  108797. * @returns the animation group
  108798. */
  108799. play(loop?: boolean): AnimationGroup;
  108800. /**
  108801. * Reset all animations to initial state
  108802. * @returns the animation group
  108803. */
  108804. reset(): AnimationGroup;
  108805. /**
  108806. * Restart animations from key 0
  108807. * @returns the animation group
  108808. */
  108809. restart(): AnimationGroup;
  108810. /**
  108811. * Stop all animations
  108812. * @returns the animation group
  108813. */
  108814. stop(): AnimationGroup;
  108815. /**
  108816. * Set animation weight for all animatables
  108817. * @param weight defines the weight to use
  108818. * @return the animationGroup
  108819. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108820. */
  108821. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108822. /**
  108823. * Synchronize and normalize all animatables with a source animatable
  108824. * @param root defines the root animatable to synchronize with
  108825. * @return the animationGroup
  108826. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108827. */
  108828. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108829. /**
  108830. * Goes to a specific frame in this animation group
  108831. * @param frame the frame number to go to
  108832. * @return the animationGroup
  108833. */
  108834. goToFrame(frame: number): AnimationGroup;
  108835. /**
  108836. * Dispose all associated resources
  108837. */
  108838. dispose(): void;
  108839. private _checkAnimationGroupEnded;
  108840. /**
  108841. * Clone the current animation group and returns a copy
  108842. * @param newName defines the name of the new group
  108843. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108844. * @returns the new aniamtion group
  108845. */
  108846. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108847. /**
  108848. * Serializes the animationGroup to an object
  108849. * @returns Serialized object
  108850. */
  108851. serialize(): any;
  108852. /**
  108853. * Returns a new AnimationGroup object parsed from the source provided.
  108854. * @param parsedAnimationGroup defines the source
  108855. * @param scene defines the scene that will receive the animationGroup
  108856. * @returns a new AnimationGroup
  108857. */
  108858. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108859. /**
  108860. * Returns the string "AnimationGroup"
  108861. * @returns "AnimationGroup"
  108862. */
  108863. getClassName(): string;
  108864. /**
  108865. * Creates a detailled string about the object
  108866. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108867. * @returns a string representing the object
  108868. */
  108869. toString(fullDetails?: boolean): string;
  108870. }
  108871. }
  108872. declare module BABYLON {
  108873. /**
  108874. * Define an interface for all classes that will hold resources
  108875. */
  108876. export interface IDisposable {
  108877. /**
  108878. * Releases all held resources
  108879. */
  108880. dispose(): void;
  108881. }
  108882. /** Interface defining initialization parameters for Scene class */
  108883. export interface SceneOptions {
  108884. /**
  108885. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108886. * It will improve performance when the number of geometries becomes important.
  108887. */
  108888. useGeometryUniqueIdsMap?: boolean;
  108889. /**
  108890. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108891. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108892. */
  108893. useMaterialMeshMap?: boolean;
  108894. /**
  108895. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108896. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108897. */
  108898. useClonedMeshMap?: boolean;
  108899. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108900. virtual?: boolean;
  108901. }
  108902. /**
  108903. * Represents a scene to be rendered by the engine.
  108904. * @see http://doc.babylonjs.com/features/scene
  108905. */
  108906. export class Scene extends AbstractScene implements IAnimatable {
  108907. /** The fog is deactivated */
  108908. static readonly FOGMODE_NONE: number;
  108909. /** The fog density is following an exponential function */
  108910. static readonly FOGMODE_EXP: number;
  108911. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108912. static readonly FOGMODE_EXP2: number;
  108913. /** The fog density is following a linear function. */
  108914. static readonly FOGMODE_LINEAR: number;
  108915. /**
  108916. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108918. */
  108919. static MinDeltaTime: number;
  108920. /**
  108921. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108923. */
  108924. static MaxDeltaTime: number;
  108925. /**
  108926. * Factory used to create the default material.
  108927. * @param name The name of the material to create
  108928. * @param scene The scene to create the material for
  108929. * @returns The default material
  108930. */
  108931. static DefaultMaterialFactory(scene: Scene): Material;
  108932. /**
  108933. * Factory used to create the a collision coordinator.
  108934. * @returns The collision coordinator
  108935. */
  108936. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108937. /** @hidden */
  108938. _inputManager: InputManager;
  108939. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108940. cameraToUseForPointers: Nullable<Camera>;
  108941. /** @hidden */
  108942. readonly _isScene: boolean;
  108943. /** @hidden */
  108944. _blockEntityCollection: boolean;
  108945. /**
  108946. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108947. */
  108948. autoClear: boolean;
  108949. /**
  108950. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108951. */
  108952. autoClearDepthAndStencil: boolean;
  108953. /**
  108954. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108955. */
  108956. clearColor: Color4;
  108957. /**
  108958. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108959. */
  108960. ambientColor: Color3;
  108961. /**
  108962. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108963. * It should only be one of the following (if not the default embedded one):
  108964. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108965. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108966. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108967. * The material properties need to be setup according to the type of texture in use.
  108968. */
  108969. environmentBRDFTexture: BaseTexture;
  108970. /** @hidden */
  108971. protected _environmentTexture: Nullable<BaseTexture>;
  108972. /**
  108973. * Texture used in all pbr material as the reflection texture.
  108974. * As in the majority of the scene they are the same (exception for multi room and so on),
  108975. * this is easier to reference from here than from all the materials.
  108976. */
  108977. get environmentTexture(): Nullable<BaseTexture>;
  108978. /**
  108979. * Texture used in all pbr material as the reflection texture.
  108980. * As in the majority of the scene they are the same (exception for multi room and so on),
  108981. * this is easier to set here than in all the materials.
  108982. */
  108983. set environmentTexture(value: Nullable<BaseTexture>);
  108984. /** @hidden */
  108985. protected _environmentIntensity: number;
  108986. /**
  108987. * Intensity of the environment in all pbr material.
  108988. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108989. * As in the majority of the scene they are the same (exception for multi room and so on),
  108990. * this is easier to reference from here than from all the materials.
  108991. */
  108992. get environmentIntensity(): number;
  108993. /**
  108994. * Intensity of the environment in all pbr material.
  108995. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108996. * As in the majority of the scene they are the same (exception for multi room and so on),
  108997. * this is easier to set here than in all the materials.
  108998. */
  108999. set environmentIntensity(value: number);
  109000. /** @hidden */
  109001. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109002. /**
  109003. * Default image processing configuration used either in the rendering
  109004. * Forward main pass or through the imageProcessingPostProcess if present.
  109005. * As in the majority of the scene they are the same (exception for multi camera),
  109006. * this is easier to reference from here than from all the materials and post process.
  109007. *
  109008. * No setter as we it is a shared configuration, you can set the values instead.
  109009. */
  109010. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109011. private _forceWireframe;
  109012. /**
  109013. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  109014. */
  109015. set forceWireframe(value: boolean);
  109016. get forceWireframe(): boolean;
  109017. private _skipFrustumClipping;
  109018. /**
  109019. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  109020. */
  109021. set skipFrustumClipping(value: boolean);
  109022. get skipFrustumClipping(): boolean;
  109023. private _forcePointsCloud;
  109024. /**
  109025. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  109026. */
  109027. set forcePointsCloud(value: boolean);
  109028. get forcePointsCloud(): boolean;
  109029. /**
  109030. * Gets or sets the active clipplane 1
  109031. */
  109032. clipPlane: Nullable<Plane>;
  109033. /**
  109034. * Gets or sets the active clipplane 2
  109035. */
  109036. clipPlane2: Nullable<Plane>;
  109037. /**
  109038. * Gets or sets the active clipplane 3
  109039. */
  109040. clipPlane3: Nullable<Plane>;
  109041. /**
  109042. * Gets or sets the active clipplane 4
  109043. */
  109044. clipPlane4: Nullable<Plane>;
  109045. /**
  109046. * Gets or sets the active clipplane 5
  109047. */
  109048. clipPlane5: Nullable<Plane>;
  109049. /**
  109050. * Gets or sets the active clipplane 6
  109051. */
  109052. clipPlane6: Nullable<Plane>;
  109053. /**
  109054. * Gets or sets a boolean indicating if animations are enabled
  109055. */
  109056. animationsEnabled: boolean;
  109057. private _animationPropertiesOverride;
  109058. /**
  109059. * Gets or sets the animation properties override
  109060. */
  109061. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109062. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109063. /**
  109064. * Gets or sets a boolean indicating if a constant deltatime has to be used
  109065. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  109066. */
  109067. useConstantAnimationDeltaTime: boolean;
  109068. /**
  109069. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  109070. * Please note that it requires to run a ray cast through the scene on every frame
  109071. */
  109072. constantlyUpdateMeshUnderPointer: boolean;
  109073. /**
  109074. * Defines the HTML cursor to use when hovering over interactive elements
  109075. */
  109076. hoverCursor: string;
  109077. /**
  109078. * Defines the HTML default cursor to use (empty by default)
  109079. */
  109080. defaultCursor: string;
  109081. /**
  109082. * Defines whether cursors are handled by the scene.
  109083. */
  109084. doNotHandleCursors: boolean;
  109085. /**
  109086. * This is used to call preventDefault() on pointer down
  109087. * in order to block unwanted artifacts like system double clicks
  109088. */
  109089. preventDefaultOnPointerDown: boolean;
  109090. /**
  109091. * This is used to call preventDefault() on pointer up
  109092. * in order to block unwanted artifacts like system double clicks
  109093. */
  109094. preventDefaultOnPointerUp: boolean;
  109095. /**
  109096. * Gets or sets user defined metadata
  109097. */
  109098. metadata: any;
  109099. /**
  109100. * For internal use only. Please do not use.
  109101. */
  109102. reservedDataStore: any;
  109103. /**
  109104. * Gets the name of the plugin used to load this scene (null by default)
  109105. */
  109106. loadingPluginName: string;
  109107. /**
  109108. * Use this array to add regular expressions used to disable offline support for specific urls
  109109. */
  109110. disableOfflineSupportExceptionRules: RegExp[];
  109111. /**
  109112. * An event triggered when the scene is disposed.
  109113. */
  109114. onDisposeObservable: Observable<Scene>;
  109115. private _onDisposeObserver;
  109116. /** Sets a function to be executed when this scene is disposed. */
  109117. set onDispose(callback: () => void);
  109118. /**
  109119. * An event triggered before rendering the scene (right after animations and physics)
  109120. */
  109121. onBeforeRenderObservable: Observable<Scene>;
  109122. private _onBeforeRenderObserver;
  109123. /** Sets a function to be executed before rendering this scene */
  109124. set beforeRender(callback: Nullable<() => void>);
  109125. /**
  109126. * An event triggered after rendering the scene
  109127. */
  109128. onAfterRenderObservable: Observable<Scene>;
  109129. /**
  109130. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109131. */
  109132. onAfterRenderCameraObservable: Observable<Camera>;
  109133. private _onAfterRenderObserver;
  109134. /** Sets a function to be executed after rendering this scene */
  109135. set afterRender(callback: Nullable<() => void>);
  109136. /**
  109137. * An event triggered before animating the scene
  109138. */
  109139. onBeforeAnimationsObservable: Observable<Scene>;
  109140. /**
  109141. * An event triggered after animations processing
  109142. */
  109143. onAfterAnimationsObservable: Observable<Scene>;
  109144. /**
  109145. * An event triggered before draw calls are ready to be sent
  109146. */
  109147. onBeforeDrawPhaseObservable: Observable<Scene>;
  109148. /**
  109149. * An event triggered after draw calls have been sent
  109150. */
  109151. onAfterDrawPhaseObservable: Observable<Scene>;
  109152. /**
  109153. * An event triggered when the scene is ready
  109154. */
  109155. onReadyObservable: Observable<Scene>;
  109156. /**
  109157. * An event triggered before rendering a camera
  109158. */
  109159. onBeforeCameraRenderObservable: Observable<Camera>;
  109160. private _onBeforeCameraRenderObserver;
  109161. /** Sets a function to be executed before rendering a camera*/
  109162. set beforeCameraRender(callback: () => void);
  109163. /**
  109164. * An event triggered after rendering a camera
  109165. */
  109166. onAfterCameraRenderObservable: Observable<Camera>;
  109167. private _onAfterCameraRenderObserver;
  109168. /** Sets a function to be executed after rendering a camera*/
  109169. set afterCameraRender(callback: () => void);
  109170. /**
  109171. * An event triggered when active meshes evaluation is about to start
  109172. */
  109173. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  109174. /**
  109175. * An event triggered when active meshes evaluation is done
  109176. */
  109177. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  109178. /**
  109179. * An event triggered when particles rendering is about to start
  109180. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109181. */
  109182. onBeforeParticlesRenderingObservable: Observable<Scene>;
  109183. /**
  109184. * An event triggered when particles rendering is done
  109185. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109186. */
  109187. onAfterParticlesRenderingObservable: Observable<Scene>;
  109188. /**
  109189. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  109190. */
  109191. onDataLoadedObservable: Observable<Scene>;
  109192. /**
  109193. * An event triggered when a camera is created
  109194. */
  109195. onNewCameraAddedObservable: Observable<Camera>;
  109196. /**
  109197. * An event triggered when a camera is removed
  109198. */
  109199. onCameraRemovedObservable: Observable<Camera>;
  109200. /**
  109201. * An event triggered when a light is created
  109202. */
  109203. onNewLightAddedObservable: Observable<Light>;
  109204. /**
  109205. * An event triggered when a light is removed
  109206. */
  109207. onLightRemovedObservable: Observable<Light>;
  109208. /**
  109209. * An event triggered when a geometry is created
  109210. */
  109211. onNewGeometryAddedObservable: Observable<Geometry>;
  109212. /**
  109213. * An event triggered when a geometry is removed
  109214. */
  109215. onGeometryRemovedObservable: Observable<Geometry>;
  109216. /**
  109217. * An event triggered when a transform node is created
  109218. */
  109219. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  109220. /**
  109221. * An event triggered when a transform node is removed
  109222. */
  109223. onTransformNodeRemovedObservable: Observable<TransformNode>;
  109224. /**
  109225. * An event triggered when a mesh is created
  109226. */
  109227. onNewMeshAddedObservable: Observable<AbstractMesh>;
  109228. /**
  109229. * An event triggered when a mesh is removed
  109230. */
  109231. onMeshRemovedObservable: Observable<AbstractMesh>;
  109232. /**
  109233. * An event triggered when a skeleton is created
  109234. */
  109235. onNewSkeletonAddedObservable: Observable<Skeleton>;
  109236. /**
  109237. * An event triggered when a skeleton is removed
  109238. */
  109239. onSkeletonRemovedObservable: Observable<Skeleton>;
  109240. /**
  109241. * An event triggered when a material is created
  109242. */
  109243. onNewMaterialAddedObservable: Observable<Material>;
  109244. /**
  109245. * An event triggered when a material is removed
  109246. */
  109247. onMaterialRemovedObservable: Observable<Material>;
  109248. /**
  109249. * An event triggered when a texture is created
  109250. */
  109251. onNewTextureAddedObservable: Observable<BaseTexture>;
  109252. /**
  109253. * An event triggered when a texture is removed
  109254. */
  109255. onTextureRemovedObservable: Observable<BaseTexture>;
  109256. /**
  109257. * An event triggered when render targets are about to be rendered
  109258. * Can happen multiple times per frame.
  109259. */
  109260. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  109261. /**
  109262. * An event triggered when render targets were rendered.
  109263. * Can happen multiple times per frame.
  109264. */
  109265. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  109266. /**
  109267. * An event triggered before calculating deterministic simulation step
  109268. */
  109269. onBeforeStepObservable: Observable<Scene>;
  109270. /**
  109271. * An event triggered after calculating deterministic simulation step
  109272. */
  109273. onAfterStepObservable: Observable<Scene>;
  109274. /**
  109275. * An event triggered when the activeCamera property is updated
  109276. */
  109277. onActiveCameraChanged: Observable<Scene>;
  109278. /**
  109279. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  109280. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  109281. * 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)
  109282. */
  109283. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  109284. /**
  109285. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  109286. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  109287. * 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)
  109288. */
  109289. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  109290. /**
  109291. * This Observable will when a mesh has been imported into the scene.
  109292. */
  109293. onMeshImportedObservable: Observable<AbstractMesh>;
  109294. /**
  109295. * This Observable will when an animation file has been imported into the scene.
  109296. */
  109297. onAnimationFileImportedObservable: Observable<Scene>;
  109298. /**
  109299. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  109300. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  109301. */
  109302. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  109303. /** @hidden */
  109304. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  109305. /**
  109306. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  109307. */
  109308. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  109309. /**
  109310. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  109311. */
  109312. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  109313. /**
  109314. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  109315. */
  109316. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  109317. /** Callback called when a pointer move is detected */
  109318. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  109319. /** Callback called when a pointer down is detected */
  109320. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  109321. /** Callback called when a pointer up is detected */
  109322. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  109323. /** Callback called when a pointer pick is detected */
  109324. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  109325. /**
  109326. * 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).
  109327. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  109328. */
  109329. onPrePointerObservable: Observable<PointerInfoPre>;
  109330. /**
  109331. * Observable event triggered each time an input event is received from the rendering canvas
  109332. */
  109333. onPointerObservable: Observable<PointerInfo>;
  109334. /**
  109335. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  109336. */
  109337. get unTranslatedPointer(): Vector2;
  109338. /**
  109339. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  109340. */
  109341. static get DragMovementThreshold(): number;
  109342. static set DragMovementThreshold(value: number);
  109343. /**
  109344. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  109345. */
  109346. static get LongPressDelay(): number;
  109347. static set LongPressDelay(value: number);
  109348. /**
  109349. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  109350. */
  109351. static get DoubleClickDelay(): number;
  109352. static set DoubleClickDelay(value: number);
  109353. /** If you need to check double click without raising a single click at first click, enable this flag */
  109354. static get ExclusiveDoubleClickMode(): boolean;
  109355. static set ExclusiveDoubleClickMode(value: boolean);
  109356. /** @hidden */
  109357. _mirroredCameraPosition: Nullable<Vector3>;
  109358. /**
  109359. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  109360. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  109361. */
  109362. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  109363. /**
  109364. * Observable event triggered each time an keyboard event is received from the hosting window
  109365. */
  109366. onKeyboardObservable: Observable<KeyboardInfo>;
  109367. private _useRightHandedSystem;
  109368. /**
  109369. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  109370. */
  109371. set useRightHandedSystem(value: boolean);
  109372. get useRightHandedSystem(): boolean;
  109373. private _timeAccumulator;
  109374. private _currentStepId;
  109375. private _currentInternalStep;
  109376. /**
  109377. * Sets the step Id used by deterministic lock step
  109378. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109379. * @param newStepId defines the step Id
  109380. */
  109381. setStepId(newStepId: number): void;
  109382. /**
  109383. * Gets the step Id used by deterministic lock step
  109384. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109385. * @returns the step Id
  109386. */
  109387. getStepId(): number;
  109388. /**
  109389. * Gets the internal step used by deterministic lock step
  109390. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109391. * @returns the internal step
  109392. */
  109393. getInternalStep(): number;
  109394. private _fogEnabled;
  109395. /**
  109396. * Gets or sets a boolean indicating if fog is enabled on this scene
  109397. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109398. * (Default is true)
  109399. */
  109400. set fogEnabled(value: boolean);
  109401. get fogEnabled(): boolean;
  109402. private _fogMode;
  109403. /**
  109404. * Gets or sets the fog mode to use
  109405. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109406. * | mode | value |
  109407. * | --- | --- |
  109408. * | FOGMODE_NONE | 0 |
  109409. * | FOGMODE_EXP | 1 |
  109410. * | FOGMODE_EXP2 | 2 |
  109411. * | FOGMODE_LINEAR | 3 |
  109412. */
  109413. set fogMode(value: number);
  109414. get fogMode(): number;
  109415. /**
  109416. * Gets or sets the fog color to use
  109417. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109418. * (Default is Color3(0.2, 0.2, 0.3))
  109419. */
  109420. fogColor: Color3;
  109421. /**
  109422. * Gets or sets the fog density to use
  109423. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109424. * (Default is 0.1)
  109425. */
  109426. fogDensity: number;
  109427. /**
  109428. * Gets or sets the fog start distance to use
  109429. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109430. * (Default is 0)
  109431. */
  109432. fogStart: number;
  109433. /**
  109434. * Gets or sets the fog end distance to use
  109435. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109436. * (Default is 1000)
  109437. */
  109438. fogEnd: number;
  109439. private _shadowsEnabled;
  109440. /**
  109441. * Gets or sets a boolean indicating if shadows are enabled on this scene
  109442. */
  109443. set shadowsEnabled(value: boolean);
  109444. get shadowsEnabled(): boolean;
  109445. private _lightsEnabled;
  109446. /**
  109447. * Gets or sets a boolean indicating if lights are enabled on this scene
  109448. */
  109449. set lightsEnabled(value: boolean);
  109450. get lightsEnabled(): boolean;
  109451. /** All of the active cameras added to this scene. */
  109452. activeCameras: Camera[];
  109453. /** @hidden */
  109454. _activeCamera: Nullable<Camera>;
  109455. /** Gets or sets the current active camera */
  109456. get activeCamera(): Nullable<Camera>;
  109457. set activeCamera(value: Nullable<Camera>);
  109458. private _defaultMaterial;
  109459. /** The default material used on meshes when no material is affected */
  109460. get defaultMaterial(): Material;
  109461. /** The default material used on meshes when no material is affected */
  109462. set defaultMaterial(value: Material);
  109463. private _texturesEnabled;
  109464. /**
  109465. * Gets or sets a boolean indicating if textures are enabled on this scene
  109466. */
  109467. set texturesEnabled(value: boolean);
  109468. get texturesEnabled(): boolean;
  109469. /**
  109470. * Gets or sets a boolean indicating if particles are enabled on this scene
  109471. */
  109472. particlesEnabled: boolean;
  109473. /**
  109474. * Gets or sets a boolean indicating if sprites are enabled on this scene
  109475. */
  109476. spritesEnabled: boolean;
  109477. private _skeletonsEnabled;
  109478. /**
  109479. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  109480. */
  109481. set skeletonsEnabled(value: boolean);
  109482. get skeletonsEnabled(): boolean;
  109483. /**
  109484. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  109485. */
  109486. lensFlaresEnabled: boolean;
  109487. /**
  109488. * Gets or sets a boolean indicating if collisions are enabled on this scene
  109489. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109490. */
  109491. collisionsEnabled: boolean;
  109492. private _collisionCoordinator;
  109493. /** @hidden */
  109494. get collisionCoordinator(): ICollisionCoordinator;
  109495. /**
  109496. * Defines the gravity applied to this scene (used only for collisions)
  109497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109498. */
  109499. gravity: Vector3;
  109500. /**
  109501. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  109502. */
  109503. postProcessesEnabled: boolean;
  109504. /**
  109505. * The list of postprocesses added to the scene
  109506. */
  109507. postProcesses: PostProcess[];
  109508. /**
  109509. * Gets the current postprocess manager
  109510. */
  109511. postProcessManager: PostProcessManager;
  109512. /**
  109513. * Gets or sets a boolean indicating if render targets are enabled on this scene
  109514. */
  109515. renderTargetsEnabled: boolean;
  109516. /**
  109517. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109518. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109519. */
  109520. dumpNextRenderTargets: boolean;
  109521. /**
  109522. * The list of user defined render targets added to the scene
  109523. */
  109524. customRenderTargets: RenderTargetTexture[];
  109525. /**
  109526. * Defines if texture loading must be delayed
  109527. * If true, textures will only be loaded when they need to be rendered
  109528. */
  109529. useDelayedTextureLoading: boolean;
  109530. /**
  109531. * Gets the list of meshes imported to the scene through SceneLoader
  109532. */
  109533. importedMeshesFiles: String[];
  109534. /**
  109535. * Gets or sets a boolean indicating if probes are enabled on this scene
  109536. */
  109537. probesEnabled: boolean;
  109538. /**
  109539. * Gets or sets the current offline provider to use to store scene data
  109540. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109541. */
  109542. offlineProvider: IOfflineProvider;
  109543. /**
  109544. * Gets or sets the action manager associated with the scene
  109545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109546. */
  109547. actionManager: AbstractActionManager;
  109548. private _meshesForIntersections;
  109549. /**
  109550. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109551. */
  109552. proceduralTexturesEnabled: boolean;
  109553. private _engine;
  109554. private _totalVertices;
  109555. /** @hidden */
  109556. _activeIndices: PerfCounter;
  109557. /** @hidden */
  109558. _activeParticles: PerfCounter;
  109559. /** @hidden */
  109560. _activeBones: PerfCounter;
  109561. private _animationRatio;
  109562. /** @hidden */
  109563. _animationTimeLast: number;
  109564. /** @hidden */
  109565. _animationTime: number;
  109566. /**
  109567. * Gets or sets a general scale for animation speed
  109568. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109569. */
  109570. animationTimeScale: number;
  109571. /** @hidden */
  109572. _cachedMaterial: Nullable<Material>;
  109573. /** @hidden */
  109574. _cachedEffect: Nullable<Effect>;
  109575. /** @hidden */
  109576. _cachedVisibility: Nullable<number>;
  109577. private _renderId;
  109578. private _frameId;
  109579. private _executeWhenReadyTimeoutId;
  109580. private _intermediateRendering;
  109581. private _viewUpdateFlag;
  109582. private _projectionUpdateFlag;
  109583. /** @hidden */
  109584. _toBeDisposed: Nullable<IDisposable>[];
  109585. private _activeRequests;
  109586. /** @hidden */
  109587. _pendingData: any[];
  109588. private _isDisposed;
  109589. /**
  109590. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109591. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109592. */
  109593. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109594. private _activeMeshes;
  109595. private _processedMaterials;
  109596. private _renderTargets;
  109597. /** @hidden */
  109598. _activeParticleSystems: SmartArray<IParticleSystem>;
  109599. private _activeSkeletons;
  109600. private _softwareSkinnedMeshes;
  109601. private _renderingManager;
  109602. /** @hidden */
  109603. _activeAnimatables: Animatable[];
  109604. private _transformMatrix;
  109605. private _sceneUbo;
  109606. /** @hidden */
  109607. _viewMatrix: Matrix;
  109608. private _projectionMatrix;
  109609. /** @hidden */
  109610. _forcedViewPosition: Nullable<Vector3>;
  109611. /** @hidden */
  109612. _frustumPlanes: Plane[];
  109613. /**
  109614. * Gets the list of frustum planes (built from the active camera)
  109615. */
  109616. get frustumPlanes(): Plane[];
  109617. /**
  109618. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109619. * This is useful if there are more lights that the maximum simulteanous authorized
  109620. */
  109621. requireLightSorting: boolean;
  109622. /** @hidden */
  109623. readonly useMaterialMeshMap: boolean;
  109624. /** @hidden */
  109625. readonly useClonedMeshMap: boolean;
  109626. private _externalData;
  109627. private _uid;
  109628. /**
  109629. * @hidden
  109630. * Backing store of defined scene components.
  109631. */
  109632. _components: ISceneComponent[];
  109633. /**
  109634. * @hidden
  109635. * Backing store of defined scene components.
  109636. */
  109637. _serializableComponents: ISceneSerializableComponent[];
  109638. /**
  109639. * List of components to register on the next registration step.
  109640. */
  109641. private _transientComponents;
  109642. /**
  109643. * Registers the transient components if needed.
  109644. */
  109645. private _registerTransientComponents;
  109646. /**
  109647. * @hidden
  109648. * Add a component to the scene.
  109649. * Note that the ccomponent could be registered on th next frame if this is called after
  109650. * the register component stage.
  109651. * @param component Defines the component to add to the scene
  109652. */
  109653. _addComponent(component: ISceneComponent): void;
  109654. /**
  109655. * @hidden
  109656. * Gets a component from the scene.
  109657. * @param name defines the name of the component to retrieve
  109658. * @returns the component or null if not present
  109659. */
  109660. _getComponent(name: string): Nullable<ISceneComponent>;
  109661. /**
  109662. * @hidden
  109663. * Defines the actions happening before camera updates.
  109664. */
  109665. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109666. /**
  109667. * @hidden
  109668. * Defines the actions happening before clear the canvas.
  109669. */
  109670. _beforeClearStage: Stage<SimpleStageAction>;
  109671. /**
  109672. * @hidden
  109673. * Defines the actions when collecting render targets for the frame.
  109674. */
  109675. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109676. /**
  109677. * @hidden
  109678. * Defines the actions happening for one camera in the frame.
  109679. */
  109680. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109681. /**
  109682. * @hidden
  109683. * Defines the actions happening during the per mesh ready checks.
  109684. */
  109685. _isReadyForMeshStage: Stage<MeshStageAction>;
  109686. /**
  109687. * @hidden
  109688. * Defines the actions happening before evaluate active mesh checks.
  109689. */
  109690. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109691. /**
  109692. * @hidden
  109693. * Defines the actions happening during the evaluate sub mesh checks.
  109694. */
  109695. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109696. /**
  109697. * @hidden
  109698. * Defines the actions happening during the active mesh stage.
  109699. */
  109700. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109701. /**
  109702. * @hidden
  109703. * Defines the actions happening during the per camera render target step.
  109704. */
  109705. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109706. /**
  109707. * @hidden
  109708. * Defines the actions happening just before the active camera is drawing.
  109709. */
  109710. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109711. /**
  109712. * @hidden
  109713. * Defines the actions happening just before a render target is drawing.
  109714. */
  109715. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109716. /**
  109717. * @hidden
  109718. * Defines the actions happening just before a rendering group is drawing.
  109719. */
  109720. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109721. /**
  109722. * @hidden
  109723. * Defines the actions happening just before a mesh is drawing.
  109724. */
  109725. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109726. /**
  109727. * @hidden
  109728. * Defines the actions happening just after a mesh has been drawn.
  109729. */
  109730. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109731. /**
  109732. * @hidden
  109733. * Defines the actions happening just after a rendering group has been drawn.
  109734. */
  109735. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109736. /**
  109737. * @hidden
  109738. * Defines the actions happening just after the active camera has been drawn.
  109739. */
  109740. _afterCameraDrawStage: Stage<CameraStageAction>;
  109741. /**
  109742. * @hidden
  109743. * Defines the actions happening just after a render target has been drawn.
  109744. */
  109745. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109746. /**
  109747. * @hidden
  109748. * Defines the actions happening just after rendering all cameras and computing intersections.
  109749. */
  109750. _afterRenderStage: Stage<SimpleStageAction>;
  109751. /**
  109752. * @hidden
  109753. * Defines the actions happening when a pointer move event happens.
  109754. */
  109755. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109756. /**
  109757. * @hidden
  109758. * Defines the actions happening when a pointer down event happens.
  109759. */
  109760. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109761. /**
  109762. * @hidden
  109763. * Defines the actions happening when a pointer up event happens.
  109764. */
  109765. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109766. /**
  109767. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109768. */
  109769. private geometriesByUniqueId;
  109770. /**
  109771. * Creates a new Scene
  109772. * @param engine defines the engine to use to render this scene
  109773. * @param options defines the scene options
  109774. */
  109775. constructor(engine: Engine, options?: SceneOptions);
  109776. /**
  109777. * Gets a string idenfifying the name of the class
  109778. * @returns "Scene" string
  109779. */
  109780. getClassName(): string;
  109781. private _defaultMeshCandidates;
  109782. /**
  109783. * @hidden
  109784. */
  109785. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109786. private _defaultSubMeshCandidates;
  109787. /**
  109788. * @hidden
  109789. */
  109790. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109791. /**
  109792. * Sets the default candidate providers for the scene.
  109793. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109794. * and getCollidingSubMeshCandidates to their default function
  109795. */
  109796. setDefaultCandidateProviders(): void;
  109797. /**
  109798. * Gets the mesh that is currently under the pointer
  109799. */
  109800. get meshUnderPointer(): Nullable<AbstractMesh>;
  109801. /**
  109802. * Gets or sets the current on-screen X position of the pointer
  109803. */
  109804. get pointerX(): number;
  109805. set pointerX(value: number);
  109806. /**
  109807. * Gets or sets the current on-screen Y position of the pointer
  109808. */
  109809. get pointerY(): number;
  109810. set pointerY(value: number);
  109811. /**
  109812. * Gets the cached material (ie. the latest rendered one)
  109813. * @returns the cached material
  109814. */
  109815. getCachedMaterial(): Nullable<Material>;
  109816. /**
  109817. * Gets the cached effect (ie. the latest rendered one)
  109818. * @returns the cached effect
  109819. */
  109820. getCachedEffect(): Nullable<Effect>;
  109821. /**
  109822. * Gets the cached visibility state (ie. the latest rendered one)
  109823. * @returns the cached visibility state
  109824. */
  109825. getCachedVisibility(): Nullable<number>;
  109826. /**
  109827. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109828. * @param material defines the current material
  109829. * @param effect defines the current effect
  109830. * @param visibility defines the current visibility state
  109831. * @returns true if one parameter is not cached
  109832. */
  109833. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109834. /**
  109835. * Gets the engine associated with the scene
  109836. * @returns an Engine
  109837. */
  109838. getEngine(): Engine;
  109839. /**
  109840. * Gets the total number of vertices rendered per frame
  109841. * @returns the total number of vertices rendered per frame
  109842. */
  109843. getTotalVertices(): number;
  109844. /**
  109845. * Gets the performance counter for total vertices
  109846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109847. */
  109848. get totalVerticesPerfCounter(): PerfCounter;
  109849. /**
  109850. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109851. * @returns the total number of active indices rendered per frame
  109852. */
  109853. getActiveIndices(): number;
  109854. /**
  109855. * Gets the performance counter for active indices
  109856. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109857. */
  109858. get totalActiveIndicesPerfCounter(): PerfCounter;
  109859. /**
  109860. * Gets the total number of active particles rendered per frame
  109861. * @returns the total number of active particles rendered per frame
  109862. */
  109863. getActiveParticles(): number;
  109864. /**
  109865. * Gets the performance counter for active particles
  109866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109867. */
  109868. get activeParticlesPerfCounter(): PerfCounter;
  109869. /**
  109870. * Gets the total number of active bones rendered per frame
  109871. * @returns the total number of active bones rendered per frame
  109872. */
  109873. getActiveBones(): number;
  109874. /**
  109875. * Gets the performance counter for active bones
  109876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109877. */
  109878. get activeBonesPerfCounter(): PerfCounter;
  109879. /**
  109880. * Gets the array of active meshes
  109881. * @returns an array of AbstractMesh
  109882. */
  109883. getActiveMeshes(): SmartArray<AbstractMesh>;
  109884. /**
  109885. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109886. * @returns a number
  109887. */
  109888. getAnimationRatio(): number;
  109889. /**
  109890. * Gets an unique Id for the current render phase
  109891. * @returns a number
  109892. */
  109893. getRenderId(): number;
  109894. /**
  109895. * Gets an unique Id for the current frame
  109896. * @returns a number
  109897. */
  109898. getFrameId(): number;
  109899. /** Call this function if you want to manually increment the render Id*/
  109900. incrementRenderId(): void;
  109901. private _createUbo;
  109902. /**
  109903. * Use this method to simulate a pointer move on a mesh
  109904. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109905. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109906. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109907. * @returns the current scene
  109908. */
  109909. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109910. /**
  109911. * Use this method to simulate a pointer down on a mesh
  109912. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109913. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109914. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109915. * @returns the current scene
  109916. */
  109917. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109918. /**
  109919. * Use this method to simulate a pointer up on a mesh
  109920. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109921. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109922. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109923. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109924. * @returns the current scene
  109925. */
  109926. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109927. /**
  109928. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109929. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109930. * @returns true if the pointer was captured
  109931. */
  109932. isPointerCaptured(pointerId?: number): boolean;
  109933. /**
  109934. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109935. * @param attachUp defines if you want to attach events to pointerup
  109936. * @param attachDown defines if you want to attach events to pointerdown
  109937. * @param attachMove defines if you want to attach events to pointermove
  109938. */
  109939. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109940. /** Detaches all event handlers*/
  109941. detachControl(): void;
  109942. /**
  109943. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109944. * Delay loaded resources are not taking in account
  109945. * @return true if all required resources are ready
  109946. */
  109947. isReady(): boolean;
  109948. /** Resets all cached information relative to material (including effect and visibility) */
  109949. resetCachedMaterial(): void;
  109950. /**
  109951. * Registers a function to be called before every frame render
  109952. * @param func defines the function to register
  109953. */
  109954. registerBeforeRender(func: () => void): void;
  109955. /**
  109956. * Unregisters a function called before every frame render
  109957. * @param func defines the function to unregister
  109958. */
  109959. unregisterBeforeRender(func: () => void): void;
  109960. /**
  109961. * Registers a function to be called after every frame render
  109962. * @param func defines the function to register
  109963. */
  109964. registerAfterRender(func: () => void): void;
  109965. /**
  109966. * Unregisters a function called after every frame render
  109967. * @param func defines the function to unregister
  109968. */
  109969. unregisterAfterRender(func: () => void): void;
  109970. private _executeOnceBeforeRender;
  109971. /**
  109972. * The provided function will run before render once and will be disposed afterwards.
  109973. * A timeout delay can be provided so that the function will be executed in N ms.
  109974. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109975. * @param func The function to be executed.
  109976. * @param timeout optional delay in ms
  109977. */
  109978. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109979. /** @hidden */
  109980. _addPendingData(data: any): void;
  109981. /** @hidden */
  109982. _removePendingData(data: any): void;
  109983. /**
  109984. * Returns the number of items waiting to be loaded
  109985. * @returns the number of items waiting to be loaded
  109986. */
  109987. getWaitingItemsCount(): number;
  109988. /**
  109989. * Returns a boolean indicating if the scene is still loading data
  109990. */
  109991. get isLoading(): boolean;
  109992. /**
  109993. * Registers a function to be executed when the scene is ready
  109994. * @param {Function} func - the function to be executed
  109995. */
  109996. executeWhenReady(func: () => void): void;
  109997. /**
  109998. * Returns a promise that resolves when the scene is ready
  109999. * @returns A promise that resolves when the scene is ready
  110000. */
  110001. whenReadyAsync(): Promise<void>;
  110002. /** @hidden */
  110003. _checkIsReady(): void;
  110004. /**
  110005. * Gets all animatable attached to the scene
  110006. */
  110007. get animatables(): Animatable[];
  110008. /**
  110009. * Resets the last animation time frame.
  110010. * Useful to override when animations start running when loading a scene for the first time.
  110011. */
  110012. resetLastAnimationTimeFrame(): void;
  110013. /**
  110014. * Gets the current view matrix
  110015. * @returns a Matrix
  110016. */
  110017. getViewMatrix(): Matrix;
  110018. /**
  110019. * Gets the current projection matrix
  110020. * @returns a Matrix
  110021. */
  110022. getProjectionMatrix(): Matrix;
  110023. /**
  110024. * Gets the current transform matrix
  110025. * @returns a Matrix made of View * Projection
  110026. */
  110027. getTransformMatrix(): Matrix;
  110028. /**
  110029. * Sets the current transform matrix
  110030. * @param viewL defines the View matrix to use
  110031. * @param projectionL defines the Projection matrix to use
  110032. * @param viewR defines the right View matrix to use (if provided)
  110033. * @param projectionR defines the right Projection matrix to use (if provided)
  110034. */
  110035. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  110036. /**
  110037. * Gets the uniform buffer used to store scene data
  110038. * @returns a UniformBuffer
  110039. */
  110040. getSceneUniformBuffer(): UniformBuffer;
  110041. /**
  110042. * Gets an unique (relatively to the current scene) Id
  110043. * @returns an unique number for the scene
  110044. */
  110045. getUniqueId(): number;
  110046. /**
  110047. * Add a mesh to the list of scene's meshes
  110048. * @param newMesh defines the mesh to add
  110049. * @param recursive if all child meshes should also be added to the scene
  110050. */
  110051. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  110052. /**
  110053. * Remove a mesh for the list of scene's meshes
  110054. * @param toRemove defines the mesh to remove
  110055. * @param recursive if all child meshes should also be removed from the scene
  110056. * @returns the index where the mesh was in the mesh list
  110057. */
  110058. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  110059. /**
  110060. * Add a transform node to the list of scene's transform nodes
  110061. * @param newTransformNode defines the transform node to add
  110062. */
  110063. addTransformNode(newTransformNode: TransformNode): void;
  110064. /**
  110065. * Remove a transform node for the list of scene's transform nodes
  110066. * @param toRemove defines the transform node to remove
  110067. * @returns the index where the transform node was in the transform node list
  110068. */
  110069. removeTransformNode(toRemove: TransformNode): number;
  110070. /**
  110071. * Remove a skeleton for the list of scene's skeletons
  110072. * @param toRemove defines the skeleton to remove
  110073. * @returns the index where the skeleton was in the skeleton list
  110074. */
  110075. removeSkeleton(toRemove: Skeleton): number;
  110076. /**
  110077. * Remove a morph target for the list of scene's morph targets
  110078. * @param toRemove defines the morph target to remove
  110079. * @returns the index where the morph target was in the morph target list
  110080. */
  110081. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  110082. /**
  110083. * Remove a light for the list of scene's lights
  110084. * @param toRemove defines the light to remove
  110085. * @returns the index where the light was in the light list
  110086. */
  110087. removeLight(toRemove: Light): number;
  110088. /**
  110089. * Remove a camera for the list of scene's cameras
  110090. * @param toRemove defines the camera to remove
  110091. * @returns the index where the camera was in the camera list
  110092. */
  110093. removeCamera(toRemove: Camera): number;
  110094. /**
  110095. * Remove a particle system for the list of scene's particle systems
  110096. * @param toRemove defines the particle system to remove
  110097. * @returns the index where the particle system was in the particle system list
  110098. */
  110099. removeParticleSystem(toRemove: IParticleSystem): number;
  110100. /**
  110101. * Remove a animation for the list of scene's animations
  110102. * @param toRemove defines the animation to remove
  110103. * @returns the index where the animation was in the animation list
  110104. */
  110105. removeAnimation(toRemove: Animation): number;
  110106. /**
  110107. * Will stop the animation of the given target
  110108. * @param target - the target
  110109. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110110. * @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)
  110111. */
  110112. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110113. /**
  110114. * Removes the given animation group from this scene.
  110115. * @param toRemove The animation group to remove
  110116. * @returns The index of the removed animation group
  110117. */
  110118. removeAnimationGroup(toRemove: AnimationGroup): number;
  110119. /**
  110120. * Removes the given multi-material from this scene.
  110121. * @param toRemove The multi-material to remove
  110122. * @returns The index of the removed multi-material
  110123. */
  110124. removeMultiMaterial(toRemove: MultiMaterial): number;
  110125. /**
  110126. * Removes the given material from this scene.
  110127. * @param toRemove The material to remove
  110128. * @returns The index of the removed material
  110129. */
  110130. removeMaterial(toRemove: Material): number;
  110131. /**
  110132. * Removes the given action manager from this scene.
  110133. * @param toRemove The action manager to remove
  110134. * @returns The index of the removed action manager
  110135. */
  110136. removeActionManager(toRemove: AbstractActionManager): number;
  110137. /**
  110138. * Removes the given texture from this scene.
  110139. * @param toRemove The texture to remove
  110140. * @returns The index of the removed texture
  110141. */
  110142. removeTexture(toRemove: BaseTexture): number;
  110143. /**
  110144. * Adds the given light to this scene
  110145. * @param newLight The light to add
  110146. */
  110147. addLight(newLight: Light): void;
  110148. /**
  110149. * Sorts the list list based on light priorities
  110150. */
  110151. sortLightsByPriority(): void;
  110152. /**
  110153. * Adds the given camera to this scene
  110154. * @param newCamera The camera to add
  110155. */
  110156. addCamera(newCamera: Camera): void;
  110157. /**
  110158. * Adds the given skeleton to this scene
  110159. * @param newSkeleton The skeleton to add
  110160. */
  110161. addSkeleton(newSkeleton: Skeleton): void;
  110162. /**
  110163. * Adds the given particle system to this scene
  110164. * @param newParticleSystem The particle system to add
  110165. */
  110166. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110167. /**
  110168. * Adds the given animation to this scene
  110169. * @param newAnimation The animation to add
  110170. */
  110171. addAnimation(newAnimation: Animation): void;
  110172. /**
  110173. * Adds the given animation group to this scene.
  110174. * @param newAnimationGroup The animation group to add
  110175. */
  110176. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  110177. /**
  110178. * Adds the given multi-material to this scene
  110179. * @param newMultiMaterial The multi-material to add
  110180. */
  110181. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  110182. /**
  110183. * Adds the given material to this scene
  110184. * @param newMaterial The material to add
  110185. */
  110186. addMaterial(newMaterial: Material): void;
  110187. /**
  110188. * Adds the given morph target to this scene
  110189. * @param newMorphTargetManager The morph target to add
  110190. */
  110191. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  110192. /**
  110193. * Adds the given geometry to this scene
  110194. * @param newGeometry The geometry to add
  110195. */
  110196. addGeometry(newGeometry: Geometry): void;
  110197. /**
  110198. * Adds the given action manager to this scene
  110199. * @param newActionManager The action manager to add
  110200. */
  110201. addActionManager(newActionManager: AbstractActionManager): void;
  110202. /**
  110203. * Adds the given texture to this scene.
  110204. * @param newTexture The texture to add
  110205. */
  110206. addTexture(newTexture: BaseTexture): void;
  110207. /**
  110208. * Switch active camera
  110209. * @param newCamera defines the new active camera
  110210. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  110211. */
  110212. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  110213. /**
  110214. * sets the active camera of the scene using its ID
  110215. * @param id defines the camera's ID
  110216. * @return the new active camera or null if none found.
  110217. */
  110218. setActiveCameraByID(id: string): Nullable<Camera>;
  110219. /**
  110220. * sets the active camera of the scene using its name
  110221. * @param name defines the camera's name
  110222. * @returns the new active camera or null if none found.
  110223. */
  110224. setActiveCameraByName(name: string): Nullable<Camera>;
  110225. /**
  110226. * get an animation group using its name
  110227. * @param name defines the material's name
  110228. * @return the animation group or null if none found.
  110229. */
  110230. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  110231. /**
  110232. * Get a material using its unique id
  110233. * @param uniqueId defines the material's unique id
  110234. * @return the material or null if none found.
  110235. */
  110236. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  110237. /**
  110238. * get a material using its id
  110239. * @param id defines the material's ID
  110240. * @return the material or null if none found.
  110241. */
  110242. getMaterialByID(id: string): Nullable<Material>;
  110243. /**
  110244. * Gets a the last added material using a given id
  110245. * @param id defines the material's ID
  110246. * @return the last material with the given id or null if none found.
  110247. */
  110248. getLastMaterialByID(id: string): Nullable<Material>;
  110249. /**
  110250. * Gets a material using its name
  110251. * @param name defines the material's name
  110252. * @return the material or null if none found.
  110253. */
  110254. getMaterialByName(name: string): Nullable<Material>;
  110255. /**
  110256. * Get a texture using its unique id
  110257. * @param uniqueId defines the texture's unique id
  110258. * @return the texture or null if none found.
  110259. */
  110260. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  110261. /**
  110262. * Gets a camera using its id
  110263. * @param id defines the id to look for
  110264. * @returns the camera or null if not found
  110265. */
  110266. getCameraByID(id: string): Nullable<Camera>;
  110267. /**
  110268. * Gets a camera using its unique id
  110269. * @param uniqueId defines the unique id to look for
  110270. * @returns the camera or null if not found
  110271. */
  110272. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  110273. /**
  110274. * Gets a camera using its name
  110275. * @param name defines the camera's name
  110276. * @return the camera or null if none found.
  110277. */
  110278. getCameraByName(name: string): Nullable<Camera>;
  110279. /**
  110280. * Gets a bone using its id
  110281. * @param id defines the bone's id
  110282. * @return the bone or null if not found
  110283. */
  110284. getBoneByID(id: string): Nullable<Bone>;
  110285. /**
  110286. * Gets a bone using its id
  110287. * @param name defines the bone's name
  110288. * @return the bone or null if not found
  110289. */
  110290. getBoneByName(name: string): Nullable<Bone>;
  110291. /**
  110292. * Gets a light node using its name
  110293. * @param name defines the the light's name
  110294. * @return the light or null if none found.
  110295. */
  110296. getLightByName(name: string): Nullable<Light>;
  110297. /**
  110298. * Gets a light node using its id
  110299. * @param id defines the light's id
  110300. * @return the light or null if none found.
  110301. */
  110302. getLightByID(id: string): Nullable<Light>;
  110303. /**
  110304. * Gets a light node using its scene-generated unique ID
  110305. * @param uniqueId defines the light's unique id
  110306. * @return the light or null if none found.
  110307. */
  110308. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  110309. /**
  110310. * Gets a particle system by id
  110311. * @param id defines the particle system id
  110312. * @return the corresponding system or null if none found
  110313. */
  110314. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  110315. /**
  110316. * Gets a geometry using its ID
  110317. * @param id defines the geometry's id
  110318. * @return the geometry or null if none found.
  110319. */
  110320. getGeometryByID(id: string): Nullable<Geometry>;
  110321. private _getGeometryByUniqueID;
  110322. /**
  110323. * Add a new geometry to this scene
  110324. * @param geometry defines the geometry to be added to the scene.
  110325. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  110326. * @return a boolean defining if the geometry was added or not
  110327. */
  110328. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  110329. /**
  110330. * Removes an existing geometry
  110331. * @param geometry defines the geometry to be removed from the scene
  110332. * @return a boolean defining if the geometry was removed or not
  110333. */
  110334. removeGeometry(geometry: Geometry): boolean;
  110335. /**
  110336. * Gets the list of geometries attached to the scene
  110337. * @returns an array of Geometry
  110338. */
  110339. getGeometries(): Geometry[];
  110340. /**
  110341. * Gets the first added mesh found of a given ID
  110342. * @param id defines the id to search for
  110343. * @return the mesh found or null if not found at all
  110344. */
  110345. getMeshByID(id: string): Nullable<AbstractMesh>;
  110346. /**
  110347. * Gets a list of meshes using their id
  110348. * @param id defines the id to search for
  110349. * @returns a list of meshes
  110350. */
  110351. getMeshesByID(id: string): Array<AbstractMesh>;
  110352. /**
  110353. * Gets the first added transform node found of a given ID
  110354. * @param id defines the id to search for
  110355. * @return the found transform node or null if not found at all.
  110356. */
  110357. getTransformNodeByID(id: string): Nullable<TransformNode>;
  110358. /**
  110359. * Gets a transform node with its auto-generated unique id
  110360. * @param uniqueId efines the unique id to search for
  110361. * @return the found transform node or null if not found at all.
  110362. */
  110363. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  110364. /**
  110365. * Gets a list of transform nodes using their id
  110366. * @param id defines the id to search for
  110367. * @returns a list of transform nodes
  110368. */
  110369. getTransformNodesByID(id: string): Array<TransformNode>;
  110370. /**
  110371. * Gets a mesh with its auto-generated unique id
  110372. * @param uniqueId defines the unique id to search for
  110373. * @return the found mesh or null if not found at all.
  110374. */
  110375. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  110376. /**
  110377. * Gets a the last added mesh using a given id
  110378. * @param id defines the id to search for
  110379. * @return the found mesh or null if not found at all.
  110380. */
  110381. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  110382. /**
  110383. * Gets a the last added node (Mesh, Camera, Light) using a given id
  110384. * @param id defines the id to search for
  110385. * @return the found node or null if not found at all
  110386. */
  110387. getLastEntryByID(id: string): Nullable<Node>;
  110388. /**
  110389. * Gets a node (Mesh, Camera, Light) using a given id
  110390. * @param id defines the id to search for
  110391. * @return the found node or null if not found at all
  110392. */
  110393. getNodeByID(id: string): Nullable<Node>;
  110394. /**
  110395. * Gets a node (Mesh, Camera, Light) using a given name
  110396. * @param name defines the name to search for
  110397. * @return the found node or null if not found at all.
  110398. */
  110399. getNodeByName(name: string): Nullable<Node>;
  110400. /**
  110401. * Gets a mesh using a given name
  110402. * @param name defines the name to search for
  110403. * @return the found mesh or null if not found at all.
  110404. */
  110405. getMeshByName(name: string): Nullable<AbstractMesh>;
  110406. /**
  110407. * Gets a transform node using a given name
  110408. * @param name defines the name to search for
  110409. * @return the found transform node or null if not found at all.
  110410. */
  110411. getTransformNodeByName(name: string): Nullable<TransformNode>;
  110412. /**
  110413. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  110414. * @param id defines the id to search for
  110415. * @return the found skeleton or null if not found at all.
  110416. */
  110417. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  110418. /**
  110419. * Gets a skeleton using a given auto generated unique id
  110420. * @param uniqueId defines the unique id to search for
  110421. * @return the found skeleton or null if not found at all.
  110422. */
  110423. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  110424. /**
  110425. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  110426. * @param id defines the id to search for
  110427. * @return the found skeleton or null if not found at all.
  110428. */
  110429. getSkeletonById(id: string): Nullable<Skeleton>;
  110430. /**
  110431. * Gets a skeleton using a given name
  110432. * @param name defines the name to search for
  110433. * @return the found skeleton or null if not found at all.
  110434. */
  110435. getSkeletonByName(name: string): Nullable<Skeleton>;
  110436. /**
  110437. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  110438. * @param id defines the id to search for
  110439. * @return the found morph target manager or null if not found at all.
  110440. */
  110441. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  110442. /**
  110443. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  110444. * @param id defines the id to search for
  110445. * @return the found morph target or null if not found at all.
  110446. */
  110447. getMorphTargetById(id: string): Nullable<MorphTarget>;
  110448. /**
  110449. * Gets a boolean indicating if the given mesh is active
  110450. * @param mesh defines the mesh to look for
  110451. * @returns true if the mesh is in the active list
  110452. */
  110453. isActiveMesh(mesh: AbstractMesh): boolean;
  110454. /**
  110455. * Return a unique id as a string which can serve as an identifier for the scene
  110456. */
  110457. get uid(): string;
  110458. /**
  110459. * Add an externaly attached data from its key.
  110460. * This method call will fail and return false, if such key already exists.
  110461. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  110462. * @param key the unique key that identifies the data
  110463. * @param data the data object to associate to the key for this Engine instance
  110464. * @return true if no such key were already present and the data was added successfully, false otherwise
  110465. */
  110466. addExternalData<T>(key: string, data: T): boolean;
  110467. /**
  110468. * Get an externaly attached data from its key
  110469. * @param key the unique key that identifies the data
  110470. * @return the associated data, if present (can be null), or undefined if not present
  110471. */
  110472. getExternalData<T>(key: string): Nullable<T>;
  110473. /**
  110474. * Get an externaly attached data from its key, create it using a factory if it's not already present
  110475. * @param key the unique key that identifies the data
  110476. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  110477. * @return the associated data, can be null if the factory returned null.
  110478. */
  110479. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  110480. /**
  110481. * Remove an externaly attached data from the Engine instance
  110482. * @param key the unique key that identifies the data
  110483. * @return true if the data was successfully removed, false if it doesn't exist
  110484. */
  110485. removeExternalData(key: string): boolean;
  110486. private _evaluateSubMesh;
  110487. /**
  110488. * Clear the processed materials smart array preventing retention point in material dispose.
  110489. */
  110490. freeProcessedMaterials(): void;
  110491. private _preventFreeActiveMeshesAndRenderingGroups;
  110492. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  110493. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  110494. * when disposing several meshes in a row or a hierarchy of meshes.
  110495. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  110496. */
  110497. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  110498. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  110499. /**
  110500. * Clear the active meshes smart array preventing retention point in mesh dispose.
  110501. */
  110502. freeActiveMeshes(): void;
  110503. /**
  110504. * Clear the info related to rendering groups preventing retention points during dispose.
  110505. */
  110506. freeRenderingGroups(): void;
  110507. /** @hidden */
  110508. _isInIntermediateRendering(): boolean;
  110509. /**
  110510. * Lambda returning the list of potentially active meshes.
  110511. */
  110512. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  110513. /**
  110514. * Lambda returning the list of potentially active sub meshes.
  110515. */
  110516. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110517. /**
  110518. * Lambda returning the list of potentially intersecting sub meshes.
  110519. */
  110520. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110521. /**
  110522. * Lambda returning the list of potentially colliding sub meshes.
  110523. */
  110524. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110525. private _activeMeshesFrozen;
  110526. private _skipEvaluateActiveMeshesCompletely;
  110527. /**
  110528. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110529. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110530. * @returns the current scene
  110531. */
  110532. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110533. /**
  110534. * Use this function to restart evaluating active meshes on every frame
  110535. * @returns the current scene
  110536. */
  110537. unfreezeActiveMeshes(): Scene;
  110538. private _evaluateActiveMeshes;
  110539. private _activeMesh;
  110540. /**
  110541. * Update the transform matrix to update from the current active camera
  110542. * @param force defines a boolean used to force the update even if cache is up to date
  110543. */
  110544. updateTransformMatrix(force?: boolean): void;
  110545. private _bindFrameBuffer;
  110546. /** @hidden */
  110547. _allowPostProcessClearColor: boolean;
  110548. /** @hidden */
  110549. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110550. private _processSubCameras;
  110551. private _checkIntersections;
  110552. /** @hidden */
  110553. _advancePhysicsEngineStep(step: number): void;
  110554. /**
  110555. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110556. */
  110557. getDeterministicFrameTime: () => number;
  110558. /** @hidden */
  110559. _animate(): void;
  110560. /** Execute all animations (for a frame) */
  110561. animate(): void;
  110562. /**
  110563. * Render the scene
  110564. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110565. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110566. */
  110567. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110568. /**
  110569. * Freeze all materials
  110570. * A frozen material will not be updatable but should be faster to render
  110571. */
  110572. freezeMaterials(): void;
  110573. /**
  110574. * Unfreeze all materials
  110575. * A frozen material will not be updatable but should be faster to render
  110576. */
  110577. unfreezeMaterials(): void;
  110578. /**
  110579. * Releases all held ressources
  110580. */
  110581. dispose(): void;
  110582. /**
  110583. * Gets if the scene is already disposed
  110584. */
  110585. get isDisposed(): boolean;
  110586. /**
  110587. * Call this function to reduce memory footprint of the scene.
  110588. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110589. */
  110590. clearCachedVertexData(): void;
  110591. /**
  110592. * This function will remove the local cached buffer data from texture.
  110593. * It will save memory but will prevent the texture from being rebuilt
  110594. */
  110595. cleanCachedTextureBuffer(): void;
  110596. /**
  110597. * Get the world extend vectors with an optional filter
  110598. *
  110599. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110600. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110601. */
  110602. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110603. min: Vector3;
  110604. max: Vector3;
  110605. };
  110606. /**
  110607. * Creates a ray that can be used to pick in the scene
  110608. * @param x defines the x coordinate of the origin (on-screen)
  110609. * @param y defines the y coordinate of the origin (on-screen)
  110610. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110611. * @param camera defines the camera to use for the picking
  110612. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110613. * @returns a Ray
  110614. */
  110615. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110616. /**
  110617. * Creates a ray that can be used to pick in the scene
  110618. * @param x defines the x coordinate of the origin (on-screen)
  110619. * @param y defines the y coordinate of the origin (on-screen)
  110620. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110621. * @param result defines the ray where to store the picking ray
  110622. * @param camera defines the camera to use for the picking
  110623. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110624. * @returns the current scene
  110625. */
  110626. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110627. /**
  110628. * Creates a ray that can be used to pick in the scene
  110629. * @param x defines the x coordinate of the origin (on-screen)
  110630. * @param y defines the y coordinate of the origin (on-screen)
  110631. * @param camera defines the camera to use for the picking
  110632. * @returns a Ray
  110633. */
  110634. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110635. /**
  110636. * Creates a ray that can be used to pick in the scene
  110637. * @param x defines the x coordinate of the origin (on-screen)
  110638. * @param y defines the y coordinate of the origin (on-screen)
  110639. * @param result defines the ray where to store the picking ray
  110640. * @param camera defines the camera to use for the picking
  110641. * @returns the current scene
  110642. */
  110643. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110644. /** Launch a ray to try to pick a mesh in the scene
  110645. * @param x position on screen
  110646. * @param y position on screen
  110647. * @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
  110648. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110649. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110650. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110651. * @returns a PickingInfo
  110652. */
  110653. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110654. /** Use the given ray to pick a mesh in the scene
  110655. * @param ray The ray to use to pick meshes
  110656. * @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
  110657. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110658. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110659. * @returns a PickingInfo
  110660. */
  110661. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110662. /**
  110663. * Launch a ray to try to pick a mesh in the scene
  110664. * @param x X position on screen
  110665. * @param y Y position on screen
  110666. * @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
  110667. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110668. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110669. * @returns an array of PickingInfo
  110670. */
  110671. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110672. /**
  110673. * Launch a ray to try to pick a mesh in the scene
  110674. * @param ray Ray to use
  110675. * @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
  110676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110677. * @returns an array of PickingInfo
  110678. */
  110679. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110680. /**
  110681. * Force the value of meshUnderPointer
  110682. * @param mesh defines the mesh to use
  110683. */
  110684. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110685. /**
  110686. * Gets the mesh under the pointer
  110687. * @returns a Mesh or null if no mesh is under the pointer
  110688. */
  110689. getPointerOverMesh(): Nullable<AbstractMesh>;
  110690. /** @hidden */
  110691. _rebuildGeometries(): void;
  110692. /** @hidden */
  110693. _rebuildTextures(): void;
  110694. private _getByTags;
  110695. /**
  110696. * Get a list of meshes by tags
  110697. * @param tagsQuery defines the tags query to use
  110698. * @param forEach defines a predicate used to filter results
  110699. * @returns an array of Mesh
  110700. */
  110701. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110702. /**
  110703. * Get a list of cameras by tags
  110704. * @param tagsQuery defines the tags query to use
  110705. * @param forEach defines a predicate used to filter results
  110706. * @returns an array of Camera
  110707. */
  110708. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110709. /**
  110710. * Get a list of lights by tags
  110711. * @param tagsQuery defines the tags query to use
  110712. * @param forEach defines a predicate used to filter results
  110713. * @returns an array of Light
  110714. */
  110715. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110716. /**
  110717. * Get a list of materials by tags
  110718. * @param tagsQuery defines the tags query to use
  110719. * @param forEach defines a predicate used to filter results
  110720. * @returns an array of Material
  110721. */
  110722. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110723. /**
  110724. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110725. * This allowed control for front to back rendering or reversly depending of the special needs.
  110726. *
  110727. * @param renderingGroupId The rendering group id corresponding to its index
  110728. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110729. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110730. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110731. */
  110732. 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;
  110733. /**
  110734. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110735. *
  110736. * @param renderingGroupId The rendering group id corresponding to its index
  110737. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110738. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110739. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110740. */
  110741. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110742. /**
  110743. * Gets the current auto clear configuration for one rendering group of the rendering
  110744. * manager.
  110745. * @param index the rendering group index to get the information for
  110746. * @returns The auto clear setup for the requested rendering group
  110747. */
  110748. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110749. private _blockMaterialDirtyMechanism;
  110750. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110751. get blockMaterialDirtyMechanism(): boolean;
  110752. set blockMaterialDirtyMechanism(value: boolean);
  110753. /**
  110754. * Will flag all materials as dirty to trigger new shader compilation
  110755. * @param flag defines the flag used to specify which material part must be marked as dirty
  110756. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110757. */
  110758. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110759. /** @hidden */
  110760. _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;
  110761. /** @hidden */
  110762. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110763. /** @hidden */
  110764. _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;
  110765. /** @hidden */
  110766. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110767. /** @hidden */
  110768. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110769. /** @hidden */
  110770. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110771. }
  110772. }
  110773. declare module BABYLON {
  110774. /**
  110775. * Set of assets to keep when moving a scene into an asset container.
  110776. */
  110777. export class KeepAssets extends AbstractScene {
  110778. }
  110779. /**
  110780. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110781. */
  110782. export class InstantiatedEntries {
  110783. /**
  110784. * List of new root nodes (eg. nodes with no parent)
  110785. */
  110786. rootNodes: TransformNode[];
  110787. /**
  110788. * List of new skeletons
  110789. */
  110790. skeletons: Skeleton[];
  110791. /**
  110792. * List of new animation groups
  110793. */
  110794. animationGroups: AnimationGroup[];
  110795. }
  110796. /**
  110797. * Container with a set of assets that can be added or removed from a scene.
  110798. */
  110799. export class AssetContainer extends AbstractScene {
  110800. private _wasAddedToScene;
  110801. /**
  110802. * The scene the AssetContainer belongs to.
  110803. */
  110804. scene: Scene;
  110805. /**
  110806. * Instantiates an AssetContainer.
  110807. * @param scene The scene the AssetContainer belongs to.
  110808. */
  110809. constructor(scene: Scene);
  110810. /**
  110811. * Instantiate or clone all meshes and add the new ones to the scene.
  110812. * Skeletons and animation groups will all be cloned
  110813. * @param nameFunction defines an optional function used to get new names for clones
  110814. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110815. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110816. */
  110817. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110818. /**
  110819. * Adds all the assets from the container to the scene.
  110820. */
  110821. addAllToScene(): void;
  110822. /**
  110823. * Removes all the assets in the container from the scene
  110824. */
  110825. removeAllFromScene(): void;
  110826. /**
  110827. * Disposes all the assets in the container
  110828. */
  110829. dispose(): void;
  110830. private _moveAssets;
  110831. /**
  110832. * Removes all the assets contained in the scene and adds them to the container.
  110833. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110834. */
  110835. moveAllFromScene(keepAssets?: KeepAssets): void;
  110836. /**
  110837. * 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.
  110838. * @returns the root mesh
  110839. */
  110840. createRootMesh(): Mesh;
  110841. /**
  110842. * Merge animations from this asset container into a scene
  110843. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110844. * @param animatables set of animatables to retarget to a node from the scene
  110845. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110846. */
  110847. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110848. }
  110849. }
  110850. declare module BABYLON {
  110851. /**
  110852. * Defines how the parser contract is defined.
  110853. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110854. */
  110855. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110856. /**
  110857. * Defines how the individual parser contract is defined.
  110858. * These parser can parse an individual asset
  110859. */
  110860. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110861. /**
  110862. * Base class of the scene acting as a container for the different elements composing a scene.
  110863. * This class is dynamically extended by the different components of the scene increasing
  110864. * flexibility and reducing coupling
  110865. */
  110866. export abstract class AbstractScene {
  110867. /**
  110868. * Stores the list of available parsers in the application.
  110869. */
  110870. private static _BabylonFileParsers;
  110871. /**
  110872. * Stores the list of available individual parsers in the application.
  110873. */
  110874. private static _IndividualBabylonFileParsers;
  110875. /**
  110876. * Adds a parser in the list of available ones
  110877. * @param name Defines the name of the parser
  110878. * @param parser Defines the parser to add
  110879. */
  110880. static AddParser(name: string, parser: BabylonFileParser): void;
  110881. /**
  110882. * Gets a general parser from the list of avaialble ones
  110883. * @param name Defines the name of the parser
  110884. * @returns the requested parser or null
  110885. */
  110886. static GetParser(name: string): Nullable<BabylonFileParser>;
  110887. /**
  110888. * Adds n individual parser in the list of available ones
  110889. * @param name Defines the name of the parser
  110890. * @param parser Defines the parser to add
  110891. */
  110892. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110893. /**
  110894. * Gets an individual parser from the list of avaialble ones
  110895. * @param name Defines the name of the parser
  110896. * @returns the requested parser or null
  110897. */
  110898. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110899. /**
  110900. * Parser json data and populate both a scene and its associated container object
  110901. * @param jsonData Defines the data to parse
  110902. * @param scene Defines the scene to parse the data for
  110903. * @param container Defines the container attached to the parsing sequence
  110904. * @param rootUrl Defines the root url of the data
  110905. */
  110906. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110907. /**
  110908. * Gets the list of root nodes (ie. nodes with no parent)
  110909. */
  110910. rootNodes: Node[];
  110911. /** All of the cameras added to this scene
  110912. * @see http://doc.babylonjs.com/babylon101/cameras
  110913. */
  110914. cameras: Camera[];
  110915. /**
  110916. * All of the lights added to this scene
  110917. * @see http://doc.babylonjs.com/babylon101/lights
  110918. */
  110919. lights: Light[];
  110920. /**
  110921. * All of the (abstract) meshes added to this scene
  110922. */
  110923. meshes: AbstractMesh[];
  110924. /**
  110925. * The list of skeletons added to the scene
  110926. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110927. */
  110928. skeletons: Skeleton[];
  110929. /**
  110930. * All of the particle systems added to this scene
  110931. * @see http://doc.babylonjs.com/babylon101/particles
  110932. */
  110933. particleSystems: IParticleSystem[];
  110934. /**
  110935. * Gets a list of Animations associated with the scene
  110936. */
  110937. animations: Animation[];
  110938. /**
  110939. * All of the animation groups added to this scene
  110940. * @see http://doc.babylonjs.com/how_to/group
  110941. */
  110942. animationGroups: AnimationGroup[];
  110943. /**
  110944. * All of the multi-materials added to this scene
  110945. * @see http://doc.babylonjs.com/how_to/multi_materials
  110946. */
  110947. multiMaterials: MultiMaterial[];
  110948. /**
  110949. * All of the materials added to this scene
  110950. * In the context of a Scene, it is not supposed to be modified manually.
  110951. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110952. * Note also that the order of the Material within the array is not significant and might change.
  110953. * @see http://doc.babylonjs.com/babylon101/materials
  110954. */
  110955. materials: Material[];
  110956. /**
  110957. * The list of morph target managers added to the scene
  110958. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110959. */
  110960. morphTargetManagers: MorphTargetManager[];
  110961. /**
  110962. * The list of geometries used in the scene.
  110963. */
  110964. geometries: Geometry[];
  110965. /**
  110966. * All of the tranform nodes added to this scene
  110967. * In the context of a Scene, it is not supposed to be modified manually.
  110968. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110969. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110970. * @see http://doc.babylonjs.com/how_to/transformnode
  110971. */
  110972. transformNodes: TransformNode[];
  110973. /**
  110974. * ActionManagers available on the scene.
  110975. */
  110976. actionManagers: AbstractActionManager[];
  110977. /**
  110978. * Textures to keep.
  110979. */
  110980. textures: BaseTexture[];
  110981. /**
  110982. * Environment texture for the scene
  110983. */
  110984. environmentTexture: Nullable<BaseTexture>;
  110985. /**
  110986. * @returns all meshes, lights, cameras, transformNodes and bones
  110987. */
  110988. getNodes(): Array<Node>;
  110989. }
  110990. }
  110991. declare module BABYLON {
  110992. /**
  110993. * Interface used to define options for Sound class
  110994. */
  110995. export interface ISoundOptions {
  110996. /**
  110997. * Does the sound autoplay once loaded.
  110998. */
  110999. autoplay?: boolean;
  111000. /**
  111001. * Does the sound loop after it finishes playing once.
  111002. */
  111003. loop?: boolean;
  111004. /**
  111005. * Sound's volume
  111006. */
  111007. volume?: number;
  111008. /**
  111009. * Is it a spatial sound?
  111010. */
  111011. spatialSound?: boolean;
  111012. /**
  111013. * Maximum distance to hear that sound
  111014. */
  111015. maxDistance?: number;
  111016. /**
  111017. * Uses user defined attenuation function
  111018. */
  111019. useCustomAttenuation?: boolean;
  111020. /**
  111021. * Define the roll off factor of spatial sounds.
  111022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111023. */
  111024. rolloffFactor?: number;
  111025. /**
  111026. * Define the reference distance the sound should be heard perfectly.
  111027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111028. */
  111029. refDistance?: number;
  111030. /**
  111031. * Define the distance attenuation model the sound will follow.
  111032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111033. */
  111034. distanceModel?: string;
  111035. /**
  111036. * Defines the playback speed (1 by default)
  111037. */
  111038. playbackRate?: number;
  111039. /**
  111040. * Defines if the sound is from a streaming source
  111041. */
  111042. streaming?: boolean;
  111043. /**
  111044. * Defines an optional length (in seconds) inside the sound file
  111045. */
  111046. length?: number;
  111047. /**
  111048. * Defines an optional offset (in seconds) inside the sound file
  111049. */
  111050. offset?: number;
  111051. /**
  111052. * If true, URLs will not be required to state the audio file codec to use.
  111053. */
  111054. skipCodecCheck?: boolean;
  111055. }
  111056. /**
  111057. * Defines a sound that can be played in the application.
  111058. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  111059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111060. */
  111061. export class Sound {
  111062. /**
  111063. * The name of the sound in the scene.
  111064. */
  111065. name: string;
  111066. /**
  111067. * Does the sound autoplay once loaded.
  111068. */
  111069. autoplay: boolean;
  111070. /**
  111071. * Does the sound loop after it finishes playing once.
  111072. */
  111073. loop: boolean;
  111074. /**
  111075. * Does the sound use a custom attenuation curve to simulate the falloff
  111076. * happening when the source gets further away from the camera.
  111077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111078. */
  111079. useCustomAttenuation: boolean;
  111080. /**
  111081. * The sound track id this sound belongs to.
  111082. */
  111083. soundTrackId: number;
  111084. /**
  111085. * Is this sound currently played.
  111086. */
  111087. isPlaying: boolean;
  111088. /**
  111089. * Is this sound currently paused.
  111090. */
  111091. isPaused: boolean;
  111092. /**
  111093. * Does this sound enables spatial sound.
  111094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111095. */
  111096. spatialSound: boolean;
  111097. /**
  111098. * Define the reference distance the sound should be heard perfectly.
  111099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111100. */
  111101. refDistance: number;
  111102. /**
  111103. * Define the roll off factor of spatial sounds.
  111104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111105. */
  111106. rolloffFactor: number;
  111107. /**
  111108. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111110. */
  111111. maxDistance: number;
  111112. /**
  111113. * Define the distance attenuation model the sound will follow.
  111114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111115. */
  111116. distanceModel: string;
  111117. /**
  111118. * @hidden
  111119. * Back Compat
  111120. **/
  111121. onended: () => any;
  111122. /**
  111123. * Observable event when the current playing sound finishes.
  111124. */
  111125. onEndedObservable: Observable<Sound>;
  111126. private _panningModel;
  111127. private _playbackRate;
  111128. private _streaming;
  111129. private _startTime;
  111130. private _startOffset;
  111131. private _position;
  111132. /** @hidden */
  111133. _positionInEmitterSpace: boolean;
  111134. private _localDirection;
  111135. private _volume;
  111136. private _isReadyToPlay;
  111137. private _isDirectional;
  111138. private _readyToPlayCallback;
  111139. private _audioBuffer;
  111140. private _soundSource;
  111141. private _streamingSource;
  111142. private _soundPanner;
  111143. private _soundGain;
  111144. private _inputAudioNode;
  111145. private _outputAudioNode;
  111146. private _coneInnerAngle;
  111147. private _coneOuterAngle;
  111148. private _coneOuterGain;
  111149. private _scene;
  111150. private _connectedTransformNode;
  111151. private _customAttenuationFunction;
  111152. private _registerFunc;
  111153. private _isOutputConnected;
  111154. private _htmlAudioElement;
  111155. private _urlType;
  111156. private _length?;
  111157. private _offset?;
  111158. /** @hidden */
  111159. static _SceneComponentInitialization: (scene: Scene) => void;
  111160. /**
  111161. * Create a sound and attach it to a scene
  111162. * @param name Name of your sound
  111163. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111164. * @param scene defines the scene the sound belongs to
  111165. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111166. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111167. */
  111168. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111169. /**
  111170. * Release the sound and its associated resources
  111171. */
  111172. dispose(): void;
  111173. /**
  111174. * Gets if the sounds is ready to be played or not.
  111175. * @returns true if ready, otherwise false
  111176. */
  111177. isReady(): boolean;
  111178. private _soundLoaded;
  111179. /**
  111180. * Sets the data of the sound from an audiobuffer
  111181. * @param audioBuffer The audioBuffer containing the data
  111182. */
  111183. setAudioBuffer(audioBuffer: AudioBuffer): void;
  111184. /**
  111185. * Updates the current sounds options such as maxdistance, loop...
  111186. * @param options A JSON object containing values named as the object properties
  111187. */
  111188. updateOptions(options: ISoundOptions): void;
  111189. private _createSpatialParameters;
  111190. private _updateSpatialParameters;
  111191. /**
  111192. * Switch the panning model to HRTF:
  111193. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111195. */
  111196. switchPanningModelToHRTF(): void;
  111197. /**
  111198. * Switch the panning model to Equal Power:
  111199. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111201. */
  111202. switchPanningModelToEqualPower(): void;
  111203. private _switchPanningModel;
  111204. /**
  111205. * Connect this sound to a sound track audio node like gain...
  111206. * @param soundTrackAudioNode the sound track audio node to connect to
  111207. */
  111208. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  111209. /**
  111210. * Transform this sound into a directional source
  111211. * @param coneInnerAngle Size of the inner cone in degree
  111212. * @param coneOuterAngle Size of the outer cone in degree
  111213. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  111214. */
  111215. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  111216. /**
  111217. * Gets or sets the inner angle for the directional cone.
  111218. */
  111219. get directionalConeInnerAngle(): number;
  111220. /**
  111221. * Gets or sets the inner angle for the directional cone.
  111222. */
  111223. set directionalConeInnerAngle(value: number);
  111224. /**
  111225. * Gets or sets the outer angle for the directional cone.
  111226. */
  111227. get directionalConeOuterAngle(): number;
  111228. /**
  111229. * Gets or sets the outer angle for the directional cone.
  111230. */
  111231. set directionalConeOuterAngle(value: number);
  111232. /**
  111233. * Sets the position of the emitter if spatial sound is enabled
  111234. * @param newPosition Defines the new posisiton
  111235. */
  111236. setPosition(newPosition: Vector3): void;
  111237. /**
  111238. * Sets the local direction of the emitter if spatial sound is enabled
  111239. * @param newLocalDirection Defines the new local direction
  111240. */
  111241. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  111242. private _updateDirection;
  111243. /** @hidden */
  111244. updateDistanceFromListener(): void;
  111245. /**
  111246. * Sets a new custom attenuation function for the sound.
  111247. * @param callback Defines the function used for the attenuation
  111248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111249. */
  111250. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  111251. /**
  111252. * Play the sound
  111253. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  111254. * @param offset (optional) Start the sound at a specific time in seconds
  111255. * @param length (optional) Sound duration (in seconds)
  111256. */
  111257. play(time?: number, offset?: number, length?: number): void;
  111258. private _onended;
  111259. /**
  111260. * Stop the sound
  111261. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  111262. */
  111263. stop(time?: number): void;
  111264. /**
  111265. * Put the sound in pause
  111266. */
  111267. pause(): void;
  111268. /**
  111269. * Sets a dedicated volume for this sounds
  111270. * @param newVolume Define the new volume of the sound
  111271. * @param time Define time for gradual change to new volume
  111272. */
  111273. setVolume(newVolume: number, time?: number): void;
  111274. /**
  111275. * Set the sound play back rate
  111276. * @param newPlaybackRate Define the playback rate the sound should be played at
  111277. */
  111278. setPlaybackRate(newPlaybackRate: number): void;
  111279. /**
  111280. * Gets the volume of the sound.
  111281. * @returns the volume of the sound
  111282. */
  111283. getVolume(): number;
  111284. /**
  111285. * Attach the sound to a dedicated mesh
  111286. * @param transformNode The transform node to connect the sound with
  111287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  111288. */
  111289. attachToMesh(transformNode: TransformNode): void;
  111290. /**
  111291. * Detach the sound from the previously attached mesh
  111292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  111293. */
  111294. detachFromMesh(): void;
  111295. private _onRegisterAfterWorldMatrixUpdate;
  111296. /**
  111297. * Clone the current sound in the scene.
  111298. * @returns the new sound clone
  111299. */
  111300. clone(): Nullable<Sound>;
  111301. /**
  111302. * Gets the current underlying audio buffer containing the data
  111303. * @returns the audio buffer
  111304. */
  111305. getAudioBuffer(): Nullable<AudioBuffer>;
  111306. /**
  111307. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  111308. * @returns the source node
  111309. */
  111310. getSoundSource(): Nullable<AudioBufferSourceNode>;
  111311. /**
  111312. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  111313. * @returns the gain node
  111314. */
  111315. getSoundGain(): Nullable<GainNode>;
  111316. /**
  111317. * Serializes the Sound in a JSON representation
  111318. * @returns the JSON representation of the sound
  111319. */
  111320. serialize(): any;
  111321. /**
  111322. * Parse a JSON representation of a sound to innstantiate in a given scene
  111323. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  111324. * @param scene Define the scene the new parsed sound should be created in
  111325. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  111326. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  111327. * @returns the newly parsed sound
  111328. */
  111329. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  111330. }
  111331. }
  111332. declare module BABYLON {
  111333. /**
  111334. * This defines an action helpful to play a defined sound on a triggered action.
  111335. */
  111336. export class PlaySoundAction extends Action {
  111337. private _sound;
  111338. /**
  111339. * Instantiate the action
  111340. * @param triggerOptions defines the trigger options
  111341. * @param sound defines the sound to play
  111342. * @param condition defines the trigger related conditions
  111343. */
  111344. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111345. /** @hidden */
  111346. _prepare(): void;
  111347. /**
  111348. * Execute the action and play the sound.
  111349. */
  111350. execute(): void;
  111351. /**
  111352. * Serializes the actions and its related information.
  111353. * @param parent defines the object to serialize in
  111354. * @returns the serialized object
  111355. */
  111356. serialize(parent: any): any;
  111357. }
  111358. /**
  111359. * This defines an action helpful to stop a defined sound on a triggered action.
  111360. */
  111361. export class StopSoundAction extends Action {
  111362. private _sound;
  111363. /**
  111364. * Instantiate the action
  111365. * @param triggerOptions defines the trigger options
  111366. * @param sound defines the sound to stop
  111367. * @param condition defines the trigger related conditions
  111368. */
  111369. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111370. /** @hidden */
  111371. _prepare(): void;
  111372. /**
  111373. * Execute the action and stop the sound.
  111374. */
  111375. execute(): void;
  111376. /**
  111377. * Serializes the actions and its related information.
  111378. * @param parent defines the object to serialize in
  111379. * @returns the serialized object
  111380. */
  111381. serialize(parent: any): any;
  111382. }
  111383. }
  111384. declare module BABYLON {
  111385. /**
  111386. * This defines an action responsible to change the value of a property
  111387. * by interpolating between its current value and the newly set one once triggered.
  111388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  111389. */
  111390. export class InterpolateValueAction extends Action {
  111391. /**
  111392. * Defines the path of the property where the value should be interpolated
  111393. */
  111394. propertyPath: string;
  111395. /**
  111396. * Defines the target value at the end of the interpolation.
  111397. */
  111398. value: any;
  111399. /**
  111400. * Defines the time it will take for the property to interpolate to the value.
  111401. */
  111402. duration: number;
  111403. /**
  111404. * Defines if the other scene animations should be stopped when the action has been triggered
  111405. */
  111406. stopOtherAnimations?: boolean;
  111407. /**
  111408. * Defines a callback raised once the interpolation animation has been done.
  111409. */
  111410. onInterpolationDone?: () => void;
  111411. /**
  111412. * Observable triggered once the interpolation animation has been done.
  111413. */
  111414. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  111415. private _target;
  111416. private _effectiveTarget;
  111417. private _property;
  111418. /**
  111419. * Instantiate the action
  111420. * @param triggerOptions defines the trigger options
  111421. * @param target defines the object containing the value to interpolate
  111422. * @param propertyPath defines the path to the property in the target object
  111423. * @param value defines the target value at the end of the interpolation
  111424. * @param duration deines the time it will take for the property to interpolate to the value.
  111425. * @param condition defines the trigger related conditions
  111426. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  111427. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  111428. */
  111429. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  111430. /** @hidden */
  111431. _prepare(): void;
  111432. /**
  111433. * Execute the action starts the value interpolation.
  111434. */
  111435. execute(): void;
  111436. /**
  111437. * Serializes the actions and its related information.
  111438. * @param parent defines the object to serialize in
  111439. * @returns the serialized object
  111440. */
  111441. serialize(parent: any): any;
  111442. }
  111443. }
  111444. declare module BABYLON {
  111445. /**
  111446. * Options allowed during the creation of a sound track.
  111447. */
  111448. export interface ISoundTrackOptions {
  111449. /**
  111450. * The volume the sound track should take during creation
  111451. */
  111452. volume?: number;
  111453. /**
  111454. * Define if the sound track is the main sound track of the scene
  111455. */
  111456. mainTrack?: boolean;
  111457. }
  111458. /**
  111459. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  111460. * It will be also used in a future release to apply effects on a specific track.
  111461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111462. */
  111463. export class SoundTrack {
  111464. /**
  111465. * The unique identifier of the sound track in the scene.
  111466. */
  111467. id: number;
  111468. /**
  111469. * The list of sounds included in the sound track.
  111470. */
  111471. soundCollection: Array<Sound>;
  111472. private _outputAudioNode;
  111473. private _scene;
  111474. private _connectedAnalyser;
  111475. private _options;
  111476. private _isInitialized;
  111477. /**
  111478. * Creates a new sound track.
  111479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111480. * @param scene Define the scene the sound track belongs to
  111481. * @param options
  111482. */
  111483. constructor(scene: Scene, options?: ISoundTrackOptions);
  111484. private _initializeSoundTrackAudioGraph;
  111485. /**
  111486. * Release the sound track and its associated resources
  111487. */
  111488. dispose(): void;
  111489. /**
  111490. * Adds a sound to this sound track
  111491. * @param sound define the cound to add
  111492. * @ignoreNaming
  111493. */
  111494. AddSound(sound: Sound): void;
  111495. /**
  111496. * Removes a sound to this sound track
  111497. * @param sound define the cound to remove
  111498. * @ignoreNaming
  111499. */
  111500. RemoveSound(sound: Sound): void;
  111501. /**
  111502. * Set a global volume for the full sound track.
  111503. * @param newVolume Define the new volume of the sound track
  111504. */
  111505. setVolume(newVolume: number): void;
  111506. /**
  111507. * Switch the panning model to HRTF:
  111508. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111510. */
  111511. switchPanningModelToHRTF(): void;
  111512. /**
  111513. * Switch the panning model to Equal Power:
  111514. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111516. */
  111517. switchPanningModelToEqualPower(): void;
  111518. /**
  111519. * Connect the sound track to an audio analyser allowing some amazing
  111520. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  111521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  111522. * @param analyser The analyser to connect to the engine
  111523. */
  111524. connectToAnalyser(analyser: Analyser): void;
  111525. }
  111526. }
  111527. declare module BABYLON {
  111528. interface AbstractScene {
  111529. /**
  111530. * The list of sounds used in the scene.
  111531. */
  111532. sounds: Nullable<Array<Sound>>;
  111533. }
  111534. interface Scene {
  111535. /**
  111536. * @hidden
  111537. * Backing field
  111538. */
  111539. _mainSoundTrack: SoundTrack;
  111540. /**
  111541. * The main sound track played by the scene.
  111542. * It cotains your primary collection of sounds.
  111543. */
  111544. mainSoundTrack: SoundTrack;
  111545. /**
  111546. * The list of sound tracks added to the scene
  111547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111548. */
  111549. soundTracks: Nullable<Array<SoundTrack>>;
  111550. /**
  111551. * Gets a sound using a given name
  111552. * @param name defines the name to search for
  111553. * @return the found sound or null if not found at all.
  111554. */
  111555. getSoundByName(name: string): Nullable<Sound>;
  111556. /**
  111557. * Gets or sets if audio support is enabled
  111558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111559. */
  111560. audioEnabled: boolean;
  111561. /**
  111562. * Gets or sets if audio will be output to headphones
  111563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111564. */
  111565. headphone: boolean;
  111566. /**
  111567. * Gets or sets custom audio listener position provider
  111568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111569. */
  111570. audioListenerPositionProvider: Nullable<() => Vector3>;
  111571. /**
  111572. * Gets or sets a refresh rate when using 3D audio positioning
  111573. */
  111574. audioPositioningRefreshRate: number;
  111575. }
  111576. /**
  111577. * Defines the sound scene component responsible to manage any sounds
  111578. * in a given scene.
  111579. */
  111580. export class AudioSceneComponent implements ISceneSerializableComponent {
  111581. /**
  111582. * The component name helpfull to identify the component in the list of scene components.
  111583. */
  111584. readonly name: string;
  111585. /**
  111586. * The scene the component belongs to.
  111587. */
  111588. scene: Scene;
  111589. private _audioEnabled;
  111590. /**
  111591. * Gets whether audio is enabled or not.
  111592. * Please use related enable/disable method to switch state.
  111593. */
  111594. get audioEnabled(): boolean;
  111595. private _headphone;
  111596. /**
  111597. * Gets whether audio is outputing to headphone or not.
  111598. * Please use the according Switch methods to change output.
  111599. */
  111600. get headphone(): boolean;
  111601. /**
  111602. * Gets or sets a refresh rate when using 3D audio positioning
  111603. */
  111604. audioPositioningRefreshRate: number;
  111605. private _audioListenerPositionProvider;
  111606. /**
  111607. * Gets the current audio listener position provider
  111608. */
  111609. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111610. /**
  111611. * Sets a custom listener position for all sounds in the scene
  111612. * By default, this is the position of the first active camera
  111613. */
  111614. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111615. /**
  111616. * Creates a new instance of the component for the given scene
  111617. * @param scene Defines the scene to register the component in
  111618. */
  111619. constructor(scene: Scene);
  111620. /**
  111621. * Registers the component in a given scene
  111622. */
  111623. register(): void;
  111624. /**
  111625. * Rebuilds the elements related to this component in case of
  111626. * context lost for instance.
  111627. */
  111628. rebuild(): void;
  111629. /**
  111630. * Serializes the component data to the specified json object
  111631. * @param serializationObject The object to serialize to
  111632. */
  111633. serialize(serializationObject: any): void;
  111634. /**
  111635. * Adds all the elements from the container to the scene
  111636. * @param container the container holding the elements
  111637. */
  111638. addFromContainer(container: AbstractScene): void;
  111639. /**
  111640. * Removes all the elements in the container from the scene
  111641. * @param container contains the elements to remove
  111642. * @param dispose if the removed element should be disposed (default: false)
  111643. */
  111644. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111645. /**
  111646. * Disposes the component and the associated ressources.
  111647. */
  111648. dispose(): void;
  111649. /**
  111650. * Disables audio in the associated scene.
  111651. */
  111652. disableAudio(): void;
  111653. /**
  111654. * Enables audio in the associated scene.
  111655. */
  111656. enableAudio(): void;
  111657. /**
  111658. * Switch audio to headphone output.
  111659. */
  111660. switchAudioModeForHeadphones(): void;
  111661. /**
  111662. * Switch audio to normal speakers.
  111663. */
  111664. switchAudioModeForNormalSpeakers(): void;
  111665. private _cachedCameraDirection;
  111666. private _cachedCameraPosition;
  111667. private _lastCheck;
  111668. private _afterRender;
  111669. }
  111670. }
  111671. declare module BABYLON {
  111672. /**
  111673. * Wraps one or more Sound objects and selects one with random weight for playback.
  111674. */
  111675. export class WeightedSound {
  111676. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111677. loop: boolean;
  111678. private _coneInnerAngle;
  111679. private _coneOuterAngle;
  111680. private _volume;
  111681. /** A Sound is currently playing. */
  111682. isPlaying: boolean;
  111683. /** A Sound is currently paused. */
  111684. isPaused: boolean;
  111685. private _sounds;
  111686. private _weights;
  111687. private _currentIndex?;
  111688. /**
  111689. * Creates a new WeightedSound from the list of sounds given.
  111690. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111691. * @param sounds Array of Sounds that will be selected from.
  111692. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111693. */
  111694. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111695. /**
  111696. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111697. */
  111698. get directionalConeInnerAngle(): number;
  111699. /**
  111700. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111701. */
  111702. set directionalConeInnerAngle(value: number);
  111703. /**
  111704. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111705. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111706. */
  111707. get directionalConeOuterAngle(): number;
  111708. /**
  111709. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111710. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111711. */
  111712. set directionalConeOuterAngle(value: number);
  111713. /**
  111714. * Playback volume.
  111715. */
  111716. get volume(): number;
  111717. /**
  111718. * Playback volume.
  111719. */
  111720. set volume(value: number);
  111721. private _onended;
  111722. /**
  111723. * Suspend playback
  111724. */
  111725. pause(): void;
  111726. /**
  111727. * Stop playback
  111728. */
  111729. stop(): void;
  111730. /**
  111731. * Start playback.
  111732. * @param startOffset Position the clip head at a specific time in seconds.
  111733. */
  111734. play(startOffset?: number): void;
  111735. }
  111736. }
  111737. declare module BABYLON {
  111738. /**
  111739. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111741. */
  111742. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111743. /**
  111744. * Gets the name of the behavior.
  111745. */
  111746. get name(): string;
  111747. /**
  111748. * The easing function used by animations
  111749. */
  111750. static EasingFunction: BackEase;
  111751. /**
  111752. * The easing mode used by animations
  111753. */
  111754. static EasingMode: number;
  111755. /**
  111756. * The duration of the animation, in milliseconds
  111757. */
  111758. transitionDuration: number;
  111759. /**
  111760. * Length of the distance animated by the transition when lower radius is reached
  111761. */
  111762. lowerRadiusTransitionRange: number;
  111763. /**
  111764. * Length of the distance animated by the transition when upper radius is reached
  111765. */
  111766. upperRadiusTransitionRange: number;
  111767. private _autoTransitionRange;
  111768. /**
  111769. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111770. */
  111771. get autoTransitionRange(): boolean;
  111772. /**
  111773. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111774. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111775. */
  111776. set autoTransitionRange(value: boolean);
  111777. private _attachedCamera;
  111778. private _onAfterCheckInputsObserver;
  111779. private _onMeshTargetChangedObserver;
  111780. /**
  111781. * Initializes the behavior.
  111782. */
  111783. init(): void;
  111784. /**
  111785. * Attaches the behavior to its arc rotate camera.
  111786. * @param camera Defines the camera to attach the behavior to
  111787. */
  111788. attach(camera: ArcRotateCamera): void;
  111789. /**
  111790. * Detaches the behavior from its current arc rotate camera.
  111791. */
  111792. detach(): void;
  111793. private _radiusIsAnimating;
  111794. private _radiusBounceTransition;
  111795. private _animatables;
  111796. private _cachedWheelPrecision;
  111797. /**
  111798. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111799. * @param radiusLimit The limit to check against.
  111800. * @return Bool to indicate if at limit.
  111801. */
  111802. private _isRadiusAtLimit;
  111803. /**
  111804. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111805. * @param radiusDelta The delta by which to animate to. Can be negative.
  111806. */
  111807. private _applyBoundRadiusAnimation;
  111808. /**
  111809. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111810. */
  111811. protected _clearAnimationLocks(): void;
  111812. /**
  111813. * Stops and removes all animations that have been applied to the camera
  111814. */
  111815. stopAllAnimations(): void;
  111816. }
  111817. }
  111818. declare module BABYLON {
  111819. /**
  111820. * 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.
  111821. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111822. */
  111823. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111824. /**
  111825. * Gets the name of the behavior.
  111826. */
  111827. get name(): string;
  111828. private _mode;
  111829. private _radiusScale;
  111830. private _positionScale;
  111831. private _defaultElevation;
  111832. private _elevationReturnTime;
  111833. private _elevationReturnWaitTime;
  111834. private _zoomStopsAnimation;
  111835. private _framingTime;
  111836. /**
  111837. * The easing function used by animations
  111838. */
  111839. static EasingFunction: ExponentialEase;
  111840. /**
  111841. * The easing mode used by animations
  111842. */
  111843. static EasingMode: number;
  111844. /**
  111845. * Sets the current mode used by the behavior
  111846. */
  111847. set mode(mode: number);
  111848. /**
  111849. * Gets current mode used by the behavior.
  111850. */
  111851. get mode(): number;
  111852. /**
  111853. * Sets the scale applied to the radius (1 by default)
  111854. */
  111855. set radiusScale(radius: number);
  111856. /**
  111857. * Gets the scale applied to the radius
  111858. */
  111859. get radiusScale(): number;
  111860. /**
  111861. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111862. */
  111863. set positionScale(scale: number);
  111864. /**
  111865. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111866. */
  111867. get positionScale(): number;
  111868. /**
  111869. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111870. * behaviour is triggered, in radians.
  111871. */
  111872. set defaultElevation(elevation: number);
  111873. /**
  111874. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111875. * behaviour is triggered, in radians.
  111876. */
  111877. get defaultElevation(): number;
  111878. /**
  111879. * Sets the time (in milliseconds) taken to return to the default beta position.
  111880. * Negative value indicates camera should not return to default.
  111881. */
  111882. set elevationReturnTime(speed: number);
  111883. /**
  111884. * Gets the time (in milliseconds) taken to return to the default beta position.
  111885. * Negative value indicates camera should not return to default.
  111886. */
  111887. get elevationReturnTime(): number;
  111888. /**
  111889. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111890. */
  111891. set elevationReturnWaitTime(time: number);
  111892. /**
  111893. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111894. */
  111895. get elevationReturnWaitTime(): number;
  111896. /**
  111897. * Sets the flag that indicates if user zooming should stop animation.
  111898. */
  111899. set zoomStopsAnimation(flag: boolean);
  111900. /**
  111901. * Gets the flag that indicates if user zooming should stop animation.
  111902. */
  111903. get zoomStopsAnimation(): boolean;
  111904. /**
  111905. * Sets the transition time when framing the mesh, in milliseconds
  111906. */
  111907. set framingTime(time: number);
  111908. /**
  111909. * Gets the transition time when framing the mesh, in milliseconds
  111910. */
  111911. get framingTime(): number;
  111912. /**
  111913. * Define if the behavior should automatically change the configured
  111914. * camera limits and sensibilities.
  111915. */
  111916. autoCorrectCameraLimitsAndSensibility: boolean;
  111917. private _onPrePointerObservableObserver;
  111918. private _onAfterCheckInputsObserver;
  111919. private _onMeshTargetChangedObserver;
  111920. private _attachedCamera;
  111921. private _isPointerDown;
  111922. private _lastInteractionTime;
  111923. /**
  111924. * Initializes the behavior.
  111925. */
  111926. init(): void;
  111927. /**
  111928. * Attaches the behavior to its arc rotate camera.
  111929. * @param camera Defines the camera to attach the behavior to
  111930. */
  111931. attach(camera: ArcRotateCamera): void;
  111932. /**
  111933. * Detaches the behavior from its current arc rotate camera.
  111934. */
  111935. detach(): void;
  111936. private _animatables;
  111937. private _betaIsAnimating;
  111938. private _betaTransition;
  111939. private _radiusTransition;
  111940. private _vectorTransition;
  111941. /**
  111942. * Targets the given mesh and updates zoom level accordingly.
  111943. * @param mesh The mesh to target.
  111944. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111945. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111946. */
  111947. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111948. /**
  111949. * Targets the given mesh with its children and updates zoom level accordingly.
  111950. * @param mesh The mesh to target.
  111951. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111952. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111953. */
  111954. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111955. /**
  111956. * Targets the given meshes with their children and updates zoom level accordingly.
  111957. * @param meshes The mesh to target.
  111958. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111959. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111960. */
  111961. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111962. /**
  111963. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111964. * @param minimumWorld Determines the smaller position of the bounding box extend
  111965. * @param maximumWorld Determines the bigger position of the bounding box extend
  111966. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111967. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111968. */
  111969. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111970. /**
  111971. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111972. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111973. * frustum width.
  111974. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111975. * to fully enclose the mesh in the viewing frustum.
  111976. */
  111977. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111978. /**
  111979. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111980. * is automatically returned to its default position (expected to be above ground plane).
  111981. */
  111982. private _maintainCameraAboveGround;
  111983. /**
  111984. * Returns the frustum slope based on the canvas ratio and camera FOV
  111985. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111986. */
  111987. private _getFrustumSlope;
  111988. /**
  111989. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111990. */
  111991. private _clearAnimationLocks;
  111992. /**
  111993. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111994. */
  111995. private _applyUserInteraction;
  111996. /**
  111997. * Stops and removes all animations that have been applied to the camera
  111998. */
  111999. stopAllAnimations(): void;
  112000. /**
  112001. * Gets a value indicating if the user is moving the camera
  112002. */
  112003. get isUserIsMoving(): boolean;
  112004. /**
  112005. * The camera can move all the way towards the mesh.
  112006. */
  112007. static IgnoreBoundsSizeMode: number;
  112008. /**
  112009. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  112010. */
  112011. static FitFrustumSidesMode: number;
  112012. }
  112013. }
  112014. declare module BABYLON {
  112015. /**
  112016. * Base class for Camera Pointer Inputs.
  112017. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  112018. * for example usage.
  112019. */
  112020. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  112021. /**
  112022. * Defines the camera the input is attached to.
  112023. */
  112024. abstract camera: Camera;
  112025. /**
  112026. * Whether keyboard modifier keys are pressed at time of last mouse event.
  112027. */
  112028. protected _altKey: boolean;
  112029. protected _ctrlKey: boolean;
  112030. protected _metaKey: boolean;
  112031. protected _shiftKey: boolean;
  112032. /**
  112033. * Which mouse buttons were pressed at time of last mouse event.
  112034. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  112035. */
  112036. protected _buttonsPressed: number;
  112037. /**
  112038. * Defines the buttons associated with the input to handle camera move.
  112039. */
  112040. buttons: number[];
  112041. /**
  112042. * Attach the input controls to a specific dom element to get the input from.
  112043. * @param element Defines the element the controls should be listened from
  112044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112045. */
  112046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112047. /**
  112048. * Detach the current controls from the specified dom element.
  112049. * @param element Defines the element to stop listening the inputs from
  112050. */
  112051. detachControl(element: Nullable<HTMLElement>): void;
  112052. /**
  112053. * Gets the class name of the current input.
  112054. * @returns the class name
  112055. */
  112056. getClassName(): string;
  112057. /**
  112058. * Get the friendly name associated with the input class.
  112059. * @returns the input friendly name
  112060. */
  112061. getSimpleName(): string;
  112062. /**
  112063. * Called on pointer POINTERDOUBLETAP event.
  112064. * Override this method to provide functionality on POINTERDOUBLETAP event.
  112065. */
  112066. protected onDoubleTap(type: string): void;
  112067. /**
  112068. * Called on pointer POINTERMOVE event if only a single touch is active.
  112069. * Override this method to provide functionality.
  112070. */
  112071. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112072. /**
  112073. * Called on pointer POINTERMOVE event if multiple touches are active.
  112074. * Override this method to provide functionality.
  112075. */
  112076. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112077. /**
  112078. * Called on JS contextmenu event.
  112079. * Override this method to provide functionality.
  112080. */
  112081. protected onContextMenu(evt: PointerEvent): void;
  112082. /**
  112083. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112084. * press.
  112085. * Override this method to provide functionality.
  112086. */
  112087. protected onButtonDown(evt: PointerEvent): void;
  112088. /**
  112089. * Called each time a new POINTERUP event occurs. Ie, for each button
  112090. * release.
  112091. * Override this method to provide functionality.
  112092. */
  112093. protected onButtonUp(evt: PointerEvent): void;
  112094. /**
  112095. * Called when window becomes inactive.
  112096. * Override this method to provide functionality.
  112097. */
  112098. protected onLostFocus(): void;
  112099. private _pointerInput;
  112100. private _observer;
  112101. private _onLostFocus;
  112102. private pointA;
  112103. private pointB;
  112104. }
  112105. }
  112106. declare module BABYLON {
  112107. /**
  112108. * Manage the pointers inputs to control an arc rotate camera.
  112109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112110. */
  112111. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112112. /**
  112113. * Defines the camera the input is attached to.
  112114. */
  112115. camera: ArcRotateCamera;
  112116. /**
  112117. * Gets the class name of the current input.
  112118. * @returns the class name
  112119. */
  112120. getClassName(): string;
  112121. /**
  112122. * Defines the buttons associated with the input to handle camera move.
  112123. */
  112124. buttons: number[];
  112125. /**
  112126. * Defines the pointer angular sensibility along the X axis or how fast is
  112127. * the camera rotating.
  112128. */
  112129. angularSensibilityX: number;
  112130. /**
  112131. * Defines the pointer angular sensibility along the Y axis or how fast is
  112132. * the camera rotating.
  112133. */
  112134. angularSensibilityY: number;
  112135. /**
  112136. * Defines the pointer pinch precision or how fast is the camera zooming.
  112137. */
  112138. pinchPrecision: number;
  112139. /**
  112140. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112141. * from 0.
  112142. * It defines the percentage of current camera.radius to use as delta when
  112143. * pinch zoom is used.
  112144. */
  112145. pinchDeltaPercentage: number;
  112146. /**
  112147. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112148. * that any object in the plane at the camera's target point will scale
  112149. * perfectly with finger motion.
  112150. * Overrides pinchDeltaPercentage and pinchPrecision.
  112151. */
  112152. useNaturalPinchZoom: boolean;
  112153. /**
  112154. * Defines the pointer panning sensibility or how fast is the camera moving.
  112155. */
  112156. panningSensibility: number;
  112157. /**
  112158. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112159. */
  112160. multiTouchPanning: boolean;
  112161. /**
  112162. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112163. * zoom (pinch) through multitouch.
  112164. */
  112165. multiTouchPanAndZoom: boolean;
  112166. /**
  112167. * Revers pinch action direction.
  112168. */
  112169. pinchInwards: boolean;
  112170. private _isPanClick;
  112171. private _twoFingerActivityCount;
  112172. private _isPinching;
  112173. /**
  112174. * Called on pointer POINTERMOVE event if only a single touch is active.
  112175. */
  112176. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112177. /**
  112178. * Called on pointer POINTERDOUBLETAP event.
  112179. */
  112180. protected onDoubleTap(type: string): void;
  112181. /**
  112182. * Called on pointer POINTERMOVE event if multiple touches are active.
  112183. */
  112184. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112185. /**
  112186. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112187. * press.
  112188. */
  112189. protected onButtonDown(evt: PointerEvent): void;
  112190. /**
  112191. * Called each time a new POINTERUP event occurs. Ie, for each button
  112192. * release.
  112193. */
  112194. protected onButtonUp(evt: PointerEvent): void;
  112195. /**
  112196. * Called when window becomes inactive.
  112197. */
  112198. protected onLostFocus(): void;
  112199. }
  112200. }
  112201. declare module BABYLON {
  112202. /**
  112203. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  112204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112205. */
  112206. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  112207. /**
  112208. * Defines the camera the input is attached to.
  112209. */
  112210. camera: ArcRotateCamera;
  112211. /**
  112212. * Defines the list of key codes associated with the up action (increase alpha)
  112213. */
  112214. keysUp: number[];
  112215. /**
  112216. * Defines the list of key codes associated with the down action (decrease alpha)
  112217. */
  112218. keysDown: number[];
  112219. /**
  112220. * Defines the list of key codes associated with the left action (increase beta)
  112221. */
  112222. keysLeft: number[];
  112223. /**
  112224. * Defines the list of key codes associated with the right action (decrease beta)
  112225. */
  112226. keysRight: number[];
  112227. /**
  112228. * Defines the list of key codes associated with the reset action.
  112229. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  112230. */
  112231. keysReset: number[];
  112232. /**
  112233. * Defines the panning sensibility of the inputs.
  112234. * (How fast is the camera panning)
  112235. */
  112236. panningSensibility: number;
  112237. /**
  112238. * Defines the zooming sensibility of the inputs.
  112239. * (How fast is the camera zooming)
  112240. */
  112241. zoomingSensibility: number;
  112242. /**
  112243. * Defines whether maintaining the alt key down switch the movement mode from
  112244. * orientation to zoom.
  112245. */
  112246. useAltToZoom: boolean;
  112247. /**
  112248. * Rotation speed of the camera
  112249. */
  112250. angularSpeed: number;
  112251. private _keys;
  112252. private _ctrlPressed;
  112253. private _altPressed;
  112254. private _onCanvasBlurObserver;
  112255. private _onKeyboardObserver;
  112256. private _engine;
  112257. private _scene;
  112258. /**
  112259. * Attach the input controls to a specific dom element to get the input from.
  112260. * @param element Defines the element the controls should be listened from
  112261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112262. */
  112263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112264. /**
  112265. * Detach the current controls from the specified dom element.
  112266. * @param element Defines the element to stop listening the inputs from
  112267. */
  112268. detachControl(element: Nullable<HTMLElement>): void;
  112269. /**
  112270. * Update the current camera state depending on the inputs that have been used this frame.
  112271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112272. */
  112273. checkInputs(): void;
  112274. /**
  112275. * Gets the class name of the current intput.
  112276. * @returns the class name
  112277. */
  112278. getClassName(): string;
  112279. /**
  112280. * Get the friendly name associated with the input class.
  112281. * @returns the input friendly name
  112282. */
  112283. getSimpleName(): string;
  112284. }
  112285. }
  112286. declare module BABYLON {
  112287. /**
  112288. * Manage the mouse wheel inputs to control an arc rotate camera.
  112289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112290. */
  112291. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  112292. /**
  112293. * Defines the camera the input is attached to.
  112294. */
  112295. camera: ArcRotateCamera;
  112296. /**
  112297. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112298. */
  112299. wheelPrecision: number;
  112300. /**
  112301. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112302. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112303. */
  112304. wheelDeltaPercentage: number;
  112305. private _wheel;
  112306. private _observer;
  112307. private computeDeltaFromMouseWheelLegacyEvent;
  112308. /**
  112309. * Attach the input controls to a specific dom element to get the input from.
  112310. * @param element Defines the element the controls should be listened from
  112311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112312. */
  112313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112314. /**
  112315. * Detach the current controls from the specified dom element.
  112316. * @param element Defines the element to stop listening the inputs from
  112317. */
  112318. detachControl(element: Nullable<HTMLElement>): void;
  112319. /**
  112320. * Gets the class name of the current intput.
  112321. * @returns the class name
  112322. */
  112323. getClassName(): string;
  112324. /**
  112325. * Get the friendly name associated with the input class.
  112326. * @returns the input friendly name
  112327. */
  112328. getSimpleName(): string;
  112329. }
  112330. }
  112331. declare module BABYLON {
  112332. /**
  112333. * Default Inputs manager for the ArcRotateCamera.
  112334. * It groups all the default supported inputs for ease of use.
  112335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112336. */
  112337. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  112338. /**
  112339. * Instantiates a new ArcRotateCameraInputsManager.
  112340. * @param camera Defines the camera the inputs belong to
  112341. */
  112342. constructor(camera: ArcRotateCamera);
  112343. /**
  112344. * Add mouse wheel input support to the input manager.
  112345. * @returns the current input manager
  112346. */
  112347. addMouseWheel(): ArcRotateCameraInputsManager;
  112348. /**
  112349. * Add pointers input support to the input manager.
  112350. * @returns the current input manager
  112351. */
  112352. addPointers(): ArcRotateCameraInputsManager;
  112353. /**
  112354. * Add keyboard input support to the input manager.
  112355. * @returns the current input manager
  112356. */
  112357. addKeyboard(): ArcRotateCameraInputsManager;
  112358. }
  112359. }
  112360. declare module BABYLON {
  112361. /**
  112362. * This represents an orbital type of camera.
  112363. *
  112364. * 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.
  112365. * 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.
  112366. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  112367. */
  112368. export class ArcRotateCamera extends TargetCamera {
  112369. /**
  112370. * Defines the rotation angle of the camera along the longitudinal axis.
  112371. */
  112372. alpha: number;
  112373. /**
  112374. * Defines the rotation angle of the camera along the latitudinal axis.
  112375. */
  112376. beta: number;
  112377. /**
  112378. * Defines the radius of the camera from it s target point.
  112379. */
  112380. radius: number;
  112381. protected _target: Vector3;
  112382. protected _targetHost: Nullable<AbstractMesh>;
  112383. /**
  112384. * Defines the target point of the camera.
  112385. * The camera looks towards it form the radius distance.
  112386. */
  112387. get target(): Vector3;
  112388. set target(value: Vector3);
  112389. /**
  112390. * Define the current local position of the camera in the scene
  112391. */
  112392. get position(): Vector3;
  112393. set position(newPosition: Vector3);
  112394. protected _upVector: Vector3;
  112395. protected _upToYMatrix: Matrix;
  112396. protected _YToUpMatrix: Matrix;
  112397. /**
  112398. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  112399. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  112400. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  112401. */
  112402. set upVector(vec: Vector3);
  112403. get upVector(): Vector3;
  112404. /**
  112405. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  112406. */
  112407. setMatUp(): void;
  112408. /**
  112409. * Current inertia value on the longitudinal axis.
  112410. * The bigger this number the longer it will take for the camera to stop.
  112411. */
  112412. inertialAlphaOffset: number;
  112413. /**
  112414. * Current inertia value on the latitudinal axis.
  112415. * The bigger this number the longer it will take for the camera to stop.
  112416. */
  112417. inertialBetaOffset: number;
  112418. /**
  112419. * Current inertia value on the radius axis.
  112420. * The bigger this number the longer it will take for the camera to stop.
  112421. */
  112422. inertialRadiusOffset: number;
  112423. /**
  112424. * Minimum allowed angle on the longitudinal axis.
  112425. * This can help limiting how the Camera is able to move in the scene.
  112426. */
  112427. lowerAlphaLimit: Nullable<number>;
  112428. /**
  112429. * Maximum allowed angle on the longitudinal axis.
  112430. * This can help limiting how the Camera is able to move in the scene.
  112431. */
  112432. upperAlphaLimit: Nullable<number>;
  112433. /**
  112434. * Minimum allowed angle on the latitudinal axis.
  112435. * This can help limiting how the Camera is able to move in the scene.
  112436. */
  112437. lowerBetaLimit: number;
  112438. /**
  112439. * Maximum allowed angle on the latitudinal axis.
  112440. * This can help limiting how the Camera is able to move in the scene.
  112441. */
  112442. upperBetaLimit: number;
  112443. /**
  112444. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  112445. * This can help limiting how the Camera is able to move in the scene.
  112446. */
  112447. lowerRadiusLimit: Nullable<number>;
  112448. /**
  112449. * Maximum allowed distance of the camera to the target (The camera can not get further).
  112450. * This can help limiting how the Camera is able to move in the scene.
  112451. */
  112452. upperRadiusLimit: Nullable<number>;
  112453. /**
  112454. * Defines the current inertia value used during panning of the camera along the X axis.
  112455. */
  112456. inertialPanningX: number;
  112457. /**
  112458. * Defines the current inertia value used during panning of the camera along the Y axis.
  112459. */
  112460. inertialPanningY: number;
  112461. /**
  112462. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  112463. * Basically if your fingers moves away from more than this distance you will be considered
  112464. * in pinch mode.
  112465. */
  112466. pinchToPanMaxDistance: number;
  112467. /**
  112468. * Defines the maximum distance the camera can pan.
  112469. * This could help keeping the cammera always in your scene.
  112470. */
  112471. panningDistanceLimit: Nullable<number>;
  112472. /**
  112473. * Defines the target of the camera before paning.
  112474. */
  112475. panningOriginTarget: Vector3;
  112476. /**
  112477. * Defines the value of the inertia used during panning.
  112478. * 0 would mean stop inertia and one would mean no decelleration at all.
  112479. */
  112480. panningInertia: number;
  112481. /**
  112482. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  112483. */
  112484. get angularSensibilityX(): number;
  112485. set angularSensibilityX(value: number);
  112486. /**
  112487. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  112488. */
  112489. get angularSensibilityY(): number;
  112490. set angularSensibilityY(value: number);
  112491. /**
  112492. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  112493. */
  112494. get pinchPrecision(): number;
  112495. set pinchPrecision(value: number);
  112496. /**
  112497. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  112498. * It will be used instead of pinchDeltaPrecision if different from 0.
  112499. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112500. */
  112501. get pinchDeltaPercentage(): number;
  112502. set pinchDeltaPercentage(value: number);
  112503. /**
  112504. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  112505. * and pinch delta percentage.
  112506. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112507. * that any object in the plane at the camera's target point will scale
  112508. * perfectly with finger motion.
  112509. */
  112510. get useNaturalPinchZoom(): boolean;
  112511. set useNaturalPinchZoom(value: boolean);
  112512. /**
  112513. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  112514. */
  112515. get panningSensibility(): number;
  112516. set panningSensibility(value: number);
  112517. /**
  112518. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112519. */
  112520. get keysUp(): number[];
  112521. set keysUp(value: number[]);
  112522. /**
  112523. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112524. */
  112525. get keysDown(): number[];
  112526. set keysDown(value: number[]);
  112527. /**
  112528. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112529. */
  112530. get keysLeft(): number[];
  112531. set keysLeft(value: number[]);
  112532. /**
  112533. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112534. */
  112535. get keysRight(): number[];
  112536. set keysRight(value: number[]);
  112537. /**
  112538. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112539. */
  112540. get wheelPrecision(): number;
  112541. set wheelPrecision(value: number);
  112542. /**
  112543. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112544. * It will be used instead of pinchDeltaPrecision if different from 0.
  112545. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112546. */
  112547. get wheelDeltaPercentage(): number;
  112548. set wheelDeltaPercentage(value: number);
  112549. /**
  112550. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112551. */
  112552. zoomOnFactor: number;
  112553. /**
  112554. * Defines a screen offset for the camera position.
  112555. */
  112556. targetScreenOffset: Vector2;
  112557. /**
  112558. * Allows the camera to be completely reversed.
  112559. * If false the camera can not arrive upside down.
  112560. */
  112561. allowUpsideDown: boolean;
  112562. /**
  112563. * Define if double tap/click is used to restore the previously saved state of the camera.
  112564. */
  112565. useInputToRestoreState: boolean;
  112566. /** @hidden */
  112567. _viewMatrix: Matrix;
  112568. /** @hidden */
  112569. _useCtrlForPanning: boolean;
  112570. /** @hidden */
  112571. _panningMouseButton: number;
  112572. /**
  112573. * Defines the input associated to the camera.
  112574. */
  112575. inputs: ArcRotateCameraInputsManager;
  112576. /** @hidden */
  112577. _reset: () => void;
  112578. /**
  112579. * Defines the allowed panning axis.
  112580. */
  112581. panningAxis: Vector3;
  112582. protected _localDirection: Vector3;
  112583. protected _transformedDirection: Vector3;
  112584. private _bouncingBehavior;
  112585. /**
  112586. * Gets the bouncing behavior of the camera if it has been enabled.
  112587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112588. */
  112589. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112590. /**
  112591. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112592. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112593. */
  112594. get useBouncingBehavior(): boolean;
  112595. set useBouncingBehavior(value: boolean);
  112596. private _framingBehavior;
  112597. /**
  112598. * Gets the framing behavior of the camera if it has been enabled.
  112599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112600. */
  112601. get framingBehavior(): Nullable<FramingBehavior>;
  112602. /**
  112603. * Defines if the framing behavior of the camera is enabled on the camera.
  112604. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112605. */
  112606. get useFramingBehavior(): boolean;
  112607. set useFramingBehavior(value: boolean);
  112608. private _autoRotationBehavior;
  112609. /**
  112610. * Gets the auto rotation behavior of the camera if it has been enabled.
  112611. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112612. */
  112613. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112614. /**
  112615. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112616. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112617. */
  112618. get useAutoRotationBehavior(): boolean;
  112619. set useAutoRotationBehavior(value: boolean);
  112620. /**
  112621. * Observable triggered when the mesh target has been changed on the camera.
  112622. */
  112623. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112624. /**
  112625. * Event raised when the camera is colliding with a mesh.
  112626. */
  112627. onCollide: (collidedMesh: AbstractMesh) => void;
  112628. /**
  112629. * Defines whether the camera should check collision with the objects oh the scene.
  112630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112631. */
  112632. checkCollisions: boolean;
  112633. /**
  112634. * Defines the collision radius of the camera.
  112635. * This simulates a sphere around the camera.
  112636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112637. */
  112638. collisionRadius: Vector3;
  112639. protected _collider: Collider;
  112640. protected _previousPosition: Vector3;
  112641. protected _collisionVelocity: Vector3;
  112642. protected _newPosition: Vector3;
  112643. protected _previousAlpha: number;
  112644. protected _previousBeta: number;
  112645. protected _previousRadius: number;
  112646. protected _collisionTriggered: boolean;
  112647. protected _targetBoundingCenter: Nullable<Vector3>;
  112648. private _computationVector;
  112649. /**
  112650. * Instantiates a new ArcRotateCamera in a given scene
  112651. * @param name Defines the name of the camera
  112652. * @param alpha Defines the camera rotation along the logitudinal axis
  112653. * @param beta Defines the camera rotation along the latitudinal axis
  112654. * @param radius Defines the camera distance from its target
  112655. * @param target Defines the camera target
  112656. * @param scene Defines the scene the camera belongs to
  112657. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112658. */
  112659. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112660. /** @hidden */
  112661. _initCache(): void;
  112662. /** @hidden */
  112663. _updateCache(ignoreParentClass?: boolean): void;
  112664. protected _getTargetPosition(): Vector3;
  112665. private _storedAlpha;
  112666. private _storedBeta;
  112667. private _storedRadius;
  112668. private _storedTarget;
  112669. private _storedTargetScreenOffset;
  112670. /**
  112671. * Stores the current state of the camera (alpha, beta, radius and target)
  112672. * @returns the camera itself
  112673. */
  112674. storeState(): Camera;
  112675. /**
  112676. * @hidden
  112677. * Restored camera state. You must call storeState() first
  112678. */
  112679. _restoreStateValues(): boolean;
  112680. /** @hidden */
  112681. _isSynchronizedViewMatrix(): boolean;
  112682. /**
  112683. * Attached controls to the current camera.
  112684. * @param element Defines the element the controls should be listened from
  112685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112686. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112687. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112688. */
  112689. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112690. /**
  112691. * Detach the current controls from the camera.
  112692. * The camera will stop reacting to inputs.
  112693. * @param element Defines the element to stop listening the inputs from
  112694. */
  112695. detachControl(element: HTMLElement): void;
  112696. /** @hidden */
  112697. _checkInputs(): void;
  112698. protected _checkLimits(): void;
  112699. /**
  112700. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112701. */
  112702. rebuildAnglesAndRadius(): void;
  112703. /**
  112704. * Use a position to define the current camera related information like alpha, beta and radius
  112705. * @param position Defines the position to set the camera at
  112706. */
  112707. setPosition(position: Vector3): void;
  112708. /**
  112709. * Defines the target the camera should look at.
  112710. * This will automatically adapt alpha beta and radius to fit within the new target.
  112711. * @param target Defines the new target as a Vector or a mesh
  112712. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112713. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112714. */
  112715. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112716. /** @hidden */
  112717. _getViewMatrix(): Matrix;
  112718. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112719. /**
  112720. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112721. * @param meshes Defines the mesh to zoom on
  112722. * @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)
  112723. */
  112724. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112725. /**
  112726. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112727. * The target will be changed but the radius
  112728. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112729. * @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)
  112730. */
  112731. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112732. min: Vector3;
  112733. max: Vector3;
  112734. distance: number;
  112735. }, doNotUpdateMaxZ?: boolean): void;
  112736. /**
  112737. * @override
  112738. * Override Camera.createRigCamera
  112739. */
  112740. createRigCamera(name: string, cameraIndex: number): Camera;
  112741. /**
  112742. * @hidden
  112743. * @override
  112744. * Override Camera._updateRigCameras
  112745. */
  112746. _updateRigCameras(): void;
  112747. /**
  112748. * Destroy the camera and release the current resources hold by it.
  112749. */
  112750. dispose(): void;
  112751. /**
  112752. * Gets the current object class name.
  112753. * @return the class name
  112754. */
  112755. getClassName(): string;
  112756. }
  112757. }
  112758. declare module BABYLON {
  112759. /**
  112760. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112762. */
  112763. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112764. /**
  112765. * Gets the name of the behavior.
  112766. */
  112767. get name(): string;
  112768. private _zoomStopsAnimation;
  112769. private _idleRotationSpeed;
  112770. private _idleRotationWaitTime;
  112771. private _idleRotationSpinupTime;
  112772. /**
  112773. * Sets the flag that indicates if user zooming should stop animation.
  112774. */
  112775. set zoomStopsAnimation(flag: boolean);
  112776. /**
  112777. * Gets the flag that indicates if user zooming should stop animation.
  112778. */
  112779. get zoomStopsAnimation(): boolean;
  112780. /**
  112781. * Sets the default speed at which the camera rotates around the model.
  112782. */
  112783. set idleRotationSpeed(speed: number);
  112784. /**
  112785. * Gets the default speed at which the camera rotates around the model.
  112786. */
  112787. get idleRotationSpeed(): number;
  112788. /**
  112789. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112790. */
  112791. set idleRotationWaitTime(time: number);
  112792. /**
  112793. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112794. */
  112795. get idleRotationWaitTime(): number;
  112796. /**
  112797. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112798. */
  112799. set idleRotationSpinupTime(time: number);
  112800. /**
  112801. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112802. */
  112803. get idleRotationSpinupTime(): number;
  112804. /**
  112805. * Gets a value indicating if the camera is currently rotating because of this behavior
  112806. */
  112807. get rotationInProgress(): boolean;
  112808. private _onPrePointerObservableObserver;
  112809. private _onAfterCheckInputsObserver;
  112810. private _attachedCamera;
  112811. private _isPointerDown;
  112812. private _lastFrameTime;
  112813. private _lastInteractionTime;
  112814. private _cameraRotationSpeed;
  112815. /**
  112816. * Initializes the behavior.
  112817. */
  112818. init(): void;
  112819. /**
  112820. * Attaches the behavior to its arc rotate camera.
  112821. * @param camera Defines the camera to attach the behavior to
  112822. */
  112823. attach(camera: ArcRotateCamera): void;
  112824. /**
  112825. * Detaches the behavior from its current arc rotate camera.
  112826. */
  112827. detach(): void;
  112828. /**
  112829. * Returns true if user is scrolling.
  112830. * @return true if user is scrolling.
  112831. */
  112832. private _userIsZooming;
  112833. private _lastFrameRadius;
  112834. private _shouldAnimationStopForInteraction;
  112835. /**
  112836. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112837. */
  112838. private _applyUserInteraction;
  112839. private _userIsMoving;
  112840. }
  112841. }
  112842. declare module BABYLON {
  112843. /**
  112844. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112845. */
  112846. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112847. private ui;
  112848. /**
  112849. * The name of the behavior
  112850. */
  112851. name: string;
  112852. /**
  112853. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112854. */
  112855. distanceAwayFromFace: number;
  112856. /**
  112857. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112858. */
  112859. distanceAwayFromBottomOfFace: number;
  112860. private _faceVectors;
  112861. private _target;
  112862. private _scene;
  112863. private _onRenderObserver;
  112864. private _tmpMatrix;
  112865. private _tmpVector;
  112866. /**
  112867. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112868. * @param ui The transform node that should be attched to the mesh
  112869. */
  112870. constructor(ui: TransformNode);
  112871. /**
  112872. * Initializes the behavior
  112873. */
  112874. init(): void;
  112875. private _closestFace;
  112876. private _zeroVector;
  112877. private _lookAtTmpMatrix;
  112878. private _lookAtToRef;
  112879. /**
  112880. * Attaches the AttachToBoxBehavior to the passed in mesh
  112881. * @param target The mesh that the specified node will be attached to
  112882. */
  112883. attach(target: Mesh): void;
  112884. /**
  112885. * Detaches the behavior from the mesh
  112886. */
  112887. detach(): void;
  112888. }
  112889. }
  112890. declare module BABYLON {
  112891. /**
  112892. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112893. */
  112894. export class FadeInOutBehavior implements Behavior<Mesh> {
  112895. /**
  112896. * Time in milliseconds to delay before fading in (Default: 0)
  112897. */
  112898. delay: number;
  112899. /**
  112900. * Time in milliseconds for the mesh to fade in (Default: 300)
  112901. */
  112902. fadeInTime: number;
  112903. private _millisecondsPerFrame;
  112904. private _hovered;
  112905. private _hoverValue;
  112906. private _ownerNode;
  112907. /**
  112908. * Instatiates the FadeInOutBehavior
  112909. */
  112910. constructor();
  112911. /**
  112912. * The name of the behavior
  112913. */
  112914. get name(): string;
  112915. /**
  112916. * Initializes the behavior
  112917. */
  112918. init(): void;
  112919. /**
  112920. * Attaches the fade behavior on the passed in mesh
  112921. * @param ownerNode The mesh that will be faded in/out once attached
  112922. */
  112923. attach(ownerNode: Mesh): void;
  112924. /**
  112925. * Detaches the behavior from the mesh
  112926. */
  112927. detach(): void;
  112928. /**
  112929. * Triggers the mesh to begin fading in or out
  112930. * @param value if the object should fade in or out (true to fade in)
  112931. */
  112932. fadeIn(value: boolean): void;
  112933. private _update;
  112934. private _setAllVisibility;
  112935. }
  112936. }
  112937. declare module BABYLON {
  112938. /**
  112939. * Class containing a set of static utilities functions for managing Pivots
  112940. * @hidden
  112941. */
  112942. export class PivotTools {
  112943. private static _PivotCached;
  112944. private static _OldPivotPoint;
  112945. private static _PivotTranslation;
  112946. private static _PivotTmpVector;
  112947. /** @hidden */
  112948. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112949. /** @hidden */
  112950. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112951. }
  112952. }
  112953. declare module BABYLON {
  112954. /**
  112955. * Class containing static functions to help procedurally build meshes
  112956. */
  112957. export class PlaneBuilder {
  112958. /**
  112959. * Creates a plane mesh
  112960. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112961. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112962. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112966. * @param name defines the name of the mesh
  112967. * @param options defines the options used to create the mesh
  112968. * @param scene defines the hosting scene
  112969. * @returns the plane mesh
  112970. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112971. */
  112972. static CreatePlane(name: string, options: {
  112973. size?: number;
  112974. width?: number;
  112975. height?: number;
  112976. sideOrientation?: number;
  112977. frontUVs?: Vector4;
  112978. backUVs?: Vector4;
  112979. updatable?: boolean;
  112980. sourcePlane?: Plane;
  112981. }, scene?: Nullable<Scene>): Mesh;
  112982. }
  112983. }
  112984. declare module BABYLON {
  112985. /**
  112986. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112987. */
  112988. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112989. private static _AnyMouseID;
  112990. /**
  112991. * Abstract mesh the behavior is set on
  112992. */
  112993. attachedNode: AbstractMesh;
  112994. private _dragPlane;
  112995. private _scene;
  112996. private _pointerObserver;
  112997. private _beforeRenderObserver;
  112998. private static _planeScene;
  112999. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  113000. /**
  113001. * 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)
  113002. */
  113003. maxDragAngle: number;
  113004. /**
  113005. * @hidden
  113006. */
  113007. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  113008. /**
  113009. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113010. */
  113011. currentDraggingPointerID: number;
  113012. /**
  113013. * The last position where the pointer hit the drag plane in world space
  113014. */
  113015. lastDragPosition: Vector3;
  113016. /**
  113017. * If the behavior is currently in a dragging state
  113018. */
  113019. dragging: boolean;
  113020. /**
  113021. * 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)
  113022. */
  113023. dragDeltaRatio: number;
  113024. /**
  113025. * If the drag plane orientation should be updated during the dragging (Default: true)
  113026. */
  113027. updateDragPlane: boolean;
  113028. private _debugMode;
  113029. private _moving;
  113030. /**
  113031. * Fires each time the attached mesh is dragged with the pointer
  113032. * * delta between last drag position and current drag position in world space
  113033. * * dragDistance along the drag axis
  113034. * * dragPlaneNormal normal of the current drag plane used during the drag
  113035. * * dragPlanePoint in world space where the drag intersects the drag plane
  113036. */
  113037. onDragObservable: Observable<{
  113038. delta: Vector3;
  113039. dragPlanePoint: Vector3;
  113040. dragPlaneNormal: Vector3;
  113041. dragDistance: number;
  113042. pointerId: number;
  113043. }>;
  113044. /**
  113045. * Fires each time a drag begins (eg. mouse down on mesh)
  113046. */
  113047. onDragStartObservable: Observable<{
  113048. dragPlanePoint: Vector3;
  113049. pointerId: number;
  113050. }>;
  113051. /**
  113052. * Fires each time a drag ends (eg. mouse release after drag)
  113053. */
  113054. onDragEndObservable: Observable<{
  113055. dragPlanePoint: Vector3;
  113056. pointerId: number;
  113057. }>;
  113058. /**
  113059. * If the attached mesh should be moved when dragged
  113060. */
  113061. moveAttached: boolean;
  113062. /**
  113063. * If the drag behavior will react to drag events (Default: true)
  113064. */
  113065. enabled: boolean;
  113066. /**
  113067. * If pointer events should start and release the drag (Default: true)
  113068. */
  113069. startAndReleaseDragOnPointerEvents: boolean;
  113070. /**
  113071. * If camera controls should be detached during the drag
  113072. */
  113073. detachCameraControls: boolean;
  113074. /**
  113075. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  113076. */
  113077. useObjectOrientationForDragging: boolean;
  113078. private _options;
  113079. /**
  113080. * Gets the options used by the behavior
  113081. */
  113082. get options(): {
  113083. dragAxis?: Vector3;
  113084. dragPlaneNormal?: Vector3;
  113085. };
  113086. /**
  113087. * Sets the options used by the behavior
  113088. */
  113089. set options(options: {
  113090. dragAxis?: Vector3;
  113091. dragPlaneNormal?: Vector3;
  113092. });
  113093. /**
  113094. * Creates a pointer drag behavior that can be attached to a mesh
  113095. * @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)
  113096. */
  113097. constructor(options?: {
  113098. dragAxis?: Vector3;
  113099. dragPlaneNormal?: Vector3;
  113100. });
  113101. /**
  113102. * Predicate to determine if it is valid to move the object to a new position when it is moved
  113103. */
  113104. validateDrag: (targetPosition: Vector3) => boolean;
  113105. /**
  113106. * The name of the behavior
  113107. */
  113108. get name(): string;
  113109. /**
  113110. * Initializes the behavior
  113111. */
  113112. init(): void;
  113113. private _tmpVector;
  113114. private _alternatePickedPoint;
  113115. private _worldDragAxis;
  113116. private _targetPosition;
  113117. private _attachedElement;
  113118. /**
  113119. * Attaches the drag behavior the passed in mesh
  113120. * @param ownerNode The mesh that will be dragged around once attached
  113121. * @param predicate Predicate to use for pick filtering
  113122. */
  113123. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113124. /**
  113125. * Force relase the drag action by code.
  113126. */
  113127. releaseDrag(): void;
  113128. private _startDragRay;
  113129. private _lastPointerRay;
  113130. /**
  113131. * Simulates the start of a pointer drag event on the behavior
  113132. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113133. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113134. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113135. */
  113136. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113137. private _startDrag;
  113138. private _dragDelta;
  113139. private _moveDrag;
  113140. private _pickWithRayOnDragPlane;
  113141. private _pointA;
  113142. private _pointB;
  113143. private _pointC;
  113144. private _lineA;
  113145. private _lineB;
  113146. private _localAxis;
  113147. private _lookAt;
  113148. private _updateDragPlanePosition;
  113149. /**
  113150. * Detaches the behavior from the mesh
  113151. */
  113152. detach(): void;
  113153. }
  113154. }
  113155. declare module BABYLON {
  113156. /**
  113157. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113158. */
  113159. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113160. private _dragBehaviorA;
  113161. private _dragBehaviorB;
  113162. private _startDistance;
  113163. private _initialScale;
  113164. private _targetScale;
  113165. private _ownerNode;
  113166. private _sceneRenderObserver;
  113167. /**
  113168. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113169. */
  113170. constructor();
  113171. /**
  113172. * The name of the behavior
  113173. */
  113174. get name(): string;
  113175. /**
  113176. * Initializes the behavior
  113177. */
  113178. init(): void;
  113179. private _getCurrentDistance;
  113180. /**
  113181. * Attaches the scale behavior the passed in mesh
  113182. * @param ownerNode The mesh that will be scaled around once attached
  113183. */
  113184. attach(ownerNode: Mesh): void;
  113185. /**
  113186. * Detaches the behavior from the mesh
  113187. */
  113188. detach(): void;
  113189. }
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * 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
  113194. */
  113195. export class SixDofDragBehavior implements Behavior<Mesh> {
  113196. private static _virtualScene;
  113197. private _ownerNode;
  113198. private _sceneRenderObserver;
  113199. private _scene;
  113200. private _targetPosition;
  113201. private _virtualOriginMesh;
  113202. private _virtualDragMesh;
  113203. private _pointerObserver;
  113204. private _moving;
  113205. private _startingOrientation;
  113206. /**
  113207. * 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)
  113208. */
  113209. private zDragFactor;
  113210. /**
  113211. * If the object should rotate to face the drag origin
  113212. */
  113213. rotateDraggedObject: boolean;
  113214. /**
  113215. * If the behavior is currently in a dragging state
  113216. */
  113217. dragging: boolean;
  113218. /**
  113219. * 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)
  113220. */
  113221. dragDeltaRatio: number;
  113222. /**
  113223. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113224. */
  113225. currentDraggingPointerID: number;
  113226. /**
  113227. * If camera controls should be detached during the drag
  113228. */
  113229. detachCameraControls: boolean;
  113230. /**
  113231. * Fires each time a drag starts
  113232. */
  113233. onDragStartObservable: Observable<{}>;
  113234. /**
  113235. * Fires each time a drag ends (eg. mouse release after drag)
  113236. */
  113237. onDragEndObservable: Observable<{}>;
  113238. /**
  113239. * 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
  113240. */
  113241. constructor();
  113242. /**
  113243. * The name of the behavior
  113244. */
  113245. get name(): string;
  113246. /**
  113247. * Initializes the behavior
  113248. */
  113249. init(): void;
  113250. /**
  113251. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  113252. */
  113253. private get _pointerCamera();
  113254. /**
  113255. * Attaches the scale behavior the passed in mesh
  113256. * @param ownerNode The mesh that will be scaled around once attached
  113257. */
  113258. attach(ownerNode: Mesh): void;
  113259. /**
  113260. * Detaches the behavior from the mesh
  113261. */
  113262. detach(): void;
  113263. }
  113264. }
  113265. declare module BABYLON {
  113266. /**
  113267. * Class used to apply inverse kinematics to bones
  113268. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  113269. */
  113270. export class BoneIKController {
  113271. private static _tmpVecs;
  113272. private static _tmpQuat;
  113273. private static _tmpMats;
  113274. /**
  113275. * Gets or sets the target mesh
  113276. */
  113277. targetMesh: AbstractMesh;
  113278. /** Gets or sets the mesh used as pole */
  113279. poleTargetMesh: AbstractMesh;
  113280. /**
  113281. * Gets or sets the bone used as pole
  113282. */
  113283. poleTargetBone: Nullable<Bone>;
  113284. /**
  113285. * Gets or sets the target position
  113286. */
  113287. targetPosition: Vector3;
  113288. /**
  113289. * Gets or sets the pole target position
  113290. */
  113291. poleTargetPosition: Vector3;
  113292. /**
  113293. * Gets or sets the pole target local offset
  113294. */
  113295. poleTargetLocalOffset: Vector3;
  113296. /**
  113297. * Gets or sets the pole angle
  113298. */
  113299. poleAngle: number;
  113300. /**
  113301. * Gets or sets the mesh associated with the controller
  113302. */
  113303. mesh: AbstractMesh;
  113304. /**
  113305. * 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)
  113306. */
  113307. slerpAmount: number;
  113308. private _bone1Quat;
  113309. private _bone1Mat;
  113310. private _bone2Ang;
  113311. private _bone1;
  113312. private _bone2;
  113313. private _bone1Length;
  113314. private _bone2Length;
  113315. private _maxAngle;
  113316. private _maxReach;
  113317. private _rightHandedSystem;
  113318. private _bendAxis;
  113319. private _slerping;
  113320. private _adjustRoll;
  113321. /**
  113322. * Gets or sets maximum allowed angle
  113323. */
  113324. get maxAngle(): number;
  113325. set maxAngle(value: number);
  113326. /**
  113327. * Creates a new BoneIKController
  113328. * @param mesh defines the mesh to control
  113329. * @param bone defines the bone to control
  113330. * @param options defines options to set up the controller
  113331. */
  113332. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  113333. targetMesh?: AbstractMesh;
  113334. poleTargetMesh?: AbstractMesh;
  113335. poleTargetBone?: Bone;
  113336. poleTargetLocalOffset?: Vector3;
  113337. poleAngle?: number;
  113338. bendAxis?: Vector3;
  113339. maxAngle?: number;
  113340. slerpAmount?: number;
  113341. });
  113342. private _setMaxAngle;
  113343. /**
  113344. * Force the controller to update the bones
  113345. */
  113346. update(): void;
  113347. }
  113348. }
  113349. declare module BABYLON {
  113350. /**
  113351. * Class used to make a bone look toward a point in space
  113352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  113353. */
  113354. export class BoneLookController {
  113355. private static _tmpVecs;
  113356. private static _tmpQuat;
  113357. private static _tmpMats;
  113358. /**
  113359. * The target Vector3 that the bone will look at
  113360. */
  113361. target: Vector3;
  113362. /**
  113363. * The mesh that the bone is attached to
  113364. */
  113365. mesh: AbstractMesh;
  113366. /**
  113367. * The bone that will be looking to the target
  113368. */
  113369. bone: Bone;
  113370. /**
  113371. * The up axis of the coordinate system that is used when the bone is rotated
  113372. */
  113373. upAxis: Vector3;
  113374. /**
  113375. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  113376. */
  113377. upAxisSpace: Space;
  113378. /**
  113379. * Used to make an adjustment to the yaw of the bone
  113380. */
  113381. adjustYaw: number;
  113382. /**
  113383. * Used to make an adjustment to the pitch of the bone
  113384. */
  113385. adjustPitch: number;
  113386. /**
  113387. * Used to make an adjustment to the roll of the bone
  113388. */
  113389. adjustRoll: number;
  113390. /**
  113391. * 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)
  113392. */
  113393. slerpAmount: number;
  113394. private _minYaw;
  113395. private _maxYaw;
  113396. private _minPitch;
  113397. private _maxPitch;
  113398. private _minYawSin;
  113399. private _minYawCos;
  113400. private _maxYawSin;
  113401. private _maxYawCos;
  113402. private _midYawConstraint;
  113403. private _minPitchTan;
  113404. private _maxPitchTan;
  113405. private _boneQuat;
  113406. private _slerping;
  113407. private _transformYawPitch;
  113408. private _transformYawPitchInv;
  113409. private _firstFrameSkipped;
  113410. private _yawRange;
  113411. private _fowardAxis;
  113412. /**
  113413. * Gets or sets the minimum yaw angle that the bone can look to
  113414. */
  113415. get minYaw(): number;
  113416. set minYaw(value: number);
  113417. /**
  113418. * Gets or sets the maximum yaw angle that the bone can look to
  113419. */
  113420. get maxYaw(): number;
  113421. set maxYaw(value: number);
  113422. /**
  113423. * Gets or sets the minimum pitch angle that the bone can look to
  113424. */
  113425. get minPitch(): number;
  113426. set minPitch(value: number);
  113427. /**
  113428. * Gets or sets the maximum pitch angle that the bone can look to
  113429. */
  113430. get maxPitch(): number;
  113431. set maxPitch(value: number);
  113432. /**
  113433. * Create a BoneLookController
  113434. * @param mesh the mesh that the bone belongs to
  113435. * @param bone the bone that will be looking to the target
  113436. * @param target the target Vector3 to look at
  113437. * @param options optional settings:
  113438. * * maxYaw: the maximum angle the bone will yaw to
  113439. * * minYaw: the minimum angle the bone will yaw to
  113440. * * maxPitch: the maximum angle the bone will pitch to
  113441. * * minPitch: the minimum angle the bone will yaw to
  113442. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  113443. * * upAxis: the up axis of the coordinate system
  113444. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  113445. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  113446. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  113447. * * adjustYaw: used to make an adjustment to the yaw of the bone
  113448. * * adjustPitch: used to make an adjustment to the pitch of the bone
  113449. * * adjustRoll: used to make an adjustment to the roll of the bone
  113450. **/
  113451. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  113452. maxYaw?: number;
  113453. minYaw?: number;
  113454. maxPitch?: number;
  113455. minPitch?: number;
  113456. slerpAmount?: number;
  113457. upAxis?: Vector3;
  113458. upAxisSpace?: Space;
  113459. yawAxis?: Vector3;
  113460. pitchAxis?: Vector3;
  113461. adjustYaw?: number;
  113462. adjustPitch?: number;
  113463. adjustRoll?: number;
  113464. });
  113465. /**
  113466. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  113467. */
  113468. update(): void;
  113469. private _getAngleDiff;
  113470. private _getAngleBetween;
  113471. private _isAngleBetween;
  113472. }
  113473. }
  113474. declare module BABYLON {
  113475. /**
  113476. * Manage the gamepad inputs to control an arc rotate camera.
  113477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113478. */
  113479. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  113480. /**
  113481. * Defines the camera the input is attached to.
  113482. */
  113483. camera: ArcRotateCamera;
  113484. /**
  113485. * Defines the gamepad the input is gathering event from.
  113486. */
  113487. gamepad: Nullable<Gamepad>;
  113488. /**
  113489. * Defines the gamepad rotation sensiblity.
  113490. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113491. */
  113492. gamepadRotationSensibility: number;
  113493. /**
  113494. * Defines the gamepad move sensiblity.
  113495. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113496. */
  113497. gamepadMoveSensibility: number;
  113498. private _yAxisScale;
  113499. /**
  113500. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113501. */
  113502. get invertYAxis(): boolean;
  113503. set invertYAxis(value: boolean);
  113504. private _onGamepadConnectedObserver;
  113505. private _onGamepadDisconnectedObserver;
  113506. /**
  113507. * Attach the input controls to a specific dom element to get the input from.
  113508. * @param element Defines the element the controls should be listened from
  113509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113510. */
  113511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113512. /**
  113513. * Detach the current controls from the specified dom element.
  113514. * @param element Defines the element to stop listening the inputs from
  113515. */
  113516. detachControl(element: Nullable<HTMLElement>): void;
  113517. /**
  113518. * Update the current camera state depending on the inputs that have been used this frame.
  113519. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113520. */
  113521. checkInputs(): void;
  113522. /**
  113523. * Gets the class name of the current intput.
  113524. * @returns the class name
  113525. */
  113526. getClassName(): string;
  113527. /**
  113528. * Get the friendly name associated with the input class.
  113529. * @returns the input friendly name
  113530. */
  113531. getSimpleName(): string;
  113532. }
  113533. }
  113534. declare module BABYLON {
  113535. interface ArcRotateCameraInputsManager {
  113536. /**
  113537. * Add orientation input support to the input manager.
  113538. * @returns the current input manager
  113539. */
  113540. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113541. }
  113542. /**
  113543. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113545. */
  113546. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113547. /**
  113548. * Defines the camera the input is attached to.
  113549. */
  113550. camera: ArcRotateCamera;
  113551. /**
  113552. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113553. */
  113554. alphaCorrection: number;
  113555. /**
  113556. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113557. */
  113558. gammaCorrection: number;
  113559. private _alpha;
  113560. private _gamma;
  113561. private _dirty;
  113562. private _deviceOrientationHandler;
  113563. /**
  113564. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113565. */
  113566. constructor();
  113567. /**
  113568. * Attach the input controls to a specific dom element to get the input from.
  113569. * @param element Defines the element the controls should be listened from
  113570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113571. */
  113572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113573. /** @hidden */
  113574. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113575. /**
  113576. * Update the current camera state depending on the inputs that have been used this frame.
  113577. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113578. */
  113579. checkInputs(): void;
  113580. /**
  113581. * Detach the current controls from the specified dom element.
  113582. * @param element Defines the element to stop listening the inputs from
  113583. */
  113584. detachControl(element: Nullable<HTMLElement>): void;
  113585. /**
  113586. * Gets the class name of the current intput.
  113587. * @returns the class name
  113588. */
  113589. getClassName(): string;
  113590. /**
  113591. * Get the friendly name associated with the input class.
  113592. * @returns the input friendly name
  113593. */
  113594. getSimpleName(): string;
  113595. }
  113596. }
  113597. declare module BABYLON {
  113598. /**
  113599. * Listen to mouse events to control the camera.
  113600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113601. */
  113602. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113603. /**
  113604. * Defines the camera the input is attached to.
  113605. */
  113606. camera: FlyCamera;
  113607. /**
  113608. * Defines if touch is enabled. (Default is true.)
  113609. */
  113610. touchEnabled: boolean;
  113611. /**
  113612. * Defines the buttons associated with the input to handle camera rotation.
  113613. */
  113614. buttons: number[];
  113615. /**
  113616. * Assign buttons for Yaw control.
  113617. */
  113618. buttonsYaw: number[];
  113619. /**
  113620. * Assign buttons for Pitch control.
  113621. */
  113622. buttonsPitch: number[];
  113623. /**
  113624. * Assign buttons for Roll control.
  113625. */
  113626. buttonsRoll: number[];
  113627. /**
  113628. * Detect if any button is being pressed while mouse is moved.
  113629. * -1 = Mouse locked.
  113630. * 0 = Left button.
  113631. * 1 = Middle Button.
  113632. * 2 = Right Button.
  113633. */
  113634. activeButton: number;
  113635. /**
  113636. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113637. * Higher values reduce its sensitivity.
  113638. */
  113639. angularSensibility: number;
  113640. private _mousemoveCallback;
  113641. private _observer;
  113642. private _rollObserver;
  113643. private previousPosition;
  113644. private noPreventDefault;
  113645. private element;
  113646. /**
  113647. * Listen to mouse events to control the camera.
  113648. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113650. */
  113651. constructor(touchEnabled?: boolean);
  113652. /**
  113653. * Attach the mouse control to the HTML DOM element.
  113654. * @param element Defines the element that listens to the input events.
  113655. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113656. */
  113657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113658. /**
  113659. * Detach the current controls from the specified dom element.
  113660. * @param element Defines the element to stop listening the inputs from
  113661. */
  113662. detachControl(element: Nullable<HTMLElement>): void;
  113663. /**
  113664. * Gets the class name of the current input.
  113665. * @returns the class name.
  113666. */
  113667. getClassName(): string;
  113668. /**
  113669. * Get the friendly name associated with the input class.
  113670. * @returns the input's friendly name.
  113671. */
  113672. getSimpleName(): string;
  113673. private _pointerInput;
  113674. private _onMouseMove;
  113675. /**
  113676. * Rotate camera by mouse offset.
  113677. */
  113678. private rotateCamera;
  113679. }
  113680. }
  113681. declare module BABYLON {
  113682. /**
  113683. * Default Inputs manager for the FlyCamera.
  113684. * It groups all the default supported inputs for ease of use.
  113685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113686. */
  113687. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113688. /**
  113689. * Instantiates a new FlyCameraInputsManager.
  113690. * @param camera Defines the camera the inputs belong to.
  113691. */
  113692. constructor(camera: FlyCamera);
  113693. /**
  113694. * Add keyboard input support to the input manager.
  113695. * @returns the new FlyCameraKeyboardMoveInput().
  113696. */
  113697. addKeyboard(): FlyCameraInputsManager;
  113698. /**
  113699. * Add mouse input support to the input manager.
  113700. * @param touchEnabled Enable touch screen support.
  113701. * @returns the new FlyCameraMouseInput().
  113702. */
  113703. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113704. }
  113705. }
  113706. declare module BABYLON {
  113707. /**
  113708. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113709. * such as in a 3D Space Shooter or a Flight Simulator.
  113710. */
  113711. export class FlyCamera extends TargetCamera {
  113712. /**
  113713. * Define the collision ellipsoid of the camera.
  113714. * This is helpful for simulating a camera body, like a player's body.
  113715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113716. */
  113717. ellipsoid: Vector3;
  113718. /**
  113719. * Define an offset for the position of the ellipsoid around the camera.
  113720. * This can be helpful if the camera is attached away from the player's body center,
  113721. * such as at its head.
  113722. */
  113723. ellipsoidOffset: Vector3;
  113724. /**
  113725. * Enable or disable collisions of the camera with the rest of the scene objects.
  113726. */
  113727. checkCollisions: boolean;
  113728. /**
  113729. * Enable or disable gravity on the camera.
  113730. */
  113731. applyGravity: boolean;
  113732. /**
  113733. * Define the current direction the camera is moving to.
  113734. */
  113735. cameraDirection: Vector3;
  113736. /**
  113737. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113738. * This overrides and empties cameraRotation.
  113739. */
  113740. rotationQuaternion: Quaternion;
  113741. /**
  113742. * Track Roll to maintain the wanted Rolling when looking around.
  113743. */
  113744. _trackRoll: number;
  113745. /**
  113746. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113747. */
  113748. rollCorrect: number;
  113749. /**
  113750. * Mimic a banked turn, Rolling the camera when Yawing.
  113751. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113752. */
  113753. bankedTurn: boolean;
  113754. /**
  113755. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113756. */
  113757. bankedTurnLimit: number;
  113758. /**
  113759. * Value of 0 disables the banked Roll.
  113760. * Value of 1 is equal to the Yaw angle in radians.
  113761. */
  113762. bankedTurnMultiplier: number;
  113763. /**
  113764. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113765. */
  113766. inputs: FlyCameraInputsManager;
  113767. /**
  113768. * Gets the input sensibility for mouse input.
  113769. * Higher values reduce sensitivity.
  113770. */
  113771. get angularSensibility(): number;
  113772. /**
  113773. * Sets the input sensibility for a mouse input.
  113774. * Higher values reduce sensitivity.
  113775. */
  113776. set angularSensibility(value: number);
  113777. /**
  113778. * Get the keys for camera movement forward.
  113779. */
  113780. get keysForward(): number[];
  113781. /**
  113782. * Set the keys for camera movement forward.
  113783. */
  113784. set keysForward(value: number[]);
  113785. /**
  113786. * Get the keys for camera movement backward.
  113787. */
  113788. get keysBackward(): number[];
  113789. set keysBackward(value: number[]);
  113790. /**
  113791. * Get the keys for camera movement up.
  113792. */
  113793. get keysUp(): number[];
  113794. /**
  113795. * Set the keys for camera movement up.
  113796. */
  113797. set keysUp(value: number[]);
  113798. /**
  113799. * Get the keys for camera movement down.
  113800. */
  113801. get keysDown(): number[];
  113802. /**
  113803. * Set the keys for camera movement down.
  113804. */
  113805. set keysDown(value: number[]);
  113806. /**
  113807. * Get the keys for camera movement left.
  113808. */
  113809. get keysLeft(): number[];
  113810. /**
  113811. * Set the keys for camera movement left.
  113812. */
  113813. set keysLeft(value: number[]);
  113814. /**
  113815. * Set the keys for camera movement right.
  113816. */
  113817. get keysRight(): number[];
  113818. /**
  113819. * Set the keys for camera movement right.
  113820. */
  113821. set keysRight(value: number[]);
  113822. /**
  113823. * Event raised when the camera collides with a mesh in the scene.
  113824. */
  113825. onCollide: (collidedMesh: AbstractMesh) => void;
  113826. private _collider;
  113827. private _needMoveForGravity;
  113828. private _oldPosition;
  113829. private _diffPosition;
  113830. private _newPosition;
  113831. /** @hidden */
  113832. _localDirection: Vector3;
  113833. /** @hidden */
  113834. _transformedDirection: Vector3;
  113835. /**
  113836. * Instantiates a FlyCamera.
  113837. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113838. * such as in a 3D Space Shooter or a Flight Simulator.
  113839. * @param name Define the name of the camera in the scene.
  113840. * @param position Define the starting position of the camera in the scene.
  113841. * @param scene Define the scene the camera belongs to.
  113842. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113843. */
  113844. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113845. /**
  113846. * Attach a control to the HTML DOM element.
  113847. * @param element Defines the element that listens to the input events.
  113848. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113849. */
  113850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113851. /**
  113852. * Detach a control from the HTML DOM element.
  113853. * The camera will stop reacting to that input.
  113854. * @param element Defines the element that listens to the input events.
  113855. */
  113856. detachControl(element: HTMLElement): void;
  113857. private _collisionMask;
  113858. /**
  113859. * Get the mask that the camera ignores in collision events.
  113860. */
  113861. get collisionMask(): number;
  113862. /**
  113863. * Set the mask that the camera ignores in collision events.
  113864. */
  113865. set collisionMask(mask: number);
  113866. /** @hidden */
  113867. _collideWithWorld(displacement: Vector3): void;
  113868. /** @hidden */
  113869. private _onCollisionPositionChange;
  113870. /** @hidden */
  113871. _checkInputs(): void;
  113872. /** @hidden */
  113873. _decideIfNeedsToMove(): boolean;
  113874. /** @hidden */
  113875. _updatePosition(): void;
  113876. /**
  113877. * Restore the Roll to its target value at the rate specified.
  113878. * @param rate - Higher means slower restoring.
  113879. * @hidden
  113880. */
  113881. restoreRoll(rate: number): void;
  113882. /**
  113883. * Destroy the camera and release the current resources held by it.
  113884. */
  113885. dispose(): void;
  113886. /**
  113887. * Get the current object class name.
  113888. * @returns the class name.
  113889. */
  113890. getClassName(): string;
  113891. }
  113892. }
  113893. declare module BABYLON {
  113894. /**
  113895. * Listen to keyboard events to control the camera.
  113896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113897. */
  113898. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113899. /**
  113900. * Defines the camera the input is attached to.
  113901. */
  113902. camera: FlyCamera;
  113903. /**
  113904. * The list of keyboard keys used to control the forward move of the camera.
  113905. */
  113906. keysForward: number[];
  113907. /**
  113908. * The list of keyboard keys used to control the backward move of the camera.
  113909. */
  113910. keysBackward: number[];
  113911. /**
  113912. * The list of keyboard keys used to control the forward move of the camera.
  113913. */
  113914. keysUp: number[];
  113915. /**
  113916. * The list of keyboard keys used to control the backward move of the camera.
  113917. */
  113918. keysDown: number[];
  113919. /**
  113920. * The list of keyboard keys used to control the right strafe move of the camera.
  113921. */
  113922. keysRight: number[];
  113923. /**
  113924. * The list of keyboard keys used to control the left strafe move of the camera.
  113925. */
  113926. keysLeft: number[];
  113927. private _keys;
  113928. private _onCanvasBlurObserver;
  113929. private _onKeyboardObserver;
  113930. private _engine;
  113931. private _scene;
  113932. /**
  113933. * Attach the input controls to a specific dom element to get the input from.
  113934. * @param element Defines the element the controls should be listened from
  113935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113936. */
  113937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113938. /**
  113939. * Detach the current controls from the specified dom element.
  113940. * @param element Defines the element to stop listening the inputs from
  113941. */
  113942. detachControl(element: Nullable<HTMLElement>): void;
  113943. /**
  113944. * Gets the class name of the current intput.
  113945. * @returns the class name
  113946. */
  113947. getClassName(): string;
  113948. /** @hidden */
  113949. _onLostFocus(e: FocusEvent): void;
  113950. /**
  113951. * Get the friendly name associated with the input class.
  113952. * @returns the input friendly name
  113953. */
  113954. getSimpleName(): string;
  113955. /**
  113956. * Update the current camera state depending on the inputs that have been used this frame.
  113957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113958. */
  113959. checkInputs(): void;
  113960. }
  113961. }
  113962. declare module BABYLON {
  113963. /**
  113964. * Manage the mouse wheel inputs to control a follow camera.
  113965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113966. */
  113967. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113968. /**
  113969. * Defines the camera the input is attached to.
  113970. */
  113971. camera: FollowCamera;
  113972. /**
  113973. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113974. */
  113975. axisControlRadius: boolean;
  113976. /**
  113977. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113978. */
  113979. axisControlHeight: boolean;
  113980. /**
  113981. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113982. */
  113983. axisControlRotation: boolean;
  113984. /**
  113985. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113986. * relation to mouseWheel events.
  113987. */
  113988. wheelPrecision: number;
  113989. /**
  113990. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113991. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113992. */
  113993. wheelDeltaPercentage: number;
  113994. private _wheel;
  113995. private _observer;
  113996. /**
  113997. * Attach the input controls to a specific dom element to get the input from.
  113998. * @param element Defines the element the controls should be listened from
  113999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114000. */
  114001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114002. /**
  114003. * Detach the current controls from the specified dom element.
  114004. * @param element Defines the element to stop listening the inputs from
  114005. */
  114006. detachControl(element: Nullable<HTMLElement>): void;
  114007. /**
  114008. * Gets the class name of the current intput.
  114009. * @returns the class name
  114010. */
  114011. getClassName(): string;
  114012. /**
  114013. * Get the friendly name associated with the input class.
  114014. * @returns the input friendly name
  114015. */
  114016. getSimpleName(): string;
  114017. }
  114018. }
  114019. declare module BABYLON {
  114020. /**
  114021. * Manage the pointers inputs to control an follow camera.
  114022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114023. */
  114024. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  114025. /**
  114026. * Defines the camera the input is attached to.
  114027. */
  114028. camera: FollowCamera;
  114029. /**
  114030. * Gets the class name of the current input.
  114031. * @returns the class name
  114032. */
  114033. getClassName(): string;
  114034. /**
  114035. * Defines the pointer angular sensibility along the X axis or how fast is
  114036. * the camera rotating.
  114037. * A negative number will reverse the axis direction.
  114038. */
  114039. angularSensibilityX: number;
  114040. /**
  114041. * Defines the pointer angular sensibility along the Y axis or how fast is
  114042. * the camera rotating.
  114043. * A negative number will reverse the axis direction.
  114044. */
  114045. angularSensibilityY: number;
  114046. /**
  114047. * Defines the pointer pinch precision or how fast is the camera zooming.
  114048. * A negative number will reverse the axis direction.
  114049. */
  114050. pinchPrecision: number;
  114051. /**
  114052. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114053. * from 0.
  114054. * It defines the percentage of current camera.radius to use as delta when
  114055. * pinch zoom is used.
  114056. */
  114057. pinchDeltaPercentage: number;
  114058. /**
  114059. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  114060. */
  114061. axisXControlRadius: boolean;
  114062. /**
  114063. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  114064. */
  114065. axisXControlHeight: boolean;
  114066. /**
  114067. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  114068. */
  114069. axisXControlRotation: boolean;
  114070. /**
  114071. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  114072. */
  114073. axisYControlRadius: boolean;
  114074. /**
  114075. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  114076. */
  114077. axisYControlHeight: boolean;
  114078. /**
  114079. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  114080. */
  114081. axisYControlRotation: boolean;
  114082. /**
  114083. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  114084. */
  114085. axisPinchControlRadius: boolean;
  114086. /**
  114087. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  114088. */
  114089. axisPinchControlHeight: boolean;
  114090. /**
  114091. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  114092. */
  114093. axisPinchControlRotation: boolean;
  114094. /**
  114095. * Log error messages if basic misconfiguration has occurred.
  114096. */
  114097. warningEnable: boolean;
  114098. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114099. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114100. private _warningCounter;
  114101. private _warning;
  114102. }
  114103. }
  114104. declare module BABYLON {
  114105. /**
  114106. * Default Inputs manager for the FollowCamera.
  114107. * It groups all the default supported inputs for ease of use.
  114108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114109. */
  114110. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114111. /**
  114112. * Instantiates a new FollowCameraInputsManager.
  114113. * @param camera Defines the camera the inputs belong to
  114114. */
  114115. constructor(camera: FollowCamera);
  114116. /**
  114117. * Add keyboard input support to the input manager.
  114118. * @returns the current input manager
  114119. */
  114120. addKeyboard(): FollowCameraInputsManager;
  114121. /**
  114122. * Add mouse wheel input support to the input manager.
  114123. * @returns the current input manager
  114124. */
  114125. addMouseWheel(): FollowCameraInputsManager;
  114126. /**
  114127. * Add pointers input support to the input manager.
  114128. * @returns the current input manager
  114129. */
  114130. addPointers(): FollowCameraInputsManager;
  114131. /**
  114132. * Add orientation input support to the input manager.
  114133. * @returns the current input manager
  114134. */
  114135. addVRDeviceOrientation(): FollowCameraInputsManager;
  114136. }
  114137. }
  114138. declare module BABYLON {
  114139. /**
  114140. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114141. * an arc rotate version arcFollowCamera are available.
  114142. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114143. */
  114144. export class FollowCamera extends TargetCamera {
  114145. /**
  114146. * Distance the follow camera should follow an object at
  114147. */
  114148. radius: number;
  114149. /**
  114150. * Minimum allowed distance of the camera to the axis of rotation
  114151. * (The camera can not get closer).
  114152. * This can help limiting how the Camera is able to move in the scene.
  114153. */
  114154. lowerRadiusLimit: Nullable<number>;
  114155. /**
  114156. * Maximum allowed distance of the camera to the axis of rotation
  114157. * (The camera can not get further).
  114158. * This can help limiting how the Camera is able to move in the scene.
  114159. */
  114160. upperRadiusLimit: Nullable<number>;
  114161. /**
  114162. * Define a rotation offset between the camera and the object it follows
  114163. */
  114164. rotationOffset: number;
  114165. /**
  114166. * Minimum allowed angle to camera position relative to target object.
  114167. * This can help limiting how the Camera is able to move in the scene.
  114168. */
  114169. lowerRotationOffsetLimit: Nullable<number>;
  114170. /**
  114171. * Maximum allowed angle to camera position relative to target object.
  114172. * This can help limiting how the Camera is able to move in the scene.
  114173. */
  114174. upperRotationOffsetLimit: Nullable<number>;
  114175. /**
  114176. * Define a height offset between the camera and the object it follows.
  114177. * It can help following an object from the top (like a car chaing a plane)
  114178. */
  114179. heightOffset: number;
  114180. /**
  114181. * Minimum allowed height of camera position relative to target object.
  114182. * This can help limiting how the Camera is able to move in the scene.
  114183. */
  114184. lowerHeightOffsetLimit: Nullable<number>;
  114185. /**
  114186. * Maximum allowed height of camera position relative to target object.
  114187. * This can help limiting how the Camera is able to move in the scene.
  114188. */
  114189. upperHeightOffsetLimit: Nullable<number>;
  114190. /**
  114191. * Define how fast the camera can accelerate to follow it s target.
  114192. */
  114193. cameraAcceleration: number;
  114194. /**
  114195. * Define the speed limit of the camera following an object.
  114196. */
  114197. maxCameraSpeed: number;
  114198. /**
  114199. * Define the target of the camera.
  114200. */
  114201. lockedTarget: Nullable<AbstractMesh>;
  114202. /**
  114203. * Defines the input associated with the camera.
  114204. */
  114205. inputs: FollowCameraInputsManager;
  114206. /**
  114207. * Instantiates the follow camera.
  114208. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114209. * @param name Define the name of the camera in the scene
  114210. * @param position Define the position of the camera
  114211. * @param scene Define the scene the camera belong to
  114212. * @param lockedTarget Define the target of the camera
  114213. */
  114214. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  114215. private _follow;
  114216. /**
  114217. * Attached controls to the current camera.
  114218. * @param element Defines the element the controls should be listened from
  114219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114220. */
  114221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114222. /**
  114223. * Detach the current controls from the camera.
  114224. * The camera will stop reacting to inputs.
  114225. * @param element Defines the element to stop listening the inputs from
  114226. */
  114227. detachControl(element: HTMLElement): void;
  114228. /** @hidden */
  114229. _checkInputs(): void;
  114230. private _checkLimits;
  114231. /**
  114232. * Gets the camera class name.
  114233. * @returns the class name
  114234. */
  114235. getClassName(): string;
  114236. }
  114237. /**
  114238. * Arc Rotate version of the follow camera.
  114239. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  114240. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114241. */
  114242. export class ArcFollowCamera extends TargetCamera {
  114243. /** The longitudinal angle of the camera */
  114244. alpha: number;
  114245. /** The latitudinal angle of the camera */
  114246. beta: number;
  114247. /** The radius of the camera from its target */
  114248. radius: number;
  114249. /** Define the camera target (the messh it should follow) */
  114250. target: Nullable<AbstractMesh>;
  114251. private _cartesianCoordinates;
  114252. /**
  114253. * Instantiates a new ArcFollowCamera
  114254. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114255. * @param name Define the name of the camera
  114256. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  114257. * @param beta Define the rotation angle of the camera around the elevation axis
  114258. * @param radius Define the radius of the camera from its target point
  114259. * @param target Define the target of the camera
  114260. * @param scene Define the scene the camera belongs to
  114261. */
  114262. constructor(name: string,
  114263. /** The longitudinal angle of the camera */
  114264. alpha: number,
  114265. /** The latitudinal angle of the camera */
  114266. beta: number,
  114267. /** The radius of the camera from its target */
  114268. radius: number,
  114269. /** Define the camera target (the messh it should follow) */
  114270. target: Nullable<AbstractMesh>, scene: Scene);
  114271. private _follow;
  114272. /** @hidden */
  114273. _checkInputs(): void;
  114274. /**
  114275. * Returns the class name of the object.
  114276. * It is mostly used internally for serialization purposes.
  114277. */
  114278. getClassName(): string;
  114279. }
  114280. }
  114281. declare module BABYLON {
  114282. /**
  114283. * Manage the keyboard inputs to control the movement of a follow camera.
  114284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114285. */
  114286. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  114287. /**
  114288. * Defines the camera the input is attached to.
  114289. */
  114290. camera: FollowCamera;
  114291. /**
  114292. * Defines the list of key codes associated with the up action (increase heightOffset)
  114293. */
  114294. keysHeightOffsetIncr: number[];
  114295. /**
  114296. * Defines the list of key codes associated with the down action (decrease heightOffset)
  114297. */
  114298. keysHeightOffsetDecr: number[];
  114299. /**
  114300. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  114301. */
  114302. keysHeightOffsetModifierAlt: boolean;
  114303. /**
  114304. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  114305. */
  114306. keysHeightOffsetModifierCtrl: boolean;
  114307. /**
  114308. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  114309. */
  114310. keysHeightOffsetModifierShift: boolean;
  114311. /**
  114312. * Defines the list of key codes associated with the left action (increase rotationOffset)
  114313. */
  114314. keysRotationOffsetIncr: number[];
  114315. /**
  114316. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  114317. */
  114318. keysRotationOffsetDecr: number[];
  114319. /**
  114320. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  114321. */
  114322. keysRotationOffsetModifierAlt: boolean;
  114323. /**
  114324. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  114325. */
  114326. keysRotationOffsetModifierCtrl: boolean;
  114327. /**
  114328. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  114329. */
  114330. keysRotationOffsetModifierShift: boolean;
  114331. /**
  114332. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  114333. */
  114334. keysRadiusIncr: number[];
  114335. /**
  114336. * Defines the list of key codes associated with the zoom-out action (increase radius)
  114337. */
  114338. keysRadiusDecr: number[];
  114339. /**
  114340. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  114341. */
  114342. keysRadiusModifierAlt: boolean;
  114343. /**
  114344. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  114345. */
  114346. keysRadiusModifierCtrl: boolean;
  114347. /**
  114348. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  114349. */
  114350. keysRadiusModifierShift: boolean;
  114351. /**
  114352. * Defines the rate of change of heightOffset.
  114353. */
  114354. heightSensibility: number;
  114355. /**
  114356. * Defines the rate of change of rotationOffset.
  114357. */
  114358. rotationSensibility: number;
  114359. /**
  114360. * Defines the rate of change of radius.
  114361. */
  114362. radiusSensibility: number;
  114363. private _keys;
  114364. private _ctrlPressed;
  114365. private _altPressed;
  114366. private _shiftPressed;
  114367. private _onCanvasBlurObserver;
  114368. private _onKeyboardObserver;
  114369. private _engine;
  114370. private _scene;
  114371. /**
  114372. * Attach the input controls to a specific dom element to get the input from.
  114373. * @param element Defines the element the controls should be listened from
  114374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114375. */
  114376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114377. /**
  114378. * Detach the current controls from the specified dom element.
  114379. * @param element Defines the element to stop listening the inputs from
  114380. */
  114381. detachControl(element: Nullable<HTMLElement>): void;
  114382. /**
  114383. * Update the current camera state depending on the inputs that have been used this frame.
  114384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114385. */
  114386. checkInputs(): void;
  114387. /**
  114388. * Gets the class name of the current input.
  114389. * @returns the class name
  114390. */
  114391. getClassName(): string;
  114392. /**
  114393. * Get the friendly name associated with the input class.
  114394. * @returns the input friendly name
  114395. */
  114396. getSimpleName(): string;
  114397. /**
  114398. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114399. * allow modification of the heightOffset value.
  114400. */
  114401. private _modifierHeightOffset;
  114402. /**
  114403. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114404. * allow modification of the rotationOffset value.
  114405. */
  114406. private _modifierRotationOffset;
  114407. /**
  114408. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114409. * allow modification of the radius value.
  114410. */
  114411. private _modifierRadius;
  114412. }
  114413. }
  114414. declare module BABYLON {
  114415. interface FreeCameraInputsManager {
  114416. /**
  114417. * @hidden
  114418. */
  114419. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  114420. /**
  114421. * Add orientation input support to the input manager.
  114422. * @returns the current input manager
  114423. */
  114424. addDeviceOrientation(): FreeCameraInputsManager;
  114425. }
  114426. /**
  114427. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  114428. * Screen rotation is taken into account.
  114429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114430. */
  114431. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  114432. private _camera;
  114433. private _screenOrientationAngle;
  114434. private _constantTranform;
  114435. private _screenQuaternion;
  114436. private _alpha;
  114437. private _beta;
  114438. private _gamma;
  114439. /**
  114440. * Can be used to detect if a device orientation sensor is available on a device
  114441. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  114442. * @returns a promise that will resolve on orientation change
  114443. */
  114444. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  114445. /**
  114446. * @hidden
  114447. */
  114448. _onDeviceOrientationChangedObservable: Observable<void>;
  114449. /**
  114450. * Instantiates a new input
  114451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114452. */
  114453. constructor();
  114454. /**
  114455. * Define the camera controlled by the input.
  114456. */
  114457. get camera(): FreeCamera;
  114458. set camera(camera: FreeCamera);
  114459. /**
  114460. * Attach the input controls to a specific dom element to get the input from.
  114461. * @param element Defines the element the controls should be listened from
  114462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114463. */
  114464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114465. private _orientationChanged;
  114466. private _deviceOrientation;
  114467. /**
  114468. * Detach the current controls from the specified dom element.
  114469. * @param element Defines the element to stop listening the inputs from
  114470. */
  114471. detachControl(element: Nullable<HTMLElement>): void;
  114472. /**
  114473. * Update the current camera state depending on the inputs that have been used this frame.
  114474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114475. */
  114476. checkInputs(): void;
  114477. /**
  114478. * Gets the class name of the current intput.
  114479. * @returns the class name
  114480. */
  114481. getClassName(): string;
  114482. /**
  114483. * Get the friendly name associated with the input class.
  114484. * @returns the input friendly name
  114485. */
  114486. getSimpleName(): string;
  114487. }
  114488. }
  114489. declare module BABYLON {
  114490. /**
  114491. * Manage the gamepad inputs to control a free camera.
  114492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114493. */
  114494. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  114495. /**
  114496. * Define the camera the input is attached to.
  114497. */
  114498. camera: FreeCamera;
  114499. /**
  114500. * Define the Gamepad controlling the input
  114501. */
  114502. gamepad: Nullable<Gamepad>;
  114503. /**
  114504. * Defines the gamepad rotation sensiblity.
  114505. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114506. */
  114507. gamepadAngularSensibility: number;
  114508. /**
  114509. * Defines the gamepad move sensiblity.
  114510. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114511. */
  114512. gamepadMoveSensibility: number;
  114513. private _yAxisScale;
  114514. /**
  114515. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114516. */
  114517. get invertYAxis(): boolean;
  114518. set invertYAxis(value: boolean);
  114519. private _onGamepadConnectedObserver;
  114520. private _onGamepadDisconnectedObserver;
  114521. private _cameraTransform;
  114522. private _deltaTransform;
  114523. private _vector3;
  114524. private _vector2;
  114525. /**
  114526. * Attach the input controls to a specific dom element to get the input from.
  114527. * @param element Defines the element the controls should be listened from
  114528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114529. */
  114530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114531. /**
  114532. * Detach the current controls from the specified dom element.
  114533. * @param element Defines the element to stop listening the inputs from
  114534. */
  114535. detachControl(element: Nullable<HTMLElement>): void;
  114536. /**
  114537. * Update the current camera state depending on the inputs that have been used this frame.
  114538. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114539. */
  114540. checkInputs(): void;
  114541. /**
  114542. * Gets the class name of the current intput.
  114543. * @returns the class name
  114544. */
  114545. getClassName(): string;
  114546. /**
  114547. * Get the friendly name associated with the input class.
  114548. * @returns the input friendly name
  114549. */
  114550. getSimpleName(): string;
  114551. }
  114552. }
  114553. declare module BABYLON {
  114554. /**
  114555. * Defines the potential axis of a Joystick
  114556. */
  114557. export enum JoystickAxis {
  114558. /** X axis */
  114559. X = 0,
  114560. /** Y axis */
  114561. Y = 1,
  114562. /** Z axis */
  114563. Z = 2
  114564. }
  114565. /**
  114566. * Class used to define virtual joystick (used in touch mode)
  114567. */
  114568. export class VirtualJoystick {
  114569. /**
  114570. * Gets or sets a boolean indicating that left and right values must be inverted
  114571. */
  114572. reverseLeftRight: boolean;
  114573. /**
  114574. * Gets or sets a boolean indicating that up and down values must be inverted
  114575. */
  114576. reverseUpDown: boolean;
  114577. /**
  114578. * Gets the offset value for the position (ie. the change of the position value)
  114579. */
  114580. deltaPosition: Vector3;
  114581. /**
  114582. * Gets a boolean indicating if the virtual joystick was pressed
  114583. */
  114584. pressed: boolean;
  114585. /**
  114586. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114587. */
  114588. static Canvas: Nullable<HTMLCanvasElement>;
  114589. private static _globalJoystickIndex;
  114590. private static vjCanvasContext;
  114591. private static vjCanvasWidth;
  114592. private static vjCanvasHeight;
  114593. private static halfWidth;
  114594. private _action;
  114595. private _axisTargetedByLeftAndRight;
  114596. private _axisTargetedByUpAndDown;
  114597. private _joystickSensibility;
  114598. private _inversedSensibility;
  114599. private _joystickPointerID;
  114600. private _joystickColor;
  114601. private _joystickPointerPos;
  114602. private _joystickPreviousPointerPos;
  114603. private _joystickPointerStartPos;
  114604. private _deltaJoystickVector;
  114605. private _leftJoystick;
  114606. private _touches;
  114607. private _onPointerDownHandlerRef;
  114608. private _onPointerMoveHandlerRef;
  114609. private _onPointerUpHandlerRef;
  114610. private _onResize;
  114611. /**
  114612. * Creates a new virtual joystick
  114613. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114614. */
  114615. constructor(leftJoystick?: boolean);
  114616. /**
  114617. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114618. * @param newJoystickSensibility defines the new sensibility
  114619. */
  114620. setJoystickSensibility(newJoystickSensibility: number): void;
  114621. private _onPointerDown;
  114622. private _onPointerMove;
  114623. private _onPointerUp;
  114624. /**
  114625. * Change the color of the virtual joystick
  114626. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114627. */
  114628. setJoystickColor(newColor: string): void;
  114629. /**
  114630. * Defines a callback to call when the joystick is touched
  114631. * @param action defines the callback
  114632. */
  114633. setActionOnTouch(action: () => any): void;
  114634. /**
  114635. * Defines which axis you'd like to control for left & right
  114636. * @param axis defines the axis to use
  114637. */
  114638. setAxisForLeftRight(axis: JoystickAxis): void;
  114639. /**
  114640. * Defines which axis you'd like to control for up & down
  114641. * @param axis defines the axis to use
  114642. */
  114643. setAxisForUpDown(axis: JoystickAxis): void;
  114644. private _drawVirtualJoystick;
  114645. /**
  114646. * Release internal HTML canvas
  114647. */
  114648. releaseCanvas(): void;
  114649. }
  114650. }
  114651. declare module BABYLON {
  114652. interface FreeCameraInputsManager {
  114653. /**
  114654. * Add virtual joystick input support to the input manager.
  114655. * @returns the current input manager
  114656. */
  114657. addVirtualJoystick(): FreeCameraInputsManager;
  114658. }
  114659. /**
  114660. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114662. */
  114663. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114664. /**
  114665. * Defines the camera the input is attached to.
  114666. */
  114667. camera: FreeCamera;
  114668. private _leftjoystick;
  114669. private _rightjoystick;
  114670. /**
  114671. * Gets the left stick of the virtual joystick.
  114672. * @returns The virtual Joystick
  114673. */
  114674. getLeftJoystick(): VirtualJoystick;
  114675. /**
  114676. * Gets the right stick of the virtual joystick.
  114677. * @returns The virtual Joystick
  114678. */
  114679. getRightJoystick(): VirtualJoystick;
  114680. /**
  114681. * Update the current camera state depending on the inputs that have been used this frame.
  114682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114683. */
  114684. checkInputs(): void;
  114685. /**
  114686. * Attach the input controls to a specific dom element to get the input from.
  114687. * @param element Defines the element the controls should be listened from
  114688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114689. */
  114690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114691. /**
  114692. * Detach the current controls from the specified dom element.
  114693. * @param element Defines the element to stop listening the inputs from
  114694. */
  114695. detachControl(element: Nullable<HTMLElement>): void;
  114696. /**
  114697. * Gets the class name of the current intput.
  114698. * @returns the class name
  114699. */
  114700. getClassName(): string;
  114701. /**
  114702. * Get the friendly name associated with the input class.
  114703. * @returns the input friendly name
  114704. */
  114705. getSimpleName(): string;
  114706. }
  114707. }
  114708. declare module BABYLON {
  114709. /**
  114710. * This represents a FPS type of camera controlled by touch.
  114711. * This is like a universal camera minus the Gamepad controls.
  114712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114713. */
  114714. export class TouchCamera extends FreeCamera {
  114715. /**
  114716. * Defines the touch sensibility for rotation.
  114717. * The higher the faster.
  114718. */
  114719. get touchAngularSensibility(): number;
  114720. set touchAngularSensibility(value: number);
  114721. /**
  114722. * Defines the touch sensibility for move.
  114723. * The higher the faster.
  114724. */
  114725. get touchMoveSensibility(): number;
  114726. set touchMoveSensibility(value: number);
  114727. /**
  114728. * Instantiates a new touch camera.
  114729. * This represents a FPS type of camera controlled by touch.
  114730. * This is like a universal camera minus the Gamepad controls.
  114731. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114732. * @param name Define the name of the camera in the scene
  114733. * @param position Define the start position of the camera in the scene
  114734. * @param scene Define the scene the camera belongs to
  114735. */
  114736. constructor(name: string, position: Vector3, scene: Scene);
  114737. /**
  114738. * Gets the current object class name.
  114739. * @return the class name
  114740. */
  114741. getClassName(): string;
  114742. /** @hidden */
  114743. _setupInputs(): void;
  114744. }
  114745. }
  114746. declare module BABYLON {
  114747. /**
  114748. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114749. * being tilted forward or back and left or right.
  114750. */
  114751. export class DeviceOrientationCamera extends FreeCamera {
  114752. private _initialQuaternion;
  114753. private _quaternionCache;
  114754. private _tmpDragQuaternion;
  114755. private _disablePointerInputWhenUsingDeviceOrientation;
  114756. /**
  114757. * Creates a new device orientation camera
  114758. * @param name The name of the camera
  114759. * @param position The start position camera
  114760. * @param scene The scene the camera belongs to
  114761. */
  114762. constructor(name: string, position: Vector3, scene: Scene);
  114763. /**
  114764. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114765. */
  114766. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114767. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114768. private _dragFactor;
  114769. /**
  114770. * Enabled turning on the y axis when the orientation sensor is active
  114771. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114772. */
  114773. enableHorizontalDragging(dragFactor?: number): void;
  114774. /**
  114775. * Gets the current instance class name ("DeviceOrientationCamera").
  114776. * This helps avoiding instanceof at run time.
  114777. * @returns the class name
  114778. */
  114779. getClassName(): string;
  114780. /**
  114781. * @hidden
  114782. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114783. */
  114784. _checkInputs(): void;
  114785. /**
  114786. * Reset the camera to its default orientation on the specified axis only.
  114787. * @param axis The axis to reset
  114788. */
  114789. resetToCurrentRotation(axis?: Axis): void;
  114790. }
  114791. }
  114792. declare module BABYLON {
  114793. /**
  114794. * Defines supported buttons for XBox360 compatible gamepads
  114795. */
  114796. export enum Xbox360Button {
  114797. /** A */
  114798. A = 0,
  114799. /** B */
  114800. B = 1,
  114801. /** X */
  114802. X = 2,
  114803. /** Y */
  114804. Y = 3,
  114805. /** Left button */
  114806. LB = 4,
  114807. /** Right button */
  114808. RB = 5,
  114809. /** Back */
  114810. Back = 8,
  114811. /** Start */
  114812. Start = 9,
  114813. /** Left stick */
  114814. LeftStick = 10,
  114815. /** Right stick */
  114816. RightStick = 11
  114817. }
  114818. /** Defines values for XBox360 DPad */
  114819. export enum Xbox360Dpad {
  114820. /** Up */
  114821. Up = 12,
  114822. /** Down */
  114823. Down = 13,
  114824. /** Left */
  114825. Left = 14,
  114826. /** Right */
  114827. Right = 15
  114828. }
  114829. /**
  114830. * Defines a XBox360 gamepad
  114831. */
  114832. export class Xbox360Pad extends Gamepad {
  114833. private _leftTrigger;
  114834. private _rightTrigger;
  114835. private _onlefttriggerchanged;
  114836. private _onrighttriggerchanged;
  114837. private _onbuttondown;
  114838. private _onbuttonup;
  114839. private _ondpaddown;
  114840. private _ondpadup;
  114841. /** Observable raised when a button is pressed */
  114842. onButtonDownObservable: Observable<Xbox360Button>;
  114843. /** Observable raised when a button is released */
  114844. onButtonUpObservable: Observable<Xbox360Button>;
  114845. /** Observable raised when a pad is pressed */
  114846. onPadDownObservable: Observable<Xbox360Dpad>;
  114847. /** Observable raised when a pad is released */
  114848. onPadUpObservable: Observable<Xbox360Dpad>;
  114849. private _buttonA;
  114850. private _buttonB;
  114851. private _buttonX;
  114852. private _buttonY;
  114853. private _buttonBack;
  114854. private _buttonStart;
  114855. private _buttonLB;
  114856. private _buttonRB;
  114857. private _buttonLeftStick;
  114858. private _buttonRightStick;
  114859. private _dPadUp;
  114860. private _dPadDown;
  114861. private _dPadLeft;
  114862. private _dPadRight;
  114863. private _isXboxOnePad;
  114864. /**
  114865. * Creates a new XBox360 gamepad object
  114866. * @param id defines the id of this gamepad
  114867. * @param index defines its index
  114868. * @param gamepad defines the internal HTML gamepad object
  114869. * @param xboxOne defines if it is a XBox One gamepad
  114870. */
  114871. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114872. /**
  114873. * Defines the callback to call when left trigger is pressed
  114874. * @param callback defines the callback to use
  114875. */
  114876. onlefttriggerchanged(callback: (value: number) => void): void;
  114877. /**
  114878. * Defines the callback to call when right trigger is pressed
  114879. * @param callback defines the callback to use
  114880. */
  114881. onrighttriggerchanged(callback: (value: number) => void): void;
  114882. /**
  114883. * Gets the left trigger value
  114884. */
  114885. get leftTrigger(): number;
  114886. /**
  114887. * Sets the left trigger value
  114888. */
  114889. set leftTrigger(newValue: number);
  114890. /**
  114891. * Gets the right trigger value
  114892. */
  114893. get rightTrigger(): number;
  114894. /**
  114895. * Sets the right trigger value
  114896. */
  114897. set rightTrigger(newValue: number);
  114898. /**
  114899. * Defines the callback to call when a button is pressed
  114900. * @param callback defines the callback to use
  114901. */
  114902. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114903. /**
  114904. * Defines the callback to call when a button is released
  114905. * @param callback defines the callback to use
  114906. */
  114907. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114908. /**
  114909. * Defines the callback to call when a pad is pressed
  114910. * @param callback defines the callback to use
  114911. */
  114912. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114913. /**
  114914. * Defines the callback to call when a pad is released
  114915. * @param callback defines the callback to use
  114916. */
  114917. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114918. private _setButtonValue;
  114919. private _setDPadValue;
  114920. /**
  114921. * Gets the value of the `A` button
  114922. */
  114923. get buttonA(): number;
  114924. /**
  114925. * Sets the value of the `A` button
  114926. */
  114927. set buttonA(value: number);
  114928. /**
  114929. * Gets the value of the `B` button
  114930. */
  114931. get buttonB(): number;
  114932. /**
  114933. * Sets the value of the `B` button
  114934. */
  114935. set buttonB(value: number);
  114936. /**
  114937. * Gets the value of the `X` button
  114938. */
  114939. get buttonX(): number;
  114940. /**
  114941. * Sets the value of the `X` button
  114942. */
  114943. set buttonX(value: number);
  114944. /**
  114945. * Gets the value of the `Y` button
  114946. */
  114947. get buttonY(): number;
  114948. /**
  114949. * Sets the value of the `Y` button
  114950. */
  114951. set buttonY(value: number);
  114952. /**
  114953. * Gets the value of the `Start` button
  114954. */
  114955. get buttonStart(): number;
  114956. /**
  114957. * Sets the value of the `Start` button
  114958. */
  114959. set buttonStart(value: number);
  114960. /**
  114961. * Gets the value of the `Back` button
  114962. */
  114963. get buttonBack(): number;
  114964. /**
  114965. * Sets the value of the `Back` button
  114966. */
  114967. set buttonBack(value: number);
  114968. /**
  114969. * Gets the value of the `Left` button
  114970. */
  114971. get buttonLB(): number;
  114972. /**
  114973. * Sets the value of the `Left` button
  114974. */
  114975. set buttonLB(value: number);
  114976. /**
  114977. * Gets the value of the `Right` button
  114978. */
  114979. get buttonRB(): number;
  114980. /**
  114981. * Sets the value of the `Right` button
  114982. */
  114983. set buttonRB(value: number);
  114984. /**
  114985. * Gets the value of the Left joystick
  114986. */
  114987. get buttonLeftStick(): number;
  114988. /**
  114989. * Sets the value of the Left joystick
  114990. */
  114991. set buttonLeftStick(value: number);
  114992. /**
  114993. * Gets the value of the Right joystick
  114994. */
  114995. get buttonRightStick(): number;
  114996. /**
  114997. * Sets the value of the Right joystick
  114998. */
  114999. set buttonRightStick(value: number);
  115000. /**
  115001. * Gets the value of D-pad up
  115002. */
  115003. get dPadUp(): number;
  115004. /**
  115005. * Sets the value of D-pad up
  115006. */
  115007. set dPadUp(value: number);
  115008. /**
  115009. * Gets the value of D-pad down
  115010. */
  115011. get dPadDown(): number;
  115012. /**
  115013. * Sets the value of D-pad down
  115014. */
  115015. set dPadDown(value: number);
  115016. /**
  115017. * Gets the value of D-pad left
  115018. */
  115019. get dPadLeft(): number;
  115020. /**
  115021. * Sets the value of D-pad left
  115022. */
  115023. set dPadLeft(value: number);
  115024. /**
  115025. * Gets the value of D-pad right
  115026. */
  115027. get dPadRight(): number;
  115028. /**
  115029. * Sets the value of D-pad right
  115030. */
  115031. set dPadRight(value: number);
  115032. /**
  115033. * Force the gamepad to synchronize with device values
  115034. */
  115035. update(): void;
  115036. /**
  115037. * Disposes the gamepad
  115038. */
  115039. dispose(): void;
  115040. }
  115041. }
  115042. declare module BABYLON {
  115043. /**
  115044. * Defines supported buttons for DualShock compatible gamepads
  115045. */
  115046. export enum DualShockButton {
  115047. /** Cross */
  115048. Cross = 0,
  115049. /** Circle */
  115050. Circle = 1,
  115051. /** Square */
  115052. Square = 2,
  115053. /** Triangle */
  115054. Triangle = 3,
  115055. /** L1 */
  115056. L1 = 4,
  115057. /** R1 */
  115058. R1 = 5,
  115059. /** Share */
  115060. Share = 8,
  115061. /** Options */
  115062. Options = 9,
  115063. /** Left stick */
  115064. LeftStick = 10,
  115065. /** Right stick */
  115066. RightStick = 11
  115067. }
  115068. /** Defines values for DualShock DPad */
  115069. export enum DualShockDpad {
  115070. /** Up */
  115071. Up = 12,
  115072. /** Down */
  115073. Down = 13,
  115074. /** Left */
  115075. Left = 14,
  115076. /** Right */
  115077. Right = 15
  115078. }
  115079. /**
  115080. * Defines a DualShock gamepad
  115081. */
  115082. export class DualShockPad extends Gamepad {
  115083. private _leftTrigger;
  115084. private _rightTrigger;
  115085. private _onlefttriggerchanged;
  115086. private _onrighttriggerchanged;
  115087. private _onbuttondown;
  115088. private _onbuttonup;
  115089. private _ondpaddown;
  115090. private _ondpadup;
  115091. /** Observable raised when a button is pressed */
  115092. onButtonDownObservable: Observable<DualShockButton>;
  115093. /** Observable raised when a button is released */
  115094. onButtonUpObservable: Observable<DualShockButton>;
  115095. /** Observable raised when a pad is pressed */
  115096. onPadDownObservable: Observable<DualShockDpad>;
  115097. /** Observable raised when a pad is released */
  115098. onPadUpObservable: Observable<DualShockDpad>;
  115099. private _buttonCross;
  115100. private _buttonCircle;
  115101. private _buttonSquare;
  115102. private _buttonTriangle;
  115103. private _buttonShare;
  115104. private _buttonOptions;
  115105. private _buttonL1;
  115106. private _buttonR1;
  115107. private _buttonLeftStick;
  115108. private _buttonRightStick;
  115109. private _dPadUp;
  115110. private _dPadDown;
  115111. private _dPadLeft;
  115112. private _dPadRight;
  115113. /**
  115114. * Creates a new DualShock gamepad object
  115115. * @param id defines the id of this gamepad
  115116. * @param index defines its index
  115117. * @param gamepad defines the internal HTML gamepad object
  115118. */
  115119. constructor(id: string, index: number, gamepad: any);
  115120. /**
  115121. * Defines the callback to call when left trigger is pressed
  115122. * @param callback defines the callback to use
  115123. */
  115124. onlefttriggerchanged(callback: (value: number) => void): void;
  115125. /**
  115126. * Defines the callback to call when right trigger is pressed
  115127. * @param callback defines the callback to use
  115128. */
  115129. onrighttriggerchanged(callback: (value: number) => void): void;
  115130. /**
  115131. * Gets the left trigger value
  115132. */
  115133. get leftTrigger(): number;
  115134. /**
  115135. * Sets the left trigger value
  115136. */
  115137. set leftTrigger(newValue: number);
  115138. /**
  115139. * Gets the right trigger value
  115140. */
  115141. get rightTrigger(): number;
  115142. /**
  115143. * Sets the right trigger value
  115144. */
  115145. set rightTrigger(newValue: number);
  115146. /**
  115147. * Defines the callback to call when a button is pressed
  115148. * @param callback defines the callback to use
  115149. */
  115150. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115151. /**
  115152. * Defines the callback to call when a button is released
  115153. * @param callback defines the callback to use
  115154. */
  115155. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115156. /**
  115157. * Defines the callback to call when a pad is pressed
  115158. * @param callback defines the callback to use
  115159. */
  115160. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115161. /**
  115162. * Defines the callback to call when a pad is released
  115163. * @param callback defines the callback to use
  115164. */
  115165. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115166. private _setButtonValue;
  115167. private _setDPadValue;
  115168. /**
  115169. * Gets the value of the `Cross` button
  115170. */
  115171. get buttonCross(): number;
  115172. /**
  115173. * Sets the value of the `Cross` button
  115174. */
  115175. set buttonCross(value: number);
  115176. /**
  115177. * Gets the value of the `Circle` button
  115178. */
  115179. get buttonCircle(): number;
  115180. /**
  115181. * Sets the value of the `Circle` button
  115182. */
  115183. set buttonCircle(value: number);
  115184. /**
  115185. * Gets the value of the `Square` button
  115186. */
  115187. get buttonSquare(): number;
  115188. /**
  115189. * Sets the value of the `Square` button
  115190. */
  115191. set buttonSquare(value: number);
  115192. /**
  115193. * Gets the value of the `Triangle` button
  115194. */
  115195. get buttonTriangle(): number;
  115196. /**
  115197. * Sets the value of the `Triangle` button
  115198. */
  115199. set buttonTriangle(value: number);
  115200. /**
  115201. * Gets the value of the `Options` button
  115202. */
  115203. get buttonOptions(): number;
  115204. /**
  115205. * Sets the value of the `Options` button
  115206. */
  115207. set buttonOptions(value: number);
  115208. /**
  115209. * Gets the value of the `Share` button
  115210. */
  115211. get buttonShare(): number;
  115212. /**
  115213. * Sets the value of the `Share` button
  115214. */
  115215. set buttonShare(value: number);
  115216. /**
  115217. * Gets the value of the `L1` button
  115218. */
  115219. get buttonL1(): number;
  115220. /**
  115221. * Sets the value of the `L1` button
  115222. */
  115223. set buttonL1(value: number);
  115224. /**
  115225. * Gets the value of the `R1` button
  115226. */
  115227. get buttonR1(): number;
  115228. /**
  115229. * Sets the value of the `R1` button
  115230. */
  115231. set buttonR1(value: number);
  115232. /**
  115233. * Gets the value of the Left joystick
  115234. */
  115235. get buttonLeftStick(): number;
  115236. /**
  115237. * Sets the value of the Left joystick
  115238. */
  115239. set buttonLeftStick(value: number);
  115240. /**
  115241. * Gets the value of the Right joystick
  115242. */
  115243. get buttonRightStick(): number;
  115244. /**
  115245. * Sets the value of the Right joystick
  115246. */
  115247. set buttonRightStick(value: number);
  115248. /**
  115249. * Gets the value of D-pad up
  115250. */
  115251. get dPadUp(): number;
  115252. /**
  115253. * Sets the value of D-pad up
  115254. */
  115255. set dPadUp(value: number);
  115256. /**
  115257. * Gets the value of D-pad down
  115258. */
  115259. get dPadDown(): number;
  115260. /**
  115261. * Sets the value of D-pad down
  115262. */
  115263. set dPadDown(value: number);
  115264. /**
  115265. * Gets the value of D-pad left
  115266. */
  115267. get dPadLeft(): number;
  115268. /**
  115269. * Sets the value of D-pad left
  115270. */
  115271. set dPadLeft(value: number);
  115272. /**
  115273. * Gets the value of D-pad right
  115274. */
  115275. get dPadRight(): number;
  115276. /**
  115277. * Sets the value of D-pad right
  115278. */
  115279. set dPadRight(value: number);
  115280. /**
  115281. * Force the gamepad to synchronize with device values
  115282. */
  115283. update(): void;
  115284. /**
  115285. * Disposes the gamepad
  115286. */
  115287. dispose(): void;
  115288. }
  115289. }
  115290. declare module BABYLON {
  115291. /**
  115292. * Manager for handling gamepads
  115293. */
  115294. export class GamepadManager {
  115295. private _scene?;
  115296. private _babylonGamepads;
  115297. private _oneGamepadConnected;
  115298. /** @hidden */
  115299. _isMonitoring: boolean;
  115300. private _gamepadEventSupported;
  115301. private _gamepadSupport?;
  115302. /**
  115303. * observable to be triggered when the gamepad controller has been connected
  115304. */
  115305. onGamepadConnectedObservable: Observable<Gamepad>;
  115306. /**
  115307. * observable to be triggered when the gamepad controller has been disconnected
  115308. */
  115309. onGamepadDisconnectedObservable: Observable<Gamepad>;
  115310. private _onGamepadConnectedEvent;
  115311. private _onGamepadDisconnectedEvent;
  115312. /**
  115313. * Initializes the gamepad manager
  115314. * @param _scene BabylonJS scene
  115315. */
  115316. constructor(_scene?: Scene | undefined);
  115317. /**
  115318. * The gamepads in the game pad manager
  115319. */
  115320. get gamepads(): Gamepad[];
  115321. /**
  115322. * Get the gamepad controllers based on type
  115323. * @param type The type of gamepad controller
  115324. * @returns Nullable gamepad
  115325. */
  115326. getGamepadByType(type?: number): Nullable<Gamepad>;
  115327. /**
  115328. * Disposes the gamepad manager
  115329. */
  115330. dispose(): void;
  115331. private _addNewGamepad;
  115332. private _startMonitoringGamepads;
  115333. private _stopMonitoringGamepads;
  115334. /** @hidden */
  115335. _checkGamepadsStatus(): void;
  115336. private _updateGamepadObjects;
  115337. }
  115338. }
  115339. declare module BABYLON {
  115340. interface Scene {
  115341. /** @hidden */
  115342. _gamepadManager: Nullable<GamepadManager>;
  115343. /**
  115344. * Gets the gamepad manager associated with the scene
  115345. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  115346. */
  115347. gamepadManager: GamepadManager;
  115348. }
  115349. /**
  115350. * Interface representing a free camera inputs manager
  115351. */
  115352. interface FreeCameraInputsManager {
  115353. /**
  115354. * Adds gamepad input support to the FreeCameraInputsManager.
  115355. * @returns the FreeCameraInputsManager
  115356. */
  115357. addGamepad(): FreeCameraInputsManager;
  115358. }
  115359. /**
  115360. * Interface representing an arc rotate camera inputs manager
  115361. */
  115362. interface ArcRotateCameraInputsManager {
  115363. /**
  115364. * Adds gamepad input support to the ArcRotateCamera InputManager.
  115365. * @returns the camera inputs manager
  115366. */
  115367. addGamepad(): ArcRotateCameraInputsManager;
  115368. }
  115369. /**
  115370. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  115371. */
  115372. export class GamepadSystemSceneComponent implements ISceneComponent {
  115373. /**
  115374. * The component name helpfull to identify the component in the list of scene components.
  115375. */
  115376. readonly name: string;
  115377. /**
  115378. * The scene the component belongs to.
  115379. */
  115380. scene: Scene;
  115381. /**
  115382. * Creates a new instance of the component for the given scene
  115383. * @param scene Defines the scene to register the component in
  115384. */
  115385. constructor(scene: Scene);
  115386. /**
  115387. * Registers the component in a given scene
  115388. */
  115389. register(): void;
  115390. /**
  115391. * Rebuilds the elements related to this component in case of
  115392. * context lost for instance.
  115393. */
  115394. rebuild(): void;
  115395. /**
  115396. * Disposes the component and the associated ressources
  115397. */
  115398. dispose(): void;
  115399. private _beforeCameraUpdate;
  115400. }
  115401. }
  115402. declare module BABYLON {
  115403. /**
  115404. * 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,
  115405. * which still works and will still be found in many Playgrounds.
  115406. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115407. */
  115408. export class UniversalCamera extends TouchCamera {
  115409. /**
  115410. * Defines the gamepad rotation sensiblity.
  115411. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115412. */
  115413. get gamepadAngularSensibility(): number;
  115414. set gamepadAngularSensibility(value: number);
  115415. /**
  115416. * Defines the gamepad move sensiblity.
  115417. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115418. */
  115419. get gamepadMoveSensibility(): number;
  115420. set gamepadMoveSensibility(value: number);
  115421. /**
  115422. * 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,
  115423. * which still works and will still be found in many Playgrounds.
  115424. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115425. * @param name Define the name of the camera in the scene
  115426. * @param position Define the start position of the camera in the scene
  115427. * @param scene Define the scene the camera belongs to
  115428. */
  115429. constructor(name: string, position: Vector3, scene: Scene);
  115430. /**
  115431. * Gets the current object class name.
  115432. * @return the class name
  115433. */
  115434. getClassName(): string;
  115435. }
  115436. }
  115437. declare module BABYLON {
  115438. /**
  115439. * This represents a FPS type of camera. This is only here for back compat purpose.
  115440. * Please use the UniversalCamera instead as both are identical.
  115441. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115442. */
  115443. export class GamepadCamera extends UniversalCamera {
  115444. /**
  115445. * Instantiates a new Gamepad Camera
  115446. * This represents a FPS type of camera. This is only here for back compat purpose.
  115447. * Please use the UniversalCamera instead as both are identical.
  115448. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115449. * @param name Define the name of the camera in the scene
  115450. * @param position Define the start position of the camera in the scene
  115451. * @param scene Define the scene the camera belongs to
  115452. */
  115453. constructor(name: string, position: Vector3, scene: Scene);
  115454. /**
  115455. * Gets the current object class name.
  115456. * @return the class name
  115457. */
  115458. getClassName(): string;
  115459. }
  115460. }
  115461. declare module BABYLON {
  115462. /** @hidden */
  115463. export var passPixelShader: {
  115464. name: string;
  115465. shader: string;
  115466. };
  115467. }
  115468. declare module BABYLON {
  115469. /** @hidden */
  115470. export var passCubePixelShader: {
  115471. name: string;
  115472. shader: string;
  115473. };
  115474. }
  115475. declare module BABYLON {
  115476. /**
  115477. * PassPostProcess which produces an output the same as it's input
  115478. */
  115479. export class PassPostProcess extends PostProcess {
  115480. /**
  115481. * Creates the PassPostProcess
  115482. * @param name The name of the effect.
  115483. * @param options The required width/height ratio to downsize to before computing the render pass.
  115484. * @param camera The camera to apply the render pass to.
  115485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115486. * @param engine The engine which the post process will be applied. (default: current engine)
  115487. * @param reusable If the post process can be reused on the same frame. (default: false)
  115488. * @param textureType The type of texture to be used when performing the post processing.
  115489. * @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)
  115490. */
  115491. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115492. }
  115493. /**
  115494. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  115495. */
  115496. export class PassCubePostProcess extends PostProcess {
  115497. private _face;
  115498. /**
  115499. * Gets or sets the cube face to display.
  115500. * * 0 is +X
  115501. * * 1 is -X
  115502. * * 2 is +Y
  115503. * * 3 is -Y
  115504. * * 4 is +Z
  115505. * * 5 is -Z
  115506. */
  115507. get face(): number;
  115508. set face(value: number);
  115509. /**
  115510. * Creates the PassCubePostProcess
  115511. * @param name The name of the effect.
  115512. * @param options The required width/height ratio to downsize to before computing the render pass.
  115513. * @param camera The camera to apply the render pass to.
  115514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115515. * @param engine The engine which the post process will be applied. (default: current engine)
  115516. * @param reusable If the post process can be reused on the same frame. (default: false)
  115517. * @param textureType The type of texture to be used when performing the post processing.
  115518. * @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)
  115519. */
  115520. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115521. }
  115522. }
  115523. declare module BABYLON {
  115524. /** @hidden */
  115525. export var anaglyphPixelShader: {
  115526. name: string;
  115527. shader: string;
  115528. };
  115529. }
  115530. declare module BABYLON {
  115531. /**
  115532. * Postprocess used to generate anaglyphic rendering
  115533. */
  115534. export class AnaglyphPostProcess extends PostProcess {
  115535. private _passedProcess;
  115536. /**
  115537. * Creates a new AnaglyphPostProcess
  115538. * @param name defines postprocess name
  115539. * @param options defines creation options or target ratio scale
  115540. * @param rigCameras defines cameras using this postprocess
  115541. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115542. * @param engine defines hosting engine
  115543. * @param reusable defines if the postprocess will be reused multiple times per frame
  115544. */
  115545. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115546. }
  115547. }
  115548. declare module BABYLON {
  115549. /**
  115550. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115551. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115552. */
  115553. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115554. /**
  115555. * Creates a new AnaglyphArcRotateCamera
  115556. * @param name defines camera name
  115557. * @param alpha defines alpha angle (in radians)
  115558. * @param beta defines beta angle (in radians)
  115559. * @param radius defines radius
  115560. * @param target defines camera target
  115561. * @param interaxialDistance defines distance between each color axis
  115562. * @param scene defines the hosting scene
  115563. */
  115564. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115565. /**
  115566. * Gets camera class name
  115567. * @returns AnaglyphArcRotateCamera
  115568. */
  115569. getClassName(): string;
  115570. }
  115571. }
  115572. declare module BABYLON {
  115573. /**
  115574. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115575. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115576. */
  115577. export class AnaglyphFreeCamera extends FreeCamera {
  115578. /**
  115579. * Creates a new AnaglyphFreeCamera
  115580. * @param name defines camera name
  115581. * @param position defines initial position
  115582. * @param interaxialDistance defines distance between each color axis
  115583. * @param scene defines the hosting scene
  115584. */
  115585. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115586. /**
  115587. * Gets camera class name
  115588. * @returns AnaglyphFreeCamera
  115589. */
  115590. getClassName(): string;
  115591. }
  115592. }
  115593. declare module BABYLON {
  115594. /**
  115595. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115596. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115597. */
  115598. export class AnaglyphGamepadCamera extends GamepadCamera {
  115599. /**
  115600. * Creates a new AnaglyphGamepadCamera
  115601. * @param name defines camera name
  115602. * @param position defines initial position
  115603. * @param interaxialDistance defines distance between each color axis
  115604. * @param scene defines the hosting scene
  115605. */
  115606. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115607. /**
  115608. * Gets camera class name
  115609. * @returns AnaglyphGamepadCamera
  115610. */
  115611. getClassName(): string;
  115612. }
  115613. }
  115614. declare module BABYLON {
  115615. /**
  115616. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115617. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115618. */
  115619. export class AnaglyphUniversalCamera extends UniversalCamera {
  115620. /**
  115621. * Creates a new AnaglyphUniversalCamera
  115622. * @param name defines camera name
  115623. * @param position defines initial position
  115624. * @param interaxialDistance defines distance between each color axis
  115625. * @param scene defines the hosting scene
  115626. */
  115627. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115628. /**
  115629. * Gets camera class name
  115630. * @returns AnaglyphUniversalCamera
  115631. */
  115632. getClassName(): string;
  115633. }
  115634. }
  115635. declare module BABYLON {
  115636. /** @hidden */
  115637. export var stereoscopicInterlacePixelShader: {
  115638. name: string;
  115639. shader: string;
  115640. };
  115641. }
  115642. declare module BABYLON {
  115643. /**
  115644. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115645. */
  115646. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115647. private _stepSize;
  115648. private _passedProcess;
  115649. /**
  115650. * Initializes a StereoscopicInterlacePostProcessI
  115651. * @param name The name of the effect.
  115652. * @param rigCameras The rig cameras to be appled to the post process
  115653. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115654. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115656. * @param engine The engine which the post process will be applied. (default: current engine)
  115657. * @param reusable If the post process can be reused on the same frame. (default: false)
  115658. */
  115659. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115660. }
  115661. /**
  115662. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115663. */
  115664. export class StereoscopicInterlacePostProcess extends PostProcess {
  115665. private _stepSize;
  115666. private _passedProcess;
  115667. /**
  115668. * Initializes a StereoscopicInterlacePostProcess
  115669. * @param name The name of the effect.
  115670. * @param rigCameras The rig cameras to be appled to the post process
  115671. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115673. * @param engine The engine which the post process will be applied. (default: current engine)
  115674. * @param reusable If the post process can be reused on the same frame. (default: false)
  115675. */
  115676. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115677. }
  115678. }
  115679. declare module BABYLON {
  115680. /**
  115681. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115682. * @see http://doc.babylonjs.com/features/cameras
  115683. */
  115684. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115685. /**
  115686. * Creates a new StereoscopicArcRotateCamera
  115687. * @param name defines camera name
  115688. * @param alpha defines alpha angle (in radians)
  115689. * @param beta defines beta angle (in radians)
  115690. * @param radius defines radius
  115691. * @param target defines camera target
  115692. * @param interaxialDistance defines distance between each color axis
  115693. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115694. * @param scene defines the hosting scene
  115695. */
  115696. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115697. /**
  115698. * Gets camera class name
  115699. * @returns StereoscopicArcRotateCamera
  115700. */
  115701. getClassName(): string;
  115702. }
  115703. }
  115704. declare module BABYLON {
  115705. /**
  115706. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115707. * @see http://doc.babylonjs.com/features/cameras
  115708. */
  115709. export class StereoscopicFreeCamera extends FreeCamera {
  115710. /**
  115711. * Creates a new StereoscopicFreeCamera
  115712. * @param name defines camera name
  115713. * @param position defines initial position
  115714. * @param interaxialDistance defines distance between each color axis
  115715. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115716. * @param scene defines the hosting scene
  115717. */
  115718. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115719. /**
  115720. * Gets camera class name
  115721. * @returns StereoscopicFreeCamera
  115722. */
  115723. getClassName(): string;
  115724. }
  115725. }
  115726. declare module BABYLON {
  115727. /**
  115728. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115729. * @see http://doc.babylonjs.com/features/cameras
  115730. */
  115731. export class StereoscopicGamepadCamera extends GamepadCamera {
  115732. /**
  115733. * Creates a new StereoscopicGamepadCamera
  115734. * @param name defines camera name
  115735. * @param position defines initial position
  115736. * @param interaxialDistance defines distance between each color axis
  115737. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115738. * @param scene defines the hosting scene
  115739. */
  115740. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115741. /**
  115742. * Gets camera class name
  115743. * @returns StereoscopicGamepadCamera
  115744. */
  115745. getClassName(): string;
  115746. }
  115747. }
  115748. declare module BABYLON {
  115749. /**
  115750. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115751. * @see http://doc.babylonjs.com/features/cameras
  115752. */
  115753. export class StereoscopicUniversalCamera extends UniversalCamera {
  115754. /**
  115755. * Creates a new StereoscopicUniversalCamera
  115756. * @param name defines camera name
  115757. * @param position defines initial position
  115758. * @param interaxialDistance defines distance between each color axis
  115759. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115760. * @param scene defines the hosting scene
  115761. */
  115762. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115763. /**
  115764. * Gets camera class name
  115765. * @returns StereoscopicUniversalCamera
  115766. */
  115767. getClassName(): string;
  115768. }
  115769. }
  115770. declare module BABYLON {
  115771. /**
  115772. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115773. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115774. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115775. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115776. */
  115777. export class VirtualJoysticksCamera extends FreeCamera {
  115778. /**
  115779. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115780. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115781. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115782. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115783. * @param name Define the name of the camera in the scene
  115784. * @param position Define the start position of the camera in the scene
  115785. * @param scene Define the scene the camera belongs to
  115786. */
  115787. constructor(name: string, position: Vector3, scene: Scene);
  115788. /**
  115789. * Gets the current object class name.
  115790. * @return the class name
  115791. */
  115792. getClassName(): string;
  115793. }
  115794. }
  115795. declare module BABYLON {
  115796. /**
  115797. * This represents all the required metrics to create a VR camera.
  115798. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115799. */
  115800. export class VRCameraMetrics {
  115801. /**
  115802. * Define the horizontal resolution off the screen.
  115803. */
  115804. hResolution: number;
  115805. /**
  115806. * Define the vertical resolution off the screen.
  115807. */
  115808. vResolution: number;
  115809. /**
  115810. * Define the horizontal screen size.
  115811. */
  115812. hScreenSize: number;
  115813. /**
  115814. * Define the vertical screen size.
  115815. */
  115816. vScreenSize: number;
  115817. /**
  115818. * Define the vertical screen center position.
  115819. */
  115820. vScreenCenter: number;
  115821. /**
  115822. * Define the distance of the eyes to the screen.
  115823. */
  115824. eyeToScreenDistance: number;
  115825. /**
  115826. * Define the distance between both lenses
  115827. */
  115828. lensSeparationDistance: number;
  115829. /**
  115830. * Define the distance between both viewer's eyes.
  115831. */
  115832. interpupillaryDistance: number;
  115833. /**
  115834. * Define the distortion factor of the VR postprocess.
  115835. * Please, touch with care.
  115836. */
  115837. distortionK: number[];
  115838. /**
  115839. * Define the chromatic aberration correction factors for the VR post process.
  115840. */
  115841. chromaAbCorrection: number[];
  115842. /**
  115843. * Define the scale factor of the post process.
  115844. * The smaller the better but the slower.
  115845. */
  115846. postProcessScaleFactor: number;
  115847. /**
  115848. * Define an offset for the lens center.
  115849. */
  115850. lensCenterOffset: number;
  115851. /**
  115852. * Define if the current vr camera should compensate the distortion of the lense or not.
  115853. */
  115854. compensateDistortion: boolean;
  115855. /**
  115856. * Defines if multiview should be enabled when rendering (Default: false)
  115857. */
  115858. multiviewEnabled: boolean;
  115859. /**
  115860. * Gets the rendering aspect ratio based on the provided resolutions.
  115861. */
  115862. get aspectRatio(): number;
  115863. /**
  115864. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115865. */
  115866. get aspectRatioFov(): number;
  115867. /**
  115868. * @hidden
  115869. */
  115870. get leftHMatrix(): Matrix;
  115871. /**
  115872. * @hidden
  115873. */
  115874. get rightHMatrix(): Matrix;
  115875. /**
  115876. * @hidden
  115877. */
  115878. get leftPreViewMatrix(): Matrix;
  115879. /**
  115880. * @hidden
  115881. */
  115882. get rightPreViewMatrix(): Matrix;
  115883. /**
  115884. * Get the default VRMetrics based on the most generic setup.
  115885. * @returns the default vr metrics
  115886. */
  115887. static GetDefault(): VRCameraMetrics;
  115888. }
  115889. }
  115890. declare module BABYLON {
  115891. /** @hidden */
  115892. export var vrDistortionCorrectionPixelShader: {
  115893. name: string;
  115894. shader: string;
  115895. };
  115896. }
  115897. declare module BABYLON {
  115898. /**
  115899. * VRDistortionCorrectionPostProcess used for mobile VR
  115900. */
  115901. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115902. private _isRightEye;
  115903. private _distortionFactors;
  115904. private _postProcessScaleFactor;
  115905. private _lensCenterOffset;
  115906. private _scaleIn;
  115907. private _scaleFactor;
  115908. private _lensCenter;
  115909. /**
  115910. * Initializes the VRDistortionCorrectionPostProcess
  115911. * @param name The name of the effect.
  115912. * @param camera The camera to apply the render pass to.
  115913. * @param isRightEye If this is for the right eye distortion
  115914. * @param vrMetrics All the required metrics for the VR camera
  115915. */
  115916. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115917. }
  115918. }
  115919. declare module BABYLON {
  115920. /**
  115921. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115922. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115923. */
  115924. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115925. /**
  115926. * Creates a new VRDeviceOrientationArcRotateCamera
  115927. * @param name defines camera name
  115928. * @param alpha defines the camera rotation along the logitudinal axis
  115929. * @param beta defines the camera rotation along the latitudinal axis
  115930. * @param radius defines the camera distance from its target
  115931. * @param target defines the camera target
  115932. * @param scene defines the scene the camera belongs to
  115933. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115934. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115935. */
  115936. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115937. /**
  115938. * Gets camera class name
  115939. * @returns VRDeviceOrientationArcRotateCamera
  115940. */
  115941. getClassName(): string;
  115942. }
  115943. }
  115944. declare module BABYLON {
  115945. /**
  115946. * Camera used to simulate VR rendering (based on FreeCamera)
  115947. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115948. */
  115949. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115950. /**
  115951. * Creates a new VRDeviceOrientationFreeCamera
  115952. * @param name defines camera name
  115953. * @param position defines the start position of the camera
  115954. * @param scene defines the scene the camera belongs to
  115955. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115956. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115957. */
  115958. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115959. /**
  115960. * Gets camera class name
  115961. * @returns VRDeviceOrientationFreeCamera
  115962. */
  115963. getClassName(): string;
  115964. }
  115965. }
  115966. declare module BABYLON {
  115967. /**
  115968. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115969. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115970. */
  115971. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115972. /**
  115973. * Creates a new VRDeviceOrientationGamepadCamera
  115974. * @param name defines camera name
  115975. * @param position defines the start position of the camera
  115976. * @param scene defines the scene the camera belongs to
  115977. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115978. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115979. */
  115980. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115981. /**
  115982. * Gets camera class name
  115983. * @returns VRDeviceOrientationGamepadCamera
  115984. */
  115985. getClassName(): string;
  115986. }
  115987. }
  115988. declare module BABYLON {
  115989. /** @hidden */
  115990. export var imageProcessingPixelShader: {
  115991. name: string;
  115992. shader: string;
  115993. };
  115994. }
  115995. declare module BABYLON {
  115996. /**
  115997. * ImageProcessingPostProcess
  115998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115999. */
  116000. export class ImageProcessingPostProcess extends PostProcess {
  116001. /**
  116002. * Default configuration related to image processing available in the PBR Material.
  116003. */
  116004. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116005. /**
  116006. * Gets the image processing configuration used either in this material.
  116007. */
  116008. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116009. /**
  116010. * Sets the Default image processing configuration used either in the this material.
  116011. *
  116012. * If sets to null, the scene one is in use.
  116013. */
  116014. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  116015. /**
  116016. * Keep track of the image processing observer to allow dispose and replace.
  116017. */
  116018. private _imageProcessingObserver;
  116019. /**
  116020. * Attaches a new image processing configuration to the PBR Material.
  116021. * @param configuration
  116022. */
  116023. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  116024. /**
  116025. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116026. */
  116027. get colorCurves(): Nullable<ColorCurves>;
  116028. /**
  116029. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116030. */
  116031. set colorCurves(value: Nullable<ColorCurves>);
  116032. /**
  116033. * Gets wether the color curves effect is enabled.
  116034. */
  116035. get colorCurvesEnabled(): boolean;
  116036. /**
  116037. * Sets wether the color curves effect is enabled.
  116038. */
  116039. set colorCurvesEnabled(value: boolean);
  116040. /**
  116041. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116042. */
  116043. get colorGradingTexture(): Nullable<BaseTexture>;
  116044. /**
  116045. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116046. */
  116047. set colorGradingTexture(value: Nullable<BaseTexture>);
  116048. /**
  116049. * Gets wether the color grading effect is enabled.
  116050. */
  116051. get colorGradingEnabled(): boolean;
  116052. /**
  116053. * Gets wether the color grading effect is enabled.
  116054. */
  116055. set colorGradingEnabled(value: boolean);
  116056. /**
  116057. * Gets exposure used in the effect.
  116058. */
  116059. get exposure(): number;
  116060. /**
  116061. * Sets exposure used in the effect.
  116062. */
  116063. set exposure(value: number);
  116064. /**
  116065. * Gets wether tonemapping is enabled or not.
  116066. */
  116067. get toneMappingEnabled(): boolean;
  116068. /**
  116069. * Sets wether tonemapping is enabled or not
  116070. */
  116071. set toneMappingEnabled(value: boolean);
  116072. /**
  116073. * Gets the type of tone mapping effect.
  116074. */
  116075. get toneMappingType(): number;
  116076. /**
  116077. * Sets the type of tone mapping effect.
  116078. */
  116079. set toneMappingType(value: number);
  116080. /**
  116081. * Gets contrast used in the effect.
  116082. */
  116083. get contrast(): number;
  116084. /**
  116085. * Sets contrast used in the effect.
  116086. */
  116087. set contrast(value: number);
  116088. /**
  116089. * Gets Vignette stretch size.
  116090. */
  116091. get vignetteStretch(): number;
  116092. /**
  116093. * Sets Vignette stretch size.
  116094. */
  116095. set vignetteStretch(value: number);
  116096. /**
  116097. * Gets Vignette centre X Offset.
  116098. */
  116099. get vignetteCentreX(): number;
  116100. /**
  116101. * Sets Vignette centre X Offset.
  116102. */
  116103. set vignetteCentreX(value: number);
  116104. /**
  116105. * Gets Vignette centre Y Offset.
  116106. */
  116107. get vignetteCentreY(): number;
  116108. /**
  116109. * Sets Vignette centre Y Offset.
  116110. */
  116111. set vignetteCentreY(value: number);
  116112. /**
  116113. * Gets Vignette weight or intensity of the vignette effect.
  116114. */
  116115. get vignetteWeight(): number;
  116116. /**
  116117. * Sets Vignette weight or intensity of the vignette effect.
  116118. */
  116119. set vignetteWeight(value: number);
  116120. /**
  116121. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116122. * if vignetteEnabled is set to true.
  116123. */
  116124. get vignetteColor(): Color4;
  116125. /**
  116126. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116127. * if vignetteEnabled is set to true.
  116128. */
  116129. set vignetteColor(value: Color4);
  116130. /**
  116131. * Gets Camera field of view used by the Vignette effect.
  116132. */
  116133. get vignetteCameraFov(): number;
  116134. /**
  116135. * Sets Camera field of view used by the Vignette effect.
  116136. */
  116137. set vignetteCameraFov(value: number);
  116138. /**
  116139. * Gets the vignette blend mode allowing different kind of effect.
  116140. */
  116141. get vignetteBlendMode(): number;
  116142. /**
  116143. * Sets the vignette blend mode allowing different kind of effect.
  116144. */
  116145. set vignetteBlendMode(value: number);
  116146. /**
  116147. * Gets wether the vignette effect is enabled.
  116148. */
  116149. get vignetteEnabled(): boolean;
  116150. /**
  116151. * Sets wether the vignette effect is enabled.
  116152. */
  116153. set vignetteEnabled(value: boolean);
  116154. private _fromLinearSpace;
  116155. /**
  116156. * Gets wether the input of the processing is in Gamma or Linear Space.
  116157. */
  116158. get fromLinearSpace(): boolean;
  116159. /**
  116160. * Sets wether the input of the processing is in Gamma or Linear Space.
  116161. */
  116162. set fromLinearSpace(value: boolean);
  116163. /**
  116164. * Defines cache preventing GC.
  116165. */
  116166. private _defines;
  116167. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116168. /**
  116169. * "ImageProcessingPostProcess"
  116170. * @returns "ImageProcessingPostProcess"
  116171. */
  116172. getClassName(): string;
  116173. protected _updateParameters(): void;
  116174. dispose(camera?: Camera): void;
  116175. }
  116176. }
  116177. declare module BABYLON {
  116178. /**
  116179. * Class containing static functions to help procedurally build meshes
  116180. */
  116181. export class GroundBuilder {
  116182. /**
  116183. * Creates a ground mesh
  116184. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116185. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116187. * @param name defines the name of the mesh
  116188. * @param options defines the options used to create the mesh
  116189. * @param scene defines the hosting scene
  116190. * @returns the ground mesh
  116191. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116192. */
  116193. static CreateGround(name: string, options: {
  116194. width?: number;
  116195. height?: number;
  116196. subdivisions?: number;
  116197. subdivisionsX?: number;
  116198. subdivisionsY?: number;
  116199. updatable?: boolean;
  116200. }, scene: any): Mesh;
  116201. /**
  116202. * Creates a tiled ground mesh
  116203. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116204. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116205. * * 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
  116206. * * 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
  116207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116208. * @param name defines the name of the mesh
  116209. * @param options defines the options used to create the mesh
  116210. * @param scene defines the hosting scene
  116211. * @returns the tiled ground mesh
  116212. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116213. */
  116214. static CreateTiledGround(name: string, options: {
  116215. xmin: number;
  116216. zmin: number;
  116217. xmax: number;
  116218. zmax: number;
  116219. subdivisions?: {
  116220. w: number;
  116221. h: number;
  116222. };
  116223. precision?: {
  116224. w: number;
  116225. h: number;
  116226. };
  116227. updatable?: boolean;
  116228. }, scene?: Nullable<Scene>): Mesh;
  116229. /**
  116230. * Creates a ground mesh from a height map
  116231. * * The parameter `url` sets the URL of the height map image resource.
  116232. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116233. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116234. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116235. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116236. * * 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.
  116237. * * 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).
  116238. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116240. * @param name defines the name of the mesh
  116241. * @param url defines the url to the height map
  116242. * @param options defines the options used to create the mesh
  116243. * @param scene defines the hosting scene
  116244. * @returns the ground mesh
  116245. * @see https://doc.babylonjs.com/babylon101/height_map
  116246. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116247. */
  116248. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116249. width?: number;
  116250. height?: number;
  116251. subdivisions?: number;
  116252. minHeight?: number;
  116253. maxHeight?: number;
  116254. colorFilter?: Color3;
  116255. alphaFilter?: number;
  116256. updatable?: boolean;
  116257. onReady?: (mesh: GroundMesh) => void;
  116258. }, scene?: Nullable<Scene>): GroundMesh;
  116259. }
  116260. }
  116261. declare module BABYLON {
  116262. /**
  116263. * Class containing static functions to help procedurally build meshes
  116264. */
  116265. export class TorusBuilder {
  116266. /**
  116267. * Creates a torus mesh
  116268. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116269. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116270. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116274. * @param name defines the name of the mesh
  116275. * @param options defines the options used to create the mesh
  116276. * @param scene defines the hosting scene
  116277. * @returns the torus mesh
  116278. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116279. */
  116280. static CreateTorus(name: string, options: {
  116281. diameter?: number;
  116282. thickness?: number;
  116283. tessellation?: number;
  116284. updatable?: boolean;
  116285. sideOrientation?: number;
  116286. frontUVs?: Vector4;
  116287. backUVs?: Vector4;
  116288. }, scene: any): Mesh;
  116289. }
  116290. }
  116291. declare module BABYLON {
  116292. /**
  116293. * Class containing static functions to help procedurally build meshes
  116294. */
  116295. export class CylinderBuilder {
  116296. /**
  116297. * Creates a cylinder or a cone mesh
  116298. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116299. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116300. * * 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.
  116301. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116302. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116303. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116304. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116305. * * 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).
  116306. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116307. * * 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).
  116308. * * 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
  116309. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116310. * * 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
  116311. * * 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.
  116312. * * If `enclose` is false, a ring surface is one element.
  116313. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116314. * * 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
  116315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116318. * @param name defines the name of the mesh
  116319. * @param options defines the options used to create the mesh
  116320. * @param scene defines the hosting scene
  116321. * @returns the cylinder mesh
  116322. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116323. */
  116324. static CreateCylinder(name: string, options: {
  116325. height?: number;
  116326. diameterTop?: number;
  116327. diameterBottom?: number;
  116328. diameter?: number;
  116329. tessellation?: number;
  116330. subdivisions?: number;
  116331. arc?: number;
  116332. faceColors?: Color4[];
  116333. faceUV?: Vector4[];
  116334. updatable?: boolean;
  116335. hasRings?: boolean;
  116336. enclose?: boolean;
  116337. cap?: number;
  116338. sideOrientation?: number;
  116339. frontUVs?: Vector4;
  116340. backUVs?: Vector4;
  116341. }, scene: any): Mesh;
  116342. }
  116343. }
  116344. declare module BABYLON {
  116345. /**
  116346. * States of the webXR experience
  116347. */
  116348. export enum WebXRState {
  116349. /**
  116350. * Transitioning to being in XR mode
  116351. */
  116352. ENTERING_XR = 0,
  116353. /**
  116354. * Transitioning to non XR mode
  116355. */
  116356. EXITING_XR = 1,
  116357. /**
  116358. * In XR mode and presenting
  116359. */
  116360. IN_XR = 2,
  116361. /**
  116362. * Not entered XR mode
  116363. */
  116364. NOT_IN_XR = 3
  116365. }
  116366. /**
  116367. * Abstraction of the XR render target
  116368. */
  116369. export interface WebXRRenderTarget extends IDisposable {
  116370. /**
  116371. * xrpresent context of the canvas which can be used to display/mirror xr content
  116372. */
  116373. canvasContext: WebGLRenderingContext;
  116374. /**
  116375. * xr layer for the canvas
  116376. */
  116377. xrLayer: Nullable<XRWebGLLayer>;
  116378. /**
  116379. * Initializes the xr layer for the session
  116380. * @param xrSession xr session
  116381. * @returns a promise that will resolve once the XR Layer has been created
  116382. */
  116383. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116384. }
  116385. }
  116386. declare module BABYLON {
  116387. /**
  116388. * COnfiguration object for WebXR output canvas
  116389. */
  116390. export class WebXRManagedOutputCanvasOptions {
  116391. /**
  116392. * An optional canvas in case you wish to create it yourself and provide it here.
  116393. * If not provided, a new canvas will be created
  116394. */
  116395. canvasElement?: HTMLCanvasElement;
  116396. /**
  116397. * Options for this XR Layer output
  116398. */
  116399. canvasOptions?: XRWebGLLayerOptions;
  116400. /**
  116401. * CSS styling for a newly created canvas (if not provided)
  116402. */
  116403. newCanvasCssStyle?: string;
  116404. /**
  116405. * Get the default values of the configuration object
  116406. * @returns default values of this configuration object
  116407. */
  116408. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  116409. }
  116410. /**
  116411. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  116412. */
  116413. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  116414. private _options;
  116415. private _canvas;
  116416. private _engine;
  116417. /**
  116418. * Rendering context of the canvas which can be used to display/mirror xr content
  116419. */
  116420. canvasContext: WebGLRenderingContext;
  116421. /**
  116422. * xr layer for the canvas
  116423. */
  116424. xrLayer: Nullable<XRWebGLLayer>;
  116425. /**
  116426. * Initializes the canvas to be added/removed upon entering/exiting xr
  116427. * @param _xrSessionManager The XR Session manager
  116428. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  116429. */
  116430. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  116431. /**
  116432. * Disposes of the object
  116433. */
  116434. dispose(): void;
  116435. /**
  116436. * Initializes the xr layer for the session
  116437. * @param xrSession xr session
  116438. * @returns a promise that will resolve once the XR Layer has been created
  116439. */
  116440. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116441. private _addCanvas;
  116442. private _removeCanvas;
  116443. private _setManagedOutputCanvas;
  116444. }
  116445. }
  116446. declare module BABYLON {
  116447. /**
  116448. * Manages an XRSession to work with Babylon's engine
  116449. * @see https://doc.babylonjs.com/how_to/webxr
  116450. */
  116451. export class WebXRSessionManager implements IDisposable {
  116452. /** The scene which the session should be created for */
  116453. scene: Scene;
  116454. private _referenceSpace;
  116455. private _rttProvider;
  116456. private _sessionEnded;
  116457. private _xrNavigator;
  116458. private baseLayer;
  116459. /**
  116460. * The base reference space from which the session started. good if you want to reset your
  116461. * reference space
  116462. */
  116463. baseReferenceSpace: XRReferenceSpace;
  116464. /**
  116465. * Current XR frame
  116466. */
  116467. currentFrame: Nullable<XRFrame>;
  116468. /** WebXR timestamp updated every frame */
  116469. currentTimestamp: number;
  116470. /**
  116471. * Used just in case of a failure to initialize an immersive session.
  116472. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  116473. */
  116474. defaultHeightCompensation: number;
  116475. /**
  116476. * Fires every time a new xrFrame arrives which can be used to update the camera
  116477. */
  116478. onXRFrameObservable: Observable<XRFrame>;
  116479. /**
  116480. * Fires when the reference space changed
  116481. */
  116482. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  116483. /**
  116484. * Fires when the xr session is ended either by the device or manually done
  116485. */
  116486. onXRSessionEnded: Observable<any>;
  116487. /**
  116488. * Fires when the xr session is ended either by the device or manually done
  116489. */
  116490. onXRSessionInit: Observable<XRSession>;
  116491. /**
  116492. * Underlying xr session
  116493. */
  116494. session: XRSession;
  116495. /**
  116496. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  116497. * or get the offset the player is currently at.
  116498. */
  116499. viewerReferenceSpace: XRReferenceSpace;
  116500. /**
  116501. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  116502. * @param scene The scene which the session should be created for
  116503. */
  116504. constructor(
  116505. /** The scene which the session should be created for */
  116506. scene: Scene);
  116507. /**
  116508. * The current reference space used in this session. This reference space can constantly change!
  116509. * It is mainly used to offset the camera's position.
  116510. */
  116511. get referenceSpace(): XRReferenceSpace;
  116512. /**
  116513. * Set a new reference space and triggers the observable
  116514. */
  116515. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  116516. /**
  116517. * Disposes of the session manager
  116518. */
  116519. dispose(): void;
  116520. /**
  116521. * Stops the xrSession and restores the render loop
  116522. * @returns Promise which resolves after it exits XR
  116523. */
  116524. exitXRAsync(): Promise<void>;
  116525. /**
  116526. * Gets the correct render target texture to be rendered this frame for this eye
  116527. * @param eye the eye for which to get the render target
  116528. * @returns the render target for the specified eye
  116529. */
  116530. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116531. /**
  116532. * Creates a WebXRRenderTarget object for the XR session
  116533. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116534. * @param options optional options to provide when creating a new render target
  116535. * @returns a WebXR render target to which the session can render
  116536. */
  116537. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116538. /**
  116539. * Initializes the manager
  116540. * After initialization enterXR can be called to start an XR session
  116541. * @returns Promise which resolves after it is initialized
  116542. */
  116543. initializeAsync(): Promise<void>;
  116544. /**
  116545. * Initializes an xr session
  116546. * @param xrSessionMode mode to initialize
  116547. * @param xrSessionInit defines optional and required values to pass to the session builder
  116548. * @returns a promise which will resolve once the session has been initialized
  116549. */
  116550. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116551. /**
  116552. * Checks if a session would be supported for the creation options specified
  116553. * @param sessionMode session mode to check if supported eg. immersive-vr
  116554. * @returns A Promise that resolves to true if supported and false if not
  116555. */
  116556. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116557. /**
  116558. * Resets the reference space to the one started the session
  116559. */
  116560. resetReferenceSpace(): void;
  116561. /**
  116562. * Starts rendering to the xr layer
  116563. */
  116564. runXRRenderLoop(): void;
  116565. /**
  116566. * Sets the reference space on the xr session
  116567. * @param referenceSpaceType space to set
  116568. * @returns a promise that will resolve once the reference space has been set
  116569. */
  116570. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116571. /**
  116572. * Updates the render state of the session
  116573. * @param state state to set
  116574. * @returns a promise that resolves once the render state has been updated
  116575. */
  116576. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116577. /**
  116578. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116579. * @param sessionMode defines the session to test
  116580. * @returns a promise with boolean as final value
  116581. */
  116582. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116583. private _createRenderTargetTexture;
  116584. }
  116585. }
  116586. declare module BABYLON {
  116587. /**
  116588. * WebXR Camera which holds the views for the xrSession
  116589. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116590. */
  116591. export class WebXRCamera extends FreeCamera {
  116592. private _xrSessionManager;
  116593. private _firstFrame;
  116594. private _referenceQuaternion;
  116595. private _referencedPosition;
  116596. private _xrInvPositionCache;
  116597. private _xrInvQuaternionCache;
  116598. /**
  116599. * Should position compensation execute on first frame.
  116600. * This is used when copying the position from a native (non XR) camera
  116601. */
  116602. compensateOnFirstFrame: boolean;
  116603. /**
  116604. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116605. * @param name the name of the camera
  116606. * @param scene the scene to add the camera to
  116607. * @param _xrSessionManager a constructed xr session manager
  116608. */
  116609. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116610. /**
  116611. * Return the user's height, unrelated to the current ground.
  116612. * This will be the y position of this camera, when ground level is 0.
  116613. */
  116614. get realWorldHeight(): number;
  116615. /** @hidden */
  116616. _updateForDualEyeDebugging(): void;
  116617. /**
  116618. * Sets this camera's transformation based on a non-vr camera
  116619. * @param otherCamera the non-vr camera to copy the transformation from
  116620. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116621. */
  116622. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116623. /**
  116624. * Gets the current instance class name ("WebXRCamera").
  116625. * @returns the class name
  116626. */
  116627. getClassName(): string;
  116628. private _updateFromXRSession;
  116629. private _updateNumberOfRigCameras;
  116630. private _updateReferenceSpace;
  116631. private _updateReferenceSpaceOffset;
  116632. }
  116633. }
  116634. declare module BABYLON {
  116635. /**
  116636. * Defining the interface required for a (webxr) feature
  116637. */
  116638. export interface IWebXRFeature extends IDisposable {
  116639. /**
  116640. * Is this feature attached
  116641. */
  116642. attached: boolean;
  116643. /**
  116644. * Should auto-attach be disabled?
  116645. */
  116646. disableAutoAttach: boolean;
  116647. /**
  116648. * Attach the feature to the session
  116649. * Will usually be called by the features manager
  116650. *
  116651. * @param force should attachment be forced (even when already attached)
  116652. * @returns true if successful.
  116653. */
  116654. attach(force?: boolean): boolean;
  116655. /**
  116656. * Detach the feature from the session
  116657. * Will usually be called by the features manager
  116658. *
  116659. * @returns true if successful.
  116660. */
  116661. detach(): boolean;
  116662. }
  116663. /**
  116664. * A list of the currently available features without referencing them
  116665. */
  116666. export class WebXRFeatureName {
  116667. /**
  116668. * The name of the anchor system feature
  116669. */
  116670. static ANCHOR_SYSTEM: string;
  116671. /**
  116672. * The name of the background remover feature
  116673. */
  116674. static BACKGROUND_REMOVER: string;
  116675. /**
  116676. * The name of the hit test feature
  116677. */
  116678. static HIT_TEST: string;
  116679. /**
  116680. * physics impostors for xr controllers feature
  116681. */
  116682. static PHYSICS_CONTROLLERS: string;
  116683. /**
  116684. * The name of the plane detection feature
  116685. */
  116686. static PLANE_DETECTION: string;
  116687. /**
  116688. * The name of the pointer selection feature
  116689. */
  116690. static POINTER_SELECTION: string;
  116691. /**
  116692. * The name of the teleportation feature
  116693. */
  116694. static TELEPORTATION: string;
  116695. }
  116696. /**
  116697. * Defining the constructor of a feature. Used to register the modules.
  116698. */
  116699. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116700. /**
  116701. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116702. * It is mainly used in AR sessions.
  116703. *
  116704. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116705. */
  116706. export class WebXRFeaturesManager implements IDisposable {
  116707. private _xrSessionManager;
  116708. private static readonly _AvailableFeatures;
  116709. private _features;
  116710. /**
  116711. * constructs a new features manages.
  116712. *
  116713. * @param _xrSessionManager an instance of WebXRSessionManager
  116714. */
  116715. constructor(_xrSessionManager: WebXRSessionManager);
  116716. /**
  116717. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116718. * Mainly used internally.
  116719. *
  116720. * @param featureName the name of the feature to register
  116721. * @param constructorFunction the function used to construct the module
  116722. * @param version the (babylon) version of the module
  116723. * @param stable is that a stable version of this module
  116724. */
  116725. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116726. /**
  116727. * Returns a constructor of a specific feature.
  116728. *
  116729. * @param featureName the name of the feature to construct
  116730. * @param version the version of the feature to load
  116731. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116732. * @param options optional options provided to the module.
  116733. * @returns a function that, when called, will return a new instance of this feature
  116734. */
  116735. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116736. /**
  116737. * Can be used to return the list of features currently registered
  116738. *
  116739. * @returns an Array of available features
  116740. */
  116741. static GetAvailableFeatures(): string[];
  116742. /**
  116743. * Gets the versions available for a specific feature
  116744. * @param featureName the name of the feature
  116745. * @returns an array with the available versions
  116746. */
  116747. static GetAvailableVersions(featureName: string): string[];
  116748. /**
  116749. * Return the latest unstable version of this feature
  116750. * @param featureName the name of the feature to search
  116751. * @returns the version number. if not found will return -1
  116752. */
  116753. static GetLatestVersionOfFeature(featureName: string): number;
  116754. /**
  116755. * Return the latest stable version of this feature
  116756. * @param featureName the name of the feature to search
  116757. * @returns the version number. if not found will return -1
  116758. */
  116759. static GetStableVersionOfFeature(featureName: string): number;
  116760. /**
  116761. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116762. * Can be used during a session to start a feature
  116763. * @param featureName the name of feature to attach
  116764. */
  116765. attachFeature(featureName: string): void;
  116766. /**
  116767. * Can be used inside a session or when the session ends to detach a specific feature
  116768. * @param featureName the name of the feature to detach
  116769. */
  116770. detachFeature(featureName: string): void;
  116771. /**
  116772. * Used to disable an already-enabled feature
  116773. * The feature will be disposed and will be recreated once enabled.
  116774. * @param featureName the feature to disable
  116775. * @returns true if disable was successful
  116776. */
  116777. disableFeature(featureName: string | {
  116778. Name: string;
  116779. }): boolean;
  116780. /**
  116781. * dispose this features manager
  116782. */
  116783. dispose(): void;
  116784. /**
  116785. * 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.
  116786. * 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.
  116787. *
  116788. * @param featureName the name of the feature to load or the class of the feature
  116789. * @param version optional version to load. if not provided the latest version will be enabled
  116790. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116791. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116792. * @returns a new constructed feature or throws an error if feature not found.
  116793. */
  116794. enableFeature(featureName: string | {
  116795. Name: string;
  116796. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116797. /**
  116798. * get the implementation of an enabled feature.
  116799. * @param featureName the name of the feature to load
  116800. * @returns the feature class, if found
  116801. */
  116802. getEnabledFeature(featureName: string): IWebXRFeature;
  116803. /**
  116804. * Get the list of enabled features
  116805. * @returns an array of enabled features
  116806. */
  116807. getEnabledFeatures(): string[];
  116808. }
  116809. }
  116810. declare module BABYLON {
  116811. /**
  116812. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116813. * @see https://doc.babylonjs.com/how_to/webxr
  116814. */
  116815. export class WebXRExperienceHelper implements IDisposable {
  116816. private scene;
  116817. private _nonVRCamera;
  116818. private _originalSceneAutoClear;
  116819. private _supported;
  116820. /**
  116821. * Camera used to render xr content
  116822. */
  116823. camera: WebXRCamera;
  116824. /** A features manager for this xr session */
  116825. featuresManager: WebXRFeaturesManager;
  116826. /**
  116827. * Observers registered here will be triggered after the camera's initial transformation is set
  116828. * This can be used to set a different ground level or an extra rotation.
  116829. *
  116830. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116831. * to the position set after this observable is done executing.
  116832. */
  116833. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116834. /**
  116835. * Fires when the state of the experience helper has changed
  116836. */
  116837. onStateChangedObservable: Observable<WebXRState>;
  116838. /** Session manager used to keep track of xr session */
  116839. sessionManager: WebXRSessionManager;
  116840. /**
  116841. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116842. */
  116843. state: WebXRState;
  116844. /**
  116845. * Creates a WebXRExperienceHelper
  116846. * @param scene The scene the helper should be created in
  116847. */
  116848. private constructor();
  116849. /**
  116850. * Creates the experience helper
  116851. * @param scene the scene to attach the experience helper to
  116852. * @returns a promise for the experience helper
  116853. */
  116854. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116855. /**
  116856. * Disposes of the experience helper
  116857. */
  116858. dispose(): void;
  116859. /**
  116860. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116861. * @param sessionMode options for the XR session
  116862. * @param referenceSpaceType frame of reference of the XR session
  116863. * @param renderTarget the output canvas that will be used to enter XR mode
  116864. * @returns promise that resolves after xr mode has entered
  116865. */
  116866. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116867. /**
  116868. * Exits XR mode and returns the scene to its original state
  116869. * @returns promise that resolves after xr mode has exited
  116870. */
  116871. exitXRAsync(): Promise<void>;
  116872. private _nonXRToXRCamera;
  116873. private _setState;
  116874. }
  116875. }
  116876. declare module BABYLON {
  116877. /**
  116878. * X-Y values for axes in WebXR
  116879. */
  116880. export interface IWebXRMotionControllerAxesValue {
  116881. /**
  116882. * The value of the x axis
  116883. */
  116884. x: number;
  116885. /**
  116886. * The value of the y-axis
  116887. */
  116888. y: number;
  116889. }
  116890. /**
  116891. * changed / previous values for the values of this component
  116892. */
  116893. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116894. /**
  116895. * current (this frame) value
  116896. */
  116897. current: T;
  116898. /**
  116899. * previous (last change) value
  116900. */
  116901. previous: T;
  116902. }
  116903. /**
  116904. * Represents changes in the component between current frame and last values recorded
  116905. */
  116906. export interface IWebXRMotionControllerComponentChanges {
  116907. /**
  116908. * will be populated with previous and current values if axes changed
  116909. */
  116910. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116911. /**
  116912. * will be populated with previous and current values if pressed changed
  116913. */
  116914. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116915. /**
  116916. * will be populated with previous and current values if touched changed
  116917. */
  116918. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116919. /**
  116920. * will be populated with previous and current values if value changed
  116921. */
  116922. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116923. }
  116924. /**
  116925. * This class represents a single component (for example button or thumbstick) of a motion controller
  116926. */
  116927. export class WebXRControllerComponent implements IDisposable {
  116928. /**
  116929. * the id of this component
  116930. */
  116931. id: string;
  116932. /**
  116933. * the type of the component
  116934. */
  116935. type: MotionControllerComponentType;
  116936. private _buttonIndex;
  116937. private _axesIndices;
  116938. private _axes;
  116939. private _changes;
  116940. private _currentValue;
  116941. private _hasChanges;
  116942. private _pressed;
  116943. private _touched;
  116944. /**
  116945. * button component type
  116946. */
  116947. static BUTTON_TYPE: MotionControllerComponentType;
  116948. /**
  116949. * squeeze component type
  116950. */
  116951. static SQUEEZE_TYPE: MotionControllerComponentType;
  116952. /**
  116953. * Thumbstick component type
  116954. */
  116955. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116956. /**
  116957. * Touchpad component type
  116958. */
  116959. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116960. /**
  116961. * trigger component type
  116962. */
  116963. static TRIGGER_TYPE: MotionControllerComponentType;
  116964. /**
  116965. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116966. * the axes data changes
  116967. */
  116968. onAxisValueChangedObservable: Observable<{
  116969. x: number;
  116970. y: number;
  116971. }>;
  116972. /**
  116973. * Observers registered here will be triggered when the state of a button changes
  116974. * State change is either pressed / touched / value
  116975. */
  116976. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116977. /**
  116978. * Creates a new component for a motion controller.
  116979. * It is created by the motion controller itself
  116980. *
  116981. * @param id the id of this component
  116982. * @param type the type of the component
  116983. * @param _buttonIndex index in the buttons array of the gamepad
  116984. * @param _axesIndices indices of the values in the axes array of the gamepad
  116985. */
  116986. constructor(
  116987. /**
  116988. * the id of this component
  116989. */
  116990. id: string,
  116991. /**
  116992. * the type of the component
  116993. */
  116994. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116995. /**
  116996. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116997. */
  116998. get axes(): IWebXRMotionControllerAxesValue;
  116999. /**
  117000. * Get the changes. Elements will be populated only if they changed with their previous and current value
  117001. */
  117002. get changes(): IWebXRMotionControllerComponentChanges;
  117003. /**
  117004. * Return whether or not the component changed the last frame
  117005. */
  117006. get hasChanges(): boolean;
  117007. /**
  117008. * is the button currently pressed
  117009. */
  117010. get pressed(): boolean;
  117011. /**
  117012. * is the button currently touched
  117013. */
  117014. get touched(): boolean;
  117015. /**
  117016. * Get the current value of this component
  117017. */
  117018. get value(): number;
  117019. /**
  117020. * Dispose this component
  117021. */
  117022. dispose(): void;
  117023. /**
  117024. * Are there axes correlating to this component
  117025. * @return true is axes data is available
  117026. */
  117027. isAxes(): boolean;
  117028. /**
  117029. * Is this component a button (hence - pressable)
  117030. * @returns true if can be pressed
  117031. */
  117032. isButton(): boolean;
  117033. /**
  117034. * update this component using the gamepad object it is in. Called on every frame
  117035. * @param nativeController the native gamepad controller object
  117036. */
  117037. update(nativeController: IMinimalMotionControllerObject): void;
  117038. }
  117039. }
  117040. declare module BABYLON {
  117041. /**
  117042. * Class used to represent data loading progression
  117043. */
  117044. export class SceneLoaderProgressEvent {
  117045. /** defines if data length to load can be evaluated */
  117046. readonly lengthComputable: boolean;
  117047. /** defines the loaded data length */
  117048. readonly loaded: number;
  117049. /** defines the data length to load */
  117050. readonly total: number;
  117051. /**
  117052. * Create a new progress event
  117053. * @param lengthComputable defines if data length to load can be evaluated
  117054. * @param loaded defines the loaded data length
  117055. * @param total defines the data length to load
  117056. */
  117057. constructor(
  117058. /** defines if data length to load can be evaluated */
  117059. lengthComputable: boolean,
  117060. /** defines the loaded data length */
  117061. loaded: number,
  117062. /** defines the data length to load */
  117063. total: number);
  117064. /**
  117065. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  117066. * @param event defines the source event
  117067. * @returns a new SceneLoaderProgressEvent
  117068. */
  117069. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  117070. }
  117071. /**
  117072. * Interface used by SceneLoader plugins to define supported file extensions
  117073. */
  117074. export interface ISceneLoaderPluginExtensions {
  117075. /**
  117076. * Defines the list of supported extensions
  117077. */
  117078. [extension: string]: {
  117079. isBinary: boolean;
  117080. };
  117081. }
  117082. /**
  117083. * Interface used by SceneLoader plugin factory
  117084. */
  117085. export interface ISceneLoaderPluginFactory {
  117086. /**
  117087. * Defines the name of the factory
  117088. */
  117089. name: string;
  117090. /**
  117091. * Function called to create a new plugin
  117092. * @return the new plugin
  117093. */
  117094. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  117095. /**
  117096. * The callback that returns true if the data can be directly loaded.
  117097. * @param data string containing the file data
  117098. * @returns if the data can be loaded directly
  117099. */
  117100. canDirectLoad?(data: string): boolean;
  117101. }
  117102. /**
  117103. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  117104. */
  117105. export interface ISceneLoaderPluginBase {
  117106. /**
  117107. * The friendly name of this plugin.
  117108. */
  117109. name: string;
  117110. /**
  117111. * The file extensions supported by this plugin.
  117112. */
  117113. extensions: string | ISceneLoaderPluginExtensions;
  117114. /**
  117115. * The callback called when loading from a url.
  117116. * @param scene scene loading this url
  117117. * @param url url to load
  117118. * @param onSuccess callback called when the file successfully loads
  117119. * @param onProgress callback called while file is loading (if the server supports this mode)
  117120. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117121. * @param onError callback called when the file fails to load
  117122. * @returns a file request object
  117123. */
  117124. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117125. /**
  117126. * The callback called when loading from a file object.
  117127. * @param scene scene loading this file
  117128. * @param file defines the file to load
  117129. * @param onSuccess defines the callback to call when data is loaded
  117130. * @param onProgress defines the callback to call during loading process
  117131. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117132. * @param onError defines the callback to call when an error occurs
  117133. * @returns a file request object
  117134. */
  117135. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117136. /**
  117137. * The callback that returns true if the data can be directly loaded.
  117138. * @param data string containing the file data
  117139. * @returns if the data can be loaded directly
  117140. */
  117141. canDirectLoad?(data: string): boolean;
  117142. /**
  117143. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117144. * @param scene scene loading this data
  117145. * @param data string containing the data
  117146. * @returns data to pass to the plugin
  117147. */
  117148. directLoad?(scene: Scene, data: string): any;
  117149. /**
  117150. * The callback that allows custom handling of the root url based on the response url.
  117151. * @param rootUrl the original root url
  117152. * @param responseURL the response url if available
  117153. * @returns the new root url
  117154. */
  117155. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117156. }
  117157. /**
  117158. * Interface used to define a SceneLoader plugin
  117159. */
  117160. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117161. /**
  117162. * Import meshes into a scene.
  117163. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117164. * @param scene The scene to import into
  117165. * @param data The data to import
  117166. * @param rootUrl The root url for scene and resources
  117167. * @param meshes The meshes array to import into
  117168. * @param particleSystems The particle systems array to import into
  117169. * @param skeletons The skeletons array to import into
  117170. * @param onError The callback when import fails
  117171. * @returns True if successful or false otherwise
  117172. */
  117173. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  117174. /**
  117175. * Load into a scene.
  117176. * @param scene The scene to load into
  117177. * @param data The data to import
  117178. * @param rootUrl The root url for scene and resources
  117179. * @param onError The callback when import fails
  117180. * @returns True if successful or false otherwise
  117181. */
  117182. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  117183. /**
  117184. * Load into an asset container.
  117185. * @param scene The scene to load into
  117186. * @param data The data to import
  117187. * @param rootUrl The root url for scene and resources
  117188. * @param onError The callback when import fails
  117189. * @returns The loaded asset container
  117190. */
  117191. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  117192. }
  117193. /**
  117194. * Interface used to define an async SceneLoader plugin
  117195. */
  117196. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  117197. /**
  117198. * Import meshes into a scene.
  117199. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117200. * @param scene The scene to import into
  117201. * @param data The data to import
  117202. * @param rootUrl The root url for scene and resources
  117203. * @param onProgress The callback when the load progresses
  117204. * @param fileName Defines the name of the file to load
  117205. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  117206. */
  117207. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  117208. meshes: AbstractMesh[];
  117209. particleSystems: IParticleSystem[];
  117210. skeletons: Skeleton[];
  117211. animationGroups: AnimationGroup[];
  117212. }>;
  117213. /**
  117214. * Load into a scene.
  117215. * @param scene The scene to load into
  117216. * @param data The data to import
  117217. * @param rootUrl The root url for scene and resources
  117218. * @param onProgress The callback when the load progresses
  117219. * @param fileName Defines the name of the file to load
  117220. * @returns Nothing
  117221. */
  117222. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  117223. /**
  117224. * Load into an asset container.
  117225. * @param scene The scene to load into
  117226. * @param data The data to import
  117227. * @param rootUrl The root url for scene and resources
  117228. * @param onProgress The callback when the load progresses
  117229. * @param fileName Defines the name of the file to load
  117230. * @returns The loaded asset container
  117231. */
  117232. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  117233. }
  117234. /**
  117235. * Mode that determines how to handle old animation groups before loading new ones.
  117236. */
  117237. export enum SceneLoaderAnimationGroupLoadingMode {
  117238. /**
  117239. * Reset all old animations to initial state then dispose them.
  117240. */
  117241. Clean = 0,
  117242. /**
  117243. * Stop all old animations.
  117244. */
  117245. Stop = 1,
  117246. /**
  117247. * Restart old animations from first frame.
  117248. */
  117249. Sync = 2,
  117250. /**
  117251. * Old animations remains untouched.
  117252. */
  117253. NoSync = 3
  117254. }
  117255. /**
  117256. * Class used to load scene from various file formats using registered plugins
  117257. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  117258. */
  117259. export class SceneLoader {
  117260. /**
  117261. * No logging while loading
  117262. */
  117263. static readonly NO_LOGGING: number;
  117264. /**
  117265. * Minimal logging while loading
  117266. */
  117267. static readonly MINIMAL_LOGGING: number;
  117268. /**
  117269. * Summary logging while loading
  117270. */
  117271. static readonly SUMMARY_LOGGING: number;
  117272. /**
  117273. * Detailled logging while loading
  117274. */
  117275. static readonly DETAILED_LOGGING: number;
  117276. /**
  117277. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  117278. */
  117279. static get ForceFullSceneLoadingForIncremental(): boolean;
  117280. static set ForceFullSceneLoadingForIncremental(value: boolean);
  117281. /**
  117282. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  117283. */
  117284. static get ShowLoadingScreen(): boolean;
  117285. static set ShowLoadingScreen(value: boolean);
  117286. /**
  117287. * Defines the current logging level (while loading the scene)
  117288. * @ignorenaming
  117289. */
  117290. static get loggingLevel(): number;
  117291. static set loggingLevel(value: number);
  117292. /**
  117293. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  117294. */
  117295. static get CleanBoneMatrixWeights(): boolean;
  117296. static set CleanBoneMatrixWeights(value: boolean);
  117297. /**
  117298. * Event raised when a plugin is used to load a scene
  117299. */
  117300. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  117301. private static _registeredPlugins;
  117302. private static _getDefaultPlugin;
  117303. private static _getPluginForExtension;
  117304. private static _getPluginForDirectLoad;
  117305. private static _getPluginForFilename;
  117306. private static _getDirectLoad;
  117307. private static _loadData;
  117308. private static _getFileInfo;
  117309. /**
  117310. * Gets a plugin that can load the given extension
  117311. * @param extension defines the extension to load
  117312. * @returns a plugin or null if none works
  117313. */
  117314. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  117315. /**
  117316. * Gets a boolean indicating that the given extension can be loaded
  117317. * @param extension defines the extension to load
  117318. * @returns true if the extension is supported
  117319. */
  117320. static IsPluginForExtensionAvailable(extension: string): boolean;
  117321. /**
  117322. * Adds a new plugin to the list of registered plugins
  117323. * @param plugin defines the plugin to add
  117324. */
  117325. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  117326. /**
  117327. * Import meshes into a scene
  117328. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117329. * @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)
  117330. * @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)
  117331. * @param scene the instance of BABYLON.Scene to append to
  117332. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  117333. * @param onProgress a callback with a progress event for each file being loaded
  117334. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117335. * @param pluginExtension the extension used to determine the plugin
  117336. * @returns The loaded plugin
  117337. */
  117338. 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>;
  117339. /**
  117340. * Import meshes into a scene
  117341. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117342. * @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)
  117343. * @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)
  117344. * @param scene the instance of BABYLON.Scene to append to
  117345. * @param onProgress a callback with a progress event for each file being loaded
  117346. * @param pluginExtension the extension used to determine the plugin
  117347. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  117348. */
  117349. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  117350. meshes: AbstractMesh[];
  117351. particleSystems: IParticleSystem[];
  117352. skeletons: Skeleton[];
  117353. animationGroups: AnimationGroup[];
  117354. }>;
  117355. /**
  117356. * Load a scene
  117357. * @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)
  117358. * @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)
  117359. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117360. * @param onSuccess a callback with the scene when import succeeds
  117361. * @param onProgress a callback with a progress event for each file being loaded
  117362. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117363. * @param pluginExtension the extension used to determine the plugin
  117364. * @returns The loaded plugin
  117365. */
  117366. 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>;
  117367. /**
  117368. * Load a scene
  117369. * @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)
  117370. * @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)
  117371. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117372. * @param onProgress a callback with a progress event for each file being loaded
  117373. * @param pluginExtension the extension used to determine the plugin
  117374. * @returns The loaded scene
  117375. */
  117376. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117377. /**
  117378. * Append a scene
  117379. * @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)
  117380. * @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)
  117381. * @param scene is the instance of BABYLON.Scene to append to
  117382. * @param onSuccess a callback with the scene when import succeeds
  117383. * @param onProgress a callback with a progress event for each file being loaded
  117384. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117385. * @param pluginExtension the extension used to determine the plugin
  117386. * @returns The loaded plugin
  117387. */
  117388. 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>;
  117389. /**
  117390. * Append a scene
  117391. * @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)
  117392. * @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)
  117393. * @param scene is the instance of BABYLON.Scene to append to
  117394. * @param onProgress a callback with a progress event for each file being loaded
  117395. * @param pluginExtension the extension used to determine the plugin
  117396. * @returns The given scene
  117397. */
  117398. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117399. /**
  117400. * Load a scene into an asset container
  117401. * @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)
  117402. * @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)
  117403. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117404. * @param onSuccess a callback with the scene when import succeeds
  117405. * @param onProgress a callback with a progress event for each file being loaded
  117406. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117407. * @param pluginExtension the extension used to determine the plugin
  117408. * @returns The loaded plugin
  117409. */
  117410. 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>;
  117411. /**
  117412. * Load a scene into an asset container
  117413. * @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)
  117414. * @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)
  117415. * @param scene is the instance of Scene to append to
  117416. * @param onProgress a callback with a progress event for each file being loaded
  117417. * @param pluginExtension the extension used to determine the plugin
  117418. * @returns The loaded asset container
  117419. */
  117420. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  117421. /**
  117422. * Import animations from a file into a scene
  117423. * @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)
  117424. * @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)
  117425. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117426. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117427. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117428. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117429. * @param onSuccess a callback with the scene when import succeeds
  117430. * @param onProgress a callback with a progress event for each file being loaded
  117431. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117432. */
  117433. 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;
  117434. /**
  117435. * Import animations from a file into a scene
  117436. * @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)
  117437. * @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)
  117438. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117439. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117440. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117441. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117442. * @param onSuccess a callback with the scene when import succeeds
  117443. * @param onProgress a callback with a progress event for each file being loaded
  117444. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117445. * @returns the updated scene with imported animations
  117446. */
  117447. 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>;
  117448. }
  117449. }
  117450. declare module BABYLON {
  117451. /**
  117452. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  117453. */
  117454. export type MotionControllerHandness = "none" | "left" | "right";
  117455. /**
  117456. * The type of components available in motion controllers.
  117457. * This is not the name of the component.
  117458. */
  117459. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  117460. /**
  117461. * The state of a controller component
  117462. */
  117463. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  117464. /**
  117465. * The schema of motion controller layout.
  117466. * No object will be initialized using this interface
  117467. * This is used just to define the profile.
  117468. */
  117469. export interface IMotionControllerLayout {
  117470. /**
  117471. * Path to load the assets. Usually relative to the base path
  117472. */
  117473. assetPath: string;
  117474. /**
  117475. * Available components (unsorted)
  117476. */
  117477. components: {
  117478. /**
  117479. * A map of component Ids
  117480. */
  117481. [componentId: string]: {
  117482. /**
  117483. * The type of input the component outputs
  117484. */
  117485. type: MotionControllerComponentType;
  117486. /**
  117487. * The indices of this component in the gamepad object
  117488. */
  117489. gamepadIndices: {
  117490. /**
  117491. * Index of button
  117492. */
  117493. button?: number;
  117494. /**
  117495. * If available, index of x-axis
  117496. */
  117497. xAxis?: number;
  117498. /**
  117499. * If available, index of y-axis
  117500. */
  117501. yAxis?: number;
  117502. };
  117503. /**
  117504. * The mesh's root node name
  117505. */
  117506. rootNodeName: string;
  117507. /**
  117508. * Animation definitions for this model
  117509. */
  117510. visualResponses: {
  117511. [stateKey: string]: {
  117512. /**
  117513. * What property will be animated
  117514. */
  117515. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  117516. /**
  117517. * What states influence this visual response
  117518. */
  117519. states: MotionControllerComponentStateType[];
  117520. /**
  117521. * Type of animation - movement or visibility
  117522. */
  117523. valueNodeProperty: "transform" | "visibility";
  117524. /**
  117525. * Base node name to move. Its position will be calculated according to the min and max nodes
  117526. */
  117527. valueNodeName?: string;
  117528. /**
  117529. * Minimum movement node
  117530. */
  117531. minNodeName?: string;
  117532. /**
  117533. * Max movement node
  117534. */
  117535. maxNodeName?: string;
  117536. };
  117537. };
  117538. /**
  117539. * If touch enabled, what is the name of node to display user feedback
  117540. */
  117541. touchPointNodeName?: string;
  117542. };
  117543. };
  117544. /**
  117545. * Is it xr standard mapping or not
  117546. */
  117547. gamepadMapping: "" | "xr-standard";
  117548. /**
  117549. * Base root node of this entire model
  117550. */
  117551. rootNodeName: string;
  117552. /**
  117553. * Defines the main button component id
  117554. */
  117555. selectComponentId: string;
  117556. }
  117557. /**
  117558. * A definition for the layout map in the input profile
  117559. */
  117560. export interface IMotionControllerLayoutMap {
  117561. /**
  117562. * Layouts with handness type as a key
  117563. */
  117564. [handness: string]: IMotionControllerLayout;
  117565. }
  117566. /**
  117567. * The XR Input profile schema
  117568. * Profiles can be found here:
  117569. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117570. */
  117571. export interface IMotionControllerProfile {
  117572. /**
  117573. * fallback profiles for this profileId
  117574. */
  117575. fallbackProfileIds: string[];
  117576. /**
  117577. * The layout map, with handness as key
  117578. */
  117579. layouts: IMotionControllerLayoutMap;
  117580. /**
  117581. * The id of this profile
  117582. * correlates to the profile(s) in the xrInput.profiles array
  117583. */
  117584. profileId: string;
  117585. }
  117586. /**
  117587. * A helper-interface for the 3 meshes needed for controller button animation
  117588. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117589. */
  117590. export interface IMotionControllerButtonMeshMap {
  117591. /**
  117592. * the mesh that defines the pressed value mesh position.
  117593. * This is used to find the max-position of this button
  117594. */
  117595. pressedMesh: AbstractMesh;
  117596. /**
  117597. * the mesh that defines the unpressed value mesh position.
  117598. * This is used to find the min (or initial) position of this button
  117599. */
  117600. unpressedMesh: AbstractMesh;
  117601. /**
  117602. * The mesh that will be changed when value changes
  117603. */
  117604. valueMesh: AbstractMesh;
  117605. }
  117606. /**
  117607. * A helper-interface for the 3 meshes needed for controller axis animation.
  117608. * This will be expanded when touchpad animations are fully supported
  117609. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117610. */
  117611. export interface IMotionControllerMeshMap {
  117612. /**
  117613. * the mesh that defines the maximum value mesh position.
  117614. */
  117615. maxMesh?: AbstractMesh;
  117616. /**
  117617. * the mesh that defines the minimum value mesh position.
  117618. */
  117619. minMesh?: AbstractMesh;
  117620. /**
  117621. * The mesh that will be changed when axis value changes
  117622. */
  117623. valueMesh: AbstractMesh;
  117624. }
  117625. /**
  117626. * The elements needed for change-detection of the gamepad objects in motion controllers
  117627. */
  117628. export interface IMinimalMotionControllerObject {
  117629. /**
  117630. * Available axes of this controller
  117631. */
  117632. axes: number[];
  117633. /**
  117634. * An array of available buttons
  117635. */
  117636. buttons: Array<{
  117637. /**
  117638. * Value of the button/trigger
  117639. */
  117640. value: number;
  117641. /**
  117642. * If the button/trigger is currently touched
  117643. */
  117644. touched: boolean;
  117645. /**
  117646. * If the button/trigger is currently pressed
  117647. */
  117648. pressed: boolean;
  117649. }>;
  117650. }
  117651. /**
  117652. * An Abstract Motion controller
  117653. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117654. * Each component has an observable to check for changes in value and state
  117655. */
  117656. export abstract class WebXRAbstractMotionController implements IDisposable {
  117657. protected scene: Scene;
  117658. protected layout: IMotionControllerLayout;
  117659. /**
  117660. * The gamepad object correlating to this controller
  117661. */
  117662. gamepadObject: IMinimalMotionControllerObject;
  117663. /**
  117664. * handness (left/right/none) of this controller
  117665. */
  117666. handness: MotionControllerHandness;
  117667. private _initComponent;
  117668. private _modelReady;
  117669. /**
  117670. * A map of components (WebXRControllerComponent) in this motion controller
  117671. * Components have a ComponentType and can also have both button and axis definitions
  117672. */
  117673. readonly components: {
  117674. [id: string]: WebXRControllerComponent;
  117675. };
  117676. /**
  117677. * Disable the model's animation. Can be set at any time.
  117678. */
  117679. disableAnimation: boolean;
  117680. /**
  117681. * Observers registered here will be triggered when the model of this controller is done loading
  117682. */
  117683. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117684. /**
  117685. * The profile id of this motion controller
  117686. */
  117687. abstract profileId: string;
  117688. /**
  117689. * The root mesh of the model. It is null if the model was not yet initialized
  117690. */
  117691. rootMesh: Nullable<AbstractMesh>;
  117692. /**
  117693. * constructs a new abstract motion controller
  117694. * @param scene the scene to which the model of the controller will be added
  117695. * @param layout The profile layout to load
  117696. * @param gamepadObject The gamepad object correlating to this controller
  117697. * @param handness handness (left/right/none) of this controller
  117698. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117699. */
  117700. constructor(scene: Scene, layout: IMotionControllerLayout,
  117701. /**
  117702. * The gamepad object correlating to this controller
  117703. */
  117704. gamepadObject: IMinimalMotionControllerObject,
  117705. /**
  117706. * handness (left/right/none) of this controller
  117707. */
  117708. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117709. /**
  117710. * Dispose this controller, the model mesh and all its components
  117711. */
  117712. dispose(): void;
  117713. /**
  117714. * Returns all components of specific type
  117715. * @param type the type to search for
  117716. * @return an array of components with this type
  117717. */
  117718. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117719. /**
  117720. * get a component based an its component id as defined in layout.components
  117721. * @param id the id of the component
  117722. * @returns the component correlates to the id or undefined if not found
  117723. */
  117724. getComponent(id: string): WebXRControllerComponent;
  117725. /**
  117726. * Get the list of components available in this motion controller
  117727. * @returns an array of strings correlating to available components
  117728. */
  117729. getComponentIds(): string[];
  117730. /**
  117731. * Get the first component of specific type
  117732. * @param type type of component to find
  117733. * @return a controller component or null if not found
  117734. */
  117735. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117736. /**
  117737. * Get the main (Select) component of this controller as defined in the layout
  117738. * @returns the main component of this controller
  117739. */
  117740. getMainComponent(): WebXRControllerComponent;
  117741. /**
  117742. * Loads the model correlating to this controller
  117743. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117744. * @returns A promise fulfilled with the result of the model loading
  117745. */
  117746. loadModel(): Promise<boolean>;
  117747. /**
  117748. * Update this model using the current XRFrame
  117749. * @param xrFrame the current xr frame to use and update the model
  117750. */
  117751. updateFromXRFrame(xrFrame: XRFrame): void;
  117752. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117753. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117754. /**
  117755. * Moves the axis on the controller mesh based on its current state
  117756. * @param axis the index of the axis
  117757. * @param axisValue the value of the axis which determines the meshes new position
  117758. * @hidden
  117759. */
  117760. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117761. /**
  117762. * Update the model itself with the current frame data
  117763. * @param xrFrame the frame to use for updating the model mesh
  117764. */
  117765. protected updateModel(xrFrame: XRFrame): void;
  117766. /**
  117767. * Get the filename and path for this controller's model
  117768. * @returns a map of filename and path
  117769. */
  117770. protected abstract _getFilenameAndPath(): {
  117771. filename: string;
  117772. path: string;
  117773. };
  117774. /**
  117775. * This function is called before the mesh is loaded. It checks for loading constraints.
  117776. * For example, this function can check if the GLB loader is available
  117777. * If this function returns false, the generic controller will be loaded instead
  117778. * @returns Is the client ready to load the mesh
  117779. */
  117780. protected abstract _getModelLoadingConstraints(): boolean;
  117781. /**
  117782. * This function will be called after the model was successfully loaded and can be used
  117783. * for mesh transformations before it is available for the user
  117784. * @param meshes the loaded meshes
  117785. */
  117786. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117787. /**
  117788. * Set the root mesh for this controller. Important for the WebXR controller class
  117789. * @param meshes the loaded meshes
  117790. */
  117791. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117792. /**
  117793. * A function executed each frame that updates the mesh (if needed)
  117794. * @param xrFrame the current xrFrame
  117795. */
  117796. protected abstract _updateModel(xrFrame: XRFrame): void;
  117797. private _getGenericFilenameAndPath;
  117798. private _getGenericParentMesh;
  117799. }
  117800. }
  117801. declare module BABYLON {
  117802. /**
  117803. * A generic trigger-only motion controller for WebXR
  117804. */
  117805. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117806. /**
  117807. * Static version of the profile id of this controller
  117808. */
  117809. static ProfileId: string;
  117810. profileId: string;
  117811. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117812. protected _getFilenameAndPath(): {
  117813. filename: string;
  117814. path: string;
  117815. };
  117816. protected _getModelLoadingConstraints(): boolean;
  117817. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117818. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117819. protected _updateModel(): void;
  117820. }
  117821. }
  117822. declare module BABYLON {
  117823. /**
  117824. * Class containing static functions to help procedurally build meshes
  117825. */
  117826. export class SphereBuilder {
  117827. /**
  117828. * Creates a sphere mesh
  117829. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117830. * * 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`)
  117831. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117832. * * 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
  117833. * * 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)
  117834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117837. * @param name defines the name of the mesh
  117838. * @param options defines the options used to create the mesh
  117839. * @param scene defines the hosting scene
  117840. * @returns the sphere mesh
  117841. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117842. */
  117843. static CreateSphere(name: string, options: {
  117844. segments?: number;
  117845. diameter?: number;
  117846. diameterX?: number;
  117847. diameterY?: number;
  117848. diameterZ?: number;
  117849. arc?: number;
  117850. slice?: number;
  117851. sideOrientation?: number;
  117852. frontUVs?: Vector4;
  117853. backUVs?: Vector4;
  117854. updatable?: boolean;
  117855. }, scene?: Nullable<Scene>): Mesh;
  117856. }
  117857. }
  117858. declare module BABYLON {
  117859. /**
  117860. * A profiled motion controller has its profile loaded from an online repository.
  117861. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117862. */
  117863. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117864. private _repositoryUrl;
  117865. private _buttonMeshMapping;
  117866. private _touchDots;
  117867. /**
  117868. * The profile ID of this controller. Will be populated when the controller initializes.
  117869. */
  117870. profileId: string;
  117871. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117872. dispose(): void;
  117873. protected _getFilenameAndPath(): {
  117874. filename: string;
  117875. path: string;
  117876. };
  117877. protected _getModelLoadingConstraints(): boolean;
  117878. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117879. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117880. protected _updateModel(_xrFrame: XRFrame): void;
  117881. }
  117882. }
  117883. declare module BABYLON {
  117884. /**
  117885. * A construction function type to create a new controller based on an xrInput object
  117886. */
  117887. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117888. /**
  117889. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117890. *
  117891. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117892. * it should be replaced with auto-loaded controllers.
  117893. *
  117894. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117895. */
  117896. export class WebXRMotionControllerManager {
  117897. private static _AvailableControllers;
  117898. private static _Fallbacks;
  117899. private static _ProfileLoadingPromises;
  117900. private static _ProfilesList;
  117901. /**
  117902. * The base URL of the online controller repository. Can be changed at any time.
  117903. */
  117904. static BaseRepositoryUrl: string;
  117905. /**
  117906. * Which repository gets priority - local or online
  117907. */
  117908. static PrioritizeOnlineRepository: boolean;
  117909. /**
  117910. * Use the online repository, or use only locally-defined controllers
  117911. */
  117912. static UseOnlineRepository: boolean;
  117913. /**
  117914. * Clear the cache used for profile loading and reload when requested again
  117915. */
  117916. static ClearProfilesCache(): void;
  117917. /**
  117918. * Register the default fallbacks.
  117919. * This function is called automatically when this file is imported.
  117920. */
  117921. static DefaultFallbacks(): void;
  117922. /**
  117923. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117924. * @param profileId the profile to which a fallback needs to be found
  117925. * @return an array with corresponding fallback profiles
  117926. */
  117927. static FindFallbackWithProfileId(profileId: string): string[];
  117928. /**
  117929. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117930. * The order of search:
  117931. *
  117932. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117933. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117934. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117935. * 4) return the generic trigger controller if none were found
  117936. *
  117937. * @param xrInput the xrInput to which a new controller is initialized
  117938. * @param scene the scene to which the model will be added
  117939. * @param forceProfile force a certain profile for this controller
  117940. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117941. */
  117942. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117943. /**
  117944. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117945. *
  117946. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117947. *
  117948. * @param type the profile type to register
  117949. * @param constructFunction the function to be called when loading this profile
  117950. */
  117951. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117952. /**
  117953. * Register a fallback to a specific profile.
  117954. * @param profileId the profileId that will receive the fallbacks
  117955. * @param fallbacks A list of fallback profiles
  117956. */
  117957. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117958. /**
  117959. * Will update the list of profiles available in the repository
  117960. * @return a promise that resolves to a map of profiles available online
  117961. */
  117962. static UpdateProfilesList(): Promise<{
  117963. [profile: string]: string;
  117964. }>;
  117965. private static _LoadProfileFromRepository;
  117966. private static _LoadProfilesFromAvailableControllers;
  117967. }
  117968. }
  117969. declare module BABYLON {
  117970. /**
  117971. * Configuration options for the WebXR controller creation
  117972. */
  117973. export interface IWebXRControllerOptions {
  117974. /**
  117975. * Should the controller mesh be animated when a user interacts with it
  117976. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117977. */
  117978. disableMotionControllerAnimation?: boolean;
  117979. /**
  117980. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117981. */
  117982. doNotLoadControllerMesh?: boolean;
  117983. /**
  117984. * Force a specific controller type for this controller.
  117985. * This can be used when creating your own profile or when testing different controllers
  117986. */
  117987. forceControllerProfile?: string;
  117988. }
  117989. /**
  117990. * Represents an XR controller
  117991. */
  117992. export class WebXRInputSource {
  117993. private _scene;
  117994. /** The underlying input source for the controller */
  117995. inputSource: XRInputSource;
  117996. private _options;
  117997. private _tmpQuaternion;
  117998. private _tmpVector;
  117999. private _uniqueId;
  118000. /**
  118001. * 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
  118002. */
  118003. grip?: AbstractMesh;
  118004. /**
  118005. * If available, this is the gamepad object related to this controller.
  118006. * Using this object it is possible to get click events and trackpad changes of the
  118007. * webxr controller that is currently being used.
  118008. */
  118009. motionController?: WebXRAbstractMotionController;
  118010. /**
  118011. * Event that fires when the controller is removed/disposed.
  118012. * The object provided as event data is this controller, after associated assets were disposed.
  118013. * uniqueId is still available.
  118014. */
  118015. onDisposeObservable: Observable<WebXRInputSource>;
  118016. /**
  118017. * Will be triggered when the mesh associated with the motion controller is done loading.
  118018. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  118019. * A shortened version of controller -> motion controller -> on mesh loaded.
  118020. */
  118021. onMeshLoadedObservable: Observable<AbstractMesh>;
  118022. /**
  118023. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  118024. */
  118025. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  118026. /**
  118027. * Pointer which can be used to select objects or attach a visible laser to
  118028. */
  118029. pointer: AbstractMesh;
  118030. /**
  118031. * Creates the controller
  118032. * @see https://doc.babylonjs.com/how_to/webxr
  118033. * @param _scene the scene which the controller should be associated to
  118034. * @param inputSource the underlying input source for the controller
  118035. * @param _options options for this controller creation
  118036. */
  118037. constructor(_scene: Scene,
  118038. /** The underlying input source for the controller */
  118039. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  118040. /**
  118041. * Get this controllers unique id
  118042. */
  118043. get uniqueId(): string;
  118044. /**
  118045. * Disposes of the object
  118046. */
  118047. dispose(): void;
  118048. /**
  118049. * Gets a world space ray coming from the pointer or grip
  118050. * @param result the resulting ray
  118051. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  118052. */
  118053. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  118054. /**
  118055. * Updates the controller pose based on the given XRFrame
  118056. * @param xrFrame xr frame to update the pose with
  118057. * @param referenceSpace reference space to use
  118058. */
  118059. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  118060. }
  118061. }
  118062. declare module BABYLON {
  118063. /**
  118064. * The schema for initialization options of the XR Input class
  118065. */
  118066. export interface IWebXRInputOptions {
  118067. /**
  118068. * If set to true no model will be automatically loaded
  118069. */
  118070. doNotLoadControllerMeshes?: boolean;
  118071. /**
  118072. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  118073. * If not found, the xr input profile data will be used.
  118074. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  118075. */
  118076. forceInputProfile?: string;
  118077. /**
  118078. * Do not send a request to the controller repository to load the profile.
  118079. *
  118080. * Instead, use the controllers available in babylon itself.
  118081. */
  118082. disableOnlineControllerRepository?: boolean;
  118083. /**
  118084. * A custom URL for the controllers repository
  118085. */
  118086. customControllersRepositoryURL?: string;
  118087. /**
  118088. * Should the controller model's components not move according to the user input
  118089. */
  118090. disableControllerAnimation?: boolean;
  118091. }
  118092. /**
  118093. * XR input used to track XR inputs such as controllers/rays
  118094. */
  118095. export class WebXRInput implements IDisposable {
  118096. /**
  118097. * the xr session manager for this session
  118098. */
  118099. xrSessionManager: WebXRSessionManager;
  118100. /**
  118101. * the WebXR camera for this session. Mainly used for teleportation
  118102. */
  118103. xrCamera: WebXRCamera;
  118104. private readonly options;
  118105. /**
  118106. * XR controllers being tracked
  118107. */
  118108. controllers: Array<WebXRInputSource>;
  118109. private _frameObserver;
  118110. private _sessionEndedObserver;
  118111. private _sessionInitObserver;
  118112. /**
  118113. * Event when a controller has been connected/added
  118114. */
  118115. onControllerAddedObservable: Observable<WebXRInputSource>;
  118116. /**
  118117. * Event when a controller has been removed/disconnected
  118118. */
  118119. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118120. /**
  118121. * Initializes the WebXRInput
  118122. * @param xrSessionManager the xr session manager for this session
  118123. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118124. * @param options = initialization options for this xr input
  118125. */
  118126. constructor(
  118127. /**
  118128. * the xr session manager for this session
  118129. */
  118130. xrSessionManager: WebXRSessionManager,
  118131. /**
  118132. * the WebXR camera for this session. Mainly used for teleportation
  118133. */
  118134. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118135. private _onInputSourcesChange;
  118136. private _addAndRemoveControllers;
  118137. /**
  118138. * Disposes of the object
  118139. */
  118140. dispose(): void;
  118141. }
  118142. }
  118143. declare module BABYLON {
  118144. /**
  118145. * This is the base class for all WebXR features.
  118146. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118147. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118148. */
  118149. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118150. protected _xrSessionManager: WebXRSessionManager;
  118151. private _attached;
  118152. private _removeOnDetach;
  118153. /**
  118154. * Should auto-attach be disabled?
  118155. */
  118156. disableAutoAttach: boolean;
  118157. /**
  118158. * Construct a new (abstract) WebXR feature
  118159. * @param _xrSessionManager the xr session manager for this feature
  118160. */
  118161. constructor(_xrSessionManager: WebXRSessionManager);
  118162. /**
  118163. * Is this feature attached
  118164. */
  118165. get attached(): boolean;
  118166. /**
  118167. * attach this feature
  118168. *
  118169. * @param force should attachment be forced (even when already attached)
  118170. * @returns true if successful, false is failed or already attached
  118171. */
  118172. attach(force?: boolean): boolean;
  118173. /**
  118174. * detach this feature.
  118175. *
  118176. * @returns true if successful, false if failed or already detached
  118177. */
  118178. detach(): boolean;
  118179. /**
  118180. * Dispose this feature and all of the resources attached
  118181. */
  118182. dispose(): void;
  118183. /**
  118184. * This is used to register callbacks that will automatically be removed when detach is called.
  118185. * @param observable the observable to which the observer will be attached
  118186. * @param callback the callback to register
  118187. */
  118188. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  118189. /**
  118190. * Code in this function will be executed on each xrFrame received from the browser.
  118191. * This function will not execute after the feature is detached.
  118192. * @param _xrFrame the current frame
  118193. */
  118194. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  118195. }
  118196. }
  118197. declare module BABYLON {
  118198. /**
  118199. * Renders a layer on top of an existing scene
  118200. */
  118201. export class UtilityLayerRenderer implements IDisposable {
  118202. /** the original scene that will be rendered on top of */
  118203. originalScene: Scene;
  118204. private _pointerCaptures;
  118205. private _lastPointerEvents;
  118206. private static _DefaultUtilityLayer;
  118207. private static _DefaultKeepDepthUtilityLayer;
  118208. private _sharedGizmoLight;
  118209. private _renderCamera;
  118210. /**
  118211. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118212. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  118213. * @returns the camera that is used when rendering the utility layer
  118214. */
  118215. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  118216. /**
  118217. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118218. * @param cam the camera that should be used when rendering the utility layer
  118219. */
  118220. setRenderCamera(cam: Nullable<Camera>): void;
  118221. /**
  118222. * @hidden
  118223. * Light which used by gizmos to get light shading
  118224. */
  118225. _getSharedGizmoLight(): HemisphericLight;
  118226. /**
  118227. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118228. */
  118229. pickUtilitySceneFirst: boolean;
  118230. /**
  118231. * 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)
  118232. */
  118233. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118234. /**
  118235. * 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)
  118236. */
  118237. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118238. /**
  118239. * The scene that is rendered on top of the original scene
  118240. */
  118241. utilityLayerScene: Scene;
  118242. /**
  118243. * If the utility layer should automatically be rendered on top of existing scene
  118244. */
  118245. shouldRender: boolean;
  118246. /**
  118247. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118248. */
  118249. onlyCheckPointerDownEvents: boolean;
  118250. /**
  118251. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118252. */
  118253. processAllEvents: boolean;
  118254. /**
  118255. * Observable raised when the pointer move from the utility layer scene to the main scene
  118256. */
  118257. onPointerOutObservable: Observable<number>;
  118258. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118259. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118260. private _afterRenderObserver;
  118261. private _sceneDisposeObserver;
  118262. private _originalPointerObserver;
  118263. /**
  118264. * Instantiates a UtilityLayerRenderer
  118265. * @param originalScene the original scene that will be rendered on top of
  118266. * @param handleEvents boolean indicating if the utility layer should handle events
  118267. */
  118268. constructor(
  118269. /** the original scene that will be rendered on top of */
  118270. originalScene: Scene, handleEvents?: boolean);
  118271. private _notifyObservers;
  118272. /**
  118273. * Renders the utility layers scene on top of the original scene
  118274. */
  118275. render(): void;
  118276. /**
  118277. * Disposes of the renderer
  118278. */
  118279. dispose(): void;
  118280. private _updateCamera;
  118281. }
  118282. }
  118283. declare module BABYLON {
  118284. /**
  118285. * Options interface for the pointer selection module
  118286. */
  118287. export interface IWebXRControllerPointerSelectionOptions {
  118288. /**
  118289. * if provided, this scene will be used to render meshes.
  118290. */
  118291. customUtilityLayerScene?: Scene;
  118292. /**
  118293. * 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)
  118294. * If not disabled, the last picked point will be used to execute a pointer up event
  118295. * If disabled, pointer up event will be triggered right after the pointer down event.
  118296. * Used in screen and gaze target ray mode only
  118297. */
  118298. disablePointerUpOnTouchOut: boolean;
  118299. /**
  118300. * For gaze mode (time to select instead of press)
  118301. */
  118302. forceGazeMode: boolean;
  118303. /**
  118304. * 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
  118305. * to start a new countdown to the pointer down event.
  118306. * Defaults to 1.
  118307. */
  118308. gazeModePointerMovedFactor?: number;
  118309. /**
  118310. * Different button type to use instead of the main component
  118311. */
  118312. overrideButtonId?: string;
  118313. /**
  118314. * use this rendering group id for the meshes (optional)
  118315. */
  118316. renderingGroupId?: number;
  118317. /**
  118318. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  118319. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  118320. * 3000 means 3 seconds between pointing at something and selecting it
  118321. */
  118322. timeToSelect?: number;
  118323. /**
  118324. * Should meshes created here be added to a utility layer or the main scene
  118325. */
  118326. useUtilityLayer?: boolean;
  118327. /**
  118328. * the xr input to use with this pointer selection
  118329. */
  118330. xrInput: WebXRInput;
  118331. }
  118332. /**
  118333. * A module that will enable pointer selection for motion controllers of XR Input Sources
  118334. */
  118335. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  118336. private readonly _options;
  118337. private static _idCounter;
  118338. private _attachController;
  118339. private _controllers;
  118340. private _scene;
  118341. private _tmpVectorForPickCompare;
  118342. /**
  118343. * The module's name
  118344. */
  118345. static readonly Name: string;
  118346. /**
  118347. * The (Babylon) version of this module.
  118348. * This is an integer representing the implementation version.
  118349. * This number does not correspond to the WebXR specs version
  118350. */
  118351. static readonly Version: number;
  118352. /**
  118353. * Disable lighting on the laser pointer (so it will always be visible)
  118354. */
  118355. disablePointerLighting: boolean;
  118356. /**
  118357. * Disable lighting on the selection mesh (so it will always be visible)
  118358. */
  118359. disableSelectionMeshLighting: boolean;
  118360. /**
  118361. * Should the laser pointer be displayed
  118362. */
  118363. displayLaserPointer: boolean;
  118364. /**
  118365. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  118366. */
  118367. displaySelectionMesh: boolean;
  118368. /**
  118369. * This color will be set to the laser pointer when selection is triggered
  118370. */
  118371. laserPointerPickedColor: Color3;
  118372. /**
  118373. * Default color of the laser pointer
  118374. */
  118375. lasterPointerDefaultColor: Color3;
  118376. /**
  118377. * default color of the selection ring
  118378. */
  118379. selectionMeshDefaultColor: Color3;
  118380. /**
  118381. * This color will be applied to the selection ring when selection is triggered
  118382. */
  118383. selectionMeshPickedColor: Color3;
  118384. /**
  118385. * Optional filter to be used for ray selection. This predicate shares behavior with
  118386. * scene.pointerMovePredicate which takes priority if it is also assigned.
  118387. */
  118388. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118389. /**
  118390. * constructs a new background remover module
  118391. * @param _xrSessionManager the session manager for this module
  118392. * @param _options read-only options to be used in this module
  118393. */
  118394. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  118395. /**
  118396. * attach this feature
  118397. * Will usually be called by the features manager
  118398. *
  118399. * @returns true if successful.
  118400. */
  118401. attach(): boolean;
  118402. /**
  118403. * detach this feature.
  118404. * Will usually be called by the features manager
  118405. *
  118406. * @returns true if successful.
  118407. */
  118408. detach(): boolean;
  118409. /**
  118410. * Will get the mesh under a specific pointer.
  118411. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  118412. * @param controllerId the controllerId to check
  118413. * @returns The mesh under pointer or null if no mesh is under the pointer
  118414. */
  118415. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  118416. /**
  118417. * Get the xr controller that correlates to the pointer id in the pointer event
  118418. *
  118419. * @param id the pointer id to search for
  118420. * @returns the controller that correlates to this id or null if not found
  118421. */
  118422. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  118423. protected _onXRFrame(_xrFrame: XRFrame): void;
  118424. private _attachGazeMode;
  118425. private _attachScreenRayMode;
  118426. private _attachTrackedPointerRayMode;
  118427. private _convertNormalToDirectionOfRay;
  118428. private _detachController;
  118429. private _generateNewMeshPair;
  118430. private _pickingMoved;
  118431. private _updatePointerDistance;
  118432. }
  118433. }
  118434. declare module BABYLON {
  118435. /**
  118436. * Button which can be used to enter a different mode of XR
  118437. */
  118438. export class WebXREnterExitUIButton {
  118439. /** button element */
  118440. element: HTMLElement;
  118441. /** XR initialization options for the button */
  118442. sessionMode: XRSessionMode;
  118443. /** Reference space type */
  118444. referenceSpaceType: XRReferenceSpaceType;
  118445. /**
  118446. * Creates a WebXREnterExitUIButton
  118447. * @param element button element
  118448. * @param sessionMode XR initialization session mode
  118449. * @param referenceSpaceType the type of reference space to be used
  118450. */
  118451. constructor(
  118452. /** button element */
  118453. element: HTMLElement,
  118454. /** XR initialization options for the button */
  118455. sessionMode: XRSessionMode,
  118456. /** Reference space type */
  118457. referenceSpaceType: XRReferenceSpaceType);
  118458. /**
  118459. * Extendable function which can be used to update the button's visuals when the state changes
  118460. * @param activeButton the current active button in the UI
  118461. */
  118462. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  118463. }
  118464. /**
  118465. * Options to create the webXR UI
  118466. */
  118467. export class WebXREnterExitUIOptions {
  118468. /**
  118469. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  118470. */
  118471. customButtons?: Array<WebXREnterExitUIButton>;
  118472. /**
  118473. * A reference space type to use when creating the default button.
  118474. * Default is local-floor
  118475. */
  118476. referenceSpaceType?: XRReferenceSpaceType;
  118477. /**
  118478. * Context to enter xr with
  118479. */
  118480. renderTarget?: Nullable<WebXRRenderTarget>;
  118481. /**
  118482. * A session mode to use when creating the default button.
  118483. * Default is immersive-vr
  118484. */
  118485. sessionMode?: XRSessionMode;
  118486. }
  118487. /**
  118488. * UI to allow the user to enter/exit XR mode
  118489. */
  118490. export class WebXREnterExitUI implements IDisposable {
  118491. private scene;
  118492. /** version of the options passed to this UI */
  118493. options: WebXREnterExitUIOptions;
  118494. private _activeButton;
  118495. private _buttons;
  118496. private _overlay;
  118497. /**
  118498. * Fired every time the active button is changed.
  118499. *
  118500. * When xr is entered via a button that launches xr that button will be the callback parameter
  118501. *
  118502. * When exiting xr the callback parameter will be null)
  118503. */
  118504. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  118505. /**
  118506. *
  118507. * @param scene babylon scene object to use
  118508. * @param options (read-only) version of the options passed to this UI
  118509. */
  118510. private constructor();
  118511. /**
  118512. * Creates UI to allow the user to enter/exit XR mode
  118513. * @param scene the scene to add the ui to
  118514. * @param helper the xr experience helper to enter/exit xr with
  118515. * @param options options to configure the UI
  118516. * @returns the created ui
  118517. */
  118518. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  118519. /**
  118520. * Disposes of the XR UI component
  118521. */
  118522. dispose(): void;
  118523. private _updateButtons;
  118524. }
  118525. }
  118526. declare module BABYLON {
  118527. /**
  118528. * Class containing static functions to help procedurally build meshes
  118529. */
  118530. export class LinesBuilder {
  118531. /**
  118532. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118533. * * 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
  118534. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118535. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118536. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118537. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118538. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118539. * * 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
  118540. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118543. * @param name defines the name of the new line system
  118544. * @param options defines the options used to create the line system
  118545. * @param scene defines the hosting scene
  118546. * @returns a new line system mesh
  118547. */
  118548. static CreateLineSystem(name: string, options: {
  118549. lines: Vector3[][];
  118550. updatable?: boolean;
  118551. instance?: Nullable<LinesMesh>;
  118552. colors?: Nullable<Color4[][]>;
  118553. useVertexAlpha?: boolean;
  118554. }, scene: Nullable<Scene>): LinesMesh;
  118555. /**
  118556. * Creates a line mesh
  118557. * 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
  118558. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118559. * * The parameter `points` is an array successive Vector3
  118560. * * 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
  118561. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118562. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118563. * * When updating an instance, remember that only point positions can change, not the number of points
  118564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118566. * @param name defines the name of the new line system
  118567. * @param options defines the options used to create the line system
  118568. * @param scene defines the hosting scene
  118569. * @returns a new line mesh
  118570. */
  118571. static CreateLines(name: string, options: {
  118572. points: Vector3[];
  118573. updatable?: boolean;
  118574. instance?: Nullable<LinesMesh>;
  118575. colors?: Color4[];
  118576. useVertexAlpha?: boolean;
  118577. }, scene?: Nullable<Scene>): LinesMesh;
  118578. /**
  118579. * Creates a dashed line mesh
  118580. * * 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
  118581. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118582. * * The parameter `points` is an array successive Vector3
  118583. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118584. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118585. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118586. * * 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
  118587. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118588. * * When updating an instance, remember that only point positions can change, not the number of points
  118589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118590. * @param name defines the name of the mesh
  118591. * @param options defines the options used to create the mesh
  118592. * @param scene defines the hosting scene
  118593. * @returns the dashed line mesh
  118594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118595. */
  118596. static CreateDashedLines(name: string, options: {
  118597. points: Vector3[];
  118598. dashSize?: number;
  118599. gapSize?: number;
  118600. dashNb?: number;
  118601. updatable?: boolean;
  118602. instance?: LinesMesh;
  118603. useVertexAlpha?: boolean;
  118604. }, scene?: Nullable<Scene>): LinesMesh;
  118605. }
  118606. }
  118607. declare module BABYLON {
  118608. /**
  118609. * The options container for the teleportation module
  118610. */
  118611. export interface IWebXRTeleportationOptions {
  118612. /**
  118613. * if provided, this scene will be used to render meshes.
  118614. */
  118615. customUtilityLayerScene?: Scene;
  118616. /**
  118617. * Values to configure the default target mesh
  118618. */
  118619. defaultTargetMeshOptions?: {
  118620. /**
  118621. * Fill color of the teleportation area
  118622. */
  118623. teleportationFillColor?: string;
  118624. /**
  118625. * Border color for the teleportation area
  118626. */
  118627. teleportationBorderColor?: string;
  118628. /**
  118629. * Disable the mesh's animation sequence
  118630. */
  118631. disableAnimation?: boolean;
  118632. /**
  118633. * Disable lighting on the material or the ring and arrow
  118634. */
  118635. disableLighting?: boolean;
  118636. /**
  118637. * Override the default material of the torus and arrow
  118638. */
  118639. torusArrowMaterial?: Material;
  118640. };
  118641. /**
  118642. * A list of meshes to use as floor meshes.
  118643. * Meshes can be added and removed after initializing the feature using the
  118644. * addFloorMesh and removeFloorMesh functions
  118645. * If empty, rotation will still work
  118646. */
  118647. floorMeshes?: AbstractMesh[];
  118648. /**
  118649. * use this rendering group id for the meshes (optional)
  118650. */
  118651. renderingGroupId?: number;
  118652. /**
  118653. * Should teleportation move only to snap points
  118654. */
  118655. snapPointsOnly?: boolean;
  118656. /**
  118657. * An array of points to which the teleportation will snap to.
  118658. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118659. */
  118660. snapPositions?: Vector3[];
  118661. /**
  118662. * How close should the teleportation ray be in order to snap to position.
  118663. * Default to 0.8 units (meters)
  118664. */
  118665. snapToPositionRadius?: number;
  118666. /**
  118667. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118668. * If you want to support rotation, make sure your mesh has a direction indicator.
  118669. *
  118670. * When left untouched, the default mesh will be initialized.
  118671. */
  118672. teleportationTargetMesh?: AbstractMesh;
  118673. /**
  118674. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118675. */
  118676. timeToTeleport?: number;
  118677. /**
  118678. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118679. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118680. */
  118681. useMainComponentOnly?: boolean;
  118682. /**
  118683. * Should meshes created here be added to a utility layer or the main scene
  118684. */
  118685. useUtilityLayer?: boolean;
  118686. /**
  118687. * Babylon XR Input class for controller
  118688. */
  118689. xrInput: WebXRInput;
  118690. }
  118691. /**
  118692. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118693. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118694. * the input of the attached controllers.
  118695. */
  118696. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118697. private _options;
  118698. private _controllers;
  118699. private _currentTeleportationControllerId;
  118700. private _floorMeshes;
  118701. private _quadraticBezierCurve;
  118702. private _selectionFeature;
  118703. private _snapToPositions;
  118704. private _snappedToPoint;
  118705. private _teleportationRingMaterial?;
  118706. private _tmpRay;
  118707. private _tmpVector;
  118708. /**
  118709. * The module's name
  118710. */
  118711. static readonly Name: string;
  118712. /**
  118713. * The (Babylon) version of this module.
  118714. * This is an integer representing the implementation version.
  118715. * This number does not correspond to the webxr specs version
  118716. */
  118717. static readonly Version: number;
  118718. /**
  118719. * Is movement backwards enabled
  118720. */
  118721. backwardsMovementEnabled: boolean;
  118722. /**
  118723. * Distance to travel when moving backwards
  118724. */
  118725. backwardsTeleportationDistance: number;
  118726. /**
  118727. * The distance from the user to the inspection point in the direction of the controller
  118728. * A higher number will allow the user to move further
  118729. * defaults to 5 (meters, in xr units)
  118730. */
  118731. parabolicCheckRadius: number;
  118732. /**
  118733. * Should the module support parabolic ray on top of direct ray
  118734. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118735. * Very helpful when moving between floors / different heights
  118736. */
  118737. parabolicRayEnabled: boolean;
  118738. /**
  118739. * How much rotation should be applied when rotating right and left
  118740. */
  118741. rotationAngle: number;
  118742. /**
  118743. * Is rotation enabled when moving forward?
  118744. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118745. */
  118746. rotationEnabled: boolean;
  118747. /**
  118748. * constructs a new anchor system
  118749. * @param _xrSessionManager an instance of WebXRSessionManager
  118750. * @param _options configuration object for this feature
  118751. */
  118752. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118753. /**
  118754. * Get the snapPointsOnly flag
  118755. */
  118756. get snapPointsOnly(): boolean;
  118757. /**
  118758. * Sets the snapPointsOnly flag
  118759. * @param snapToPoints should teleportation be exclusively to snap points
  118760. */
  118761. set snapPointsOnly(snapToPoints: boolean);
  118762. /**
  118763. * Add a new mesh to the floor meshes array
  118764. * @param mesh the mesh to use as floor mesh
  118765. */
  118766. addFloorMesh(mesh: AbstractMesh): void;
  118767. /**
  118768. * Add a new snap-to point to fix teleportation to this position
  118769. * @param newSnapPoint The new Snap-To point
  118770. */
  118771. addSnapPoint(newSnapPoint: Vector3): void;
  118772. attach(): boolean;
  118773. detach(): boolean;
  118774. dispose(): void;
  118775. /**
  118776. * Remove a mesh from the floor meshes array
  118777. * @param mesh the mesh to remove
  118778. */
  118779. removeFloorMesh(mesh: AbstractMesh): void;
  118780. /**
  118781. * Remove a mesh from the floor meshes array using its name
  118782. * @param name the mesh name to remove
  118783. */
  118784. removeFloorMeshByName(name: string): void;
  118785. /**
  118786. * 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
  118787. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118788. * @returns was the point found and removed or not
  118789. */
  118790. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118791. /**
  118792. * This function sets a selection feature that will be disabled when
  118793. * the forward ray is shown and will be reattached when hidden.
  118794. * This is used to remove the selection rays when moving.
  118795. * @param selectionFeature the feature to disable when forward movement is enabled
  118796. */
  118797. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118798. protected _onXRFrame(_xrFrame: XRFrame): void;
  118799. private _attachController;
  118800. private _createDefaultTargetMesh;
  118801. private _detachController;
  118802. private _findClosestSnapPointWithRadius;
  118803. private _setTargetMeshPosition;
  118804. private _setTargetMeshVisibility;
  118805. private _showParabolicPath;
  118806. private _teleportForward;
  118807. }
  118808. }
  118809. declare module BABYLON {
  118810. /**
  118811. * Options for the default xr helper
  118812. */
  118813. export class WebXRDefaultExperienceOptions {
  118814. /**
  118815. * Enable or disable default UI to enter XR
  118816. */
  118817. disableDefaultUI?: boolean;
  118818. /**
  118819. * Should teleportation not initialize. defaults to false.
  118820. */
  118821. disableTeleportation?: boolean;
  118822. /**
  118823. * Floor meshes that will be used for teleport
  118824. */
  118825. floorMeshes?: Array<AbstractMesh>;
  118826. /**
  118827. * If set to true, the first frame will not be used to reset position
  118828. * The first frame is mainly used when copying transformation from the old camera
  118829. * Mainly used in AR
  118830. */
  118831. ignoreNativeCameraTransformation?: boolean;
  118832. /**
  118833. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118834. */
  118835. inputOptions?: IWebXRInputOptions;
  118836. /**
  118837. * optional configuration for the output canvas
  118838. */
  118839. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118840. /**
  118841. * optional UI options. This can be used among other to change session mode and reference space type
  118842. */
  118843. uiOptions?: WebXREnterExitUIOptions;
  118844. /**
  118845. * When loading teleportation and pointer select, use stable versions instead of latest.
  118846. */
  118847. useStablePlugins?: boolean;
  118848. }
  118849. /**
  118850. * Default experience which provides a similar setup to the previous webVRExperience
  118851. */
  118852. export class WebXRDefaultExperience {
  118853. /**
  118854. * Base experience
  118855. */
  118856. baseExperience: WebXRExperienceHelper;
  118857. /**
  118858. * Enables ui for entering/exiting xr
  118859. */
  118860. enterExitUI: WebXREnterExitUI;
  118861. /**
  118862. * Input experience extension
  118863. */
  118864. input: WebXRInput;
  118865. /**
  118866. * Enables laser pointer and selection
  118867. */
  118868. pointerSelection: WebXRControllerPointerSelection;
  118869. /**
  118870. * Default target xr should render to
  118871. */
  118872. renderTarget: WebXRRenderTarget;
  118873. /**
  118874. * Enables teleportation
  118875. */
  118876. teleportation: WebXRMotionControllerTeleportation;
  118877. private constructor();
  118878. /**
  118879. * Creates the default xr experience
  118880. * @param scene scene
  118881. * @param options options for basic configuration
  118882. * @returns resulting WebXRDefaultExperience
  118883. */
  118884. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118885. /**
  118886. * DIsposes of the experience helper
  118887. */
  118888. dispose(): void;
  118889. }
  118890. }
  118891. declare module BABYLON {
  118892. /**
  118893. * Options to modify the vr teleportation behavior.
  118894. */
  118895. export interface VRTeleportationOptions {
  118896. /**
  118897. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118898. */
  118899. floorMeshName?: string;
  118900. /**
  118901. * A list of meshes to be used as the teleportation floor. (default: empty)
  118902. */
  118903. floorMeshes?: Mesh[];
  118904. /**
  118905. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118906. */
  118907. teleportationMode?: number;
  118908. /**
  118909. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118910. */
  118911. teleportationTime?: number;
  118912. /**
  118913. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118914. */
  118915. teleportationSpeed?: number;
  118916. /**
  118917. * The easing function used in the animation or null for Linear. (default CircleEase)
  118918. */
  118919. easingFunction?: EasingFunction;
  118920. }
  118921. /**
  118922. * Options to modify the vr experience helper's behavior.
  118923. */
  118924. export interface VRExperienceHelperOptions extends WebVROptions {
  118925. /**
  118926. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118927. */
  118928. createDeviceOrientationCamera?: boolean;
  118929. /**
  118930. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118931. */
  118932. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118933. /**
  118934. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118935. */
  118936. laserToggle?: boolean;
  118937. /**
  118938. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118939. */
  118940. floorMeshes?: Mesh[];
  118941. /**
  118942. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118943. */
  118944. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118945. /**
  118946. * Defines if WebXR should be used instead of WebVR (if available)
  118947. */
  118948. useXR?: boolean;
  118949. }
  118950. /**
  118951. * Event containing information after VR has been entered
  118952. */
  118953. export class OnAfterEnteringVRObservableEvent {
  118954. /**
  118955. * If entering vr was successful
  118956. */
  118957. success: boolean;
  118958. }
  118959. /**
  118960. * Helps to quickly add VR support to an existing scene.
  118961. * See http://doc.babylonjs.com/how_to/webvr_helper
  118962. */
  118963. export class VRExperienceHelper {
  118964. /** Options to modify the vr experience helper's behavior. */
  118965. webVROptions: VRExperienceHelperOptions;
  118966. private _scene;
  118967. private _position;
  118968. private _btnVR;
  118969. private _btnVRDisplayed;
  118970. private _webVRsupported;
  118971. private _webVRready;
  118972. private _webVRrequesting;
  118973. private _webVRpresenting;
  118974. private _hasEnteredVR;
  118975. private _fullscreenVRpresenting;
  118976. private _inputElement;
  118977. private _webVRCamera;
  118978. private _vrDeviceOrientationCamera;
  118979. private _deviceOrientationCamera;
  118980. private _existingCamera;
  118981. private _onKeyDown;
  118982. private _onVrDisplayPresentChange;
  118983. private _onVRDisplayChanged;
  118984. private _onVRRequestPresentStart;
  118985. private _onVRRequestPresentComplete;
  118986. /**
  118987. * 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)
  118988. */
  118989. enableGazeEvenWhenNoPointerLock: boolean;
  118990. /**
  118991. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118992. */
  118993. exitVROnDoubleTap: boolean;
  118994. /**
  118995. * Observable raised right before entering VR.
  118996. */
  118997. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118998. /**
  118999. * Observable raised when entering VR has completed.
  119000. */
  119001. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  119002. /**
  119003. * Observable raised when exiting VR.
  119004. */
  119005. onExitingVRObservable: Observable<VRExperienceHelper>;
  119006. /**
  119007. * Observable raised when controller mesh is loaded.
  119008. */
  119009. onControllerMeshLoadedObservable: Observable<WebVRController>;
  119010. /** Return this.onEnteringVRObservable
  119011. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  119012. */
  119013. get onEnteringVR(): Observable<VRExperienceHelper>;
  119014. /** Return this.onExitingVRObservable
  119015. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  119016. */
  119017. get onExitingVR(): Observable<VRExperienceHelper>;
  119018. /** Return this.onControllerMeshLoadedObservable
  119019. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  119020. */
  119021. get onControllerMeshLoaded(): Observable<WebVRController>;
  119022. private _rayLength;
  119023. private _useCustomVRButton;
  119024. private _teleportationRequested;
  119025. private _teleportActive;
  119026. private _floorMeshName;
  119027. private _floorMeshesCollection;
  119028. private _teleportationMode;
  119029. private _teleportationTime;
  119030. private _teleportationSpeed;
  119031. private _teleportationEasing;
  119032. private _rotationAllowed;
  119033. private _teleportBackwardsVector;
  119034. private _teleportationTarget;
  119035. private _isDefaultTeleportationTarget;
  119036. private _postProcessMove;
  119037. private _teleportationFillColor;
  119038. private _teleportationBorderColor;
  119039. private _rotationAngle;
  119040. private _haloCenter;
  119041. private _cameraGazer;
  119042. private _padSensibilityUp;
  119043. private _padSensibilityDown;
  119044. private _leftController;
  119045. private _rightController;
  119046. private _gazeColor;
  119047. private _laserColor;
  119048. private _pickedLaserColor;
  119049. private _pickedGazeColor;
  119050. /**
  119051. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  119052. */
  119053. onNewMeshSelected: Observable<AbstractMesh>;
  119054. /**
  119055. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  119056. * This observable will provide the mesh and the controller used to select the mesh
  119057. */
  119058. onMeshSelectedWithController: Observable<{
  119059. mesh: AbstractMesh;
  119060. controller: WebVRController;
  119061. }>;
  119062. /**
  119063. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  119064. */
  119065. onNewMeshPicked: Observable<PickingInfo>;
  119066. private _circleEase;
  119067. /**
  119068. * Observable raised before camera teleportation
  119069. */
  119070. onBeforeCameraTeleport: Observable<Vector3>;
  119071. /**
  119072. * Observable raised after camera teleportation
  119073. */
  119074. onAfterCameraTeleport: Observable<Vector3>;
  119075. /**
  119076. * Observable raised when current selected mesh gets unselected
  119077. */
  119078. onSelectedMeshUnselected: Observable<AbstractMesh>;
  119079. private _raySelectionPredicate;
  119080. /**
  119081. * To be optionaly changed by user to define custom ray selection
  119082. */
  119083. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119084. /**
  119085. * To be optionaly changed by user to define custom selection logic (after ray selection)
  119086. */
  119087. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119088. /**
  119089. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  119090. */
  119091. teleportationEnabled: boolean;
  119092. private _defaultHeight;
  119093. private _teleportationInitialized;
  119094. private _interactionsEnabled;
  119095. private _interactionsRequested;
  119096. private _displayGaze;
  119097. private _displayLaserPointer;
  119098. /**
  119099. * The mesh used to display where the user is going to teleport.
  119100. */
  119101. get teleportationTarget(): Mesh;
  119102. /**
  119103. * Sets the mesh to be used to display where the user is going to teleport.
  119104. */
  119105. set teleportationTarget(value: Mesh);
  119106. /**
  119107. * 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
  119108. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119109. * See http://doc.babylonjs.com/resources/baking_transformations
  119110. */
  119111. get gazeTrackerMesh(): Mesh;
  119112. set gazeTrackerMesh(value: Mesh);
  119113. /**
  119114. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119115. */
  119116. updateGazeTrackerScale: boolean;
  119117. /**
  119118. * If the gaze trackers color should be updated when selecting meshes
  119119. */
  119120. updateGazeTrackerColor: boolean;
  119121. /**
  119122. * If the controller laser color should be updated when selecting meshes
  119123. */
  119124. updateControllerLaserColor: boolean;
  119125. /**
  119126. * The gaze tracking mesh corresponding to the left controller
  119127. */
  119128. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119129. /**
  119130. * The gaze tracking mesh corresponding to the right controller
  119131. */
  119132. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119133. /**
  119134. * If the ray of the gaze should be displayed.
  119135. */
  119136. get displayGaze(): boolean;
  119137. /**
  119138. * Sets if the ray of the gaze should be displayed.
  119139. */
  119140. set displayGaze(value: boolean);
  119141. /**
  119142. * If the ray of the LaserPointer should be displayed.
  119143. */
  119144. get displayLaserPointer(): boolean;
  119145. /**
  119146. * Sets if the ray of the LaserPointer should be displayed.
  119147. */
  119148. set displayLaserPointer(value: boolean);
  119149. /**
  119150. * The deviceOrientationCamera used as the camera when not in VR.
  119151. */
  119152. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119153. /**
  119154. * Based on the current WebVR support, returns the current VR camera used.
  119155. */
  119156. get currentVRCamera(): Nullable<Camera>;
  119157. /**
  119158. * The webVRCamera which is used when in VR.
  119159. */
  119160. get webVRCamera(): WebVRFreeCamera;
  119161. /**
  119162. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119163. */
  119164. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119165. /**
  119166. * The html button that is used to trigger entering into VR.
  119167. */
  119168. get vrButton(): Nullable<HTMLButtonElement>;
  119169. private get _teleportationRequestInitiated();
  119170. /**
  119171. * Defines whether or not Pointer lock should be requested when switching to
  119172. * full screen.
  119173. */
  119174. requestPointerLockOnFullScreen: boolean;
  119175. /**
  119176. * If asking to force XR, this will be populated with the default xr experience
  119177. */
  119178. xr: WebXRDefaultExperience;
  119179. /**
  119180. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  119181. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  119182. */
  119183. xrTestDone: boolean;
  119184. /**
  119185. * Instantiates a VRExperienceHelper.
  119186. * Helps to quickly add VR support to an existing scene.
  119187. * @param scene The scene the VRExperienceHelper belongs to.
  119188. * @param webVROptions Options to modify the vr experience helper's behavior.
  119189. */
  119190. constructor(scene: Scene,
  119191. /** Options to modify the vr experience helper's behavior. */
  119192. webVROptions?: VRExperienceHelperOptions);
  119193. private completeVRInit;
  119194. private _onDefaultMeshLoaded;
  119195. private _onResize;
  119196. private _onFullscreenChange;
  119197. /**
  119198. * Gets a value indicating if we are currently in VR mode.
  119199. */
  119200. get isInVRMode(): boolean;
  119201. private onVrDisplayPresentChange;
  119202. private onVRDisplayChanged;
  119203. private moveButtonToBottomRight;
  119204. private displayVRButton;
  119205. private updateButtonVisibility;
  119206. private _cachedAngularSensibility;
  119207. /**
  119208. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  119209. * Otherwise, will use the fullscreen API.
  119210. */
  119211. enterVR(): void;
  119212. /**
  119213. * Attempt to exit VR, or fullscreen.
  119214. */
  119215. exitVR(): void;
  119216. /**
  119217. * The position of the vr experience helper.
  119218. */
  119219. get position(): Vector3;
  119220. /**
  119221. * Sets the position of the vr experience helper.
  119222. */
  119223. set position(value: Vector3);
  119224. /**
  119225. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  119226. */
  119227. enableInteractions(): void;
  119228. private get _noControllerIsActive();
  119229. private beforeRender;
  119230. private _isTeleportationFloor;
  119231. /**
  119232. * Adds a floor mesh to be used for teleportation.
  119233. * @param floorMesh the mesh to be used for teleportation.
  119234. */
  119235. addFloorMesh(floorMesh: Mesh): void;
  119236. /**
  119237. * Removes a floor mesh from being used for teleportation.
  119238. * @param floorMesh the mesh to be removed.
  119239. */
  119240. removeFloorMesh(floorMesh: Mesh): void;
  119241. /**
  119242. * Enables interactions and teleportation using the VR controllers and gaze.
  119243. * @param vrTeleportationOptions options to modify teleportation behavior.
  119244. */
  119245. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  119246. private _onNewGamepadConnected;
  119247. private _tryEnableInteractionOnController;
  119248. private _onNewGamepadDisconnected;
  119249. private _enableInteractionOnController;
  119250. private _checkTeleportWithRay;
  119251. private _checkRotate;
  119252. private _checkTeleportBackwards;
  119253. private _enableTeleportationOnController;
  119254. private _createTeleportationCircles;
  119255. private _displayTeleportationTarget;
  119256. private _hideTeleportationTarget;
  119257. private _rotateCamera;
  119258. private _moveTeleportationSelectorTo;
  119259. private _workingVector;
  119260. private _workingQuaternion;
  119261. private _workingMatrix;
  119262. /**
  119263. * Time Constant Teleportation Mode
  119264. */
  119265. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  119266. /**
  119267. * Speed Constant Teleportation Mode
  119268. */
  119269. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  119270. /**
  119271. * Teleports the users feet to the desired location
  119272. * @param location The location where the user's feet should be placed
  119273. */
  119274. teleportCamera(location: Vector3): void;
  119275. private _convertNormalToDirectionOfRay;
  119276. private _castRayAndSelectObject;
  119277. private _notifySelectedMeshUnselected;
  119278. /**
  119279. * Permanently set new colors for the laser pointer
  119280. * @param color the new laser color
  119281. * @param pickedColor the new laser color when picked mesh detected
  119282. */
  119283. setLaserColor(color: Color3, pickedColor?: Color3): void;
  119284. /**
  119285. * Set lighting enabled / disabled on the laser pointer of both controllers
  119286. * @param enabled should the lighting be enabled on the laser pointer
  119287. */
  119288. setLaserLightingState(enabled?: boolean): void;
  119289. /**
  119290. * Permanently set new colors for the gaze pointer
  119291. * @param color the new gaze color
  119292. * @param pickedColor the new gaze color when picked mesh detected
  119293. */
  119294. setGazeColor(color: Color3, pickedColor?: Color3): void;
  119295. /**
  119296. * Sets the color of the laser ray from the vr controllers.
  119297. * @param color new color for the ray.
  119298. */
  119299. changeLaserColor(color: Color3): void;
  119300. /**
  119301. * Sets the color of the ray from the vr headsets gaze.
  119302. * @param color new color for the ray.
  119303. */
  119304. changeGazeColor(color: Color3): void;
  119305. /**
  119306. * Exits VR and disposes of the vr experience helper
  119307. */
  119308. dispose(): void;
  119309. /**
  119310. * Gets the name of the VRExperienceHelper class
  119311. * @returns "VRExperienceHelper"
  119312. */
  119313. getClassName(): string;
  119314. }
  119315. }
  119316. declare module BABYLON {
  119317. /**
  119318. * Contains an array of blocks representing the octree
  119319. */
  119320. export interface IOctreeContainer<T> {
  119321. /**
  119322. * Blocks within the octree
  119323. */
  119324. blocks: Array<OctreeBlock<T>>;
  119325. }
  119326. /**
  119327. * Class used to store a cell in an octree
  119328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119329. */
  119330. export class OctreeBlock<T> {
  119331. /**
  119332. * Gets the content of the current block
  119333. */
  119334. entries: T[];
  119335. /**
  119336. * Gets the list of block children
  119337. */
  119338. blocks: Array<OctreeBlock<T>>;
  119339. private _depth;
  119340. private _maxDepth;
  119341. private _capacity;
  119342. private _minPoint;
  119343. private _maxPoint;
  119344. private _boundingVectors;
  119345. private _creationFunc;
  119346. /**
  119347. * Creates a new block
  119348. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  119349. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  119350. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119351. * @param depth defines the current depth of this block in the octree
  119352. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  119353. * @param creationFunc defines a callback to call when an element is added to the block
  119354. */
  119355. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  119356. /**
  119357. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119358. */
  119359. get capacity(): number;
  119360. /**
  119361. * Gets the minimum vector (in world space) of the block's bounding box
  119362. */
  119363. get minPoint(): Vector3;
  119364. /**
  119365. * Gets the maximum vector (in world space) of the block's bounding box
  119366. */
  119367. get maxPoint(): Vector3;
  119368. /**
  119369. * Add a new element to this block
  119370. * @param entry defines the element to add
  119371. */
  119372. addEntry(entry: T): void;
  119373. /**
  119374. * Remove an element from this block
  119375. * @param entry defines the element to remove
  119376. */
  119377. removeEntry(entry: T): void;
  119378. /**
  119379. * Add an array of elements to this block
  119380. * @param entries defines the array of elements to add
  119381. */
  119382. addEntries(entries: T[]): void;
  119383. /**
  119384. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  119385. * @param frustumPlanes defines the frustum planes to test
  119386. * @param selection defines the array to store current content if selection is positive
  119387. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119388. */
  119389. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119390. /**
  119391. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  119392. * @param sphereCenter defines the bounding sphere center
  119393. * @param sphereRadius defines the bounding sphere radius
  119394. * @param selection defines the array to store current content if selection is positive
  119395. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119396. */
  119397. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119398. /**
  119399. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  119400. * @param ray defines the ray to test with
  119401. * @param selection defines the array to store current content if selection is positive
  119402. */
  119403. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  119404. /**
  119405. * Subdivide the content into child blocks (this block will then be empty)
  119406. */
  119407. createInnerBlocks(): void;
  119408. /**
  119409. * @hidden
  119410. */
  119411. 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;
  119412. }
  119413. }
  119414. declare module BABYLON {
  119415. /**
  119416. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  119417. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119418. */
  119419. export class Octree<T> {
  119420. /** 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.) */
  119421. maxDepth: number;
  119422. /**
  119423. * Blocks within the octree containing objects
  119424. */
  119425. blocks: Array<OctreeBlock<T>>;
  119426. /**
  119427. * Content stored in the octree
  119428. */
  119429. dynamicContent: T[];
  119430. private _maxBlockCapacity;
  119431. private _selectionContent;
  119432. private _creationFunc;
  119433. /**
  119434. * Creates a octree
  119435. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119436. * @param creationFunc function to be used to instatiate the octree
  119437. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  119438. * @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.)
  119439. */
  119440. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  119441. /** 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.) */
  119442. maxDepth?: number);
  119443. /**
  119444. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  119445. * @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);
  119446. * @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);
  119447. * @param entries meshes to be added to the octree blocks
  119448. */
  119449. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  119450. /**
  119451. * Adds a mesh to the octree
  119452. * @param entry Mesh to add to the octree
  119453. */
  119454. addMesh(entry: T): void;
  119455. /**
  119456. * Remove an element from the octree
  119457. * @param entry defines the element to remove
  119458. */
  119459. removeMesh(entry: T): void;
  119460. /**
  119461. * Selects an array of meshes within the frustum
  119462. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  119463. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  119464. * @returns array of meshes within the frustum
  119465. */
  119466. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  119467. /**
  119468. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  119469. * @param sphereCenter defines the bounding sphere center
  119470. * @param sphereRadius defines the bounding sphere radius
  119471. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119472. * @returns an array of objects that intersect the sphere
  119473. */
  119474. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  119475. /**
  119476. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  119477. * @param ray defines the ray to test with
  119478. * @returns array of intersected objects
  119479. */
  119480. intersectsRay(ray: Ray): SmartArray<T>;
  119481. /**
  119482. * Adds a mesh into the octree block if it intersects the block
  119483. */
  119484. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  119485. /**
  119486. * Adds a submesh into the octree block if it intersects the block
  119487. */
  119488. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  119489. }
  119490. }
  119491. declare module BABYLON {
  119492. interface Scene {
  119493. /**
  119494. * @hidden
  119495. * Backing Filed
  119496. */
  119497. _selectionOctree: Octree<AbstractMesh>;
  119498. /**
  119499. * Gets the octree used to boost mesh selection (picking)
  119500. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119501. */
  119502. selectionOctree: Octree<AbstractMesh>;
  119503. /**
  119504. * Creates or updates the octree used to boost selection (picking)
  119505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119506. * @param maxCapacity defines the maximum capacity per leaf
  119507. * @param maxDepth defines the maximum depth of the octree
  119508. * @returns an octree of AbstractMesh
  119509. */
  119510. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  119511. }
  119512. interface AbstractMesh {
  119513. /**
  119514. * @hidden
  119515. * Backing Field
  119516. */
  119517. _submeshesOctree: Octree<SubMesh>;
  119518. /**
  119519. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  119520. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  119521. * @param maxCapacity defines the maximum size of each block (64 by default)
  119522. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119523. * @returns the new octree
  119524. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119525. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119526. */
  119527. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119528. }
  119529. /**
  119530. * Defines the octree scene component responsible to manage any octrees
  119531. * in a given scene.
  119532. */
  119533. export class OctreeSceneComponent {
  119534. /**
  119535. * The component name help to identify the component in the list of scene components.
  119536. */
  119537. readonly name: string;
  119538. /**
  119539. * The scene the component belongs to.
  119540. */
  119541. scene: Scene;
  119542. /**
  119543. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119544. */
  119545. readonly checksIsEnabled: boolean;
  119546. /**
  119547. * Creates a new instance of the component for the given scene
  119548. * @param scene Defines the scene to register the component in
  119549. */
  119550. constructor(scene: Scene);
  119551. /**
  119552. * Registers the component in a given scene
  119553. */
  119554. register(): void;
  119555. /**
  119556. * Return the list of active meshes
  119557. * @returns the list of active meshes
  119558. */
  119559. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119560. /**
  119561. * Return the list of active sub meshes
  119562. * @param mesh The mesh to get the candidates sub meshes from
  119563. * @returns the list of active sub meshes
  119564. */
  119565. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119566. private _tempRay;
  119567. /**
  119568. * Return the list of sub meshes intersecting with a given local ray
  119569. * @param mesh defines the mesh to find the submesh for
  119570. * @param localRay defines the ray in local space
  119571. * @returns the list of intersecting sub meshes
  119572. */
  119573. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119574. /**
  119575. * Return the list of sub meshes colliding with a collider
  119576. * @param mesh defines the mesh to find the submesh for
  119577. * @param collider defines the collider to evaluate the collision against
  119578. * @returns the list of colliding sub meshes
  119579. */
  119580. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119581. /**
  119582. * Rebuilds the elements related to this component in case of
  119583. * context lost for instance.
  119584. */
  119585. rebuild(): void;
  119586. /**
  119587. * Disposes the component and the associated ressources.
  119588. */
  119589. dispose(): void;
  119590. }
  119591. }
  119592. declare module BABYLON {
  119593. /**
  119594. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119595. */
  119596. export class Gizmo implements IDisposable {
  119597. /** The utility layer the gizmo will be added to */
  119598. gizmoLayer: UtilityLayerRenderer;
  119599. /**
  119600. * The root mesh of the gizmo
  119601. */
  119602. _rootMesh: Mesh;
  119603. private _attachedMesh;
  119604. /**
  119605. * Ratio for the scale of the gizmo (Default: 1)
  119606. */
  119607. scaleRatio: number;
  119608. /**
  119609. * If a custom mesh has been set (Default: false)
  119610. */
  119611. protected _customMeshSet: boolean;
  119612. /**
  119613. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119614. * * When set, interactions will be enabled
  119615. */
  119616. get attachedMesh(): Nullable<AbstractMesh>;
  119617. set attachedMesh(value: Nullable<AbstractMesh>);
  119618. /**
  119619. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119620. * @param mesh The mesh to replace the default mesh of the gizmo
  119621. */
  119622. setCustomMesh(mesh: Mesh): void;
  119623. /**
  119624. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119625. */
  119626. updateGizmoRotationToMatchAttachedMesh: boolean;
  119627. /**
  119628. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119629. */
  119630. updateGizmoPositionToMatchAttachedMesh: boolean;
  119631. /**
  119632. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119633. */
  119634. updateScale: boolean;
  119635. protected _interactionsEnabled: boolean;
  119636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119637. private _beforeRenderObserver;
  119638. private _tempVector;
  119639. /**
  119640. * Creates a gizmo
  119641. * @param gizmoLayer The utility layer the gizmo will be added to
  119642. */
  119643. constructor(
  119644. /** The utility layer the gizmo will be added to */
  119645. gizmoLayer?: UtilityLayerRenderer);
  119646. /**
  119647. * Updates the gizmo to match the attached mesh's position/rotation
  119648. */
  119649. protected _update(): void;
  119650. /**
  119651. * Disposes of the gizmo
  119652. */
  119653. dispose(): void;
  119654. }
  119655. }
  119656. declare module BABYLON {
  119657. /**
  119658. * Single plane drag gizmo
  119659. */
  119660. export class PlaneDragGizmo extends Gizmo {
  119661. /**
  119662. * Drag behavior responsible for the gizmos dragging interactions
  119663. */
  119664. dragBehavior: PointerDragBehavior;
  119665. private _pointerObserver;
  119666. /**
  119667. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119668. */
  119669. snapDistance: number;
  119670. /**
  119671. * Event that fires each time the gizmo snaps to a new location.
  119672. * * snapDistance is the the change in distance
  119673. */
  119674. onSnapObservable: Observable<{
  119675. snapDistance: number;
  119676. }>;
  119677. private _plane;
  119678. private _coloredMaterial;
  119679. private _hoverMaterial;
  119680. private _isEnabled;
  119681. private _parent;
  119682. /** @hidden */
  119683. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119684. /** @hidden */
  119685. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119686. /**
  119687. * Creates a PlaneDragGizmo
  119688. * @param gizmoLayer The utility layer the gizmo will be added to
  119689. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119690. * @param color The color of the gizmo
  119691. */
  119692. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119693. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119694. /**
  119695. * If the gizmo is enabled
  119696. */
  119697. set isEnabled(value: boolean);
  119698. get isEnabled(): boolean;
  119699. /**
  119700. * Disposes of the gizmo
  119701. */
  119702. dispose(): void;
  119703. }
  119704. }
  119705. declare module BABYLON {
  119706. /**
  119707. * Gizmo that enables dragging a mesh along 3 axis
  119708. */
  119709. export class PositionGizmo extends Gizmo {
  119710. /**
  119711. * Internal gizmo used for interactions on the x axis
  119712. */
  119713. xGizmo: AxisDragGizmo;
  119714. /**
  119715. * Internal gizmo used for interactions on the y axis
  119716. */
  119717. yGizmo: AxisDragGizmo;
  119718. /**
  119719. * Internal gizmo used for interactions on the z axis
  119720. */
  119721. zGizmo: AxisDragGizmo;
  119722. /**
  119723. * Internal gizmo used for interactions on the yz plane
  119724. */
  119725. xPlaneGizmo: PlaneDragGizmo;
  119726. /**
  119727. * Internal gizmo used for interactions on the xz plane
  119728. */
  119729. yPlaneGizmo: PlaneDragGizmo;
  119730. /**
  119731. * Internal gizmo used for interactions on the xy plane
  119732. */
  119733. zPlaneGizmo: PlaneDragGizmo;
  119734. /**
  119735. * private variables
  119736. */
  119737. private _meshAttached;
  119738. private _updateGizmoRotationToMatchAttachedMesh;
  119739. private _snapDistance;
  119740. private _scaleRatio;
  119741. /** Fires an event when any of it's sub gizmos are dragged */
  119742. onDragStartObservable: Observable<unknown>;
  119743. /** Fires an event when any of it's sub gizmos are released from dragging */
  119744. onDragEndObservable: Observable<unknown>;
  119745. /**
  119746. * If set to true, planar drag is enabled
  119747. */
  119748. private _planarGizmoEnabled;
  119749. get attachedMesh(): Nullable<AbstractMesh>;
  119750. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119751. /**
  119752. * Creates a PositionGizmo
  119753. * @param gizmoLayer The utility layer the gizmo will be added to
  119754. */
  119755. constructor(gizmoLayer?: UtilityLayerRenderer);
  119756. /**
  119757. * If the planar drag gizmo is enabled
  119758. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119759. */
  119760. set planarGizmoEnabled(value: boolean);
  119761. get planarGizmoEnabled(): boolean;
  119762. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119763. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119764. /**
  119765. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119766. */
  119767. set snapDistance(value: number);
  119768. get snapDistance(): number;
  119769. /**
  119770. * Ratio for the scale of the gizmo (Default: 1)
  119771. */
  119772. set scaleRatio(value: number);
  119773. get scaleRatio(): number;
  119774. /**
  119775. * Disposes of the gizmo
  119776. */
  119777. dispose(): void;
  119778. /**
  119779. * CustomMeshes are not supported by this gizmo
  119780. * @param mesh The mesh to replace the default mesh of the gizmo
  119781. */
  119782. setCustomMesh(mesh: Mesh): void;
  119783. }
  119784. }
  119785. declare module BABYLON {
  119786. /**
  119787. * Single axis drag gizmo
  119788. */
  119789. export class AxisDragGizmo extends Gizmo {
  119790. /**
  119791. * Drag behavior responsible for the gizmos dragging interactions
  119792. */
  119793. dragBehavior: PointerDragBehavior;
  119794. private _pointerObserver;
  119795. /**
  119796. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119797. */
  119798. snapDistance: number;
  119799. /**
  119800. * Event that fires each time the gizmo snaps to a new location.
  119801. * * snapDistance is the the change in distance
  119802. */
  119803. onSnapObservable: Observable<{
  119804. snapDistance: number;
  119805. }>;
  119806. private _isEnabled;
  119807. private _parent;
  119808. private _arrow;
  119809. private _coloredMaterial;
  119810. private _hoverMaterial;
  119811. /** @hidden */
  119812. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119813. /** @hidden */
  119814. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119815. /**
  119816. * Creates an AxisDragGizmo
  119817. * @param gizmoLayer The utility layer the gizmo will be added to
  119818. * @param dragAxis The axis which the gizmo will be able to drag on
  119819. * @param color The color of the gizmo
  119820. */
  119821. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119822. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119823. /**
  119824. * If the gizmo is enabled
  119825. */
  119826. set isEnabled(value: boolean);
  119827. get isEnabled(): boolean;
  119828. /**
  119829. * Disposes of the gizmo
  119830. */
  119831. dispose(): void;
  119832. }
  119833. }
  119834. declare module BABYLON.Debug {
  119835. /**
  119836. * The Axes viewer will show 3 axes in a specific point in space
  119837. */
  119838. export class AxesViewer {
  119839. private _xAxis;
  119840. private _yAxis;
  119841. private _zAxis;
  119842. private _scaleLinesFactor;
  119843. private _instanced;
  119844. /**
  119845. * Gets the hosting scene
  119846. */
  119847. scene: Scene;
  119848. /**
  119849. * Gets or sets a number used to scale line length
  119850. */
  119851. scaleLines: number;
  119852. /** Gets the node hierarchy used to render x-axis */
  119853. get xAxis(): TransformNode;
  119854. /** Gets the node hierarchy used to render y-axis */
  119855. get yAxis(): TransformNode;
  119856. /** Gets the node hierarchy used to render z-axis */
  119857. get zAxis(): TransformNode;
  119858. /**
  119859. * Creates a new AxesViewer
  119860. * @param scene defines the hosting scene
  119861. * @param scaleLines defines a number used to scale line length (1 by default)
  119862. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119863. * @param xAxis defines the node hierarchy used to render the x-axis
  119864. * @param yAxis defines the node hierarchy used to render the y-axis
  119865. * @param zAxis defines the node hierarchy used to render the z-axis
  119866. */
  119867. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119868. /**
  119869. * Force the viewer to update
  119870. * @param position defines the position of the viewer
  119871. * @param xaxis defines the x axis of the viewer
  119872. * @param yaxis defines the y axis of the viewer
  119873. * @param zaxis defines the z axis of the viewer
  119874. */
  119875. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119876. /**
  119877. * Creates an instance of this axes viewer.
  119878. * @returns a new axes viewer with instanced meshes
  119879. */
  119880. createInstance(): AxesViewer;
  119881. /** Releases resources */
  119882. dispose(): void;
  119883. private static _SetRenderingGroupId;
  119884. }
  119885. }
  119886. declare module BABYLON.Debug {
  119887. /**
  119888. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119889. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119890. */
  119891. export class BoneAxesViewer extends AxesViewer {
  119892. /**
  119893. * Gets or sets the target mesh where to display the axes viewer
  119894. */
  119895. mesh: Nullable<Mesh>;
  119896. /**
  119897. * Gets or sets the target bone where to display the axes viewer
  119898. */
  119899. bone: Nullable<Bone>;
  119900. /** Gets current position */
  119901. pos: Vector3;
  119902. /** Gets direction of X axis */
  119903. xaxis: Vector3;
  119904. /** Gets direction of Y axis */
  119905. yaxis: Vector3;
  119906. /** Gets direction of Z axis */
  119907. zaxis: Vector3;
  119908. /**
  119909. * Creates a new BoneAxesViewer
  119910. * @param scene defines the hosting scene
  119911. * @param bone defines the target bone
  119912. * @param mesh defines the target mesh
  119913. * @param scaleLines defines a scaling factor for line length (1 by default)
  119914. */
  119915. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119916. /**
  119917. * Force the viewer to update
  119918. */
  119919. update(): void;
  119920. /** Releases resources */
  119921. dispose(): void;
  119922. }
  119923. }
  119924. declare module BABYLON {
  119925. /**
  119926. * Interface used to define scene explorer extensibility option
  119927. */
  119928. export interface IExplorerExtensibilityOption {
  119929. /**
  119930. * Define the option label
  119931. */
  119932. label: string;
  119933. /**
  119934. * Defines the action to execute on click
  119935. */
  119936. action: (entity: any) => void;
  119937. }
  119938. /**
  119939. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119940. */
  119941. export interface IExplorerExtensibilityGroup {
  119942. /**
  119943. * Defines a predicate to test if a given type mut be extended
  119944. */
  119945. predicate: (entity: any) => boolean;
  119946. /**
  119947. * Gets the list of options added to a type
  119948. */
  119949. entries: IExplorerExtensibilityOption[];
  119950. }
  119951. /**
  119952. * Interface used to define the options to use to create the Inspector
  119953. */
  119954. export interface IInspectorOptions {
  119955. /**
  119956. * Display in overlay mode (default: false)
  119957. */
  119958. overlay?: boolean;
  119959. /**
  119960. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119961. */
  119962. globalRoot?: HTMLElement;
  119963. /**
  119964. * Display the Scene explorer
  119965. */
  119966. showExplorer?: boolean;
  119967. /**
  119968. * Display the property inspector
  119969. */
  119970. showInspector?: boolean;
  119971. /**
  119972. * Display in embed mode (both panes on the right)
  119973. */
  119974. embedMode?: boolean;
  119975. /**
  119976. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119977. */
  119978. handleResize?: boolean;
  119979. /**
  119980. * Allow the panes to popup (default: true)
  119981. */
  119982. enablePopup?: boolean;
  119983. /**
  119984. * Allow the panes to be closed by users (default: true)
  119985. */
  119986. enableClose?: boolean;
  119987. /**
  119988. * Optional list of extensibility entries
  119989. */
  119990. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119991. /**
  119992. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119993. */
  119994. inspectorURL?: string;
  119995. /**
  119996. * Optional initial tab (default to DebugLayerTab.Properties)
  119997. */
  119998. initialTab?: DebugLayerTab;
  119999. }
  120000. interface Scene {
  120001. /**
  120002. * @hidden
  120003. * Backing field
  120004. */
  120005. _debugLayer: DebugLayer;
  120006. /**
  120007. * Gets the debug layer (aka Inspector) associated with the scene
  120008. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120009. */
  120010. debugLayer: DebugLayer;
  120011. }
  120012. /**
  120013. * Enum of inspector action tab
  120014. */
  120015. export enum DebugLayerTab {
  120016. /**
  120017. * Properties tag (default)
  120018. */
  120019. Properties = 0,
  120020. /**
  120021. * Debug tab
  120022. */
  120023. Debug = 1,
  120024. /**
  120025. * Statistics tab
  120026. */
  120027. Statistics = 2,
  120028. /**
  120029. * Tools tab
  120030. */
  120031. Tools = 3,
  120032. /**
  120033. * Settings tab
  120034. */
  120035. Settings = 4
  120036. }
  120037. /**
  120038. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120039. * what is happening in your scene
  120040. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120041. */
  120042. export class DebugLayer {
  120043. /**
  120044. * Define the url to get the inspector script from.
  120045. * By default it uses the babylonjs CDN.
  120046. * @ignoreNaming
  120047. */
  120048. static InspectorURL: string;
  120049. private _scene;
  120050. private BJSINSPECTOR;
  120051. private _onPropertyChangedObservable?;
  120052. /**
  120053. * Observable triggered when a property is changed through the inspector.
  120054. */
  120055. get onPropertyChangedObservable(): any;
  120056. /**
  120057. * Instantiates a new debug layer.
  120058. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120059. * what is happening in your scene
  120060. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120061. * @param scene Defines the scene to inspect
  120062. */
  120063. constructor(scene: Scene);
  120064. /** Creates the inspector window. */
  120065. private _createInspector;
  120066. /**
  120067. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  120068. * @param entity defines the entity to select
  120069. * @param lineContainerTitle defines the specific block to highlight
  120070. */
  120071. select(entity: any, lineContainerTitle?: string): void;
  120072. /** Get the inspector from bundle or global */
  120073. private _getGlobalInspector;
  120074. /**
  120075. * Get if the inspector is visible or not.
  120076. * @returns true if visible otherwise, false
  120077. */
  120078. isVisible(): boolean;
  120079. /**
  120080. * Hide the inspector and close its window.
  120081. */
  120082. hide(): void;
  120083. /**
  120084. * Launch the debugLayer.
  120085. * @param config Define the configuration of the inspector
  120086. * @return a promise fulfilled when the debug layer is visible
  120087. */
  120088. show(config?: IInspectorOptions): Promise<DebugLayer>;
  120089. }
  120090. }
  120091. declare module BABYLON {
  120092. /**
  120093. * Class containing static functions to help procedurally build meshes
  120094. */
  120095. export class BoxBuilder {
  120096. /**
  120097. * Creates a box mesh
  120098. * * The parameter `size` sets the size (float) of each box side (default 1)
  120099. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120100. * * 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)
  120101. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120105. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120106. * @param name defines the name of the mesh
  120107. * @param options defines the options used to create the mesh
  120108. * @param scene defines the hosting scene
  120109. * @returns the box mesh
  120110. */
  120111. static CreateBox(name: string, options: {
  120112. size?: number;
  120113. width?: number;
  120114. height?: number;
  120115. depth?: number;
  120116. faceUV?: Vector4[];
  120117. faceColors?: Color4[];
  120118. sideOrientation?: number;
  120119. frontUVs?: Vector4;
  120120. backUVs?: Vector4;
  120121. wrap?: boolean;
  120122. topBaseAt?: number;
  120123. bottomBaseAt?: number;
  120124. updatable?: boolean;
  120125. }, scene?: Nullable<Scene>): Mesh;
  120126. }
  120127. }
  120128. declare module BABYLON.Debug {
  120129. /**
  120130. * Used to show the physics impostor around the specific mesh
  120131. */
  120132. export class PhysicsViewer {
  120133. /** @hidden */
  120134. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120135. /** @hidden */
  120136. protected _meshes: Array<Nullable<AbstractMesh>>;
  120137. /** @hidden */
  120138. protected _scene: Nullable<Scene>;
  120139. /** @hidden */
  120140. protected _numMeshes: number;
  120141. /** @hidden */
  120142. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120143. private _renderFunction;
  120144. private _utilityLayer;
  120145. private _debugBoxMesh;
  120146. private _debugSphereMesh;
  120147. private _debugCylinderMesh;
  120148. private _debugMaterial;
  120149. private _debugMeshMeshes;
  120150. /**
  120151. * Creates a new PhysicsViewer
  120152. * @param scene defines the hosting scene
  120153. */
  120154. constructor(scene: Scene);
  120155. /** @hidden */
  120156. protected _updateDebugMeshes(): void;
  120157. /**
  120158. * Renders a specified physic impostor
  120159. * @param impostor defines the impostor to render
  120160. * @param targetMesh defines the mesh represented by the impostor
  120161. * @returns the new debug mesh used to render the impostor
  120162. */
  120163. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120164. /**
  120165. * Hides a specified physic impostor
  120166. * @param impostor defines the impostor to hide
  120167. */
  120168. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120169. private _getDebugMaterial;
  120170. private _getDebugBoxMesh;
  120171. private _getDebugSphereMesh;
  120172. private _getDebugCylinderMesh;
  120173. private _getDebugMeshMesh;
  120174. private _getDebugMesh;
  120175. /** Releases all resources */
  120176. dispose(): void;
  120177. }
  120178. }
  120179. declare module BABYLON {
  120180. /**
  120181. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120182. * in order to better appreciate the issue one might have.
  120183. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120184. */
  120185. export class RayHelper {
  120186. /**
  120187. * Defines the ray we are currently tryin to visualize.
  120188. */
  120189. ray: Nullable<Ray>;
  120190. private _renderPoints;
  120191. private _renderLine;
  120192. private _renderFunction;
  120193. private _scene;
  120194. private _updateToMeshFunction;
  120195. private _attachedToMesh;
  120196. private _meshSpaceDirection;
  120197. private _meshSpaceOrigin;
  120198. /**
  120199. * Helper function to create a colored helper in a scene in one line.
  120200. * @param ray Defines the ray we are currently tryin to visualize
  120201. * @param scene Defines the scene the ray is used in
  120202. * @param color Defines the color we want to see the ray in
  120203. * @returns The newly created ray helper.
  120204. */
  120205. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  120206. /**
  120207. * Instantiate a new ray helper.
  120208. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120209. * in order to better appreciate the issue one might have.
  120210. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120211. * @param ray Defines the ray we are currently tryin to visualize
  120212. */
  120213. constructor(ray: Ray);
  120214. /**
  120215. * Shows the ray we are willing to debug.
  120216. * @param scene Defines the scene the ray needs to be rendered in
  120217. * @param color Defines the color the ray needs to be rendered in
  120218. */
  120219. show(scene: Scene, color?: Color3): void;
  120220. /**
  120221. * Hides the ray we are debugging.
  120222. */
  120223. hide(): void;
  120224. private _render;
  120225. /**
  120226. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  120227. * @param mesh Defines the mesh we want the helper attached to
  120228. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  120229. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  120230. * @param length Defines the length of the ray
  120231. */
  120232. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  120233. /**
  120234. * Detach the ray helper from the mesh it has previously been attached to.
  120235. */
  120236. detachFromMesh(): void;
  120237. private _updateToMesh;
  120238. /**
  120239. * Dispose the helper and release its associated resources.
  120240. */
  120241. dispose(): void;
  120242. }
  120243. }
  120244. declare module BABYLON.Debug {
  120245. /**
  120246. * Class used to render a debug view of a given skeleton
  120247. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  120248. */
  120249. export class SkeletonViewer {
  120250. /** defines the skeleton to render */
  120251. skeleton: Skeleton;
  120252. /** defines the mesh attached to the skeleton */
  120253. mesh: AbstractMesh;
  120254. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  120255. autoUpdateBonesMatrices: boolean;
  120256. /** defines the rendering group id to use with the viewer */
  120257. renderingGroupId: number;
  120258. /** Gets or sets the color used to render the skeleton */
  120259. color: Color3;
  120260. private _scene;
  120261. private _debugLines;
  120262. private _debugMesh;
  120263. private _isEnabled;
  120264. private _renderFunction;
  120265. private _utilityLayer;
  120266. /**
  120267. * Returns the mesh used to render the bones
  120268. */
  120269. get debugMesh(): Nullable<LinesMesh>;
  120270. /**
  120271. * Creates a new SkeletonViewer
  120272. * @param skeleton defines the skeleton to render
  120273. * @param mesh defines the mesh attached to the skeleton
  120274. * @param scene defines the hosting scene
  120275. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  120276. * @param renderingGroupId defines the rendering group id to use with the viewer
  120277. */
  120278. constructor(
  120279. /** defines the skeleton to render */
  120280. skeleton: Skeleton,
  120281. /** defines the mesh attached to the skeleton */
  120282. mesh: AbstractMesh, scene: Scene,
  120283. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  120284. autoUpdateBonesMatrices?: boolean,
  120285. /** defines the rendering group id to use with the viewer */
  120286. renderingGroupId?: number);
  120287. /** Gets or sets a boolean indicating if the viewer is enabled */
  120288. set isEnabled(value: boolean);
  120289. get isEnabled(): boolean;
  120290. private _getBonePosition;
  120291. private _getLinesForBonesWithLength;
  120292. private _getLinesForBonesNoLength;
  120293. /** Update the viewer to sync with current skeleton state */
  120294. update(): void;
  120295. /** Release associated resources */
  120296. dispose(): void;
  120297. }
  120298. }
  120299. declare module BABYLON {
  120300. /**
  120301. * Options to create the null engine
  120302. */
  120303. export class NullEngineOptions {
  120304. /**
  120305. * Render width (Default: 512)
  120306. */
  120307. renderWidth: number;
  120308. /**
  120309. * Render height (Default: 256)
  120310. */
  120311. renderHeight: number;
  120312. /**
  120313. * Texture size (Default: 512)
  120314. */
  120315. textureSize: number;
  120316. /**
  120317. * If delta time between frames should be constant
  120318. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120319. */
  120320. deterministicLockstep: boolean;
  120321. /**
  120322. * Maximum about of steps between frames (Default: 4)
  120323. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120324. */
  120325. lockstepMaxSteps: number;
  120326. }
  120327. /**
  120328. * The null engine class provides support for headless version of babylon.js.
  120329. * This can be used in server side scenario or for testing purposes
  120330. */
  120331. export class NullEngine extends Engine {
  120332. private _options;
  120333. /**
  120334. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  120335. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120336. * @returns true if engine is in deterministic lock step mode
  120337. */
  120338. isDeterministicLockStep(): boolean;
  120339. /**
  120340. * Gets the max steps when engine is running in deterministic lock step
  120341. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120342. * @returns the max steps
  120343. */
  120344. getLockstepMaxSteps(): number;
  120345. /**
  120346. * Gets the current hardware scaling level.
  120347. * By default the hardware scaling level is computed from the window device ratio.
  120348. * 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.
  120349. * @returns a number indicating the current hardware scaling level
  120350. */
  120351. getHardwareScalingLevel(): number;
  120352. constructor(options?: NullEngineOptions);
  120353. /**
  120354. * Creates a vertex buffer
  120355. * @param vertices the data for the vertex buffer
  120356. * @returns the new WebGL static buffer
  120357. */
  120358. createVertexBuffer(vertices: FloatArray): DataBuffer;
  120359. /**
  120360. * Creates a new index buffer
  120361. * @param indices defines the content of the index buffer
  120362. * @param updatable defines if the index buffer must be updatable
  120363. * @returns a new webGL buffer
  120364. */
  120365. createIndexBuffer(indices: IndicesArray): DataBuffer;
  120366. /**
  120367. * Clear the current render buffer or the current render target (if any is set up)
  120368. * @param color defines the color to use
  120369. * @param backBuffer defines if the back buffer must be cleared
  120370. * @param depth defines if the depth buffer must be cleared
  120371. * @param stencil defines if the stencil buffer must be cleared
  120372. */
  120373. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120374. /**
  120375. * Gets the current render width
  120376. * @param useScreen defines if screen size must be used (or the current render target if any)
  120377. * @returns a number defining the current render width
  120378. */
  120379. getRenderWidth(useScreen?: boolean): number;
  120380. /**
  120381. * Gets the current render height
  120382. * @param useScreen defines if screen size must be used (or the current render target if any)
  120383. * @returns a number defining the current render height
  120384. */
  120385. getRenderHeight(useScreen?: boolean): number;
  120386. /**
  120387. * Set the WebGL's viewport
  120388. * @param viewport defines the viewport element to be used
  120389. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120390. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120391. */
  120392. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120393. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  120394. /**
  120395. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120396. * @param pipelineContext defines the pipeline context to use
  120397. * @param uniformsNames defines the list of uniform names
  120398. * @returns an array of webGL uniform locations
  120399. */
  120400. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120401. /**
  120402. * Gets the lsit of active attributes for a given webGL program
  120403. * @param pipelineContext defines the pipeline context to use
  120404. * @param attributesNames defines the list of attribute names to get
  120405. * @returns an array of indices indicating the offset of each attribute
  120406. */
  120407. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120408. /**
  120409. * Binds an effect to the webGL context
  120410. * @param effect defines the effect to bind
  120411. */
  120412. bindSamplers(effect: Effect): void;
  120413. /**
  120414. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120415. * @param effect defines the effect to activate
  120416. */
  120417. enableEffect(effect: Effect): void;
  120418. /**
  120419. * Set various states to the webGL context
  120420. * @param culling defines backface culling state
  120421. * @param zOffset defines the value to apply to zOffset (0 by default)
  120422. * @param force defines if states must be applied even if cache is up to date
  120423. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  120424. */
  120425. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120426. /**
  120427. * Set the value of an uniform to an array of int32
  120428. * @param uniform defines the webGL uniform location where to store the value
  120429. * @param array defines the array of int32 to store
  120430. */
  120431. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120432. /**
  120433. * Set the value of an uniform to an array of int32 (stored as vec2)
  120434. * @param uniform defines the webGL uniform location where to store the value
  120435. * @param array defines the array of int32 to store
  120436. */
  120437. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120438. /**
  120439. * Set the value of an uniform to an array of int32 (stored as vec3)
  120440. * @param uniform defines the webGL uniform location where to store the value
  120441. * @param array defines the array of int32 to store
  120442. */
  120443. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120444. /**
  120445. * Set the value of an uniform to an array of int32 (stored as vec4)
  120446. * @param uniform defines the webGL uniform location where to store the value
  120447. * @param array defines the array of int32 to store
  120448. */
  120449. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120450. /**
  120451. * Set the value of an uniform to an array of float32
  120452. * @param uniform defines the webGL uniform location where to store the value
  120453. * @param array defines the array of float32 to store
  120454. */
  120455. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120456. /**
  120457. * Set the value of an uniform to an array of float32 (stored as vec2)
  120458. * @param uniform defines the webGL uniform location where to store the value
  120459. * @param array defines the array of float32 to store
  120460. */
  120461. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120462. /**
  120463. * Set the value of an uniform to an array of float32 (stored as vec3)
  120464. * @param uniform defines the webGL uniform location where to store the value
  120465. * @param array defines the array of float32 to store
  120466. */
  120467. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120468. /**
  120469. * Set the value of an uniform to an array of float32 (stored as vec4)
  120470. * @param uniform defines the webGL uniform location where to store the value
  120471. * @param array defines the array of float32 to store
  120472. */
  120473. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120474. /**
  120475. * Set the value of an uniform to an array of number
  120476. * @param uniform defines the webGL uniform location where to store the value
  120477. * @param array defines the array of number to store
  120478. */
  120479. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120480. /**
  120481. * Set the value of an uniform to an array of number (stored as vec2)
  120482. * @param uniform defines the webGL uniform location where to store the value
  120483. * @param array defines the array of number to store
  120484. */
  120485. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120486. /**
  120487. * Set the value of an uniform to an array of number (stored as vec3)
  120488. * @param uniform defines the webGL uniform location where to store the value
  120489. * @param array defines the array of number to store
  120490. */
  120491. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120492. /**
  120493. * Set the value of an uniform to an array of number (stored as vec4)
  120494. * @param uniform defines the webGL uniform location where to store the value
  120495. * @param array defines the array of number to store
  120496. */
  120497. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120498. /**
  120499. * Set the value of an uniform to an array of float32 (stored as matrices)
  120500. * @param uniform defines the webGL uniform location where to store the value
  120501. * @param matrices defines the array of float32 to store
  120502. */
  120503. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120504. /**
  120505. * Set the value of an uniform to a matrix (3x3)
  120506. * @param uniform defines the webGL uniform location where to store the value
  120507. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120508. */
  120509. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120510. /**
  120511. * Set the value of an uniform to a matrix (2x2)
  120512. * @param uniform defines the webGL uniform location where to store the value
  120513. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120514. */
  120515. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120516. /**
  120517. * Set the value of an uniform to a number (float)
  120518. * @param uniform defines the webGL uniform location where to store the value
  120519. * @param value defines the float number to store
  120520. */
  120521. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120522. /**
  120523. * Set the value of an uniform to a vec2
  120524. * @param uniform defines the webGL uniform location where to store the value
  120525. * @param x defines the 1st component of the value
  120526. * @param y defines the 2nd component of the value
  120527. */
  120528. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120529. /**
  120530. * Set the value of an uniform to a vec3
  120531. * @param uniform defines the webGL uniform location where to store the value
  120532. * @param x defines the 1st component of the value
  120533. * @param y defines the 2nd component of the value
  120534. * @param z defines the 3rd component of the value
  120535. */
  120536. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120537. /**
  120538. * Set the value of an uniform to a boolean
  120539. * @param uniform defines the webGL uniform location where to store the value
  120540. * @param bool defines the boolean to store
  120541. */
  120542. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120543. /**
  120544. * Set the value of an uniform to a vec4
  120545. * @param uniform defines the webGL uniform location where to store the value
  120546. * @param x defines the 1st component of the value
  120547. * @param y defines the 2nd component of the value
  120548. * @param z defines the 3rd component of the value
  120549. * @param w defines the 4th component of the value
  120550. */
  120551. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120552. /**
  120553. * Sets the current alpha mode
  120554. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120555. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120556. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120557. */
  120558. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120559. /**
  120560. * Bind webGl buffers directly to the webGL context
  120561. * @param vertexBuffers defines the vertex buffer to bind
  120562. * @param indexBuffer defines the index buffer to bind
  120563. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120564. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120565. * @param effect defines the effect associated with the vertex buffer
  120566. */
  120567. bindBuffers(vertexBuffers: {
  120568. [key: string]: VertexBuffer;
  120569. }, indexBuffer: DataBuffer, effect: Effect): void;
  120570. /**
  120571. * Force the entire cache to be cleared
  120572. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120573. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120574. */
  120575. wipeCaches(bruteForce?: boolean): void;
  120576. /**
  120577. * Send a draw order
  120578. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120579. * @param indexStart defines the starting index
  120580. * @param indexCount defines the number of index to draw
  120581. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120582. */
  120583. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120584. /**
  120585. * Draw a list of indexed primitives
  120586. * @param fillMode defines the primitive to use
  120587. * @param indexStart defines the starting index
  120588. * @param indexCount defines the number of index to draw
  120589. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120590. */
  120591. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120592. /**
  120593. * Draw a list of unindexed primitives
  120594. * @param fillMode defines the primitive to use
  120595. * @param verticesStart defines the index of first vertex to draw
  120596. * @param verticesCount defines the count of vertices to draw
  120597. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120598. */
  120599. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120600. /** @hidden */
  120601. _createTexture(): WebGLTexture;
  120602. /** @hidden */
  120603. _releaseTexture(texture: InternalTexture): void;
  120604. /**
  120605. * Usually called from Texture.ts.
  120606. * Passed information to create a WebGLTexture
  120607. * @param urlArg defines a value which contains one of the following:
  120608. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120609. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120610. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120612. * @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)
  120613. * @param scene needed for loading to the correct scene
  120614. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120615. * @param onLoad optional callback to be called upon successful completion
  120616. * @param onError optional callback to be called upon failure
  120617. * @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
  120618. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120619. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120620. * @param forcedExtension defines the extension to use to pick the right loader
  120621. * @param mimeType defines an optional mime type
  120622. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120623. */
  120624. 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;
  120625. /**
  120626. * Creates a new render target texture
  120627. * @param size defines the size of the texture
  120628. * @param options defines the options used to create the texture
  120629. * @returns a new render target texture stored in an InternalTexture
  120630. */
  120631. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120632. /**
  120633. * Update the sampling mode of a given texture
  120634. * @param samplingMode defines the required sampling mode
  120635. * @param texture defines the texture to update
  120636. */
  120637. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120638. /**
  120639. * Binds the frame buffer to the specified texture.
  120640. * @param texture The texture to render to or null for the default canvas
  120641. * @param faceIndex The face of the texture to render to in case of cube texture
  120642. * @param requiredWidth The width of the target to render to
  120643. * @param requiredHeight The height of the target to render to
  120644. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120645. * @param lodLevel defines le lod level to bind to the frame buffer
  120646. */
  120647. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120648. /**
  120649. * Unbind the current render target texture from the webGL context
  120650. * @param texture defines the render target texture to unbind
  120651. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120652. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120653. */
  120654. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120655. /**
  120656. * Creates a dynamic vertex buffer
  120657. * @param vertices the data for the dynamic vertex buffer
  120658. * @returns the new WebGL dynamic buffer
  120659. */
  120660. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120661. /**
  120662. * Update the content of a dynamic texture
  120663. * @param texture defines the texture to update
  120664. * @param canvas defines the canvas containing the source
  120665. * @param invertY defines if data must be stored with Y axis inverted
  120666. * @param premulAlpha defines if alpha is stored as premultiplied
  120667. * @param format defines the format of the data
  120668. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120669. */
  120670. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120671. /**
  120672. * Gets a boolean indicating if all created effects are ready
  120673. * @returns true if all effects are ready
  120674. */
  120675. areAllEffectsReady(): boolean;
  120676. /**
  120677. * @hidden
  120678. * Get the current error code of the webGL context
  120679. * @returns the error code
  120680. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120681. */
  120682. getError(): number;
  120683. /** @hidden */
  120684. _getUnpackAlignement(): number;
  120685. /** @hidden */
  120686. _unpackFlipY(value: boolean): void;
  120687. /**
  120688. * Update a dynamic index buffer
  120689. * @param indexBuffer defines the target index buffer
  120690. * @param indices defines the data to update
  120691. * @param offset defines the offset in the target index buffer where update should start
  120692. */
  120693. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120694. /**
  120695. * Updates a dynamic vertex buffer.
  120696. * @param vertexBuffer the vertex buffer to update
  120697. * @param vertices the data used to update the vertex buffer
  120698. * @param byteOffset the byte offset of the data (optional)
  120699. * @param byteLength the byte length of the data (optional)
  120700. */
  120701. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120702. /** @hidden */
  120703. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120704. /** @hidden */
  120705. _bindTexture(channel: number, texture: InternalTexture): void;
  120706. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120707. /**
  120708. * 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
  120709. */
  120710. releaseEffects(): void;
  120711. displayLoadingUI(): void;
  120712. hideLoadingUI(): void;
  120713. /** @hidden */
  120714. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120715. /** @hidden */
  120716. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120717. /** @hidden */
  120718. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120719. /** @hidden */
  120720. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120721. }
  120722. }
  120723. declare module BABYLON {
  120724. /**
  120725. * @hidden
  120726. **/
  120727. export class _TimeToken {
  120728. _startTimeQuery: Nullable<WebGLQuery>;
  120729. _endTimeQuery: Nullable<WebGLQuery>;
  120730. _timeElapsedQuery: Nullable<WebGLQuery>;
  120731. _timeElapsedQueryEnded: boolean;
  120732. }
  120733. }
  120734. declare module BABYLON {
  120735. /** @hidden */
  120736. export class _OcclusionDataStorage {
  120737. /** @hidden */
  120738. occlusionInternalRetryCounter: number;
  120739. /** @hidden */
  120740. isOcclusionQueryInProgress: boolean;
  120741. /** @hidden */
  120742. isOccluded: boolean;
  120743. /** @hidden */
  120744. occlusionRetryCount: number;
  120745. /** @hidden */
  120746. occlusionType: number;
  120747. /** @hidden */
  120748. occlusionQueryAlgorithmType: number;
  120749. }
  120750. interface Engine {
  120751. /**
  120752. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120753. * @return the new query
  120754. */
  120755. createQuery(): WebGLQuery;
  120756. /**
  120757. * Delete and release a webGL query
  120758. * @param query defines the query to delete
  120759. * @return the current engine
  120760. */
  120761. deleteQuery(query: WebGLQuery): Engine;
  120762. /**
  120763. * Check if a given query has resolved and got its value
  120764. * @param query defines the query to check
  120765. * @returns true if the query got its value
  120766. */
  120767. isQueryResultAvailable(query: WebGLQuery): boolean;
  120768. /**
  120769. * Gets the value of a given query
  120770. * @param query defines the query to check
  120771. * @returns the value of the query
  120772. */
  120773. getQueryResult(query: WebGLQuery): number;
  120774. /**
  120775. * Initiates an occlusion query
  120776. * @param algorithmType defines the algorithm to use
  120777. * @param query defines the query to use
  120778. * @returns the current engine
  120779. * @see http://doc.babylonjs.com/features/occlusionquery
  120780. */
  120781. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120782. /**
  120783. * Ends an occlusion query
  120784. * @see http://doc.babylonjs.com/features/occlusionquery
  120785. * @param algorithmType defines the algorithm to use
  120786. * @returns the current engine
  120787. */
  120788. endOcclusionQuery(algorithmType: number): Engine;
  120789. /**
  120790. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120791. * Please note that only one query can be issued at a time
  120792. * @returns a time token used to track the time span
  120793. */
  120794. startTimeQuery(): Nullable<_TimeToken>;
  120795. /**
  120796. * Ends a time query
  120797. * @param token defines the token used to measure the time span
  120798. * @returns the time spent (in ns)
  120799. */
  120800. endTimeQuery(token: _TimeToken): int;
  120801. /** @hidden */
  120802. _currentNonTimestampToken: Nullable<_TimeToken>;
  120803. /** @hidden */
  120804. _createTimeQuery(): WebGLQuery;
  120805. /** @hidden */
  120806. _deleteTimeQuery(query: WebGLQuery): void;
  120807. /** @hidden */
  120808. _getGlAlgorithmType(algorithmType: number): number;
  120809. /** @hidden */
  120810. _getTimeQueryResult(query: WebGLQuery): any;
  120811. /** @hidden */
  120812. _getTimeQueryAvailability(query: WebGLQuery): any;
  120813. }
  120814. interface AbstractMesh {
  120815. /**
  120816. * Backing filed
  120817. * @hidden
  120818. */
  120819. __occlusionDataStorage: _OcclusionDataStorage;
  120820. /**
  120821. * Access property
  120822. * @hidden
  120823. */
  120824. _occlusionDataStorage: _OcclusionDataStorage;
  120825. /**
  120826. * 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.
  120827. * The default value is -1 which means don't break the query and wait till the result
  120828. * @see http://doc.babylonjs.com/features/occlusionquery
  120829. */
  120830. occlusionRetryCount: number;
  120831. /**
  120832. * 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:
  120833. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120834. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120835. * * 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.
  120836. * @see http://doc.babylonjs.com/features/occlusionquery
  120837. */
  120838. occlusionType: number;
  120839. /**
  120840. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120841. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120842. * * 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.
  120843. * @see http://doc.babylonjs.com/features/occlusionquery
  120844. */
  120845. occlusionQueryAlgorithmType: number;
  120846. /**
  120847. * 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
  120848. * @see http://doc.babylonjs.com/features/occlusionquery
  120849. */
  120850. isOccluded: boolean;
  120851. /**
  120852. * Flag to check the progress status of the query
  120853. * @see http://doc.babylonjs.com/features/occlusionquery
  120854. */
  120855. isOcclusionQueryInProgress: boolean;
  120856. }
  120857. }
  120858. declare module BABYLON {
  120859. /** @hidden */
  120860. export var _forceTransformFeedbackToBundle: boolean;
  120861. interface Engine {
  120862. /**
  120863. * Creates a webGL transform feedback object
  120864. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120865. * @returns the webGL transform feedback object
  120866. */
  120867. createTransformFeedback(): WebGLTransformFeedback;
  120868. /**
  120869. * Delete a webGL transform feedback object
  120870. * @param value defines the webGL transform feedback object to delete
  120871. */
  120872. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120873. /**
  120874. * Bind a webGL transform feedback object to the webgl context
  120875. * @param value defines the webGL transform feedback object to bind
  120876. */
  120877. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120878. /**
  120879. * Begins a transform feedback operation
  120880. * @param usePoints defines if points or triangles must be used
  120881. */
  120882. beginTransformFeedback(usePoints: boolean): void;
  120883. /**
  120884. * Ends a transform feedback operation
  120885. */
  120886. endTransformFeedback(): void;
  120887. /**
  120888. * Specify the varyings to use with transform feedback
  120889. * @param program defines the associated webGL program
  120890. * @param value defines the list of strings representing the varying names
  120891. */
  120892. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120893. /**
  120894. * Bind a webGL buffer for a transform feedback operation
  120895. * @param value defines the webGL buffer to bind
  120896. */
  120897. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120898. }
  120899. }
  120900. declare module BABYLON {
  120901. /**
  120902. * Creation options of the multi render target texture.
  120903. */
  120904. export interface IMultiRenderTargetOptions {
  120905. /**
  120906. * Define if the texture needs to create mip maps after render.
  120907. */
  120908. generateMipMaps?: boolean;
  120909. /**
  120910. * Define the types of all the draw buffers we want to create
  120911. */
  120912. types?: number[];
  120913. /**
  120914. * Define the sampling modes of all the draw buffers we want to create
  120915. */
  120916. samplingModes?: number[];
  120917. /**
  120918. * Define if a depth buffer is required
  120919. */
  120920. generateDepthBuffer?: boolean;
  120921. /**
  120922. * Define if a stencil buffer is required
  120923. */
  120924. generateStencilBuffer?: boolean;
  120925. /**
  120926. * Define if a depth texture is required instead of a depth buffer
  120927. */
  120928. generateDepthTexture?: boolean;
  120929. /**
  120930. * Define the number of desired draw buffers
  120931. */
  120932. textureCount?: number;
  120933. /**
  120934. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120935. */
  120936. doNotChangeAspectRatio?: boolean;
  120937. /**
  120938. * Define the default type of the buffers we are creating
  120939. */
  120940. defaultType?: number;
  120941. }
  120942. /**
  120943. * A multi render target, like a render target provides the ability to render to a texture.
  120944. * Unlike the render target, it can render to several draw buffers in one draw.
  120945. * This is specially interesting in deferred rendering or for any effects requiring more than
  120946. * just one color from a single pass.
  120947. */
  120948. export class MultiRenderTarget extends RenderTargetTexture {
  120949. private _internalTextures;
  120950. private _textures;
  120951. private _multiRenderTargetOptions;
  120952. /**
  120953. * Get if draw buffers are currently supported by the used hardware and browser.
  120954. */
  120955. get isSupported(): boolean;
  120956. /**
  120957. * Get the list of textures generated by the multi render target.
  120958. */
  120959. get textures(): Texture[];
  120960. /**
  120961. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120962. */
  120963. get depthTexture(): Texture;
  120964. /**
  120965. * Set the wrapping mode on U of all the textures we are rendering to.
  120966. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120967. */
  120968. set wrapU(wrap: number);
  120969. /**
  120970. * Set the wrapping mode on V of all the textures we are rendering to.
  120971. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120972. */
  120973. set wrapV(wrap: number);
  120974. /**
  120975. * Instantiate a new multi render target texture.
  120976. * A multi render target, like a render target provides the ability to render to a texture.
  120977. * Unlike the render target, it can render to several draw buffers in one draw.
  120978. * This is specially interesting in deferred rendering or for any effects requiring more than
  120979. * just one color from a single pass.
  120980. * @param name Define the name of the texture
  120981. * @param size Define the size of the buffers to render to
  120982. * @param count Define the number of target we are rendering into
  120983. * @param scene Define the scene the texture belongs to
  120984. * @param options Define the options used to create the multi render target
  120985. */
  120986. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120987. /** @hidden */
  120988. _rebuild(): void;
  120989. private _createInternalTextures;
  120990. private _createTextures;
  120991. /**
  120992. * Define the number of samples used if MSAA is enabled.
  120993. */
  120994. get samples(): number;
  120995. set samples(value: number);
  120996. /**
  120997. * Resize all the textures in the multi render target.
  120998. * Be carrefull as it will recreate all the data in the new texture.
  120999. * @param size Define the new size
  121000. */
  121001. resize(size: any): void;
  121002. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  121003. /**
  121004. * Dispose the render targets and their associated resources
  121005. */
  121006. dispose(): void;
  121007. /**
  121008. * Release all the underlying texture used as draw buffers.
  121009. */
  121010. releaseInternalTextures(): void;
  121011. }
  121012. }
  121013. declare module BABYLON {
  121014. interface ThinEngine {
  121015. /**
  121016. * Unbind a list of render target textures from the webGL context
  121017. * This is used only when drawBuffer extension or webGL2 are active
  121018. * @param textures defines the render target textures to unbind
  121019. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121020. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121021. */
  121022. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  121023. /**
  121024. * Create a multi render target texture
  121025. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  121026. * @param size defines the size of the texture
  121027. * @param options defines the creation options
  121028. * @returns the cube texture as an InternalTexture
  121029. */
  121030. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  121031. /**
  121032. * Update the sample count for a given multiple render target texture
  121033. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121034. * @param textures defines the textures to update
  121035. * @param samples defines the sample count to set
  121036. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121037. */
  121038. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  121039. }
  121040. }
  121041. declare module BABYLON {
  121042. /**
  121043. * Class used to define an additional view for the engine
  121044. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121045. */
  121046. export class EngineView {
  121047. /** Defines the canvas where to render the view */
  121048. target: HTMLCanvasElement;
  121049. /** Defines an optional camera used to render the view (will use active camera else) */
  121050. camera?: Camera;
  121051. }
  121052. interface Engine {
  121053. /**
  121054. * Gets or sets the HTML element to use for attaching events
  121055. */
  121056. inputElement: Nullable<HTMLElement>;
  121057. /**
  121058. * Gets the current engine view
  121059. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121060. */
  121061. activeView: Nullable<EngineView>;
  121062. /** Gets or sets the list of views */
  121063. views: EngineView[];
  121064. /**
  121065. * Register a new child canvas
  121066. * @param canvas defines the canvas to register
  121067. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  121068. * @returns the associated view
  121069. */
  121070. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  121071. /**
  121072. * Remove a registered child canvas
  121073. * @param canvas defines the canvas to remove
  121074. * @returns the current engine
  121075. */
  121076. unRegisterView(canvas: HTMLCanvasElement): Engine;
  121077. }
  121078. }
  121079. declare module BABYLON {
  121080. interface Engine {
  121081. /** @hidden */
  121082. _excludedCompressedTextures: string[];
  121083. /** @hidden */
  121084. _textureFormatInUse: string;
  121085. /**
  121086. * Gets the list of texture formats supported
  121087. */
  121088. readonly texturesSupported: Array<string>;
  121089. /**
  121090. * Gets the texture format in use
  121091. */
  121092. readonly textureFormatInUse: Nullable<string>;
  121093. /**
  121094. * Set the compressed texture extensions or file names to skip.
  121095. *
  121096. * @param skippedFiles defines the list of those texture files you want to skip
  121097. * Example: [".dds", ".env", "myfile.png"]
  121098. */
  121099. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  121100. /**
  121101. * Set the compressed texture format to use, based on the formats you have, and the formats
  121102. * supported by the hardware / browser.
  121103. *
  121104. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  121105. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  121106. * to API arguments needed to compressed textures. This puts the burden on the container
  121107. * generator to house the arcane code for determining these for current & future formats.
  121108. *
  121109. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121110. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121111. *
  121112. * Note: The result of this call is not taken into account when a texture is base64.
  121113. *
  121114. * @param formatsAvailable defines the list of those format families you have created
  121115. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121116. *
  121117. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121118. * @returns The extension selected.
  121119. */
  121120. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121121. }
  121122. }
  121123. declare module BABYLON {
  121124. /**
  121125. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121126. */
  121127. export interface CubeMapInfo {
  121128. /**
  121129. * The pixel array for the front face.
  121130. * This is stored in format, left to right, up to down format.
  121131. */
  121132. front: Nullable<ArrayBufferView>;
  121133. /**
  121134. * The pixel array for the back face.
  121135. * This is stored in format, left to right, up to down format.
  121136. */
  121137. back: Nullable<ArrayBufferView>;
  121138. /**
  121139. * The pixel array for the left face.
  121140. * This is stored in format, left to right, up to down format.
  121141. */
  121142. left: Nullable<ArrayBufferView>;
  121143. /**
  121144. * The pixel array for the right face.
  121145. * This is stored in format, left to right, up to down format.
  121146. */
  121147. right: Nullable<ArrayBufferView>;
  121148. /**
  121149. * The pixel array for the up face.
  121150. * This is stored in format, left to right, up to down format.
  121151. */
  121152. up: Nullable<ArrayBufferView>;
  121153. /**
  121154. * The pixel array for the down face.
  121155. * This is stored in format, left to right, up to down format.
  121156. */
  121157. down: Nullable<ArrayBufferView>;
  121158. /**
  121159. * The size of the cubemap stored.
  121160. *
  121161. * Each faces will be size * size pixels.
  121162. */
  121163. size: number;
  121164. /**
  121165. * The format of the texture.
  121166. *
  121167. * RGBA, RGB.
  121168. */
  121169. format: number;
  121170. /**
  121171. * The type of the texture data.
  121172. *
  121173. * UNSIGNED_INT, FLOAT.
  121174. */
  121175. type: number;
  121176. /**
  121177. * Specifies whether the texture is in gamma space.
  121178. */
  121179. gammaSpace: boolean;
  121180. }
  121181. /**
  121182. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  121183. */
  121184. export class PanoramaToCubeMapTools {
  121185. private static FACE_FRONT;
  121186. private static FACE_BACK;
  121187. private static FACE_RIGHT;
  121188. private static FACE_LEFT;
  121189. private static FACE_DOWN;
  121190. private static FACE_UP;
  121191. /**
  121192. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  121193. *
  121194. * @param float32Array The source data.
  121195. * @param inputWidth The width of the input panorama.
  121196. * @param inputHeight The height of the input panorama.
  121197. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  121198. * @return The cubemap data
  121199. */
  121200. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  121201. private static CreateCubemapTexture;
  121202. private static CalcProjectionSpherical;
  121203. }
  121204. }
  121205. declare module BABYLON {
  121206. /**
  121207. * Helper class dealing with the extraction of spherical polynomial dataArray
  121208. * from a cube map.
  121209. */
  121210. export class CubeMapToSphericalPolynomialTools {
  121211. private static FileFaces;
  121212. /**
  121213. * Converts a texture to the according Spherical Polynomial data.
  121214. * This extracts the first 3 orders only as they are the only one used in the lighting.
  121215. *
  121216. * @param texture The texture to extract the information from.
  121217. * @return The Spherical Polynomial data.
  121218. */
  121219. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  121220. /**
  121221. * Converts a cubemap to the according Spherical Polynomial data.
  121222. * This extracts the first 3 orders only as they are the only one used in the lighting.
  121223. *
  121224. * @param cubeInfo The Cube map to extract the information from.
  121225. * @return The Spherical Polynomial data.
  121226. */
  121227. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  121228. }
  121229. }
  121230. declare module BABYLON {
  121231. interface BaseTexture {
  121232. /**
  121233. * Get the polynomial representation of the texture data.
  121234. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  121235. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  121236. */
  121237. sphericalPolynomial: Nullable<SphericalPolynomial>;
  121238. }
  121239. }
  121240. declare module BABYLON {
  121241. /** @hidden */
  121242. export var rgbdEncodePixelShader: {
  121243. name: string;
  121244. shader: string;
  121245. };
  121246. }
  121247. declare module BABYLON {
  121248. /** @hidden */
  121249. export var rgbdDecodePixelShader: {
  121250. name: string;
  121251. shader: string;
  121252. };
  121253. }
  121254. declare module BABYLON {
  121255. /**
  121256. * Raw texture data and descriptor sufficient for WebGL texture upload
  121257. */
  121258. export interface EnvironmentTextureInfo {
  121259. /**
  121260. * Version of the environment map
  121261. */
  121262. version: number;
  121263. /**
  121264. * Width of image
  121265. */
  121266. width: number;
  121267. /**
  121268. * Irradiance information stored in the file.
  121269. */
  121270. irradiance: any;
  121271. /**
  121272. * Specular information stored in the file.
  121273. */
  121274. specular: any;
  121275. }
  121276. /**
  121277. * Defines One Image in the file. It requires only the position in the file
  121278. * as well as the length.
  121279. */
  121280. interface BufferImageData {
  121281. /**
  121282. * Length of the image data.
  121283. */
  121284. length: number;
  121285. /**
  121286. * Position of the data from the null terminator delimiting the end of the JSON.
  121287. */
  121288. position: number;
  121289. }
  121290. /**
  121291. * Defines the specular data enclosed in the file.
  121292. * This corresponds to the version 1 of the data.
  121293. */
  121294. export interface EnvironmentTextureSpecularInfoV1 {
  121295. /**
  121296. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  121297. */
  121298. specularDataPosition?: number;
  121299. /**
  121300. * This contains all the images data needed to reconstruct the cubemap.
  121301. */
  121302. mipmaps: Array<BufferImageData>;
  121303. /**
  121304. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  121305. */
  121306. lodGenerationScale: number;
  121307. }
  121308. /**
  121309. * Sets of helpers addressing the serialization and deserialization of environment texture
  121310. * stored in a BabylonJS env file.
  121311. * Those files are usually stored as .env files.
  121312. */
  121313. export class EnvironmentTextureTools {
  121314. /**
  121315. * Magic number identifying the env file.
  121316. */
  121317. private static _MagicBytes;
  121318. /**
  121319. * Gets the environment info from an env file.
  121320. * @param data The array buffer containing the .env bytes.
  121321. * @returns the environment file info (the json header) if successfully parsed.
  121322. */
  121323. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  121324. /**
  121325. * Creates an environment texture from a loaded cube texture.
  121326. * @param texture defines the cube texture to convert in env file
  121327. * @return a promise containing the environment data if succesfull.
  121328. */
  121329. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  121330. /**
  121331. * Creates a JSON representation of the spherical data.
  121332. * @param texture defines the texture containing the polynomials
  121333. * @return the JSON representation of the spherical info
  121334. */
  121335. private static _CreateEnvTextureIrradiance;
  121336. /**
  121337. * Creates the ArrayBufferViews used for initializing environment texture image data.
  121338. * @param data the image data
  121339. * @param info parameters that determine what views will be created for accessing the underlying buffer
  121340. * @return the views described by info providing access to the underlying buffer
  121341. */
  121342. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  121343. /**
  121344. * Uploads the texture info contained in the env file to the GPU.
  121345. * @param texture defines the internal texture to upload to
  121346. * @param data defines the data to load
  121347. * @param info defines the texture info retrieved through the GetEnvInfo method
  121348. * @returns a promise
  121349. */
  121350. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  121351. private static _OnImageReadyAsync;
  121352. /**
  121353. * Uploads the levels of image data to the GPU.
  121354. * @param texture defines the internal texture to upload to
  121355. * @param imageData defines the array buffer views of image data [mipmap][face]
  121356. * @returns a promise
  121357. */
  121358. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  121359. /**
  121360. * Uploads spherical polynomials information to the texture.
  121361. * @param texture defines the texture we are trying to upload the information to
  121362. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  121363. */
  121364. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  121365. /** @hidden */
  121366. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121367. }
  121368. }
  121369. declare module BABYLON {
  121370. /**
  121371. * Contains position and normal vectors for a vertex
  121372. */
  121373. export class PositionNormalVertex {
  121374. /** the position of the vertex (defaut: 0,0,0) */
  121375. position: Vector3;
  121376. /** the normal of the vertex (defaut: 0,1,0) */
  121377. normal: Vector3;
  121378. /**
  121379. * Creates a PositionNormalVertex
  121380. * @param position the position of the vertex (defaut: 0,0,0)
  121381. * @param normal the normal of the vertex (defaut: 0,1,0)
  121382. */
  121383. constructor(
  121384. /** the position of the vertex (defaut: 0,0,0) */
  121385. position?: Vector3,
  121386. /** the normal of the vertex (defaut: 0,1,0) */
  121387. normal?: Vector3);
  121388. /**
  121389. * Clones the PositionNormalVertex
  121390. * @returns the cloned PositionNormalVertex
  121391. */
  121392. clone(): PositionNormalVertex;
  121393. }
  121394. /**
  121395. * Contains position, normal and uv vectors for a vertex
  121396. */
  121397. export class PositionNormalTextureVertex {
  121398. /** the position of the vertex (defaut: 0,0,0) */
  121399. position: Vector3;
  121400. /** the normal of the vertex (defaut: 0,1,0) */
  121401. normal: Vector3;
  121402. /** the uv of the vertex (default: 0,0) */
  121403. uv: Vector2;
  121404. /**
  121405. * Creates a PositionNormalTextureVertex
  121406. * @param position the position of the vertex (defaut: 0,0,0)
  121407. * @param normal the normal of the vertex (defaut: 0,1,0)
  121408. * @param uv the uv of the vertex (default: 0,0)
  121409. */
  121410. constructor(
  121411. /** the position of the vertex (defaut: 0,0,0) */
  121412. position?: Vector3,
  121413. /** the normal of the vertex (defaut: 0,1,0) */
  121414. normal?: Vector3,
  121415. /** the uv of the vertex (default: 0,0) */
  121416. uv?: Vector2);
  121417. /**
  121418. * Clones the PositionNormalTextureVertex
  121419. * @returns the cloned PositionNormalTextureVertex
  121420. */
  121421. clone(): PositionNormalTextureVertex;
  121422. }
  121423. }
  121424. declare module BABYLON {
  121425. /** @hidden */
  121426. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  121427. private _genericAttributeLocation;
  121428. private _varyingLocationCount;
  121429. private _varyingLocationMap;
  121430. private _replacements;
  121431. private _textureCount;
  121432. private _uniforms;
  121433. lineProcessor(line: string): string;
  121434. attributeProcessor(attribute: string): string;
  121435. varyingProcessor(varying: string, isFragment: boolean): string;
  121436. uniformProcessor(uniform: string): string;
  121437. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  121438. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  121439. }
  121440. }
  121441. declare module BABYLON {
  121442. /**
  121443. * Container for accessors for natively-stored mesh data buffers.
  121444. */
  121445. class NativeDataBuffer extends DataBuffer {
  121446. /**
  121447. * Accessor value used to identify/retrieve a natively-stored index buffer.
  121448. */
  121449. nativeIndexBuffer?: any;
  121450. /**
  121451. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  121452. */
  121453. nativeVertexBuffer?: any;
  121454. }
  121455. /** @hidden */
  121456. class NativeTexture extends InternalTexture {
  121457. getInternalTexture(): InternalTexture;
  121458. getViewCount(): number;
  121459. }
  121460. /** @hidden */
  121461. export class NativeEngine extends Engine {
  121462. private readonly _native;
  121463. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  121464. private readonly INVALID_HANDLE;
  121465. getHardwareScalingLevel(): number;
  121466. constructor();
  121467. /**
  121468. * Can be used to override the current requestAnimationFrame requester.
  121469. * @hidden
  121470. */
  121471. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121472. /**
  121473. * Override default engine behavior.
  121474. * @param color
  121475. * @param backBuffer
  121476. * @param depth
  121477. * @param stencil
  121478. */
  121479. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121480. /**
  121481. * Gets host document
  121482. * @returns the host document object
  121483. */
  121484. getHostDocument(): Nullable<Document>;
  121485. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121486. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  121487. createVertexBuffer(data: DataArray): NativeDataBuffer;
  121488. recordVertexArrayObject(vertexBuffers: {
  121489. [key: string]: VertexBuffer;
  121490. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121491. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121492. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121493. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121494. /**
  121495. * Draw a list of indexed primitives
  121496. * @param fillMode defines the primitive to use
  121497. * @param indexStart defines the starting index
  121498. * @param indexCount defines the number of index to draw
  121499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121500. */
  121501. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121502. /**
  121503. * Draw a list of unindexed primitives
  121504. * @param fillMode defines the primitive to use
  121505. * @param verticesStart defines the index of first vertex to draw
  121506. * @param verticesCount defines the count of vertices to draw
  121507. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121508. */
  121509. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121510. createPipelineContext(): IPipelineContext;
  121511. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121512. /** @hidden */
  121513. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121514. /** @hidden */
  121515. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121516. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121517. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121518. protected _setProgram(program: WebGLProgram): void;
  121519. _releaseEffect(effect: Effect): void;
  121520. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121521. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  121522. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  121523. bindSamplers(effect: Effect): void;
  121524. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  121525. getRenderWidth(useScreen?: boolean): number;
  121526. getRenderHeight(useScreen?: boolean): number;
  121527. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  121528. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121529. /**
  121530. * Set the z offset to apply to current rendering
  121531. * @param value defines the offset to apply
  121532. */
  121533. setZOffset(value: number): void;
  121534. /**
  121535. * Gets the current value of the zOffset
  121536. * @returns the current zOffset state
  121537. */
  121538. getZOffset(): number;
  121539. /**
  121540. * Enable or disable depth buffering
  121541. * @param enable defines the state to set
  121542. */
  121543. setDepthBuffer(enable: boolean): void;
  121544. /**
  121545. * Gets a boolean indicating if depth writing is enabled
  121546. * @returns the current depth writing state
  121547. */
  121548. getDepthWrite(): boolean;
  121549. /**
  121550. * Enable or disable depth writing
  121551. * @param enable defines the state to set
  121552. */
  121553. setDepthWrite(enable: boolean): void;
  121554. /**
  121555. * Enable or disable color writing
  121556. * @param enable defines the state to set
  121557. */
  121558. setColorWrite(enable: boolean): void;
  121559. /**
  121560. * Gets a boolean indicating if color writing is enabled
  121561. * @returns the current color writing state
  121562. */
  121563. getColorWrite(): boolean;
  121564. /**
  121565. * Sets alpha constants used by some alpha blending modes
  121566. * @param r defines the red component
  121567. * @param g defines the green component
  121568. * @param b defines the blue component
  121569. * @param a defines the alpha component
  121570. */
  121571. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121572. /**
  121573. * Sets the current alpha mode
  121574. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121575. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121576. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121577. */
  121578. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121579. /**
  121580. * Gets the current alpha mode
  121581. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121582. * @returns the current alpha mode
  121583. */
  121584. getAlphaMode(): number;
  121585. setInt(uniform: WebGLUniformLocation, int: number): void;
  121586. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121587. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121588. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121589. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121590. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121591. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121592. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121593. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121594. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121595. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121596. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121597. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121598. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121599. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121600. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121601. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121602. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121603. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121604. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121605. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121606. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121607. wipeCaches(bruteForce?: boolean): void;
  121608. _createTexture(): WebGLTexture;
  121609. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121610. /**
  121611. * Usually called from Texture.ts.
  121612. * Passed information to create a WebGLTexture
  121613. * @param urlArg defines a value which contains one of the following:
  121614. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121615. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121616. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121617. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121618. * @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)
  121619. * @param scene needed for loading to the correct scene
  121620. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121621. * @param onLoad optional callback to be called upon successful completion
  121622. * @param onError optional callback to be called upon failure
  121623. * @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
  121624. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121625. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121626. * @param forcedExtension defines the extension to use to pick the right loader
  121627. * @param mimeType defines an optional mime type
  121628. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121629. */
  121630. 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;
  121631. /**
  121632. * Creates a cube texture
  121633. * @param rootUrl defines the url where the files to load is located
  121634. * @param scene defines the current scene
  121635. * @param files defines the list of files to load (1 per face)
  121636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121637. * @param onLoad defines an optional callback raised when the texture is loaded
  121638. * @param onError defines an optional callback raised if there is an issue to load the texture
  121639. * @param format defines the format of the data
  121640. * @param forcedExtension defines the extension to use to pick the right loader
  121641. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121642. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121643. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121644. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121645. * @returns the cube texture as an InternalTexture
  121646. */
  121647. 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;
  121648. private _getSamplingFilter;
  121649. private static _GetNativeTextureFormat;
  121650. createRenderTargetTexture(size: number | {
  121651. width: number;
  121652. height: number;
  121653. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121654. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121655. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121656. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121657. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121658. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121659. /**
  121660. * Updates a dynamic vertex buffer.
  121661. * @param vertexBuffer the vertex buffer to update
  121662. * @param data the data used to update the vertex buffer
  121663. * @param byteOffset the byte offset of the data (optional)
  121664. * @param byteLength the byte length of the data (optional)
  121665. */
  121666. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121667. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121668. private _updateAnisotropicLevel;
  121669. private _getAddressMode;
  121670. /** @hidden */
  121671. _bindTexture(channel: number, texture: InternalTexture): void;
  121672. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121673. releaseEffects(): void;
  121674. /** @hidden */
  121675. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121676. /** @hidden */
  121677. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121678. /** @hidden */
  121679. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121680. /** @hidden */
  121681. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121682. }
  121683. }
  121684. declare module BABYLON {
  121685. /**
  121686. * Gather the list of clipboard event types as constants.
  121687. */
  121688. export class ClipboardEventTypes {
  121689. /**
  121690. * The clipboard event is fired when a copy command is active (pressed).
  121691. */
  121692. static readonly COPY: number;
  121693. /**
  121694. * The clipboard event is fired when a cut command is active (pressed).
  121695. */
  121696. static readonly CUT: number;
  121697. /**
  121698. * The clipboard event is fired when a paste command is active (pressed).
  121699. */
  121700. static readonly PASTE: number;
  121701. }
  121702. /**
  121703. * This class is used to store clipboard related info for the onClipboardObservable event.
  121704. */
  121705. export class ClipboardInfo {
  121706. /**
  121707. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121708. */
  121709. type: number;
  121710. /**
  121711. * Defines the related dom event
  121712. */
  121713. event: ClipboardEvent;
  121714. /**
  121715. *Creates an instance of ClipboardInfo.
  121716. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121717. * @param event Defines the related dom event
  121718. */
  121719. constructor(
  121720. /**
  121721. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121722. */
  121723. type: number,
  121724. /**
  121725. * Defines the related dom event
  121726. */
  121727. event: ClipboardEvent);
  121728. /**
  121729. * Get the clipboard event's type from the keycode.
  121730. * @param keyCode Defines the keyCode for the current keyboard event.
  121731. * @return {number}
  121732. */
  121733. static GetTypeFromCharacter(keyCode: number): number;
  121734. }
  121735. }
  121736. declare module BABYLON {
  121737. /**
  121738. * Google Daydream controller
  121739. */
  121740. export class DaydreamController extends WebVRController {
  121741. /**
  121742. * Base Url for the controller model.
  121743. */
  121744. static MODEL_BASE_URL: string;
  121745. /**
  121746. * File name for the controller model.
  121747. */
  121748. static MODEL_FILENAME: string;
  121749. /**
  121750. * Gamepad Id prefix used to identify Daydream Controller.
  121751. */
  121752. static readonly GAMEPAD_ID_PREFIX: string;
  121753. /**
  121754. * Creates a new DaydreamController from a gamepad
  121755. * @param vrGamepad the gamepad that the controller should be created from
  121756. */
  121757. constructor(vrGamepad: any);
  121758. /**
  121759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121760. * @param scene scene in which to add meshes
  121761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121762. */
  121763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121764. /**
  121765. * Called once for each button that changed state since the last frame
  121766. * @param buttonIdx Which button index changed
  121767. * @param state New state of the button
  121768. * @param changes Which properties on the state changed since last frame
  121769. */
  121770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121771. }
  121772. }
  121773. declare module BABYLON {
  121774. /**
  121775. * Gear VR Controller
  121776. */
  121777. export class GearVRController extends WebVRController {
  121778. /**
  121779. * Base Url for the controller model.
  121780. */
  121781. static MODEL_BASE_URL: string;
  121782. /**
  121783. * File name for the controller model.
  121784. */
  121785. static MODEL_FILENAME: string;
  121786. /**
  121787. * Gamepad Id prefix used to identify this controller.
  121788. */
  121789. static readonly GAMEPAD_ID_PREFIX: string;
  121790. private readonly _buttonIndexToObservableNameMap;
  121791. /**
  121792. * Creates a new GearVRController from a gamepad
  121793. * @param vrGamepad the gamepad that the controller should be created from
  121794. */
  121795. constructor(vrGamepad: any);
  121796. /**
  121797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121798. * @param scene scene in which to add meshes
  121799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121800. */
  121801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121802. /**
  121803. * Called once for each button that changed state since the last frame
  121804. * @param buttonIdx Which button index changed
  121805. * @param state New state of the button
  121806. * @param changes Which properties on the state changed since last frame
  121807. */
  121808. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121809. }
  121810. }
  121811. declare module BABYLON {
  121812. /**
  121813. * Generic Controller
  121814. */
  121815. export class GenericController extends WebVRController {
  121816. /**
  121817. * Base Url for the controller model.
  121818. */
  121819. static readonly MODEL_BASE_URL: string;
  121820. /**
  121821. * File name for the controller model.
  121822. */
  121823. static readonly MODEL_FILENAME: string;
  121824. /**
  121825. * Creates a new GenericController from a gamepad
  121826. * @param vrGamepad the gamepad that the controller should be created from
  121827. */
  121828. constructor(vrGamepad: any);
  121829. /**
  121830. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121831. * @param scene scene in which to add meshes
  121832. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121833. */
  121834. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121835. /**
  121836. * Called once for each button that changed state since the last frame
  121837. * @param buttonIdx Which button index changed
  121838. * @param state New state of the button
  121839. * @param changes Which properties on the state changed since last frame
  121840. */
  121841. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121842. }
  121843. }
  121844. declare module BABYLON {
  121845. /**
  121846. * Oculus Touch Controller
  121847. */
  121848. export class OculusTouchController extends WebVRController {
  121849. /**
  121850. * Base Url for the controller model.
  121851. */
  121852. static MODEL_BASE_URL: string;
  121853. /**
  121854. * File name for the left controller model.
  121855. */
  121856. static MODEL_LEFT_FILENAME: string;
  121857. /**
  121858. * File name for the right controller model.
  121859. */
  121860. static MODEL_RIGHT_FILENAME: string;
  121861. /**
  121862. * Base Url for the Quest controller model.
  121863. */
  121864. static QUEST_MODEL_BASE_URL: string;
  121865. /**
  121866. * @hidden
  121867. * If the controllers are running on a device that needs the updated Quest controller models
  121868. */
  121869. static _IsQuest: boolean;
  121870. /**
  121871. * Fired when the secondary trigger on this controller is modified
  121872. */
  121873. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121874. /**
  121875. * Fired when the thumb rest on this controller is modified
  121876. */
  121877. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121878. /**
  121879. * Creates a new OculusTouchController from a gamepad
  121880. * @param vrGamepad the gamepad that the controller should be created from
  121881. */
  121882. constructor(vrGamepad: any);
  121883. /**
  121884. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121885. * @param scene scene in which to add meshes
  121886. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121887. */
  121888. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121889. /**
  121890. * Fired when the A button on this controller is modified
  121891. */
  121892. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121893. /**
  121894. * Fired when the B button on this controller is modified
  121895. */
  121896. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121897. /**
  121898. * Fired when the X button on this controller is modified
  121899. */
  121900. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121901. /**
  121902. * Fired when the Y button on this controller is modified
  121903. */
  121904. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121905. /**
  121906. * Called once for each button that changed state since the last frame
  121907. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121908. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121909. * 2) secondary trigger (same)
  121910. * 3) A (right) X (left), touch, pressed = value
  121911. * 4) B / Y
  121912. * 5) thumb rest
  121913. * @param buttonIdx Which button index changed
  121914. * @param state New state of the button
  121915. * @param changes Which properties on the state changed since last frame
  121916. */
  121917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121918. }
  121919. }
  121920. declare module BABYLON {
  121921. /**
  121922. * Vive Controller
  121923. */
  121924. export class ViveController extends WebVRController {
  121925. /**
  121926. * Base Url for the controller model.
  121927. */
  121928. static MODEL_BASE_URL: string;
  121929. /**
  121930. * File name for the controller model.
  121931. */
  121932. static MODEL_FILENAME: string;
  121933. /**
  121934. * Creates a new ViveController from a gamepad
  121935. * @param vrGamepad the gamepad that the controller should be created from
  121936. */
  121937. constructor(vrGamepad: any);
  121938. /**
  121939. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121940. * @param scene scene in which to add meshes
  121941. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121942. */
  121943. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121944. /**
  121945. * Fired when the left button on this controller is modified
  121946. */
  121947. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121948. /**
  121949. * Fired when the right button on this controller is modified
  121950. */
  121951. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121952. /**
  121953. * Fired when the menu button on this controller is modified
  121954. */
  121955. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121956. /**
  121957. * Called once for each button that changed state since the last frame
  121958. * Vive mapping:
  121959. * 0: touchpad
  121960. * 1: trigger
  121961. * 2: left AND right buttons
  121962. * 3: menu button
  121963. * @param buttonIdx Which button index changed
  121964. * @param state New state of the button
  121965. * @param changes Which properties on the state changed since last frame
  121966. */
  121967. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121968. }
  121969. }
  121970. declare module BABYLON {
  121971. /**
  121972. * Defines the WindowsMotionController object that the state of the windows motion controller
  121973. */
  121974. export class WindowsMotionController extends WebVRController {
  121975. /**
  121976. * The base url used to load the left and right controller models
  121977. */
  121978. static MODEL_BASE_URL: string;
  121979. /**
  121980. * The name of the left controller model file
  121981. */
  121982. static MODEL_LEFT_FILENAME: string;
  121983. /**
  121984. * The name of the right controller model file
  121985. */
  121986. static MODEL_RIGHT_FILENAME: string;
  121987. /**
  121988. * The controller name prefix for this controller type
  121989. */
  121990. static readonly GAMEPAD_ID_PREFIX: string;
  121991. /**
  121992. * The controller id pattern for this controller type
  121993. */
  121994. private static readonly GAMEPAD_ID_PATTERN;
  121995. private _loadedMeshInfo;
  121996. protected readonly _mapping: {
  121997. buttons: string[];
  121998. buttonMeshNames: {
  121999. 'trigger': string;
  122000. 'menu': string;
  122001. 'grip': string;
  122002. 'thumbstick': string;
  122003. 'trackpad': string;
  122004. };
  122005. buttonObservableNames: {
  122006. 'trigger': string;
  122007. 'menu': string;
  122008. 'grip': string;
  122009. 'thumbstick': string;
  122010. 'trackpad': string;
  122011. };
  122012. axisMeshNames: string[];
  122013. pointingPoseMeshName: string;
  122014. };
  122015. /**
  122016. * Fired when the trackpad on this controller is clicked
  122017. */
  122018. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122019. /**
  122020. * Fired when the trackpad on this controller is modified
  122021. */
  122022. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122023. /**
  122024. * The current x and y values of this controller's trackpad
  122025. */
  122026. trackpad: StickValues;
  122027. /**
  122028. * Creates a new WindowsMotionController from a gamepad
  122029. * @param vrGamepad the gamepad that the controller should be created from
  122030. */
  122031. constructor(vrGamepad: any);
  122032. /**
  122033. * Fired when the trigger on this controller is modified
  122034. */
  122035. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122036. /**
  122037. * Fired when the menu button on this controller is modified
  122038. */
  122039. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122040. /**
  122041. * Fired when the grip button on this controller is modified
  122042. */
  122043. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122044. /**
  122045. * Fired when the thumbstick button on this controller is modified
  122046. */
  122047. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122048. /**
  122049. * Fired when the touchpad button on this controller is modified
  122050. */
  122051. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122052. /**
  122053. * Fired when the touchpad values on this controller are modified
  122054. */
  122055. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  122056. protected _updateTrackpad(): void;
  122057. /**
  122058. * Called once per frame by the engine.
  122059. */
  122060. update(): void;
  122061. /**
  122062. * Called once for each button that changed state since the last frame
  122063. * @param buttonIdx Which button index changed
  122064. * @param state New state of the button
  122065. * @param changes Which properties on the state changed since last frame
  122066. */
  122067. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122068. /**
  122069. * Moves the buttons on the controller mesh based on their current state
  122070. * @param buttonName the name of the button to move
  122071. * @param buttonValue the value of the button which determines the buttons new position
  122072. */
  122073. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  122074. /**
  122075. * Moves the axis on the controller mesh based on its current state
  122076. * @param axis the index of the axis
  122077. * @param axisValue the value of the axis which determines the meshes new position
  122078. * @hidden
  122079. */
  122080. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  122081. /**
  122082. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122083. * @param scene scene in which to add meshes
  122084. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122085. */
  122086. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  122087. /**
  122088. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  122089. * can be transformed by button presses and axes values, based on this._mapping.
  122090. *
  122091. * @param scene scene in which the meshes exist
  122092. * @param meshes list of meshes that make up the controller model to process
  122093. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  122094. */
  122095. private processModel;
  122096. private createMeshInfo;
  122097. /**
  122098. * Gets the ray of the controller in the direction the controller is pointing
  122099. * @param length the length the resulting ray should be
  122100. * @returns a ray in the direction the controller is pointing
  122101. */
  122102. getForwardRay(length?: number): Ray;
  122103. /**
  122104. * Disposes of the controller
  122105. */
  122106. dispose(): void;
  122107. }
  122108. /**
  122109. * This class represents a new windows motion controller in XR.
  122110. */
  122111. export class XRWindowsMotionController extends WindowsMotionController {
  122112. /**
  122113. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122114. */
  122115. protected readonly _mapping: {
  122116. buttons: string[];
  122117. buttonMeshNames: {
  122118. 'trigger': string;
  122119. 'menu': string;
  122120. 'grip': string;
  122121. 'thumbstick': string;
  122122. 'trackpad': string;
  122123. };
  122124. buttonObservableNames: {
  122125. 'trigger': string;
  122126. 'menu': string;
  122127. 'grip': string;
  122128. 'thumbstick': string;
  122129. 'trackpad': string;
  122130. };
  122131. axisMeshNames: string[];
  122132. pointingPoseMeshName: string;
  122133. };
  122134. /**
  122135. * Construct a new XR-Based windows motion controller
  122136. *
  122137. * @param gamepadInfo the gamepad object from the browser
  122138. */
  122139. constructor(gamepadInfo: any);
  122140. /**
  122141. * holds the thumbstick values (X,Y)
  122142. */
  122143. thumbstickValues: StickValues;
  122144. /**
  122145. * Fired when the thumbstick on this controller is clicked
  122146. */
  122147. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122148. /**
  122149. * Fired when the thumbstick on this controller is modified
  122150. */
  122151. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122152. /**
  122153. * Fired when the touchpad button on this controller is modified
  122154. */
  122155. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122156. /**
  122157. * Fired when the touchpad values on this controller are modified
  122158. */
  122159. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122160. /**
  122161. * Fired when the thumbstick button on this controller is modified
  122162. * here to prevent breaking changes
  122163. */
  122164. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122165. /**
  122166. * updating the thumbstick(!) and not the trackpad.
  122167. * This is named this way due to the difference between WebVR and XR and to avoid
  122168. * changing the parent class.
  122169. */
  122170. protected _updateTrackpad(): void;
  122171. /**
  122172. * Disposes the class with joy
  122173. */
  122174. dispose(): void;
  122175. }
  122176. }
  122177. declare module BABYLON {
  122178. /**
  122179. * Class containing static functions to help procedurally build meshes
  122180. */
  122181. export class PolyhedronBuilder {
  122182. /**
  122183. * Creates a polyhedron mesh
  122184. * * 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
  122185. * * The parameter `size` (positive float, default 1) sets the polygon size
  122186. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122187. * * 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`
  122188. * * 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
  122189. * * 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)`)
  122190. * * 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
  122191. * * 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
  122192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122195. * @param name defines the name of the mesh
  122196. * @param options defines the options used to create the mesh
  122197. * @param scene defines the hosting scene
  122198. * @returns the polyhedron mesh
  122199. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122200. */
  122201. static CreatePolyhedron(name: string, options: {
  122202. type?: number;
  122203. size?: number;
  122204. sizeX?: number;
  122205. sizeY?: number;
  122206. sizeZ?: number;
  122207. custom?: any;
  122208. faceUV?: Vector4[];
  122209. faceColors?: Color4[];
  122210. flat?: boolean;
  122211. updatable?: boolean;
  122212. sideOrientation?: number;
  122213. frontUVs?: Vector4;
  122214. backUVs?: Vector4;
  122215. }, scene?: Nullable<Scene>): Mesh;
  122216. }
  122217. }
  122218. declare module BABYLON {
  122219. /**
  122220. * Gizmo that enables scaling a mesh along 3 axis
  122221. */
  122222. export class ScaleGizmo extends Gizmo {
  122223. /**
  122224. * Internal gizmo used for interactions on the x axis
  122225. */
  122226. xGizmo: AxisScaleGizmo;
  122227. /**
  122228. * Internal gizmo used for interactions on the y axis
  122229. */
  122230. yGizmo: AxisScaleGizmo;
  122231. /**
  122232. * Internal gizmo used for interactions on the z axis
  122233. */
  122234. zGizmo: AxisScaleGizmo;
  122235. /**
  122236. * Internal gizmo used to scale all axis equally
  122237. */
  122238. uniformScaleGizmo: AxisScaleGizmo;
  122239. private _meshAttached;
  122240. private _updateGizmoRotationToMatchAttachedMesh;
  122241. private _snapDistance;
  122242. private _scaleRatio;
  122243. private _uniformScalingMesh;
  122244. private _octahedron;
  122245. private _sensitivity;
  122246. /** Fires an event when any of it's sub gizmos are dragged */
  122247. onDragStartObservable: Observable<unknown>;
  122248. /** Fires an event when any of it's sub gizmos are released from dragging */
  122249. onDragEndObservable: Observable<unknown>;
  122250. get attachedMesh(): Nullable<AbstractMesh>;
  122251. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122252. /**
  122253. * Creates a ScaleGizmo
  122254. * @param gizmoLayer The utility layer the gizmo will be added to
  122255. */
  122256. constructor(gizmoLayer?: UtilityLayerRenderer);
  122257. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122258. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122259. /**
  122260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122261. */
  122262. set snapDistance(value: number);
  122263. get snapDistance(): number;
  122264. /**
  122265. * Ratio for the scale of the gizmo (Default: 1)
  122266. */
  122267. set scaleRatio(value: number);
  122268. get scaleRatio(): number;
  122269. /**
  122270. * Sensitivity factor for dragging (Default: 1)
  122271. */
  122272. set sensitivity(value: number);
  122273. get sensitivity(): number;
  122274. /**
  122275. * Disposes of the gizmo
  122276. */
  122277. dispose(): void;
  122278. }
  122279. }
  122280. declare module BABYLON {
  122281. /**
  122282. * Single axis scale gizmo
  122283. */
  122284. export class AxisScaleGizmo extends Gizmo {
  122285. /**
  122286. * Drag behavior responsible for the gizmos dragging interactions
  122287. */
  122288. dragBehavior: PointerDragBehavior;
  122289. private _pointerObserver;
  122290. /**
  122291. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122292. */
  122293. snapDistance: number;
  122294. /**
  122295. * Event that fires each time the gizmo snaps to a new location.
  122296. * * snapDistance is the the change in distance
  122297. */
  122298. onSnapObservable: Observable<{
  122299. snapDistance: number;
  122300. }>;
  122301. /**
  122302. * If the scaling operation should be done on all axis (default: false)
  122303. */
  122304. uniformScaling: boolean;
  122305. /**
  122306. * Custom sensitivity value for the drag strength
  122307. */
  122308. sensitivity: number;
  122309. private _isEnabled;
  122310. private _parent;
  122311. private _arrow;
  122312. private _coloredMaterial;
  122313. private _hoverMaterial;
  122314. /**
  122315. * Creates an AxisScaleGizmo
  122316. * @param gizmoLayer The utility layer the gizmo will be added to
  122317. * @param dragAxis The axis which the gizmo will be able to scale on
  122318. * @param color The color of the gizmo
  122319. */
  122320. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  122321. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122322. /**
  122323. * If the gizmo is enabled
  122324. */
  122325. set isEnabled(value: boolean);
  122326. get isEnabled(): boolean;
  122327. /**
  122328. * Disposes of the gizmo
  122329. */
  122330. dispose(): void;
  122331. /**
  122332. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122333. * @param mesh The mesh to replace the default mesh of the gizmo
  122334. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  122335. */
  122336. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  122337. }
  122338. }
  122339. declare module BABYLON {
  122340. /**
  122341. * Bounding box gizmo
  122342. */
  122343. export class BoundingBoxGizmo extends Gizmo {
  122344. private _lineBoundingBox;
  122345. private _rotateSpheresParent;
  122346. private _scaleBoxesParent;
  122347. private _boundingDimensions;
  122348. private _renderObserver;
  122349. private _pointerObserver;
  122350. private _scaleDragSpeed;
  122351. private _tmpQuaternion;
  122352. private _tmpVector;
  122353. private _tmpRotationMatrix;
  122354. /**
  122355. * 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)
  122356. */
  122357. ignoreChildren: boolean;
  122358. /**
  122359. * 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)
  122360. */
  122361. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  122362. /**
  122363. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  122364. */
  122365. rotationSphereSize: number;
  122366. /**
  122367. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  122368. */
  122369. scaleBoxSize: number;
  122370. /**
  122371. * 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)
  122372. */
  122373. fixedDragMeshScreenSize: boolean;
  122374. /**
  122375. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  122376. */
  122377. fixedDragMeshScreenSizeDistanceFactor: number;
  122378. /**
  122379. * Fired when a rotation sphere or scale box is dragged
  122380. */
  122381. onDragStartObservable: Observable<{}>;
  122382. /**
  122383. * Fired when a scale box is dragged
  122384. */
  122385. onScaleBoxDragObservable: Observable<{}>;
  122386. /**
  122387. * Fired when a scale box drag is ended
  122388. */
  122389. onScaleBoxDragEndObservable: Observable<{}>;
  122390. /**
  122391. * Fired when a rotation sphere is dragged
  122392. */
  122393. onRotationSphereDragObservable: Observable<{}>;
  122394. /**
  122395. * Fired when a rotation sphere drag is ended
  122396. */
  122397. onRotationSphereDragEndObservable: Observable<{}>;
  122398. /**
  122399. * 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)
  122400. */
  122401. scalePivot: Nullable<Vector3>;
  122402. /**
  122403. * Mesh used as a pivot to rotate the attached mesh
  122404. */
  122405. private _anchorMesh;
  122406. private _existingMeshScale;
  122407. private _dragMesh;
  122408. private pointerDragBehavior;
  122409. private coloredMaterial;
  122410. private hoverColoredMaterial;
  122411. /**
  122412. * Sets the color of the bounding box gizmo
  122413. * @param color the color to set
  122414. */
  122415. setColor(color: Color3): void;
  122416. /**
  122417. * Creates an BoundingBoxGizmo
  122418. * @param gizmoLayer The utility layer the gizmo will be added to
  122419. * @param color The color of the gizmo
  122420. */
  122421. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  122422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122423. private _selectNode;
  122424. /**
  122425. * Updates the bounding box information for the Gizmo
  122426. */
  122427. updateBoundingBox(): void;
  122428. private _updateRotationSpheres;
  122429. private _updateScaleBoxes;
  122430. /**
  122431. * Enables rotation on the specified axis and disables rotation on the others
  122432. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  122433. */
  122434. setEnabledRotationAxis(axis: string): void;
  122435. /**
  122436. * Enables/disables scaling
  122437. * @param enable if scaling should be enabled
  122438. */
  122439. setEnabledScaling(enable: boolean): void;
  122440. private _updateDummy;
  122441. /**
  122442. * Enables a pointer drag behavior on the bounding box of the gizmo
  122443. */
  122444. enableDragBehavior(): void;
  122445. /**
  122446. * Disposes of the gizmo
  122447. */
  122448. dispose(): void;
  122449. /**
  122450. * 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)
  122451. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  122452. * @returns the bounding box mesh with the passed in mesh as a child
  122453. */
  122454. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  122455. /**
  122456. * CustomMeshes are not supported by this gizmo
  122457. * @param mesh The mesh to replace the default mesh of the gizmo
  122458. */
  122459. setCustomMesh(mesh: Mesh): void;
  122460. }
  122461. }
  122462. declare module BABYLON {
  122463. /**
  122464. * Single plane rotation gizmo
  122465. */
  122466. export class PlaneRotationGizmo extends Gizmo {
  122467. /**
  122468. * Drag behavior responsible for the gizmos dragging interactions
  122469. */
  122470. dragBehavior: PointerDragBehavior;
  122471. private _pointerObserver;
  122472. /**
  122473. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  122474. */
  122475. snapDistance: number;
  122476. /**
  122477. * Event that fires each time the gizmo snaps to a new location.
  122478. * * snapDistance is the the change in distance
  122479. */
  122480. onSnapObservable: Observable<{
  122481. snapDistance: number;
  122482. }>;
  122483. private _isEnabled;
  122484. private _parent;
  122485. /**
  122486. * Creates a PlaneRotationGizmo
  122487. * @param gizmoLayer The utility layer the gizmo will be added to
  122488. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  122489. * @param color The color of the gizmo
  122490. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122491. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122492. */
  122493. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  122494. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122495. /**
  122496. * If the gizmo is enabled
  122497. */
  122498. set isEnabled(value: boolean);
  122499. get isEnabled(): boolean;
  122500. /**
  122501. * Disposes of the gizmo
  122502. */
  122503. dispose(): void;
  122504. }
  122505. }
  122506. declare module BABYLON {
  122507. /**
  122508. * Gizmo that enables rotating a mesh along 3 axis
  122509. */
  122510. export class RotationGizmo extends Gizmo {
  122511. /**
  122512. * Internal gizmo used for interactions on the x axis
  122513. */
  122514. xGizmo: PlaneRotationGizmo;
  122515. /**
  122516. * Internal gizmo used for interactions on the y axis
  122517. */
  122518. yGizmo: PlaneRotationGizmo;
  122519. /**
  122520. * Internal gizmo used for interactions on the z axis
  122521. */
  122522. zGizmo: PlaneRotationGizmo;
  122523. /** Fires an event when any of it's sub gizmos are dragged */
  122524. onDragStartObservable: Observable<unknown>;
  122525. /** Fires an event when any of it's sub gizmos are released from dragging */
  122526. onDragEndObservable: Observable<unknown>;
  122527. private _meshAttached;
  122528. get attachedMesh(): Nullable<AbstractMesh>;
  122529. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122530. /**
  122531. * Creates a RotationGizmo
  122532. * @param gizmoLayer The utility layer the gizmo will be added to
  122533. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122534. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122535. */
  122536. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  122537. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122538. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122539. /**
  122540. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122541. */
  122542. set snapDistance(value: number);
  122543. get snapDistance(): number;
  122544. /**
  122545. * Ratio for the scale of the gizmo (Default: 1)
  122546. */
  122547. set scaleRatio(value: number);
  122548. get scaleRatio(): number;
  122549. /**
  122550. * Disposes of the gizmo
  122551. */
  122552. dispose(): void;
  122553. /**
  122554. * CustomMeshes are not supported by this gizmo
  122555. * @param mesh The mesh to replace the default mesh of the gizmo
  122556. */
  122557. setCustomMesh(mesh: Mesh): void;
  122558. }
  122559. }
  122560. declare module BABYLON {
  122561. /**
  122562. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  122563. */
  122564. export class GizmoManager implements IDisposable {
  122565. private scene;
  122566. /**
  122567. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122568. */
  122569. gizmos: {
  122570. positionGizmo: Nullable<PositionGizmo>;
  122571. rotationGizmo: Nullable<RotationGizmo>;
  122572. scaleGizmo: Nullable<ScaleGizmo>;
  122573. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122574. };
  122575. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122576. clearGizmoOnEmptyPointerEvent: boolean;
  122577. /** Fires an event when the manager is attached to a mesh */
  122578. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122579. private _gizmosEnabled;
  122580. private _pointerObserver;
  122581. private _attachedMesh;
  122582. private _boundingBoxColor;
  122583. private _defaultUtilityLayer;
  122584. private _defaultKeepDepthUtilityLayer;
  122585. /**
  122586. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122587. */
  122588. boundingBoxDragBehavior: SixDofDragBehavior;
  122589. /**
  122590. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122591. */
  122592. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122593. /**
  122594. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122595. */
  122596. usePointerToAttachGizmos: boolean;
  122597. /**
  122598. * Utility layer that the bounding box gizmo belongs to
  122599. */
  122600. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122601. /**
  122602. * Utility layer that all gizmos besides bounding box belong to
  122603. */
  122604. get utilityLayer(): UtilityLayerRenderer;
  122605. /**
  122606. * Instatiates a gizmo manager
  122607. * @param scene the scene to overlay the gizmos on top of
  122608. */
  122609. constructor(scene: Scene);
  122610. /**
  122611. * Attaches a set of gizmos to the specified mesh
  122612. * @param mesh The mesh the gizmo's should be attached to
  122613. */
  122614. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122615. /**
  122616. * If the position gizmo is enabled
  122617. */
  122618. set positionGizmoEnabled(value: boolean);
  122619. get positionGizmoEnabled(): boolean;
  122620. /**
  122621. * If the rotation gizmo is enabled
  122622. */
  122623. set rotationGizmoEnabled(value: boolean);
  122624. get rotationGizmoEnabled(): boolean;
  122625. /**
  122626. * If the scale gizmo is enabled
  122627. */
  122628. set scaleGizmoEnabled(value: boolean);
  122629. get scaleGizmoEnabled(): boolean;
  122630. /**
  122631. * If the boundingBox gizmo is enabled
  122632. */
  122633. set boundingBoxGizmoEnabled(value: boolean);
  122634. get boundingBoxGizmoEnabled(): boolean;
  122635. /**
  122636. * Disposes of the gizmo manager
  122637. */
  122638. dispose(): void;
  122639. }
  122640. }
  122641. declare module BABYLON {
  122642. /**
  122643. * A directional light is defined by a direction (what a surprise!).
  122644. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122645. * 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.
  122646. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122647. */
  122648. export class DirectionalLight extends ShadowLight {
  122649. private _shadowFrustumSize;
  122650. /**
  122651. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122652. */
  122653. get shadowFrustumSize(): number;
  122654. /**
  122655. * Specifies a fix frustum size for the shadow generation.
  122656. */
  122657. set shadowFrustumSize(value: number);
  122658. private _shadowOrthoScale;
  122659. /**
  122660. * Gets the shadow projection scale against the optimal computed one.
  122661. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122662. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122663. */
  122664. get shadowOrthoScale(): number;
  122665. /**
  122666. * Sets the shadow projection scale against the optimal computed one.
  122667. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122668. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122669. */
  122670. set shadowOrthoScale(value: number);
  122671. /**
  122672. * Automatically compute the projection matrix to best fit (including all the casters)
  122673. * on each frame.
  122674. */
  122675. autoUpdateExtends: boolean;
  122676. /**
  122677. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122678. * on each frame. autoUpdateExtends must be set to true for this to work
  122679. */
  122680. autoCalcShadowZBounds: boolean;
  122681. private _orthoLeft;
  122682. private _orthoRight;
  122683. private _orthoTop;
  122684. private _orthoBottom;
  122685. /**
  122686. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122687. * The directional light is emitted from everywhere in the given direction.
  122688. * It can cast shadows.
  122689. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122690. * @param name The friendly name of the light
  122691. * @param direction The direction of the light
  122692. * @param scene The scene the light belongs to
  122693. */
  122694. constructor(name: string, direction: Vector3, scene: Scene);
  122695. /**
  122696. * Returns the string "DirectionalLight".
  122697. * @return The class name
  122698. */
  122699. getClassName(): string;
  122700. /**
  122701. * Returns the integer 1.
  122702. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122703. */
  122704. getTypeID(): number;
  122705. /**
  122706. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122707. * Returns the DirectionalLight Shadow projection matrix.
  122708. */
  122709. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122710. /**
  122711. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122712. * Returns the DirectionalLight Shadow projection matrix.
  122713. */
  122714. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122715. /**
  122716. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122717. * Returns the DirectionalLight Shadow projection matrix.
  122718. */
  122719. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122720. protected _buildUniformLayout(): void;
  122721. /**
  122722. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122723. * @param effect The effect to update
  122724. * @param lightIndex The index of the light in the effect to update
  122725. * @returns The directional light
  122726. */
  122727. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122728. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122729. /**
  122730. * Gets the minZ used for shadow according to both the scene and the light.
  122731. *
  122732. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122733. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122734. * @param activeCamera The camera we are returning the min for
  122735. * @returns the depth min z
  122736. */
  122737. getDepthMinZ(activeCamera: Camera): number;
  122738. /**
  122739. * Gets the maxZ used for shadow according to both the scene and the light.
  122740. *
  122741. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122742. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122743. * @param activeCamera The camera we are returning the max for
  122744. * @returns the depth max z
  122745. */
  122746. getDepthMaxZ(activeCamera: Camera): number;
  122747. /**
  122748. * Prepares the list of defines specific to the light type.
  122749. * @param defines the list of defines
  122750. * @param lightIndex defines the index of the light for the effect
  122751. */
  122752. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122753. }
  122754. }
  122755. declare module BABYLON {
  122756. /**
  122757. * Class containing static functions to help procedurally build meshes
  122758. */
  122759. export class HemisphereBuilder {
  122760. /**
  122761. * Creates a hemisphere mesh
  122762. * @param name defines the name of the mesh
  122763. * @param options defines the options used to create the mesh
  122764. * @param scene defines the hosting scene
  122765. * @returns the hemisphere mesh
  122766. */
  122767. static CreateHemisphere(name: string, options: {
  122768. segments?: number;
  122769. diameter?: number;
  122770. sideOrientation?: number;
  122771. }, scene: any): Mesh;
  122772. }
  122773. }
  122774. declare module BABYLON {
  122775. /**
  122776. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122777. * These values define a cone of light starting from the position, emitting toward the direction.
  122778. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122779. * and the exponent defines the speed of the decay of the light with distance (reach).
  122780. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122781. */
  122782. export class SpotLight extends ShadowLight {
  122783. private _angle;
  122784. private _innerAngle;
  122785. private _cosHalfAngle;
  122786. private _lightAngleScale;
  122787. private _lightAngleOffset;
  122788. /**
  122789. * Gets the cone angle of the spot light in Radians.
  122790. */
  122791. get angle(): number;
  122792. /**
  122793. * Sets the cone angle of the spot light in Radians.
  122794. */
  122795. set angle(value: number);
  122796. /**
  122797. * Only used in gltf falloff mode, this defines the angle where
  122798. * the directional falloff will start before cutting at angle which could be seen
  122799. * as outer angle.
  122800. */
  122801. get innerAngle(): number;
  122802. /**
  122803. * Only used in gltf falloff mode, this defines the angle where
  122804. * the directional falloff will start before cutting at angle which could be seen
  122805. * as outer angle.
  122806. */
  122807. set innerAngle(value: number);
  122808. private _shadowAngleScale;
  122809. /**
  122810. * Allows scaling the angle of the light for shadow generation only.
  122811. */
  122812. get shadowAngleScale(): number;
  122813. /**
  122814. * Allows scaling the angle of the light for shadow generation only.
  122815. */
  122816. set shadowAngleScale(value: number);
  122817. /**
  122818. * The light decay speed with the distance from the emission spot.
  122819. */
  122820. exponent: number;
  122821. private _projectionTextureMatrix;
  122822. /**
  122823. * Allows reading the projecton texture
  122824. */
  122825. get projectionTextureMatrix(): Matrix;
  122826. protected _projectionTextureLightNear: number;
  122827. /**
  122828. * Gets the near clip of the Spotlight for texture projection.
  122829. */
  122830. get projectionTextureLightNear(): number;
  122831. /**
  122832. * Sets the near clip of the Spotlight for texture projection.
  122833. */
  122834. set projectionTextureLightNear(value: number);
  122835. protected _projectionTextureLightFar: number;
  122836. /**
  122837. * Gets the far clip of the Spotlight for texture projection.
  122838. */
  122839. get projectionTextureLightFar(): number;
  122840. /**
  122841. * Sets the far clip of the Spotlight for texture projection.
  122842. */
  122843. set projectionTextureLightFar(value: number);
  122844. protected _projectionTextureUpDirection: Vector3;
  122845. /**
  122846. * Gets the Up vector of the Spotlight for texture projection.
  122847. */
  122848. get projectionTextureUpDirection(): Vector3;
  122849. /**
  122850. * Sets the Up vector of the Spotlight for texture projection.
  122851. */
  122852. set projectionTextureUpDirection(value: Vector3);
  122853. private _projectionTexture;
  122854. /**
  122855. * Gets the projection texture of the light.
  122856. */
  122857. get projectionTexture(): Nullable<BaseTexture>;
  122858. /**
  122859. * Sets the projection texture of the light.
  122860. */
  122861. set projectionTexture(value: Nullable<BaseTexture>);
  122862. private _projectionTextureViewLightDirty;
  122863. private _projectionTextureProjectionLightDirty;
  122864. private _projectionTextureDirty;
  122865. private _projectionTextureViewTargetVector;
  122866. private _projectionTextureViewLightMatrix;
  122867. private _projectionTextureProjectionLightMatrix;
  122868. private _projectionTextureScalingMatrix;
  122869. /**
  122870. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122871. * It can cast shadows.
  122872. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122873. * @param name The light friendly name
  122874. * @param position The position of the spot light in the scene
  122875. * @param direction The direction of the light in the scene
  122876. * @param angle The cone angle of the light in Radians
  122877. * @param exponent The light decay speed with the distance from the emission spot
  122878. * @param scene The scene the lights belongs to
  122879. */
  122880. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122881. /**
  122882. * Returns the string "SpotLight".
  122883. * @returns the class name
  122884. */
  122885. getClassName(): string;
  122886. /**
  122887. * Returns the integer 2.
  122888. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122889. */
  122890. getTypeID(): number;
  122891. /**
  122892. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122893. */
  122894. protected _setDirection(value: Vector3): void;
  122895. /**
  122896. * Overrides the position setter to recompute the projection texture view light Matrix.
  122897. */
  122898. protected _setPosition(value: Vector3): void;
  122899. /**
  122900. * 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.
  122901. * Returns the SpotLight.
  122902. */
  122903. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122904. protected _computeProjectionTextureViewLightMatrix(): void;
  122905. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122906. /**
  122907. * Main function for light texture projection matrix computing.
  122908. */
  122909. protected _computeProjectionTextureMatrix(): void;
  122910. protected _buildUniformLayout(): void;
  122911. private _computeAngleValues;
  122912. /**
  122913. * Sets the passed Effect "effect" with the Light textures.
  122914. * @param effect The effect to update
  122915. * @param lightIndex The index of the light in the effect to update
  122916. * @returns The light
  122917. */
  122918. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122919. /**
  122920. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122921. * @param effect The effect to update
  122922. * @param lightIndex The index of the light in the effect to update
  122923. * @returns The spot light
  122924. */
  122925. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122926. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122927. /**
  122928. * Disposes the light and the associated resources.
  122929. */
  122930. dispose(): void;
  122931. /**
  122932. * Prepares the list of defines specific to the light type.
  122933. * @param defines the list of defines
  122934. * @param lightIndex defines the index of the light for the effect
  122935. */
  122936. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122937. }
  122938. }
  122939. declare module BABYLON {
  122940. /**
  122941. * Gizmo that enables viewing a light
  122942. */
  122943. export class LightGizmo extends Gizmo {
  122944. private _lightMesh;
  122945. private _material;
  122946. private _cachedPosition;
  122947. private _cachedForward;
  122948. private _attachedMeshParent;
  122949. /**
  122950. * Creates a LightGizmo
  122951. * @param gizmoLayer The utility layer the gizmo will be added to
  122952. */
  122953. constructor(gizmoLayer?: UtilityLayerRenderer);
  122954. private _light;
  122955. /**
  122956. * The light that the gizmo is attached to
  122957. */
  122958. set light(light: Nullable<Light>);
  122959. get light(): Nullable<Light>;
  122960. /**
  122961. * Gets the material used to render the light gizmo
  122962. */
  122963. get material(): StandardMaterial;
  122964. /**
  122965. * @hidden
  122966. * Updates the gizmo to match the attached mesh's position/rotation
  122967. */
  122968. protected _update(): void;
  122969. private static _Scale;
  122970. /**
  122971. * Creates the lines for a light mesh
  122972. */
  122973. private static _CreateLightLines;
  122974. /**
  122975. * Disposes of the light gizmo
  122976. */
  122977. dispose(): void;
  122978. private static _CreateHemisphericLightMesh;
  122979. private static _CreatePointLightMesh;
  122980. private static _CreateSpotLightMesh;
  122981. private static _CreateDirectionalLightMesh;
  122982. }
  122983. }
  122984. declare module BABYLON {
  122985. /** @hidden */
  122986. export var backgroundFragmentDeclaration: {
  122987. name: string;
  122988. shader: string;
  122989. };
  122990. }
  122991. declare module BABYLON {
  122992. /** @hidden */
  122993. export var backgroundUboDeclaration: {
  122994. name: string;
  122995. shader: string;
  122996. };
  122997. }
  122998. declare module BABYLON {
  122999. /** @hidden */
  123000. export var backgroundPixelShader: {
  123001. name: string;
  123002. shader: string;
  123003. };
  123004. }
  123005. declare module BABYLON {
  123006. /** @hidden */
  123007. export var backgroundVertexDeclaration: {
  123008. name: string;
  123009. shader: string;
  123010. };
  123011. }
  123012. declare module BABYLON {
  123013. /** @hidden */
  123014. export var backgroundVertexShader: {
  123015. name: string;
  123016. shader: string;
  123017. };
  123018. }
  123019. declare module BABYLON {
  123020. /**
  123021. * Background material used to create an efficient environement around your scene.
  123022. */
  123023. export class BackgroundMaterial extends PushMaterial {
  123024. /**
  123025. * Standard reflectance value at parallel view angle.
  123026. */
  123027. static StandardReflectance0: number;
  123028. /**
  123029. * Standard reflectance value at grazing angle.
  123030. */
  123031. static StandardReflectance90: number;
  123032. protected _primaryColor: Color3;
  123033. /**
  123034. * Key light Color (multiply against the environement texture)
  123035. */
  123036. primaryColor: Color3;
  123037. protected __perceptualColor: Nullable<Color3>;
  123038. /**
  123039. * Experimental Internal Use Only.
  123040. *
  123041. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  123042. * This acts as a helper to set the primary color to a more "human friendly" value.
  123043. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  123044. * output color as close as possible from the chosen value.
  123045. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  123046. * part of lighting setup.)
  123047. */
  123048. get _perceptualColor(): Nullable<Color3>;
  123049. set _perceptualColor(value: Nullable<Color3>);
  123050. protected _primaryColorShadowLevel: float;
  123051. /**
  123052. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  123053. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  123054. */
  123055. get primaryColorShadowLevel(): float;
  123056. set primaryColorShadowLevel(value: float);
  123057. protected _primaryColorHighlightLevel: float;
  123058. /**
  123059. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  123060. * The primary color is used at the level chosen to define what the white area would look.
  123061. */
  123062. get primaryColorHighlightLevel(): float;
  123063. set primaryColorHighlightLevel(value: float);
  123064. protected _reflectionTexture: Nullable<BaseTexture>;
  123065. /**
  123066. * Reflection Texture used in the material.
  123067. * Should be author in a specific way for the best result (refer to the documentation).
  123068. */
  123069. reflectionTexture: Nullable<BaseTexture>;
  123070. protected _reflectionBlur: float;
  123071. /**
  123072. * Reflection Texture level of blur.
  123073. *
  123074. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  123075. * texture twice.
  123076. */
  123077. reflectionBlur: float;
  123078. protected _diffuseTexture: Nullable<BaseTexture>;
  123079. /**
  123080. * Diffuse Texture used in the material.
  123081. * Should be author in a specific way for the best result (refer to the documentation).
  123082. */
  123083. diffuseTexture: Nullable<BaseTexture>;
  123084. protected _shadowLights: Nullable<IShadowLight[]>;
  123085. /**
  123086. * Specify the list of lights casting shadow on the material.
  123087. * All scene shadow lights will be included if null.
  123088. */
  123089. shadowLights: Nullable<IShadowLight[]>;
  123090. protected _shadowLevel: float;
  123091. /**
  123092. * Helps adjusting the shadow to a softer level if required.
  123093. * 0 means black shadows and 1 means no shadows.
  123094. */
  123095. shadowLevel: float;
  123096. protected _sceneCenter: Vector3;
  123097. /**
  123098. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  123099. * It is usually zero but might be interesting to modify according to your setup.
  123100. */
  123101. sceneCenter: Vector3;
  123102. protected _opacityFresnel: boolean;
  123103. /**
  123104. * This helps specifying that the material is falling off to the sky box at grazing angle.
  123105. * This helps ensuring a nice transition when the camera goes under the ground.
  123106. */
  123107. opacityFresnel: boolean;
  123108. protected _reflectionFresnel: boolean;
  123109. /**
  123110. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123111. * This helps adding a mirror texture on the ground.
  123112. */
  123113. reflectionFresnel: boolean;
  123114. protected _reflectionFalloffDistance: number;
  123115. /**
  123116. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123117. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123118. */
  123119. reflectionFalloffDistance: number;
  123120. protected _reflectionAmount: number;
  123121. /**
  123122. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123123. */
  123124. reflectionAmount: number;
  123125. protected _reflectionReflectance0: number;
  123126. /**
  123127. * This specifies the weight of the reflection at grazing angle.
  123128. */
  123129. reflectionReflectance0: number;
  123130. protected _reflectionReflectance90: number;
  123131. /**
  123132. * This specifies the weight of the reflection at a perpendicular point of view.
  123133. */
  123134. reflectionReflectance90: number;
  123135. /**
  123136. * Sets the reflection reflectance fresnel values according to the default standard
  123137. * empirically know to work well :-)
  123138. */
  123139. set reflectionStandardFresnelWeight(value: number);
  123140. protected _useRGBColor: boolean;
  123141. /**
  123142. * Helps to directly use the maps channels instead of their level.
  123143. */
  123144. useRGBColor: boolean;
  123145. protected _enableNoise: boolean;
  123146. /**
  123147. * This helps reducing the banding effect that could occur on the background.
  123148. */
  123149. enableNoise: boolean;
  123150. /**
  123151. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123152. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123153. * Recommended to be keep at 1.0 except for special cases.
  123154. */
  123155. get fovMultiplier(): number;
  123156. set fovMultiplier(value: number);
  123157. private _fovMultiplier;
  123158. /**
  123159. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123160. */
  123161. useEquirectangularFOV: boolean;
  123162. private _maxSimultaneousLights;
  123163. /**
  123164. * Number of Simultaneous lights allowed on the material.
  123165. */
  123166. maxSimultaneousLights: int;
  123167. /**
  123168. * Default configuration related to image processing available in the Background Material.
  123169. */
  123170. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123171. /**
  123172. * Keep track of the image processing observer to allow dispose and replace.
  123173. */
  123174. private _imageProcessingObserver;
  123175. /**
  123176. * Attaches a new image processing configuration to the PBR Material.
  123177. * @param configuration (if null the scene configuration will be use)
  123178. */
  123179. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123180. /**
  123181. * Gets the image processing configuration used either in this material.
  123182. */
  123183. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  123184. /**
  123185. * Sets the Default image processing configuration used either in the this material.
  123186. *
  123187. * If sets to null, the scene one is in use.
  123188. */
  123189. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  123190. /**
  123191. * Gets wether the color curves effect is enabled.
  123192. */
  123193. get cameraColorCurvesEnabled(): boolean;
  123194. /**
  123195. * Sets wether the color curves effect is enabled.
  123196. */
  123197. set cameraColorCurvesEnabled(value: boolean);
  123198. /**
  123199. * Gets wether the color grading effect is enabled.
  123200. */
  123201. get cameraColorGradingEnabled(): boolean;
  123202. /**
  123203. * Gets wether the color grading effect is enabled.
  123204. */
  123205. set cameraColorGradingEnabled(value: boolean);
  123206. /**
  123207. * Gets wether tonemapping is enabled or not.
  123208. */
  123209. get cameraToneMappingEnabled(): boolean;
  123210. /**
  123211. * Sets wether tonemapping is enabled or not
  123212. */
  123213. set cameraToneMappingEnabled(value: boolean);
  123214. /**
  123215. * The camera exposure used on this material.
  123216. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  123217. * This corresponds to a photographic exposure.
  123218. */
  123219. get cameraExposure(): float;
  123220. /**
  123221. * The camera exposure used on this material.
  123222. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  123223. * This corresponds to a photographic exposure.
  123224. */
  123225. set cameraExposure(value: float);
  123226. /**
  123227. * Gets The camera contrast used on this material.
  123228. */
  123229. get cameraContrast(): float;
  123230. /**
  123231. * Sets The camera contrast used on this material.
  123232. */
  123233. set cameraContrast(value: float);
  123234. /**
  123235. * Gets the Color Grading 2D Lookup Texture.
  123236. */
  123237. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  123238. /**
  123239. * Sets the Color Grading 2D Lookup Texture.
  123240. */
  123241. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  123242. /**
  123243. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  123244. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  123245. * 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;
  123246. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  123247. */
  123248. get cameraColorCurves(): Nullable<ColorCurves>;
  123249. /**
  123250. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  123251. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  123252. * 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;
  123253. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  123254. */
  123255. set cameraColorCurves(value: Nullable<ColorCurves>);
  123256. /**
  123257. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  123258. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  123259. */
  123260. switchToBGR: boolean;
  123261. private _renderTargets;
  123262. private _reflectionControls;
  123263. private _white;
  123264. private _primaryShadowColor;
  123265. private _primaryHighlightColor;
  123266. /**
  123267. * Instantiates a Background Material in the given scene
  123268. * @param name The friendly name of the material
  123269. * @param scene The scene to add the material to
  123270. */
  123271. constructor(name: string, scene: Scene);
  123272. /**
  123273. * Gets a boolean indicating that current material needs to register RTT
  123274. */
  123275. get hasRenderTargetTextures(): boolean;
  123276. /**
  123277. * The entire material has been created in order to prevent overdraw.
  123278. * @returns false
  123279. */
  123280. needAlphaTesting(): boolean;
  123281. /**
  123282. * The entire material has been created in order to prevent overdraw.
  123283. * @returns true if blending is enable
  123284. */
  123285. needAlphaBlending(): boolean;
  123286. /**
  123287. * Checks wether the material is ready to be rendered for a given mesh.
  123288. * @param mesh The mesh to render
  123289. * @param subMesh The submesh to check against
  123290. * @param useInstances Specify wether or not the material is used with instances
  123291. * @returns true if all the dependencies are ready (Textures, Effects...)
  123292. */
  123293. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123294. /**
  123295. * Compute the primary color according to the chosen perceptual color.
  123296. */
  123297. private _computePrimaryColorFromPerceptualColor;
  123298. /**
  123299. * Compute the highlights and shadow colors according to their chosen levels.
  123300. */
  123301. private _computePrimaryColors;
  123302. /**
  123303. * Build the uniform buffer used in the material.
  123304. */
  123305. buildUniformLayout(): void;
  123306. /**
  123307. * Unbind the material.
  123308. */
  123309. unbind(): void;
  123310. /**
  123311. * Bind only the world matrix to the material.
  123312. * @param world The world matrix to bind.
  123313. */
  123314. bindOnlyWorldMatrix(world: Matrix): void;
  123315. /**
  123316. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  123317. * @param world The world matrix to bind.
  123318. * @param subMesh The submesh to bind for.
  123319. */
  123320. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123321. /**
  123322. * Checks to see if a texture is used in the material.
  123323. * @param texture - Base texture to use.
  123324. * @returns - Boolean specifying if a texture is used in the material.
  123325. */
  123326. hasTexture(texture: BaseTexture): boolean;
  123327. /**
  123328. * Dispose the material.
  123329. * @param forceDisposeEffect Force disposal of the associated effect.
  123330. * @param forceDisposeTextures Force disposal of the associated textures.
  123331. */
  123332. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  123333. /**
  123334. * Clones the material.
  123335. * @param name The cloned name.
  123336. * @returns The cloned material.
  123337. */
  123338. clone(name: string): BackgroundMaterial;
  123339. /**
  123340. * Serializes the current material to its JSON representation.
  123341. * @returns The JSON representation.
  123342. */
  123343. serialize(): any;
  123344. /**
  123345. * Gets the class name of the material
  123346. * @returns "BackgroundMaterial"
  123347. */
  123348. getClassName(): string;
  123349. /**
  123350. * Parse a JSON input to create back a background material.
  123351. * @param source The JSON data to parse
  123352. * @param scene The scene to create the parsed material in
  123353. * @param rootUrl The root url of the assets the material depends upon
  123354. * @returns the instantiated BackgroundMaterial.
  123355. */
  123356. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  123357. }
  123358. }
  123359. declare module BABYLON {
  123360. /**
  123361. * Represents the different options available during the creation of
  123362. * a Environment helper.
  123363. *
  123364. * This can control the default ground, skybox and image processing setup of your scene.
  123365. */
  123366. export interface IEnvironmentHelperOptions {
  123367. /**
  123368. * Specifies whether or not to create a ground.
  123369. * True by default.
  123370. */
  123371. createGround: boolean;
  123372. /**
  123373. * Specifies the ground size.
  123374. * 15 by default.
  123375. */
  123376. groundSize: number;
  123377. /**
  123378. * The texture used on the ground for the main color.
  123379. * Comes from the BabylonJS CDN by default.
  123380. *
  123381. * Remarks: Can be either a texture or a url.
  123382. */
  123383. groundTexture: string | BaseTexture;
  123384. /**
  123385. * The color mixed in the ground texture by default.
  123386. * BabylonJS clearColor by default.
  123387. */
  123388. groundColor: Color3;
  123389. /**
  123390. * Specifies the ground opacity.
  123391. * 1 by default.
  123392. */
  123393. groundOpacity: number;
  123394. /**
  123395. * Enables the ground to receive shadows.
  123396. * True by default.
  123397. */
  123398. enableGroundShadow: boolean;
  123399. /**
  123400. * Helps preventing the shadow to be fully black on the ground.
  123401. * 0.5 by default.
  123402. */
  123403. groundShadowLevel: number;
  123404. /**
  123405. * Creates a mirror texture attach to the ground.
  123406. * false by default.
  123407. */
  123408. enableGroundMirror: boolean;
  123409. /**
  123410. * Specifies the ground mirror size ratio.
  123411. * 0.3 by default as the default kernel is 64.
  123412. */
  123413. groundMirrorSizeRatio: number;
  123414. /**
  123415. * Specifies the ground mirror blur kernel size.
  123416. * 64 by default.
  123417. */
  123418. groundMirrorBlurKernel: number;
  123419. /**
  123420. * Specifies the ground mirror visibility amount.
  123421. * 1 by default
  123422. */
  123423. groundMirrorAmount: number;
  123424. /**
  123425. * Specifies the ground mirror reflectance weight.
  123426. * This uses the standard weight of the background material to setup the fresnel effect
  123427. * of the mirror.
  123428. * 1 by default.
  123429. */
  123430. groundMirrorFresnelWeight: number;
  123431. /**
  123432. * Specifies the ground mirror Falloff distance.
  123433. * This can helps reducing the size of the reflection.
  123434. * 0 by Default.
  123435. */
  123436. groundMirrorFallOffDistance: number;
  123437. /**
  123438. * Specifies the ground mirror texture type.
  123439. * Unsigned Int by Default.
  123440. */
  123441. groundMirrorTextureType: number;
  123442. /**
  123443. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  123444. * the shown objects.
  123445. */
  123446. groundYBias: number;
  123447. /**
  123448. * Specifies whether or not to create a skybox.
  123449. * True by default.
  123450. */
  123451. createSkybox: boolean;
  123452. /**
  123453. * Specifies the skybox size.
  123454. * 20 by default.
  123455. */
  123456. skyboxSize: number;
  123457. /**
  123458. * The texture used on the skybox for the main color.
  123459. * Comes from the BabylonJS CDN by default.
  123460. *
  123461. * Remarks: Can be either a texture or a url.
  123462. */
  123463. skyboxTexture: string | BaseTexture;
  123464. /**
  123465. * The color mixed in the skybox texture by default.
  123466. * BabylonJS clearColor by default.
  123467. */
  123468. skyboxColor: Color3;
  123469. /**
  123470. * The background rotation around the Y axis of the scene.
  123471. * This helps aligning the key lights of your scene with the background.
  123472. * 0 by default.
  123473. */
  123474. backgroundYRotation: number;
  123475. /**
  123476. * Compute automatically the size of the elements to best fit with the scene.
  123477. */
  123478. sizeAuto: boolean;
  123479. /**
  123480. * Default position of the rootMesh if autoSize is not true.
  123481. */
  123482. rootPosition: Vector3;
  123483. /**
  123484. * Sets up the image processing in the scene.
  123485. * true by default.
  123486. */
  123487. setupImageProcessing: boolean;
  123488. /**
  123489. * The texture used as your environment texture in the scene.
  123490. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  123491. *
  123492. * Remarks: Can be either a texture or a url.
  123493. */
  123494. environmentTexture: string | BaseTexture;
  123495. /**
  123496. * The value of the exposure to apply to the scene.
  123497. * 0.6 by default if setupImageProcessing is true.
  123498. */
  123499. cameraExposure: number;
  123500. /**
  123501. * The value of the contrast to apply to the scene.
  123502. * 1.6 by default if setupImageProcessing is true.
  123503. */
  123504. cameraContrast: number;
  123505. /**
  123506. * Specifies whether or not tonemapping should be enabled in the scene.
  123507. * true by default if setupImageProcessing is true.
  123508. */
  123509. toneMappingEnabled: boolean;
  123510. }
  123511. /**
  123512. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  123513. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  123514. * It also helps with the default setup of your imageProcessing configuration.
  123515. */
  123516. export class EnvironmentHelper {
  123517. /**
  123518. * Default ground texture URL.
  123519. */
  123520. private static _groundTextureCDNUrl;
  123521. /**
  123522. * Default skybox texture URL.
  123523. */
  123524. private static _skyboxTextureCDNUrl;
  123525. /**
  123526. * Default environment texture URL.
  123527. */
  123528. private static _environmentTextureCDNUrl;
  123529. /**
  123530. * Creates the default options for the helper.
  123531. */
  123532. private static _getDefaultOptions;
  123533. private _rootMesh;
  123534. /**
  123535. * Gets the root mesh created by the helper.
  123536. */
  123537. get rootMesh(): Mesh;
  123538. private _skybox;
  123539. /**
  123540. * Gets the skybox created by the helper.
  123541. */
  123542. get skybox(): Nullable<Mesh>;
  123543. private _skyboxTexture;
  123544. /**
  123545. * Gets the skybox texture created by the helper.
  123546. */
  123547. get skyboxTexture(): Nullable<BaseTexture>;
  123548. private _skyboxMaterial;
  123549. /**
  123550. * Gets the skybox material created by the helper.
  123551. */
  123552. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  123553. private _ground;
  123554. /**
  123555. * Gets the ground mesh created by the helper.
  123556. */
  123557. get ground(): Nullable<Mesh>;
  123558. private _groundTexture;
  123559. /**
  123560. * Gets the ground texture created by the helper.
  123561. */
  123562. get groundTexture(): Nullable<BaseTexture>;
  123563. private _groundMirror;
  123564. /**
  123565. * Gets the ground mirror created by the helper.
  123566. */
  123567. get groundMirror(): Nullable<MirrorTexture>;
  123568. /**
  123569. * Gets the ground mirror render list to helps pushing the meshes
  123570. * you wish in the ground reflection.
  123571. */
  123572. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123573. private _groundMaterial;
  123574. /**
  123575. * Gets the ground material created by the helper.
  123576. */
  123577. get groundMaterial(): Nullable<BackgroundMaterial>;
  123578. /**
  123579. * Stores the creation options.
  123580. */
  123581. private readonly _scene;
  123582. private _options;
  123583. /**
  123584. * This observable will be notified with any error during the creation of the environment,
  123585. * mainly texture creation errors.
  123586. */
  123587. onErrorObservable: Observable<{
  123588. message?: string;
  123589. exception?: any;
  123590. }>;
  123591. /**
  123592. * constructor
  123593. * @param options Defines the options we want to customize the helper
  123594. * @param scene The scene to add the material to
  123595. */
  123596. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123597. /**
  123598. * Updates the background according to the new options
  123599. * @param options
  123600. */
  123601. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123602. /**
  123603. * Sets the primary color of all the available elements.
  123604. * @param color the main color to affect to the ground and the background
  123605. */
  123606. setMainColor(color: Color3): void;
  123607. /**
  123608. * Setup the image processing according to the specified options.
  123609. */
  123610. private _setupImageProcessing;
  123611. /**
  123612. * Setup the environment texture according to the specified options.
  123613. */
  123614. private _setupEnvironmentTexture;
  123615. /**
  123616. * Setup the background according to the specified options.
  123617. */
  123618. private _setupBackground;
  123619. /**
  123620. * Get the scene sizes according to the setup.
  123621. */
  123622. private _getSceneSize;
  123623. /**
  123624. * Setup the ground according to the specified options.
  123625. */
  123626. private _setupGround;
  123627. /**
  123628. * Setup the ground material according to the specified options.
  123629. */
  123630. private _setupGroundMaterial;
  123631. /**
  123632. * Setup the ground diffuse texture according to the specified options.
  123633. */
  123634. private _setupGroundDiffuseTexture;
  123635. /**
  123636. * Setup the ground mirror texture according to the specified options.
  123637. */
  123638. private _setupGroundMirrorTexture;
  123639. /**
  123640. * Setup the ground to receive the mirror texture.
  123641. */
  123642. private _setupMirrorInGroundMaterial;
  123643. /**
  123644. * Setup the skybox according to the specified options.
  123645. */
  123646. private _setupSkybox;
  123647. /**
  123648. * Setup the skybox material according to the specified options.
  123649. */
  123650. private _setupSkyboxMaterial;
  123651. /**
  123652. * Setup the skybox reflection texture according to the specified options.
  123653. */
  123654. private _setupSkyboxReflectionTexture;
  123655. private _errorHandler;
  123656. /**
  123657. * Dispose all the elements created by the Helper.
  123658. */
  123659. dispose(): void;
  123660. }
  123661. }
  123662. declare module BABYLON {
  123663. /**
  123664. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123665. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123666. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123667. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123668. */
  123669. export class PhotoDome extends TransformNode {
  123670. /**
  123671. * Define the image as a Monoscopic panoramic 360 image.
  123672. */
  123673. static readonly MODE_MONOSCOPIC: number;
  123674. /**
  123675. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123676. */
  123677. static readonly MODE_TOPBOTTOM: number;
  123678. /**
  123679. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123680. */
  123681. static readonly MODE_SIDEBYSIDE: number;
  123682. private _useDirectMapping;
  123683. /**
  123684. * The texture being displayed on the sphere
  123685. */
  123686. protected _photoTexture: Texture;
  123687. /**
  123688. * Gets or sets the texture being displayed on the sphere
  123689. */
  123690. get photoTexture(): Texture;
  123691. set photoTexture(value: Texture);
  123692. /**
  123693. * Observable raised when an error occured while loading the 360 image
  123694. */
  123695. onLoadErrorObservable: Observable<string>;
  123696. /**
  123697. * The skybox material
  123698. */
  123699. protected _material: BackgroundMaterial;
  123700. /**
  123701. * The surface used for the skybox
  123702. */
  123703. protected _mesh: Mesh;
  123704. /**
  123705. * Gets the mesh used for the skybox.
  123706. */
  123707. get mesh(): Mesh;
  123708. /**
  123709. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123710. * Also see the options.resolution property.
  123711. */
  123712. get fovMultiplier(): number;
  123713. set fovMultiplier(value: number);
  123714. private _imageMode;
  123715. /**
  123716. * Gets or set the current video mode for the video. It can be:
  123717. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123718. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123719. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123720. */
  123721. get imageMode(): number;
  123722. set imageMode(value: number);
  123723. /**
  123724. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123725. * @param name Element's name, child elements will append suffixes for their own names.
  123726. * @param urlsOfPhoto defines the url of the photo to display
  123727. * @param options defines an object containing optional or exposed sub element properties
  123728. * @param onError defines a callback called when an error occured while loading the texture
  123729. */
  123730. constructor(name: string, urlOfPhoto: string, options: {
  123731. resolution?: number;
  123732. size?: number;
  123733. useDirectMapping?: boolean;
  123734. faceForward?: boolean;
  123735. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123736. private _onBeforeCameraRenderObserver;
  123737. private _changeImageMode;
  123738. /**
  123739. * Releases resources associated with this node.
  123740. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123741. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123742. */
  123743. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123744. }
  123745. }
  123746. declare module BABYLON {
  123747. /**
  123748. * Class used to host RGBD texture specific utilities
  123749. */
  123750. export class RGBDTextureTools {
  123751. /**
  123752. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123753. * @param texture the texture to expand.
  123754. */
  123755. static ExpandRGBDTexture(texture: Texture): void;
  123756. }
  123757. }
  123758. declare module BABYLON {
  123759. /**
  123760. * Class used to host texture specific utilities
  123761. */
  123762. export class BRDFTextureTools {
  123763. /**
  123764. * Prevents texture cache collision
  123765. */
  123766. private static _instanceNumber;
  123767. /**
  123768. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123769. * @param scene defines the hosting scene
  123770. * @returns the environment BRDF texture
  123771. */
  123772. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123773. private static _environmentBRDFBase64Texture;
  123774. }
  123775. }
  123776. declare module BABYLON {
  123777. /**
  123778. * @hidden
  123779. */
  123780. export interface IMaterialClearCoatDefines {
  123781. CLEARCOAT: boolean;
  123782. CLEARCOAT_DEFAULTIOR: boolean;
  123783. CLEARCOAT_TEXTURE: boolean;
  123784. CLEARCOAT_TEXTUREDIRECTUV: number;
  123785. CLEARCOAT_BUMP: boolean;
  123786. CLEARCOAT_BUMPDIRECTUV: number;
  123787. CLEARCOAT_TINT: boolean;
  123788. CLEARCOAT_TINT_TEXTURE: boolean;
  123789. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123790. /** @hidden */
  123791. _areTexturesDirty: boolean;
  123792. }
  123793. /**
  123794. * Define the code related to the clear coat parameters of the pbr material.
  123795. */
  123796. export class PBRClearCoatConfiguration {
  123797. /**
  123798. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123799. * The default fits with a polyurethane material.
  123800. */
  123801. private static readonly _DefaultIndexOfRefraction;
  123802. private _isEnabled;
  123803. /**
  123804. * Defines if the clear coat is enabled in the material.
  123805. */
  123806. isEnabled: boolean;
  123807. /**
  123808. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123809. */
  123810. intensity: number;
  123811. /**
  123812. * Defines the clear coat layer roughness.
  123813. */
  123814. roughness: number;
  123815. private _indexOfRefraction;
  123816. /**
  123817. * Defines the index of refraction of the clear coat.
  123818. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123819. * The default fits with a polyurethane material.
  123820. * Changing the default value is more performance intensive.
  123821. */
  123822. indexOfRefraction: number;
  123823. private _texture;
  123824. /**
  123825. * Stores the clear coat values in a texture.
  123826. */
  123827. texture: Nullable<BaseTexture>;
  123828. private _bumpTexture;
  123829. /**
  123830. * Define the clear coat specific bump texture.
  123831. */
  123832. bumpTexture: Nullable<BaseTexture>;
  123833. private _isTintEnabled;
  123834. /**
  123835. * Defines if the clear coat tint is enabled in the material.
  123836. */
  123837. isTintEnabled: boolean;
  123838. /**
  123839. * Defines the clear coat tint of the material.
  123840. * This is only use if tint is enabled
  123841. */
  123842. tintColor: Color3;
  123843. /**
  123844. * Defines the distance at which the tint color should be found in the
  123845. * clear coat media.
  123846. * This is only use if tint is enabled
  123847. */
  123848. tintColorAtDistance: number;
  123849. /**
  123850. * Defines the clear coat layer thickness.
  123851. * This is only use if tint is enabled
  123852. */
  123853. tintThickness: number;
  123854. private _tintTexture;
  123855. /**
  123856. * Stores the clear tint values in a texture.
  123857. * rgb is tint
  123858. * a is a thickness factor
  123859. */
  123860. tintTexture: Nullable<BaseTexture>;
  123861. /** @hidden */
  123862. private _internalMarkAllSubMeshesAsTexturesDirty;
  123863. /** @hidden */
  123864. _markAllSubMeshesAsTexturesDirty(): void;
  123865. /**
  123866. * Instantiate a new istance of clear coat configuration.
  123867. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123868. */
  123869. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123870. /**
  123871. * Gets wehter the submesh is ready to be used or not.
  123872. * @param defines the list of "defines" to update.
  123873. * @param scene defines the scene the material belongs to.
  123874. * @param engine defines the engine the material belongs to.
  123875. * @param disableBumpMap defines wether the material disables bump or not.
  123876. * @returns - boolean indicating that the submesh is ready or not.
  123877. */
  123878. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123879. /**
  123880. * Checks to see if a texture is used in the material.
  123881. * @param defines the list of "defines" to update.
  123882. * @param scene defines the scene to the material belongs to.
  123883. */
  123884. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123885. /**
  123886. * Binds the material data.
  123887. * @param uniformBuffer defines the Uniform buffer to fill in.
  123888. * @param scene defines the scene the material belongs to.
  123889. * @param engine defines the engine the material belongs to.
  123890. * @param disableBumpMap defines wether the material disables bump or not.
  123891. * @param isFrozen defines wether the material is frozen or not.
  123892. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123893. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123894. */
  123895. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123896. /**
  123897. * Checks to see if a texture is used in the material.
  123898. * @param texture - Base texture to use.
  123899. * @returns - Boolean specifying if a texture is used in the material.
  123900. */
  123901. hasTexture(texture: BaseTexture): boolean;
  123902. /**
  123903. * Returns an array of the actively used textures.
  123904. * @param activeTextures Array of BaseTextures
  123905. */
  123906. getActiveTextures(activeTextures: BaseTexture[]): void;
  123907. /**
  123908. * Returns the animatable textures.
  123909. * @param animatables Array of animatable textures.
  123910. */
  123911. getAnimatables(animatables: IAnimatable[]): void;
  123912. /**
  123913. * Disposes the resources of the material.
  123914. * @param forceDisposeTextures - Forces the disposal of all textures.
  123915. */
  123916. dispose(forceDisposeTextures?: boolean): void;
  123917. /**
  123918. * Get the current class name of the texture useful for serialization or dynamic coding.
  123919. * @returns "PBRClearCoatConfiguration"
  123920. */
  123921. getClassName(): string;
  123922. /**
  123923. * Add fallbacks to the effect fallbacks list.
  123924. * @param defines defines the Base texture to use.
  123925. * @param fallbacks defines the current fallback list.
  123926. * @param currentRank defines the current fallback rank.
  123927. * @returns the new fallback rank.
  123928. */
  123929. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123930. /**
  123931. * Add the required uniforms to the current list.
  123932. * @param uniforms defines the current uniform list.
  123933. */
  123934. static AddUniforms(uniforms: string[]): void;
  123935. /**
  123936. * Add the required samplers to the current list.
  123937. * @param samplers defines the current sampler list.
  123938. */
  123939. static AddSamplers(samplers: string[]): void;
  123940. /**
  123941. * Add the required uniforms to the current buffer.
  123942. * @param uniformBuffer defines the current uniform buffer.
  123943. */
  123944. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123945. /**
  123946. * Makes a duplicate of the current configuration into another one.
  123947. * @param clearCoatConfiguration define the config where to copy the info
  123948. */
  123949. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123950. /**
  123951. * Serializes this clear coat configuration.
  123952. * @returns - An object with the serialized config.
  123953. */
  123954. serialize(): any;
  123955. /**
  123956. * Parses a anisotropy Configuration from a serialized object.
  123957. * @param source - Serialized object.
  123958. * @param scene Defines the scene we are parsing for
  123959. * @param rootUrl Defines the rootUrl to load from
  123960. */
  123961. parse(source: any, scene: Scene, rootUrl: string): void;
  123962. }
  123963. }
  123964. declare module BABYLON {
  123965. /**
  123966. * @hidden
  123967. */
  123968. export interface IMaterialAnisotropicDefines {
  123969. ANISOTROPIC: boolean;
  123970. ANISOTROPIC_TEXTURE: boolean;
  123971. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123972. MAINUV1: boolean;
  123973. _areTexturesDirty: boolean;
  123974. _needUVs: boolean;
  123975. }
  123976. /**
  123977. * Define the code related to the anisotropic parameters of the pbr material.
  123978. */
  123979. export class PBRAnisotropicConfiguration {
  123980. private _isEnabled;
  123981. /**
  123982. * Defines if the anisotropy is enabled in the material.
  123983. */
  123984. isEnabled: boolean;
  123985. /**
  123986. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123987. */
  123988. intensity: number;
  123989. /**
  123990. * Defines if the effect is along the tangents, bitangents or in between.
  123991. * By default, the effect is "strectching" the highlights along the tangents.
  123992. */
  123993. direction: Vector2;
  123994. private _texture;
  123995. /**
  123996. * Stores the anisotropy values in a texture.
  123997. * rg is direction (like normal from -1 to 1)
  123998. * b is a intensity
  123999. */
  124000. texture: Nullable<BaseTexture>;
  124001. /** @hidden */
  124002. private _internalMarkAllSubMeshesAsTexturesDirty;
  124003. /** @hidden */
  124004. _markAllSubMeshesAsTexturesDirty(): void;
  124005. /**
  124006. * Instantiate a new istance of anisotropy configuration.
  124007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124008. */
  124009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124010. /**
  124011. * Specifies that the submesh is ready to be used.
  124012. * @param defines the list of "defines" to update.
  124013. * @param scene defines the scene the material belongs to.
  124014. * @returns - boolean indicating that the submesh is ready or not.
  124015. */
  124016. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  124017. /**
  124018. * Checks to see if a texture is used in the material.
  124019. * @param defines the list of "defines" to update.
  124020. * @param mesh the mesh we are preparing the defines for.
  124021. * @param scene defines the scene the material belongs to.
  124022. */
  124023. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  124024. /**
  124025. * Binds the material data.
  124026. * @param uniformBuffer defines the Uniform buffer to fill in.
  124027. * @param scene defines the scene the material belongs to.
  124028. * @param isFrozen defines wether the material is frozen or not.
  124029. */
  124030. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124031. /**
  124032. * Checks to see if a texture is used in the material.
  124033. * @param texture - Base texture to use.
  124034. * @returns - Boolean specifying if a texture is used in the material.
  124035. */
  124036. hasTexture(texture: BaseTexture): boolean;
  124037. /**
  124038. * Returns an array of the actively used textures.
  124039. * @param activeTextures Array of BaseTextures
  124040. */
  124041. getActiveTextures(activeTextures: BaseTexture[]): void;
  124042. /**
  124043. * Returns the animatable textures.
  124044. * @param animatables Array of animatable textures.
  124045. */
  124046. getAnimatables(animatables: IAnimatable[]): void;
  124047. /**
  124048. * Disposes the resources of the material.
  124049. * @param forceDisposeTextures - Forces the disposal of all textures.
  124050. */
  124051. dispose(forceDisposeTextures?: boolean): void;
  124052. /**
  124053. * Get the current class name of the texture useful for serialization or dynamic coding.
  124054. * @returns "PBRAnisotropicConfiguration"
  124055. */
  124056. getClassName(): string;
  124057. /**
  124058. * Add fallbacks to the effect fallbacks list.
  124059. * @param defines defines the Base texture to use.
  124060. * @param fallbacks defines the current fallback list.
  124061. * @param currentRank defines the current fallback rank.
  124062. * @returns the new fallback rank.
  124063. */
  124064. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124065. /**
  124066. * Add the required uniforms to the current list.
  124067. * @param uniforms defines the current uniform list.
  124068. */
  124069. static AddUniforms(uniforms: string[]): void;
  124070. /**
  124071. * Add the required uniforms to the current buffer.
  124072. * @param uniformBuffer defines the current uniform buffer.
  124073. */
  124074. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124075. /**
  124076. * Add the required samplers to the current list.
  124077. * @param samplers defines the current sampler list.
  124078. */
  124079. static AddSamplers(samplers: string[]): void;
  124080. /**
  124081. * Makes a duplicate of the current configuration into another one.
  124082. * @param anisotropicConfiguration define the config where to copy the info
  124083. */
  124084. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  124085. /**
  124086. * Serializes this anisotropy configuration.
  124087. * @returns - An object with the serialized config.
  124088. */
  124089. serialize(): any;
  124090. /**
  124091. * Parses a anisotropy Configuration from a serialized object.
  124092. * @param source - Serialized object.
  124093. * @param scene Defines the scene we are parsing for
  124094. * @param rootUrl Defines the rootUrl to load from
  124095. */
  124096. parse(source: any, scene: Scene, rootUrl: string): void;
  124097. }
  124098. }
  124099. declare module BABYLON {
  124100. /**
  124101. * @hidden
  124102. */
  124103. export interface IMaterialBRDFDefines {
  124104. BRDF_V_HEIGHT_CORRELATED: boolean;
  124105. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124106. SPHERICAL_HARMONICS: boolean;
  124107. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124108. /** @hidden */
  124109. _areMiscDirty: boolean;
  124110. }
  124111. /**
  124112. * Define the code related to the BRDF parameters of the pbr material.
  124113. */
  124114. export class PBRBRDFConfiguration {
  124115. /**
  124116. * Default value used for the energy conservation.
  124117. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124118. */
  124119. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124120. /**
  124121. * Default value used for the Smith Visibility Height Correlated mode.
  124122. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124123. */
  124124. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124125. /**
  124126. * Default value used for the IBL diffuse part.
  124127. * This can help switching back to the polynomials mode globally which is a tiny bit
  124128. * less GPU intensive at the drawback of a lower quality.
  124129. */
  124130. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124131. /**
  124132. * Default value used for activating energy conservation for the specular workflow.
  124133. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124134. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124135. */
  124136. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124137. private _useEnergyConservation;
  124138. /**
  124139. * Defines if the material uses energy conservation.
  124140. */
  124141. useEnergyConservation: boolean;
  124142. private _useSmithVisibilityHeightCorrelated;
  124143. /**
  124144. * LEGACY Mode set to false
  124145. * Defines if the material uses height smith correlated visibility term.
  124146. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124147. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124148. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124149. * Not relying on height correlated will also disable energy conservation.
  124150. */
  124151. useSmithVisibilityHeightCorrelated: boolean;
  124152. private _useSphericalHarmonics;
  124153. /**
  124154. * LEGACY Mode set to false
  124155. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124156. * diffuse part of the IBL.
  124157. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124158. * to the ground truth.
  124159. */
  124160. useSphericalHarmonics: boolean;
  124161. private _useSpecularGlossinessInputEnergyConservation;
  124162. /**
  124163. * Defines if the material uses energy conservation, when the specular workflow is active.
  124164. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124165. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124166. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  124167. */
  124168. useSpecularGlossinessInputEnergyConservation: boolean;
  124169. /** @hidden */
  124170. private _internalMarkAllSubMeshesAsMiscDirty;
  124171. /** @hidden */
  124172. _markAllSubMeshesAsMiscDirty(): void;
  124173. /**
  124174. * Instantiate a new istance of clear coat configuration.
  124175. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  124176. */
  124177. constructor(markAllSubMeshesAsMiscDirty: () => void);
  124178. /**
  124179. * Checks to see if a texture is used in the material.
  124180. * @param defines the list of "defines" to update.
  124181. */
  124182. prepareDefines(defines: IMaterialBRDFDefines): void;
  124183. /**
  124184. * Get the current class name of the texture useful for serialization or dynamic coding.
  124185. * @returns "PBRClearCoatConfiguration"
  124186. */
  124187. getClassName(): string;
  124188. /**
  124189. * Makes a duplicate of the current configuration into another one.
  124190. * @param brdfConfiguration define the config where to copy the info
  124191. */
  124192. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  124193. /**
  124194. * Serializes this BRDF configuration.
  124195. * @returns - An object with the serialized config.
  124196. */
  124197. serialize(): any;
  124198. /**
  124199. * Parses a anisotropy Configuration from a serialized object.
  124200. * @param source - Serialized object.
  124201. * @param scene Defines the scene we are parsing for
  124202. * @param rootUrl Defines the rootUrl to load from
  124203. */
  124204. parse(source: any, scene: Scene, rootUrl: string): void;
  124205. }
  124206. }
  124207. declare module BABYLON {
  124208. /**
  124209. * @hidden
  124210. */
  124211. export interface IMaterialSheenDefines {
  124212. SHEEN: boolean;
  124213. SHEEN_TEXTURE: boolean;
  124214. SHEEN_TEXTUREDIRECTUV: number;
  124215. SHEEN_LINKWITHALBEDO: boolean;
  124216. SHEEN_ROUGHNESS: boolean;
  124217. SHEEN_ALBEDOSCALING: boolean;
  124218. /** @hidden */
  124219. _areTexturesDirty: boolean;
  124220. }
  124221. /**
  124222. * Define the code related to the Sheen parameters of the pbr material.
  124223. */
  124224. export class PBRSheenConfiguration {
  124225. private _isEnabled;
  124226. /**
  124227. * Defines if the material uses sheen.
  124228. */
  124229. isEnabled: boolean;
  124230. private _linkSheenWithAlbedo;
  124231. /**
  124232. * Defines if the sheen is linked to the sheen color.
  124233. */
  124234. linkSheenWithAlbedo: boolean;
  124235. /**
  124236. * Defines the sheen intensity.
  124237. */
  124238. intensity: number;
  124239. /**
  124240. * Defines the sheen color.
  124241. */
  124242. color: Color3;
  124243. private _texture;
  124244. /**
  124245. * Stores the sheen tint values in a texture.
  124246. * rgb is tint
  124247. * a is a intensity
  124248. */
  124249. texture: Nullable<BaseTexture>;
  124250. private _roughness;
  124251. /**
  124252. * Defines the sheen roughness.
  124253. * It is not taken into account if linkSheenWithAlbedo is true.
  124254. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  124255. */
  124256. roughness: Nullable<number>;
  124257. private _albedoScaling;
  124258. /**
  124259. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  124260. * It allows the strength of the sheen effect to not depend on the base color of the material,
  124261. * making it easier to setup and tweak the effect
  124262. */
  124263. albedoScaling: boolean;
  124264. /** @hidden */
  124265. private _internalMarkAllSubMeshesAsTexturesDirty;
  124266. /** @hidden */
  124267. _markAllSubMeshesAsTexturesDirty(): void;
  124268. /**
  124269. * Instantiate a new istance of clear coat configuration.
  124270. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124271. */
  124272. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124273. /**
  124274. * Specifies that the submesh is ready to be used.
  124275. * @param defines the list of "defines" to update.
  124276. * @param scene defines the scene the material belongs to.
  124277. * @returns - boolean indicating that the submesh is ready or not.
  124278. */
  124279. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  124280. /**
  124281. * Checks to see if a texture is used in the material.
  124282. * @param defines the list of "defines" to update.
  124283. * @param scene defines the scene the material belongs to.
  124284. */
  124285. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  124286. /**
  124287. * Binds the material data.
  124288. * @param uniformBuffer defines the Uniform buffer to fill in.
  124289. * @param scene defines the scene the material belongs to.
  124290. * @param isFrozen defines wether the material is frozen or not.
  124291. */
  124292. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124293. /**
  124294. * Checks to see if a texture is used in the material.
  124295. * @param texture - Base texture to use.
  124296. * @returns - Boolean specifying if a texture is used in the material.
  124297. */
  124298. hasTexture(texture: BaseTexture): boolean;
  124299. /**
  124300. * Returns an array of the actively used textures.
  124301. * @param activeTextures Array of BaseTextures
  124302. */
  124303. getActiveTextures(activeTextures: BaseTexture[]): void;
  124304. /**
  124305. * Returns the animatable textures.
  124306. * @param animatables Array of animatable textures.
  124307. */
  124308. getAnimatables(animatables: IAnimatable[]): void;
  124309. /**
  124310. * Disposes the resources of the material.
  124311. * @param forceDisposeTextures - Forces the disposal of all textures.
  124312. */
  124313. dispose(forceDisposeTextures?: boolean): void;
  124314. /**
  124315. * Get the current class name of the texture useful for serialization or dynamic coding.
  124316. * @returns "PBRSheenConfiguration"
  124317. */
  124318. getClassName(): string;
  124319. /**
  124320. * Add fallbacks to the effect fallbacks list.
  124321. * @param defines defines the Base texture to use.
  124322. * @param fallbacks defines the current fallback list.
  124323. * @param currentRank defines the current fallback rank.
  124324. * @returns the new fallback rank.
  124325. */
  124326. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124327. /**
  124328. * Add the required uniforms to the current list.
  124329. * @param uniforms defines the current uniform list.
  124330. */
  124331. static AddUniforms(uniforms: string[]): void;
  124332. /**
  124333. * Add the required uniforms to the current buffer.
  124334. * @param uniformBuffer defines the current uniform buffer.
  124335. */
  124336. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124337. /**
  124338. * Add the required samplers to the current list.
  124339. * @param samplers defines the current sampler list.
  124340. */
  124341. static AddSamplers(samplers: string[]): void;
  124342. /**
  124343. * Makes a duplicate of the current configuration into another one.
  124344. * @param sheenConfiguration define the config where to copy the info
  124345. */
  124346. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  124347. /**
  124348. * Serializes this BRDF configuration.
  124349. * @returns - An object with the serialized config.
  124350. */
  124351. serialize(): any;
  124352. /**
  124353. * Parses a anisotropy Configuration from a serialized object.
  124354. * @param source - Serialized object.
  124355. * @param scene Defines the scene we are parsing for
  124356. * @param rootUrl Defines the rootUrl to load from
  124357. */
  124358. parse(source: any, scene: Scene, rootUrl: string): void;
  124359. }
  124360. }
  124361. declare module BABYLON {
  124362. /**
  124363. * @hidden
  124364. */
  124365. export interface IMaterialSubSurfaceDefines {
  124366. SUBSURFACE: boolean;
  124367. SS_REFRACTION: boolean;
  124368. SS_TRANSLUCENCY: boolean;
  124369. SS_SCATERRING: boolean;
  124370. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124371. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124372. SS_REFRACTIONMAP_3D: boolean;
  124373. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124374. SS_LODINREFRACTIONALPHA: boolean;
  124375. SS_GAMMAREFRACTION: boolean;
  124376. SS_RGBDREFRACTION: boolean;
  124377. SS_LINEARSPECULARREFRACTION: boolean;
  124378. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124379. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124380. /** @hidden */
  124381. _areTexturesDirty: boolean;
  124382. }
  124383. /**
  124384. * Define the code related to the sub surface parameters of the pbr material.
  124385. */
  124386. export class PBRSubSurfaceConfiguration {
  124387. private _isRefractionEnabled;
  124388. /**
  124389. * Defines if the refraction is enabled in the material.
  124390. */
  124391. isRefractionEnabled: boolean;
  124392. private _isTranslucencyEnabled;
  124393. /**
  124394. * Defines if the translucency is enabled in the material.
  124395. */
  124396. isTranslucencyEnabled: boolean;
  124397. private _isScatteringEnabled;
  124398. /**
  124399. * Defines the refraction intensity of the material.
  124400. * The refraction when enabled replaces the Diffuse part of the material.
  124401. * The intensity helps transitionning between diffuse and refraction.
  124402. */
  124403. refractionIntensity: number;
  124404. /**
  124405. * Defines the translucency intensity of the material.
  124406. * When translucency has been enabled, this defines how much of the "translucency"
  124407. * is addded to the diffuse part of the material.
  124408. */
  124409. translucencyIntensity: number;
  124410. /**
  124411. * Defines the scattering intensity of the material.
  124412. * When scattering has been enabled, this defines how much of the "scattered light"
  124413. * is addded to the diffuse part of the material.
  124414. */
  124415. scatteringIntensity: number;
  124416. private _thicknessTexture;
  124417. /**
  124418. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  124419. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  124420. * 0 would mean minimumThickness
  124421. * 1 would mean maximumThickness
  124422. * The other channels might be use as a mask to vary the different effects intensity.
  124423. */
  124424. thicknessTexture: Nullable<BaseTexture>;
  124425. private _refractionTexture;
  124426. /**
  124427. * Defines the texture to use for refraction.
  124428. */
  124429. refractionTexture: Nullable<BaseTexture>;
  124430. private _indexOfRefraction;
  124431. /**
  124432. * Defines the index of refraction used in the material.
  124433. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  124434. */
  124435. indexOfRefraction: number;
  124436. private _invertRefractionY;
  124437. /**
  124438. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124439. */
  124440. invertRefractionY: boolean;
  124441. private _linkRefractionWithTransparency;
  124442. /**
  124443. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124444. * Materials half opaque for instance using refraction could benefit from this control.
  124445. */
  124446. linkRefractionWithTransparency: boolean;
  124447. /**
  124448. * Defines the minimum thickness stored in the thickness map.
  124449. * If no thickness map is defined, this value will be used to simulate thickness.
  124450. */
  124451. minimumThickness: number;
  124452. /**
  124453. * Defines the maximum thickness stored in the thickness map.
  124454. */
  124455. maximumThickness: number;
  124456. /**
  124457. * Defines the volume tint of the material.
  124458. * This is used for both translucency and scattering.
  124459. */
  124460. tintColor: Color3;
  124461. /**
  124462. * Defines the distance at which the tint color should be found in the media.
  124463. * This is used for refraction only.
  124464. */
  124465. tintColorAtDistance: number;
  124466. /**
  124467. * Defines how far each channel transmit through the media.
  124468. * It is defined as a color to simplify it selection.
  124469. */
  124470. diffusionDistance: Color3;
  124471. private _useMaskFromThicknessTexture;
  124472. /**
  124473. * Stores the intensity of the different subsurface effects in the thickness texture.
  124474. * * the green channel is the translucency intensity.
  124475. * * the blue channel is the scattering intensity.
  124476. * * the alpha channel is the refraction intensity.
  124477. */
  124478. useMaskFromThicknessTexture: boolean;
  124479. /** @hidden */
  124480. private _internalMarkAllSubMeshesAsTexturesDirty;
  124481. /** @hidden */
  124482. _markAllSubMeshesAsTexturesDirty(): void;
  124483. /**
  124484. * Instantiate a new istance of sub surface configuration.
  124485. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124486. */
  124487. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124488. /**
  124489. * Gets wehter the submesh is ready to be used or not.
  124490. * @param defines the list of "defines" to update.
  124491. * @param scene defines the scene the material belongs to.
  124492. * @returns - boolean indicating that the submesh is ready or not.
  124493. */
  124494. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  124495. /**
  124496. * Checks to see if a texture is used in the material.
  124497. * @param defines the list of "defines" to update.
  124498. * @param scene defines the scene to the material belongs to.
  124499. */
  124500. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  124501. /**
  124502. * Binds the material data.
  124503. * @param uniformBuffer defines the Uniform buffer to fill in.
  124504. * @param scene defines the scene the material belongs to.
  124505. * @param engine defines the engine the material belongs to.
  124506. * @param isFrozen defines wether the material is frozen or not.
  124507. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  124508. */
  124509. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  124510. /**
  124511. * Unbinds the material from the mesh.
  124512. * @param activeEffect defines the effect that should be unbound from.
  124513. * @returns true if unbound, otherwise false
  124514. */
  124515. unbind(activeEffect: Effect): boolean;
  124516. /**
  124517. * Returns the texture used for refraction or null if none is used.
  124518. * @param scene defines the scene the material belongs to.
  124519. * @returns - Refraction texture if present. If no refraction texture and refraction
  124520. * is linked with transparency, returns environment texture. Otherwise, returns null.
  124521. */
  124522. private _getRefractionTexture;
  124523. /**
  124524. * Returns true if alpha blending should be disabled.
  124525. */
  124526. get disableAlphaBlending(): boolean;
  124527. /**
  124528. * Fills the list of render target textures.
  124529. * @param renderTargets the list of render targets to update
  124530. */
  124531. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  124532. /**
  124533. * Checks to see if a texture is used in the material.
  124534. * @param texture - Base texture to use.
  124535. * @returns - Boolean specifying if a texture is used in the material.
  124536. */
  124537. hasTexture(texture: BaseTexture): boolean;
  124538. /**
  124539. * Gets a boolean indicating that current material needs to register RTT
  124540. * @returns true if this uses a render target otherwise false.
  124541. */
  124542. hasRenderTargetTextures(): boolean;
  124543. /**
  124544. * Returns an array of the actively used textures.
  124545. * @param activeTextures Array of BaseTextures
  124546. */
  124547. getActiveTextures(activeTextures: BaseTexture[]): void;
  124548. /**
  124549. * Returns the animatable textures.
  124550. * @param animatables Array of animatable textures.
  124551. */
  124552. getAnimatables(animatables: IAnimatable[]): void;
  124553. /**
  124554. * Disposes the resources of the material.
  124555. * @param forceDisposeTextures - Forces the disposal of all textures.
  124556. */
  124557. dispose(forceDisposeTextures?: boolean): void;
  124558. /**
  124559. * Get the current class name of the texture useful for serialization or dynamic coding.
  124560. * @returns "PBRSubSurfaceConfiguration"
  124561. */
  124562. getClassName(): string;
  124563. /**
  124564. * Add fallbacks to the effect fallbacks list.
  124565. * @param defines defines the Base texture to use.
  124566. * @param fallbacks defines the current fallback list.
  124567. * @param currentRank defines the current fallback rank.
  124568. * @returns the new fallback rank.
  124569. */
  124570. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124571. /**
  124572. * Add the required uniforms to the current list.
  124573. * @param uniforms defines the current uniform list.
  124574. */
  124575. static AddUniforms(uniforms: string[]): void;
  124576. /**
  124577. * Add the required samplers to the current list.
  124578. * @param samplers defines the current sampler list.
  124579. */
  124580. static AddSamplers(samplers: string[]): void;
  124581. /**
  124582. * Add the required uniforms to the current buffer.
  124583. * @param uniformBuffer defines the current uniform buffer.
  124584. */
  124585. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124586. /**
  124587. * Makes a duplicate of the current configuration into another one.
  124588. * @param configuration define the config where to copy the info
  124589. */
  124590. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124591. /**
  124592. * Serializes this Sub Surface configuration.
  124593. * @returns - An object with the serialized config.
  124594. */
  124595. serialize(): any;
  124596. /**
  124597. * Parses a anisotropy Configuration from a serialized object.
  124598. * @param source - Serialized object.
  124599. * @param scene Defines the scene we are parsing for
  124600. * @param rootUrl Defines the rootUrl to load from
  124601. */
  124602. parse(source: any, scene: Scene, rootUrl: string): void;
  124603. }
  124604. }
  124605. declare module BABYLON {
  124606. /** @hidden */
  124607. export var pbrFragmentDeclaration: {
  124608. name: string;
  124609. shader: string;
  124610. };
  124611. }
  124612. declare module BABYLON {
  124613. /** @hidden */
  124614. export var pbrUboDeclaration: {
  124615. name: string;
  124616. shader: string;
  124617. };
  124618. }
  124619. declare module BABYLON {
  124620. /** @hidden */
  124621. export var pbrFragmentExtraDeclaration: {
  124622. name: string;
  124623. shader: string;
  124624. };
  124625. }
  124626. declare module BABYLON {
  124627. /** @hidden */
  124628. export var pbrFragmentSamplersDeclaration: {
  124629. name: string;
  124630. shader: string;
  124631. };
  124632. }
  124633. declare module BABYLON {
  124634. /** @hidden */
  124635. export var pbrHelperFunctions: {
  124636. name: string;
  124637. shader: string;
  124638. };
  124639. }
  124640. declare module BABYLON {
  124641. /** @hidden */
  124642. export var harmonicsFunctions: {
  124643. name: string;
  124644. shader: string;
  124645. };
  124646. }
  124647. declare module BABYLON {
  124648. /** @hidden */
  124649. export var pbrDirectLightingSetupFunctions: {
  124650. name: string;
  124651. shader: string;
  124652. };
  124653. }
  124654. declare module BABYLON {
  124655. /** @hidden */
  124656. export var pbrDirectLightingFalloffFunctions: {
  124657. name: string;
  124658. shader: string;
  124659. };
  124660. }
  124661. declare module BABYLON {
  124662. /** @hidden */
  124663. export var pbrBRDFFunctions: {
  124664. name: string;
  124665. shader: string;
  124666. };
  124667. }
  124668. declare module BABYLON {
  124669. /** @hidden */
  124670. export var pbrDirectLightingFunctions: {
  124671. name: string;
  124672. shader: string;
  124673. };
  124674. }
  124675. declare module BABYLON {
  124676. /** @hidden */
  124677. export var pbrIBLFunctions: {
  124678. name: string;
  124679. shader: string;
  124680. };
  124681. }
  124682. declare module BABYLON {
  124683. /** @hidden */
  124684. export var pbrDebug: {
  124685. name: string;
  124686. shader: string;
  124687. };
  124688. }
  124689. declare module BABYLON {
  124690. /** @hidden */
  124691. export var pbrPixelShader: {
  124692. name: string;
  124693. shader: string;
  124694. };
  124695. }
  124696. declare module BABYLON {
  124697. /** @hidden */
  124698. export var pbrVertexDeclaration: {
  124699. name: string;
  124700. shader: string;
  124701. };
  124702. }
  124703. declare module BABYLON {
  124704. /** @hidden */
  124705. export var pbrVertexShader: {
  124706. name: string;
  124707. shader: string;
  124708. };
  124709. }
  124710. declare module BABYLON {
  124711. /**
  124712. * Manages the defines for the PBR Material.
  124713. * @hidden
  124714. */
  124715. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124716. PBR: boolean;
  124717. MAINUV1: boolean;
  124718. MAINUV2: boolean;
  124719. UV1: boolean;
  124720. UV2: boolean;
  124721. ALBEDO: boolean;
  124722. GAMMAALBEDO: boolean;
  124723. ALBEDODIRECTUV: number;
  124724. VERTEXCOLOR: boolean;
  124725. AMBIENT: boolean;
  124726. AMBIENTDIRECTUV: number;
  124727. AMBIENTINGRAYSCALE: boolean;
  124728. OPACITY: boolean;
  124729. VERTEXALPHA: boolean;
  124730. OPACITYDIRECTUV: number;
  124731. OPACITYRGB: boolean;
  124732. ALPHATEST: boolean;
  124733. DEPTHPREPASS: boolean;
  124734. ALPHABLEND: boolean;
  124735. ALPHAFROMALBEDO: boolean;
  124736. ALPHATESTVALUE: string;
  124737. SPECULAROVERALPHA: boolean;
  124738. RADIANCEOVERALPHA: boolean;
  124739. ALPHAFRESNEL: boolean;
  124740. LINEARALPHAFRESNEL: boolean;
  124741. PREMULTIPLYALPHA: boolean;
  124742. EMISSIVE: boolean;
  124743. EMISSIVEDIRECTUV: number;
  124744. REFLECTIVITY: boolean;
  124745. REFLECTIVITYDIRECTUV: number;
  124746. SPECULARTERM: boolean;
  124747. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124748. MICROSURFACEAUTOMATIC: boolean;
  124749. LODBASEDMICROSFURACE: boolean;
  124750. MICROSURFACEMAP: boolean;
  124751. MICROSURFACEMAPDIRECTUV: number;
  124752. METALLICWORKFLOW: boolean;
  124753. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124754. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124755. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124756. AOSTOREINMETALMAPRED: boolean;
  124757. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124758. ENVIRONMENTBRDF: boolean;
  124759. ENVIRONMENTBRDF_RGBD: boolean;
  124760. NORMAL: boolean;
  124761. TANGENT: boolean;
  124762. BUMP: boolean;
  124763. BUMPDIRECTUV: number;
  124764. OBJECTSPACE_NORMALMAP: boolean;
  124765. PARALLAX: boolean;
  124766. PARALLAXOCCLUSION: boolean;
  124767. NORMALXYSCALE: boolean;
  124768. LIGHTMAP: boolean;
  124769. LIGHTMAPDIRECTUV: number;
  124770. USELIGHTMAPASSHADOWMAP: boolean;
  124771. GAMMALIGHTMAP: boolean;
  124772. RGBDLIGHTMAP: boolean;
  124773. REFLECTION: boolean;
  124774. REFLECTIONMAP_3D: boolean;
  124775. REFLECTIONMAP_SPHERICAL: boolean;
  124776. REFLECTIONMAP_PLANAR: boolean;
  124777. REFLECTIONMAP_CUBIC: boolean;
  124778. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124779. REFLECTIONMAP_PROJECTION: boolean;
  124780. REFLECTIONMAP_SKYBOX: boolean;
  124781. REFLECTIONMAP_EXPLICIT: boolean;
  124782. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124783. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124784. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124785. INVERTCUBICMAP: boolean;
  124786. USESPHERICALFROMREFLECTIONMAP: boolean;
  124787. USEIRRADIANCEMAP: boolean;
  124788. SPHERICAL_HARMONICS: boolean;
  124789. USESPHERICALINVERTEX: boolean;
  124790. REFLECTIONMAP_OPPOSITEZ: boolean;
  124791. LODINREFLECTIONALPHA: boolean;
  124792. GAMMAREFLECTION: boolean;
  124793. RGBDREFLECTION: boolean;
  124794. LINEARSPECULARREFLECTION: boolean;
  124795. RADIANCEOCCLUSION: boolean;
  124796. HORIZONOCCLUSION: boolean;
  124797. INSTANCES: boolean;
  124798. NUM_BONE_INFLUENCERS: number;
  124799. BonesPerMesh: number;
  124800. BONETEXTURE: boolean;
  124801. NONUNIFORMSCALING: boolean;
  124802. MORPHTARGETS: boolean;
  124803. MORPHTARGETS_NORMAL: boolean;
  124804. MORPHTARGETS_TANGENT: boolean;
  124805. MORPHTARGETS_UV: boolean;
  124806. NUM_MORPH_INFLUENCERS: number;
  124807. IMAGEPROCESSING: boolean;
  124808. VIGNETTE: boolean;
  124809. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124810. VIGNETTEBLENDMODEOPAQUE: boolean;
  124811. TONEMAPPING: boolean;
  124812. TONEMAPPING_ACES: boolean;
  124813. CONTRAST: boolean;
  124814. COLORCURVES: boolean;
  124815. COLORGRADING: boolean;
  124816. COLORGRADING3D: boolean;
  124817. SAMPLER3DGREENDEPTH: boolean;
  124818. SAMPLER3DBGRMAP: boolean;
  124819. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124820. EXPOSURE: boolean;
  124821. MULTIVIEW: boolean;
  124822. USEPHYSICALLIGHTFALLOFF: boolean;
  124823. USEGLTFLIGHTFALLOFF: boolean;
  124824. TWOSIDEDLIGHTING: boolean;
  124825. SHADOWFLOAT: boolean;
  124826. CLIPPLANE: boolean;
  124827. CLIPPLANE2: boolean;
  124828. CLIPPLANE3: boolean;
  124829. CLIPPLANE4: boolean;
  124830. CLIPPLANE5: boolean;
  124831. CLIPPLANE6: boolean;
  124832. POINTSIZE: boolean;
  124833. FOG: boolean;
  124834. LOGARITHMICDEPTH: boolean;
  124835. FORCENORMALFORWARD: boolean;
  124836. SPECULARAA: boolean;
  124837. CLEARCOAT: boolean;
  124838. CLEARCOAT_DEFAULTIOR: boolean;
  124839. CLEARCOAT_TEXTURE: boolean;
  124840. CLEARCOAT_TEXTUREDIRECTUV: number;
  124841. CLEARCOAT_BUMP: boolean;
  124842. CLEARCOAT_BUMPDIRECTUV: number;
  124843. CLEARCOAT_TINT: boolean;
  124844. CLEARCOAT_TINT_TEXTURE: boolean;
  124845. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124846. ANISOTROPIC: boolean;
  124847. ANISOTROPIC_TEXTURE: boolean;
  124848. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124849. BRDF_V_HEIGHT_CORRELATED: boolean;
  124850. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124851. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124852. SHEEN: boolean;
  124853. SHEEN_TEXTURE: boolean;
  124854. SHEEN_TEXTUREDIRECTUV: number;
  124855. SHEEN_LINKWITHALBEDO: boolean;
  124856. SHEEN_ROUGHNESS: boolean;
  124857. SHEEN_ALBEDOSCALING: boolean;
  124858. SUBSURFACE: boolean;
  124859. SS_REFRACTION: boolean;
  124860. SS_TRANSLUCENCY: boolean;
  124861. SS_SCATERRING: boolean;
  124862. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124863. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124864. SS_REFRACTIONMAP_3D: boolean;
  124865. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124866. SS_LODINREFRACTIONALPHA: boolean;
  124867. SS_GAMMAREFRACTION: boolean;
  124868. SS_RGBDREFRACTION: boolean;
  124869. SS_LINEARSPECULARREFRACTION: boolean;
  124870. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124871. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124872. UNLIT: boolean;
  124873. DEBUGMODE: number;
  124874. /**
  124875. * Initializes the PBR Material defines.
  124876. */
  124877. constructor();
  124878. /**
  124879. * Resets the PBR Material defines.
  124880. */
  124881. reset(): void;
  124882. }
  124883. /**
  124884. * The Physically based material base class of BJS.
  124885. *
  124886. * This offers the main features of a standard PBR material.
  124887. * For more information, please refer to the documentation :
  124888. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124889. */
  124890. export abstract class PBRBaseMaterial extends PushMaterial {
  124891. /**
  124892. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124893. */
  124894. static readonly PBRMATERIAL_OPAQUE: number;
  124895. /**
  124896. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124897. */
  124898. static readonly PBRMATERIAL_ALPHATEST: number;
  124899. /**
  124900. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124901. */
  124902. static readonly PBRMATERIAL_ALPHABLEND: number;
  124903. /**
  124904. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124905. * They are also discarded below the alpha cutoff threshold to improve performances.
  124906. */
  124907. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124908. /**
  124909. * Defines the default value of how much AO map is occluding the analytical lights
  124910. * (point spot...).
  124911. */
  124912. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124913. /**
  124914. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124915. */
  124916. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124917. /**
  124918. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124919. * to enhance interoperability with other engines.
  124920. */
  124921. static readonly LIGHTFALLOFF_GLTF: number;
  124922. /**
  124923. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124924. * to enhance interoperability with other materials.
  124925. */
  124926. static readonly LIGHTFALLOFF_STANDARD: number;
  124927. /**
  124928. * Intensity of the direct lights e.g. the four lights available in your scene.
  124929. * This impacts both the direct diffuse and specular highlights.
  124930. */
  124931. protected _directIntensity: number;
  124932. /**
  124933. * Intensity of the emissive part of the material.
  124934. * This helps controlling the emissive effect without modifying the emissive color.
  124935. */
  124936. protected _emissiveIntensity: number;
  124937. /**
  124938. * Intensity of the environment e.g. how much the environment will light the object
  124939. * either through harmonics for rough material or through the refelction for shiny ones.
  124940. */
  124941. protected _environmentIntensity: number;
  124942. /**
  124943. * This is a special control allowing the reduction of the specular highlights coming from the
  124944. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124945. */
  124946. protected _specularIntensity: number;
  124947. /**
  124948. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124949. */
  124950. private _lightingInfos;
  124951. /**
  124952. * Debug Control allowing disabling the bump map on this material.
  124953. */
  124954. protected _disableBumpMap: boolean;
  124955. /**
  124956. * AKA Diffuse Texture in standard nomenclature.
  124957. */
  124958. protected _albedoTexture: Nullable<BaseTexture>;
  124959. /**
  124960. * AKA Occlusion Texture in other nomenclature.
  124961. */
  124962. protected _ambientTexture: Nullable<BaseTexture>;
  124963. /**
  124964. * AKA Occlusion Texture Intensity in other nomenclature.
  124965. */
  124966. protected _ambientTextureStrength: number;
  124967. /**
  124968. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124969. * 1 means it completely occludes it
  124970. * 0 mean it has no impact
  124971. */
  124972. protected _ambientTextureImpactOnAnalyticalLights: number;
  124973. /**
  124974. * Stores the alpha values in a texture.
  124975. */
  124976. protected _opacityTexture: Nullable<BaseTexture>;
  124977. /**
  124978. * Stores the reflection values in a texture.
  124979. */
  124980. protected _reflectionTexture: Nullable<BaseTexture>;
  124981. /**
  124982. * Stores the emissive values in a texture.
  124983. */
  124984. protected _emissiveTexture: Nullable<BaseTexture>;
  124985. /**
  124986. * AKA Specular texture in other nomenclature.
  124987. */
  124988. protected _reflectivityTexture: Nullable<BaseTexture>;
  124989. /**
  124990. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124991. */
  124992. protected _metallicTexture: Nullable<BaseTexture>;
  124993. /**
  124994. * Specifies the metallic scalar of the metallic/roughness workflow.
  124995. * Can also be used to scale the metalness values of the metallic texture.
  124996. */
  124997. protected _metallic: Nullable<number>;
  124998. /**
  124999. * Specifies the roughness scalar of the metallic/roughness workflow.
  125000. * Can also be used to scale the roughness values of the metallic texture.
  125001. */
  125002. protected _roughness: Nullable<number>;
  125003. /**
  125004. * Specifies the an F0 factor to help configuring the material F0.
  125005. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125006. * to 0.5 the previously hard coded value stays the same.
  125007. * Can also be used to scale the F0 values of the metallic texture.
  125008. */
  125009. protected _metallicF0Factor: number;
  125010. /**
  125011. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125012. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125013. * your expectation as it multiplies with the texture data.
  125014. */
  125015. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  125016. /**
  125017. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125018. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125019. */
  125020. protected _microSurfaceTexture: Nullable<BaseTexture>;
  125021. /**
  125022. * Stores surface normal data used to displace a mesh in a texture.
  125023. */
  125024. protected _bumpTexture: Nullable<BaseTexture>;
  125025. /**
  125026. * Stores the pre-calculated light information of a mesh in a texture.
  125027. */
  125028. protected _lightmapTexture: Nullable<BaseTexture>;
  125029. /**
  125030. * The color of a material in ambient lighting.
  125031. */
  125032. protected _ambientColor: Color3;
  125033. /**
  125034. * AKA Diffuse Color in other nomenclature.
  125035. */
  125036. protected _albedoColor: Color3;
  125037. /**
  125038. * AKA Specular Color in other nomenclature.
  125039. */
  125040. protected _reflectivityColor: Color3;
  125041. /**
  125042. * The color applied when light is reflected from a material.
  125043. */
  125044. protected _reflectionColor: Color3;
  125045. /**
  125046. * The color applied when light is emitted from a material.
  125047. */
  125048. protected _emissiveColor: Color3;
  125049. /**
  125050. * AKA Glossiness in other nomenclature.
  125051. */
  125052. protected _microSurface: number;
  125053. /**
  125054. * Specifies that the material will use the light map as a show map.
  125055. */
  125056. protected _useLightmapAsShadowmap: boolean;
  125057. /**
  125058. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125059. * makes the reflect vector face the model (under horizon).
  125060. */
  125061. protected _useHorizonOcclusion: boolean;
  125062. /**
  125063. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125064. * too much the area relying on ambient texture to define their ambient occlusion.
  125065. */
  125066. protected _useRadianceOcclusion: boolean;
  125067. /**
  125068. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125069. */
  125070. protected _useAlphaFromAlbedoTexture: boolean;
  125071. /**
  125072. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  125073. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125074. */
  125075. protected _useSpecularOverAlpha: boolean;
  125076. /**
  125077. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125078. */
  125079. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125080. /**
  125081. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125082. */
  125083. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  125084. /**
  125085. * Specifies if the metallic texture contains the roughness information in its green channel.
  125086. */
  125087. protected _useRoughnessFromMetallicTextureGreen: boolean;
  125088. /**
  125089. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125090. */
  125091. protected _useMetallnessFromMetallicTextureBlue: boolean;
  125092. /**
  125093. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125094. */
  125095. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  125096. /**
  125097. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125098. */
  125099. protected _useAmbientInGrayScale: boolean;
  125100. /**
  125101. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125102. * The material will try to infer what glossiness each pixel should be.
  125103. */
  125104. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  125105. /**
  125106. * Defines the falloff type used in this material.
  125107. * It by default is Physical.
  125108. */
  125109. protected _lightFalloff: number;
  125110. /**
  125111. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125112. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125113. */
  125114. protected _useRadianceOverAlpha: boolean;
  125115. /**
  125116. * Allows using an object space normal map (instead of tangent space).
  125117. */
  125118. protected _useObjectSpaceNormalMap: boolean;
  125119. /**
  125120. * Allows using the bump map in parallax mode.
  125121. */
  125122. protected _useParallax: boolean;
  125123. /**
  125124. * Allows using the bump map in parallax occlusion mode.
  125125. */
  125126. protected _useParallaxOcclusion: boolean;
  125127. /**
  125128. * Controls the scale bias of the parallax mode.
  125129. */
  125130. protected _parallaxScaleBias: number;
  125131. /**
  125132. * If sets to true, disables all the lights affecting the material.
  125133. */
  125134. protected _disableLighting: boolean;
  125135. /**
  125136. * Number of Simultaneous lights allowed on the material.
  125137. */
  125138. protected _maxSimultaneousLights: number;
  125139. /**
  125140. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  125141. */
  125142. protected _invertNormalMapX: boolean;
  125143. /**
  125144. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  125145. */
  125146. protected _invertNormalMapY: boolean;
  125147. /**
  125148. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125149. */
  125150. protected _twoSidedLighting: boolean;
  125151. /**
  125152. * Defines the alpha limits in alpha test mode.
  125153. */
  125154. protected _alphaCutOff: number;
  125155. /**
  125156. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125157. */
  125158. protected _forceAlphaTest: boolean;
  125159. /**
  125160. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125161. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125162. */
  125163. protected _useAlphaFresnel: boolean;
  125164. /**
  125165. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125166. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125167. */
  125168. protected _useLinearAlphaFresnel: boolean;
  125169. /**
  125170. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  125171. * from cos thetav and roughness:
  125172. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  125173. */
  125174. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  125175. /**
  125176. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125177. */
  125178. protected _forceIrradianceInFragment: boolean;
  125179. /**
  125180. * Force normal to face away from face.
  125181. */
  125182. protected _forceNormalForward: boolean;
  125183. /**
  125184. * Enables specular anti aliasing in the PBR shader.
  125185. * It will both interacts on the Geometry for analytical and IBL lighting.
  125186. * It also prefilter the roughness map based on the bump values.
  125187. */
  125188. protected _enableSpecularAntiAliasing: boolean;
  125189. /**
  125190. * Default configuration related to image processing available in the PBR Material.
  125191. */
  125192. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125193. /**
  125194. * Keep track of the image processing observer to allow dispose and replace.
  125195. */
  125196. private _imageProcessingObserver;
  125197. /**
  125198. * Attaches a new image processing configuration to the PBR Material.
  125199. * @param configuration
  125200. */
  125201. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125202. /**
  125203. * Stores the available render targets.
  125204. */
  125205. private _renderTargets;
  125206. /**
  125207. * Sets the global ambient color for the material used in lighting calculations.
  125208. */
  125209. private _globalAmbientColor;
  125210. /**
  125211. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  125212. */
  125213. private _useLogarithmicDepth;
  125214. /**
  125215. * If set to true, no lighting calculations will be applied.
  125216. */
  125217. private _unlit;
  125218. private _debugMode;
  125219. /**
  125220. * @hidden
  125221. * This is reserved for the inspector.
  125222. * Defines the material debug mode.
  125223. * It helps seeing only some components of the material while troubleshooting.
  125224. */
  125225. debugMode: number;
  125226. /**
  125227. * @hidden
  125228. * This is reserved for the inspector.
  125229. * Specify from where on screen the debug mode should start.
  125230. * The value goes from -1 (full screen) to 1 (not visible)
  125231. * It helps with side by side comparison against the final render
  125232. * This defaults to -1
  125233. */
  125234. private debugLimit;
  125235. /**
  125236. * @hidden
  125237. * This is reserved for the inspector.
  125238. * As the default viewing range might not be enough (if the ambient is really small for instance)
  125239. * You can use the factor to better multiply the final value.
  125240. */
  125241. private debugFactor;
  125242. /**
  125243. * Defines the clear coat layer parameters for the material.
  125244. */
  125245. readonly clearCoat: PBRClearCoatConfiguration;
  125246. /**
  125247. * Defines the anisotropic parameters for the material.
  125248. */
  125249. readonly anisotropy: PBRAnisotropicConfiguration;
  125250. /**
  125251. * Defines the BRDF parameters for the material.
  125252. */
  125253. readonly brdf: PBRBRDFConfiguration;
  125254. /**
  125255. * Defines the Sheen parameters for the material.
  125256. */
  125257. readonly sheen: PBRSheenConfiguration;
  125258. /**
  125259. * Defines the SubSurface parameters for the material.
  125260. */
  125261. readonly subSurface: PBRSubSurfaceConfiguration;
  125262. /**
  125263. * Custom callback helping to override the default shader used in the material.
  125264. */
  125265. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  125266. protected _rebuildInParallel: boolean;
  125267. /**
  125268. * Instantiates a new PBRMaterial instance.
  125269. *
  125270. * @param name The material name
  125271. * @param scene The scene the material will be use in.
  125272. */
  125273. constructor(name: string, scene: Scene);
  125274. /**
  125275. * Gets a boolean indicating that current material needs to register RTT
  125276. */
  125277. get hasRenderTargetTextures(): boolean;
  125278. /**
  125279. * Gets the name of the material class.
  125280. */
  125281. getClassName(): string;
  125282. /**
  125283. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  125284. */
  125285. get useLogarithmicDepth(): boolean;
  125286. /**
  125287. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  125288. */
  125289. set useLogarithmicDepth(value: boolean);
  125290. /**
  125291. * Returns true if alpha blending should be disabled.
  125292. */
  125293. protected get _disableAlphaBlending(): boolean;
  125294. /**
  125295. * Specifies whether or not this material should be rendered in alpha blend mode.
  125296. */
  125297. needAlphaBlending(): boolean;
  125298. /**
  125299. * Specifies whether or not this material should be rendered in alpha test mode.
  125300. */
  125301. needAlphaTesting(): boolean;
  125302. /**
  125303. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  125304. */
  125305. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  125306. /**
  125307. * Gets the texture used for the alpha test.
  125308. */
  125309. getAlphaTestTexture(): Nullable<BaseTexture>;
  125310. /**
  125311. * Specifies that the submesh is ready to be used.
  125312. * @param mesh - BJS mesh.
  125313. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  125314. * @param useInstances - Specifies that instances should be used.
  125315. * @returns - boolean indicating that the submesh is ready or not.
  125316. */
  125317. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  125318. /**
  125319. * Specifies if the material uses metallic roughness workflow.
  125320. * @returns boolean specifiying if the material uses metallic roughness workflow.
  125321. */
  125322. isMetallicWorkflow(): boolean;
  125323. private _prepareEffect;
  125324. private _prepareDefines;
  125325. /**
  125326. * Force shader compilation
  125327. */
  125328. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  125329. /**
  125330. * Initializes the uniform buffer layout for the shader.
  125331. */
  125332. buildUniformLayout(): void;
  125333. /**
  125334. * Unbinds the material from the mesh
  125335. */
  125336. unbind(): void;
  125337. /**
  125338. * Binds the submesh data.
  125339. * @param world - The world matrix.
  125340. * @param mesh - The BJS mesh.
  125341. * @param subMesh - A submesh of the BJS mesh.
  125342. */
  125343. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  125344. /**
  125345. * Returns the animatable textures.
  125346. * @returns - Array of animatable textures.
  125347. */
  125348. getAnimatables(): IAnimatable[];
  125349. /**
  125350. * Returns the texture used for reflections.
  125351. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  125352. */
  125353. private _getReflectionTexture;
  125354. /**
  125355. * Returns an array of the actively used textures.
  125356. * @returns - Array of BaseTextures
  125357. */
  125358. getActiveTextures(): BaseTexture[];
  125359. /**
  125360. * Checks to see if a texture is used in the material.
  125361. * @param texture - Base texture to use.
  125362. * @returns - Boolean specifying if a texture is used in the material.
  125363. */
  125364. hasTexture(texture: BaseTexture): boolean;
  125365. /**
  125366. * Disposes the resources of the material.
  125367. * @param forceDisposeEffect - Forces the disposal of effects.
  125368. * @param forceDisposeTextures - Forces the disposal of all textures.
  125369. */
  125370. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  125371. }
  125372. }
  125373. declare module BABYLON {
  125374. /**
  125375. * The Physically based material of BJS.
  125376. *
  125377. * This offers the main features of a standard PBR material.
  125378. * For more information, please refer to the documentation :
  125379. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125380. */
  125381. export class PBRMaterial extends PBRBaseMaterial {
  125382. /**
  125383. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125384. */
  125385. static readonly PBRMATERIAL_OPAQUE: number;
  125386. /**
  125387. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125388. */
  125389. static readonly PBRMATERIAL_ALPHATEST: number;
  125390. /**
  125391. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125392. */
  125393. static readonly PBRMATERIAL_ALPHABLEND: number;
  125394. /**
  125395. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125396. * They are also discarded below the alpha cutoff threshold to improve performances.
  125397. */
  125398. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125399. /**
  125400. * Defines the default value of how much AO map is occluding the analytical lights
  125401. * (point spot...).
  125402. */
  125403. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125404. /**
  125405. * Intensity of the direct lights e.g. the four lights available in your scene.
  125406. * This impacts both the direct diffuse and specular highlights.
  125407. */
  125408. directIntensity: number;
  125409. /**
  125410. * Intensity of the emissive part of the material.
  125411. * This helps controlling the emissive effect without modifying the emissive color.
  125412. */
  125413. emissiveIntensity: number;
  125414. /**
  125415. * Intensity of the environment e.g. how much the environment will light the object
  125416. * either through harmonics for rough material or through the refelction for shiny ones.
  125417. */
  125418. environmentIntensity: number;
  125419. /**
  125420. * This is a special control allowing the reduction of the specular highlights coming from the
  125421. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125422. */
  125423. specularIntensity: number;
  125424. /**
  125425. * Debug Control allowing disabling the bump map on this material.
  125426. */
  125427. disableBumpMap: boolean;
  125428. /**
  125429. * AKA Diffuse Texture in standard nomenclature.
  125430. */
  125431. albedoTexture: BaseTexture;
  125432. /**
  125433. * AKA Occlusion Texture in other nomenclature.
  125434. */
  125435. ambientTexture: BaseTexture;
  125436. /**
  125437. * AKA Occlusion Texture Intensity in other nomenclature.
  125438. */
  125439. ambientTextureStrength: number;
  125440. /**
  125441. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125442. * 1 means it completely occludes it
  125443. * 0 mean it has no impact
  125444. */
  125445. ambientTextureImpactOnAnalyticalLights: number;
  125446. /**
  125447. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  125448. */
  125449. opacityTexture: BaseTexture;
  125450. /**
  125451. * Stores the reflection values in a texture.
  125452. */
  125453. reflectionTexture: Nullable<BaseTexture>;
  125454. /**
  125455. * Stores the emissive values in a texture.
  125456. */
  125457. emissiveTexture: BaseTexture;
  125458. /**
  125459. * AKA Specular texture in other nomenclature.
  125460. */
  125461. reflectivityTexture: BaseTexture;
  125462. /**
  125463. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125464. */
  125465. metallicTexture: BaseTexture;
  125466. /**
  125467. * Specifies the metallic scalar of the metallic/roughness workflow.
  125468. * Can also be used to scale the metalness values of the metallic texture.
  125469. */
  125470. metallic: Nullable<number>;
  125471. /**
  125472. * Specifies the roughness scalar of the metallic/roughness workflow.
  125473. * Can also be used to scale the roughness values of the metallic texture.
  125474. */
  125475. roughness: Nullable<number>;
  125476. /**
  125477. * Specifies the an F0 factor to help configuring the material F0.
  125478. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125479. * to 0.5 the previously hard coded value stays the same.
  125480. * Can also be used to scale the F0 values of the metallic texture.
  125481. */
  125482. metallicF0Factor: number;
  125483. /**
  125484. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125485. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125486. * your expectation as it multiplies with the texture data.
  125487. */
  125488. useMetallicF0FactorFromMetallicTexture: boolean;
  125489. /**
  125490. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125491. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125492. */
  125493. microSurfaceTexture: BaseTexture;
  125494. /**
  125495. * Stores surface normal data used to displace a mesh in a texture.
  125496. */
  125497. bumpTexture: BaseTexture;
  125498. /**
  125499. * Stores the pre-calculated light information of a mesh in a texture.
  125500. */
  125501. lightmapTexture: BaseTexture;
  125502. /**
  125503. * Stores the refracted light information in a texture.
  125504. */
  125505. get refractionTexture(): Nullable<BaseTexture>;
  125506. set refractionTexture(value: Nullable<BaseTexture>);
  125507. /**
  125508. * The color of a material in ambient lighting.
  125509. */
  125510. ambientColor: Color3;
  125511. /**
  125512. * AKA Diffuse Color in other nomenclature.
  125513. */
  125514. albedoColor: Color3;
  125515. /**
  125516. * AKA Specular Color in other nomenclature.
  125517. */
  125518. reflectivityColor: Color3;
  125519. /**
  125520. * The color reflected from the material.
  125521. */
  125522. reflectionColor: Color3;
  125523. /**
  125524. * The color emitted from the material.
  125525. */
  125526. emissiveColor: Color3;
  125527. /**
  125528. * AKA Glossiness in other nomenclature.
  125529. */
  125530. microSurface: number;
  125531. /**
  125532. * source material index of refraction (IOR)' / 'destination material IOR.
  125533. */
  125534. get indexOfRefraction(): number;
  125535. set indexOfRefraction(value: number);
  125536. /**
  125537. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125538. */
  125539. get invertRefractionY(): boolean;
  125540. set invertRefractionY(value: boolean);
  125541. /**
  125542. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125543. * Materials half opaque for instance using refraction could benefit from this control.
  125544. */
  125545. get linkRefractionWithTransparency(): boolean;
  125546. set linkRefractionWithTransparency(value: boolean);
  125547. /**
  125548. * If true, the light map contains occlusion information instead of lighting info.
  125549. */
  125550. useLightmapAsShadowmap: boolean;
  125551. /**
  125552. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125553. */
  125554. useAlphaFromAlbedoTexture: boolean;
  125555. /**
  125556. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125557. */
  125558. forceAlphaTest: boolean;
  125559. /**
  125560. * Defines the alpha limits in alpha test mode.
  125561. */
  125562. alphaCutOff: number;
  125563. /**
  125564. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  125565. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125566. */
  125567. useSpecularOverAlpha: boolean;
  125568. /**
  125569. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125570. */
  125571. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125572. /**
  125573. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125574. */
  125575. useRoughnessFromMetallicTextureAlpha: boolean;
  125576. /**
  125577. * Specifies if the metallic texture contains the roughness information in its green channel.
  125578. */
  125579. useRoughnessFromMetallicTextureGreen: boolean;
  125580. /**
  125581. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125582. */
  125583. useMetallnessFromMetallicTextureBlue: boolean;
  125584. /**
  125585. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125586. */
  125587. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125588. /**
  125589. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125590. */
  125591. useAmbientInGrayScale: boolean;
  125592. /**
  125593. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125594. * The material will try to infer what glossiness each pixel should be.
  125595. */
  125596. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125597. /**
  125598. * BJS is using an harcoded light falloff based on a manually sets up range.
  125599. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125600. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125601. */
  125602. get usePhysicalLightFalloff(): boolean;
  125603. /**
  125604. * BJS is using an harcoded light falloff based on a manually sets up range.
  125605. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125606. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125607. */
  125608. set usePhysicalLightFalloff(value: boolean);
  125609. /**
  125610. * In order to support the falloff compatibility with gltf, a special mode has been added
  125611. * to reproduce the gltf light falloff.
  125612. */
  125613. get useGLTFLightFalloff(): boolean;
  125614. /**
  125615. * In order to support the falloff compatibility with gltf, a special mode has been added
  125616. * to reproduce the gltf light falloff.
  125617. */
  125618. set useGLTFLightFalloff(value: boolean);
  125619. /**
  125620. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125621. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125622. */
  125623. useRadianceOverAlpha: boolean;
  125624. /**
  125625. * Allows using an object space normal map (instead of tangent space).
  125626. */
  125627. useObjectSpaceNormalMap: boolean;
  125628. /**
  125629. * Allows using the bump map in parallax mode.
  125630. */
  125631. useParallax: boolean;
  125632. /**
  125633. * Allows using the bump map in parallax occlusion mode.
  125634. */
  125635. useParallaxOcclusion: boolean;
  125636. /**
  125637. * Controls the scale bias of the parallax mode.
  125638. */
  125639. parallaxScaleBias: number;
  125640. /**
  125641. * If sets to true, disables all the lights affecting the material.
  125642. */
  125643. disableLighting: boolean;
  125644. /**
  125645. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125646. */
  125647. forceIrradianceInFragment: boolean;
  125648. /**
  125649. * Number of Simultaneous lights allowed on the material.
  125650. */
  125651. maxSimultaneousLights: number;
  125652. /**
  125653. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125654. */
  125655. invertNormalMapX: boolean;
  125656. /**
  125657. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125658. */
  125659. invertNormalMapY: boolean;
  125660. /**
  125661. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125662. */
  125663. twoSidedLighting: boolean;
  125664. /**
  125665. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125666. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125667. */
  125668. useAlphaFresnel: boolean;
  125669. /**
  125670. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125671. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125672. */
  125673. useLinearAlphaFresnel: boolean;
  125674. /**
  125675. * Let user defines the brdf lookup texture used for IBL.
  125676. * A default 8bit version is embedded but you could point at :
  125677. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125678. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125679. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125680. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125681. */
  125682. environmentBRDFTexture: Nullable<BaseTexture>;
  125683. /**
  125684. * Force normal to face away from face.
  125685. */
  125686. forceNormalForward: boolean;
  125687. /**
  125688. * Enables specular anti aliasing in the PBR shader.
  125689. * It will both interacts on the Geometry for analytical and IBL lighting.
  125690. * It also prefilter the roughness map based on the bump values.
  125691. */
  125692. enableSpecularAntiAliasing: boolean;
  125693. /**
  125694. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125695. * makes the reflect vector face the model (under horizon).
  125696. */
  125697. useHorizonOcclusion: boolean;
  125698. /**
  125699. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125700. * too much the area relying on ambient texture to define their ambient occlusion.
  125701. */
  125702. useRadianceOcclusion: boolean;
  125703. /**
  125704. * If set to true, no lighting calculations will be applied.
  125705. */
  125706. unlit: boolean;
  125707. /**
  125708. * Gets the image processing configuration used either in this material.
  125709. */
  125710. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125711. /**
  125712. * Sets the Default image processing configuration used either in the this material.
  125713. *
  125714. * If sets to null, the scene one is in use.
  125715. */
  125716. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125717. /**
  125718. * Gets wether the color curves effect is enabled.
  125719. */
  125720. get cameraColorCurvesEnabled(): boolean;
  125721. /**
  125722. * Sets wether the color curves effect is enabled.
  125723. */
  125724. set cameraColorCurvesEnabled(value: boolean);
  125725. /**
  125726. * Gets wether the color grading effect is enabled.
  125727. */
  125728. get cameraColorGradingEnabled(): boolean;
  125729. /**
  125730. * Gets wether the color grading effect is enabled.
  125731. */
  125732. set cameraColorGradingEnabled(value: boolean);
  125733. /**
  125734. * Gets wether tonemapping is enabled or not.
  125735. */
  125736. get cameraToneMappingEnabled(): boolean;
  125737. /**
  125738. * Sets wether tonemapping is enabled or not
  125739. */
  125740. set cameraToneMappingEnabled(value: boolean);
  125741. /**
  125742. * The camera exposure used on this material.
  125743. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125744. * This corresponds to a photographic exposure.
  125745. */
  125746. get cameraExposure(): number;
  125747. /**
  125748. * The camera exposure used on this material.
  125749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125750. * This corresponds to a photographic exposure.
  125751. */
  125752. set cameraExposure(value: number);
  125753. /**
  125754. * Gets The camera contrast used on this material.
  125755. */
  125756. get cameraContrast(): number;
  125757. /**
  125758. * Sets The camera contrast used on this material.
  125759. */
  125760. set cameraContrast(value: number);
  125761. /**
  125762. * Gets the Color Grading 2D Lookup Texture.
  125763. */
  125764. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125765. /**
  125766. * Sets the Color Grading 2D Lookup Texture.
  125767. */
  125768. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125769. /**
  125770. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125771. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125772. * 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;
  125773. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125774. */
  125775. get cameraColorCurves(): Nullable<ColorCurves>;
  125776. /**
  125777. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125778. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125779. * 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;
  125780. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125781. */
  125782. set cameraColorCurves(value: Nullable<ColorCurves>);
  125783. /**
  125784. * Instantiates a new PBRMaterial instance.
  125785. *
  125786. * @param name The material name
  125787. * @param scene The scene the material will be use in.
  125788. */
  125789. constructor(name: string, scene: Scene);
  125790. /**
  125791. * Returns the name of this material class.
  125792. */
  125793. getClassName(): string;
  125794. /**
  125795. * Makes a duplicate of the current material.
  125796. * @param name - name to use for the new material.
  125797. */
  125798. clone(name: string): PBRMaterial;
  125799. /**
  125800. * Serializes this PBR Material.
  125801. * @returns - An object with the serialized material.
  125802. */
  125803. serialize(): any;
  125804. /**
  125805. * Parses a PBR Material from a serialized object.
  125806. * @param source - Serialized object.
  125807. * @param scene - BJS scene instance.
  125808. * @param rootUrl - url for the scene object
  125809. * @returns - PBRMaterial
  125810. */
  125811. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125812. }
  125813. }
  125814. declare module BABYLON {
  125815. /**
  125816. * Direct draw surface info
  125817. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125818. */
  125819. export interface DDSInfo {
  125820. /**
  125821. * Width of the texture
  125822. */
  125823. width: number;
  125824. /**
  125825. * Width of the texture
  125826. */
  125827. height: number;
  125828. /**
  125829. * Number of Mipmaps for the texture
  125830. * @see https://en.wikipedia.org/wiki/Mipmap
  125831. */
  125832. mipmapCount: number;
  125833. /**
  125834. * If the textures format is a known fourCC format
  125835. * @see https://www.fourcc.org/
  125836. */
  125837. isFourCC: boolean;
  125838. /**
  125839. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125840. */
  125841. isRGB: boolean;
  125842. /**
  125843. * If the texture is a lumincance format
  125844. */
  125845. isLuminance: boolean;
  125846. /**
  125847. * If this is a cube texture
  125848. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125849. */
  125850. isCube: boolean;
  125851. /**
  125852. * If the texture is a compressed format eg. FOURCC_DXT1
  125853. */
  125854. isCompressed: boolean;
  125855. /**
  125856. * The dxgiFormat of the texture
  125857. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125858. */
  125859. dxgiFormat: number;
  125860. /**
  125861. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125862. */
  125863. textureType: number;
  125864. /**
  125865. * Sphericle polynomial created for the dds texture
  125866. */
  125867. sphericalPolynomial?: SphericalPolynomial;
  125868. }
  125869. /**
  125870. * Class used to provide DDS decompression tools
  125871. */
  125872. export class DDSTools {
  125873. /**
  125874. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125875. */
  125876. static StoreLODInAlphaChannel: boolean;
  125877. /**
  125878. * Gets DDS information from an array buffer
  125879. * @param data defines the array buffer view to read data from
  125880. * @returns the DDS information
  125881. */
  125882. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125883. private static _FloatView;
  125884. private static _Int32View;
  125885. private static _ToHalfFloat;
  125886. private static _FromHalfFloat;
  125887. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125888. private static _GetHalfFloatRGBAArrayBuffer;
  125889. private static _GetFloatRGBAArrayBuffer;
  125890. private static _GetFloatAsUIntRGBAArrayBuffer;
  125891. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125892. private static _GetRGBAArrayBuffer;
  125893. private static _ExtractLongWordOrder;
  125894. private static _GetRGBArrayBuffer;
  125895. private static _GetLuminanceArrayBuffer;
  125896. /**
  125897. * Uploads DDS Levels to a Babylon Texture
  125898. * @hidden
  125899. */
  125900. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125901. }
  125902. interface ThinEngine {
  125903. /**
  125904. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125905. * @param rootUrl defines the url where the file to load is located
  125906. * @param scene defines the current scene
  125907. * @param lodScale defines scale to apply to the mip map selection
  125908. * @param lodOffset defines offset to apply to the mip map selection
  125909. * @param onLoad defines an optional callback raised when the texture is loaded
  125910. * @param onError defines an optional callback raised if there is an issue to load the texture
  125911. * @param format defines the format of the data
  125912. * @param forcedExtension defines the extension to use to pick the right loader
  125913. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125914. * @returns the cube texture as an InternalTexture
  125915. */
  125916. 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;
  125917. }
  125918. }
  125919. declare module BABYLON {
  125920. /**
  125921. * Implementation of the DDS Texture Loader.
  125922. * @hidden
  125923. */
  125924. export class _DDSTextureLoader implements IInternalTextureLoader {
  125925. /**
  125926. * Defines wether the loader supports cascade loading the different faces.
  125927. */
  125928. readonly supportCascades: boolean;
  125929. /**
  125930. * This returns if the loader support the current file information.
  125931. * @param extension defines the file extension of the file being loaded
  125932. * @returns true if the loader can load the specified file
  125933. */
  125934. canLoad(extension: string): boolean;
  125935. /**
  125936. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125937. * @param data contains the texture data
  125938. * @param texture defines the BabylonJS internal texture
  125939. * @param createPolynomials will be true if polynomials have been requested
  125940. * @param onLoad defines the callback to trigger once the texture is ready
  125941. * @param onError defines the callback to trigger in case of error
  125942. */
  125943. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125944. /**
  125945. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125946. * @param data contains the texture data
  125947. * @param texture defines the BabylonJS internal texture
  125948. * @param callback defines the method to call once ready to upload
  125949. */
  125950. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125951. }
  125952. }
  125953. declare module BABYLON {
  125954. /**
  125955. * Implementation of the ENV Texture Loader.
  125956. * @hidden
  125957. */
  125958. export class _ENVTextureLoader implements IInternalTextureLoader {
  125959. /**
  125960. * Defines wether the loader supports cascade loading the different faces.
  125961. */
  125962. readonly supportCascades: boolean;
  125963. /**
  125964. * This returns if the loader support the current file information.
  125965. * @param extension defines the file extension of the file being loaded
  125966. * @returns true if the loader can load the specified file
  125967. */
  125968. canLoad(extension: string): boolean;
  125969. /**
  125970. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125971. * @param data contains the texture data
  125972. * @param texture defines the BabylonJS internal texture
  125973. * @param createPolynomials will be true if polynomials have been requested
  125974. * @param onLoad defines the callback to trigger once the texture is ready
  125975. * @param onError defines the callback to trigger in case of error
  125976. */
  125977. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125978. /**
  125979. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125980. * @param data contains the texture data
  125981. * @param texture defines the BabylonJS internal texture
  125982. * @param callback defines the method to call once ready to upload
  125983. */
  125984. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125985. }
  125986. }
  125987. declare module BABYLON {
  125988. /**
  125989. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125990. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125991. */
  125992. export class KhronosTextureContainer {
  125993. /** contents of the KTX container file */
  125994. data: ArrayBufferView;
  125995. private static HEADER_LEN;
  125996. private static COMPRESSED_2D;
  125997. private static COMPRESSED_3D;
  125998. private static TEX_2D;
  125999. private static TEX_3D;
  126000. /**
  126001. * Gets the openGL type
  126002. */
  126003. glType: number;
  126004. /**
  126005. * Gets the openGL type size
  126006. */
  126007. glTypeSize: number;
  126008. /**
  126009. * Gets the openGL format
  126010. */
  126011. glFormat: number;
  126012. /**
  126013. * Gets the openGL internal format
  126014. */
  126015. glInternalFormat: number;
  126016. /**
  126017. * Gets the base internal format
  126018. */
  126019. glBaseInternalFormat: number;
  126020. /**
  126021. * Gets image width in pixel
  126022. */
  126023. pixelWidth: number;
  126024. /**
  126025. * Gets image height in pixel
  126026. */
  126027. pixelHeight: number;
  126028. /**
  126029. * Gets image depth in pixels
  126030. */
  126031. pixelDepth: number;
  126032. /**
  126033. * Gets the number of array elements
  126034. */
  126035. numberOfArrayElements: number;
  126036. /**
  126037. * Gets the number of faces
  126038. */
  126039. numberOfFaces: number;
  126040. /**
  126041. * Gets the number of mipmap levels
  126042. */
  126043. numberOfMipmapLevels: number;
  126044. /**
  126045. * Gets the bytes of key value data
  126046. */
  126047. bytesOfKeyValueData: number;
  126048. /**
  126049. * Gets the load type
  126050. */
  126051. loadType: number;
  126052. /**
  126053. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  126054. */
  126055. isInvalid: boolean;
  126056. /**
  126057. * Creates a new KhronosTextureContainer
  126058. * @param data contents of the KTX container file
  126059. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  126060. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  126061. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  126062. */
  126063. constructor(
  126064. /** contents of the KTX container file */
  126065. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  126066. /**
  126067. * Uploads KTX content to a Babylon Texture.
  126068. * It is assumed that the texture has already been created & is currently bound
  126069. * @hidden
  126070. */
  126071. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  126072. private _upload2DCompressedLevels;
  126073. /**
  126074. * Checks if the given data starts with a KTX file identifier.
  126075. * @param data the data to check
  126076. * @returns true if the data is a KTX file or false otherwise
  126077. */
  126078. static IsValid(data: ArrayBufferView): boolean;
  126079. }
  126080. }
  126081. declare module BABYLON {
  126082. /**
  126083. * Class for loading KTX2 files
  126084. * !!! Experimental Extension Subject to Changes !!!
  126085. * @hidden
  126086. */
  126087. export class KhronosTextureContainer2 {
  126088. private static _ModulePromise;
  126089. private static _TranscodeFormat;
  126090. constructor(engine: ThinEngine);
  126091. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  126092. private _determineTranscodeFormat;
  126093. /**
  126094. * Checks if the given data starts with a KTX2 file identifier.
  126095. * @param data the data to check
  126096. * @returns true if the data is a KTX2 file or false otherwise
  126097. */
  126098. static IsValid(data: ArrayBufferView): boolean;
  126099. }
  126100. }
  126101. declare module BABYLON {
  126102. /**
  126103. * Implementation of the KTX Texture Loader.
  126104. * @hidden
  126105. */
  126106. export class _KTXTextureLoader implements IInternalTextureLoader {
  126107. /**
  126108. * Defines wether the loader supports cascade loading the different faces.
  126109. */
  126110. readonly supportCascades: boolean;
  126111. /**
  126112. * This returns if the loader support the current file information.
  126113. * @param extension defines the file extension of the file being loaded
  126114. * @returns true if the loader can load the specified file
  126115. */
  126116. canLoad(extension: string): boolean;
  126117. /**
  126118. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126119. * @param data contains the texture data
  126120. * @param texture defines the BabylonJS internal texture
  126121. * @param createPolynomials will be true if polynomials have been requested
  126122. * @param onLoad defines the callback to trigger once the texture is ready
  126123. * @param onError defines the callback to trigger in case of error
  126124. */
  126125. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126126. /**
  126127. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126128. * @param data contains the texture data
  126129. * @param texture defines the BabylonJS internal texture
  126130. * @param callback defines the method to call once ready to upload
  126131. */
  126132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  126133. }
  126134. }
  126135. declare module BABYLON {
  126136. /** @hidden */
  126137. export var _forceSceneHelpersToBundle: boolean;
  126138. interface Scene {
  126139. /**
  126140. * Creates a default light for the scene.
  126141. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  126142. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  126143. */
  126144. createDefaultLight(replace?: boolean): void;
  126145. /**
  126146. * Creates a default camera for the scene.
  126147. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  126148. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  126149. * @param replace has default false, when true replaces the active camera in the scene
  126150. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  126151. */
  126152. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  126153. /**
  126154. * Creates a default camera and a default light.
  126155. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  126156. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  126157. * @param replace has the default false, when true replaces the active camera/light in the scene
  126158. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  126159. */
  126160. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  126161. /**
  126162. * Creates a new sky box
  126163. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  126164. * @param environmentTexture defines the texture to use as environment texture
  126165. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  126166. * @param scale defines the overall scale of the skybox
  126167. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  126168. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  126169. * @returns a new mesh holding the sky box
  126170. */
  126171. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  126172. /**
  126173. * Creates a new environment
  126174. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  126175. * @param options defines the options you can use to configure the environment
  126176. * @returns the new EnvironmentHelper
  126177. */
  126178. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  126179. /**
  126180. * Creates a new VREXperienceHelper
  126181. * @see http://doc.babylonjs.com/how_to/webvr_helper
  126182. * @param webVROptions defines the options used to create the new VREXperienceHelper
  126183. * @returns a new VREXperienceHelper
  126184. */
  126185. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  126186. /**
  126187. * Creates a new WebXRDefaultExperience
  126188. * @see http://doc.babylonjs.com/how_to/webxr
  126189. * @param options experience options
  126190. * @returns a promise for a new WebXRDefaultExperience
  126191. */
  126192. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126193. }
  126194. }
  126195. declare module BABYLON {
  126196. /**
  126197. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  126198. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  126199. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  126200. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126201. */
  126202. export class VideoDome extends TransformNode {
  126203. /**
  126204. * Define the video source as a Monoscopic panoramic 360 video.
  126205. */
  126206. static readonly MODE_MONOSCOPIC: number;
  126207. /**
  126208. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  126209. */
  126210. static readonly MODE_TOPBOTTOM: number;
  126211. /**
  126212. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  126213. */
  126214. static readonly MODE_SIDEBYSIDE: number;
  126215. private _halfDome;
  126216. private _useDirectMapping;
  126217. /**
  126218. * The video texture being displayed on the sphere
  126219. */
  126220. protected _videoTexture: VideoTexture;
  126221. /**
  126222. * Gets the video texture being displayed on the sphere
  126223. */
  126224. get videoTexture(): VideoTexture;
  126225. /**
  126226. * The skybox material
  126227. */
  126228. protected _material: BackgroundMaterial;
  126229. /**
  126230. * The surface used for the skybox
  126231. */
  126232. protected _mesh: Mesh;
  126233. /**
  126234. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  126235. */
  126236. private _halfDomeMask;
  126237. /**
  126238. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126239. * Also see the options.resolution property.
  126240. */
  126241. get fovMultiplier(): number;
  126242. set fovMultiplier(value: number);
  126243. private _videoMode;
  126244. /**
  126245. * Gets or set the current video mode for the video. It can be:
  126246. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  126247. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  126248. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  126249. */
  126250. get videoMode(): number;
  126251. set videoMode(value: number);
  126252. /**
  126253. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  126254. *
  126255. */
  126256. get halfDome(): boolean;
  126257. /**
  126258. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  126259. */
  126260. set halfDome(enabled: boolean);
  126261. /**
  126262. * Oberserver used in Stereoscopic VR Mode.
  126263. */
  126264. private _onBeforeCameraRenderObserver;
  126265. /**
  126266. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  126267. * @param name Element's name, child elements will append suffixes for their own names.
  126268. * @param urlsOrVideo defines the url(s) or the video element to use
  126269. * @param options An object containing optional or exposed sub element properties
  126270. */
  126271. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  126272. resolution?: number;
  126273. clickToPlay?: boolean;
  126274. autoPlay?: boolean;
  126275. loop?: boolean;
  126276. size?: number;
  126277. poster?: string;
  126278. faceForward?: boolean;
  126279. useDirectMapping?: boolean;
  126280. halfDomeMode?: boolean;
  126281. }, scene: Scene);
  126282. private _changeVideoMode;
  126283. /**
  126284. * Releases resources associated with this node.
  126285. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126286. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126287. */
  126288. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126289. }
  126290. }
  126291. declare module BABYLON {
  126292. /**
  126293. * This class can be used to get instrumentation data from a Babylon engine
  126294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126295. */
  126296. export class EngineInstrumentation implements IDisposable {
  126297. /**
  126298. * Define the instrumented engine.
  126299. */
  126300. engine: Engine;
  126301. private _captureGPUFrameTime;
  126302. private _gpuFrameTimeToken;
  126303. private _gpuFrameTime;
  126304. private _captureShaderCompilationTime;
  126305. private _shaderCompilationTime;
  126306. private _onBeginFrameObserver;
  126307. private _onEndFrameObserver;
  126308. private _onBeforeShaderCompilationObserver;
  126309. private _onAfterShaderCompilationObserver;
  126310. /**
  126311. * Gets the perf counter used for GPU frame time
  126312. */
  126313. get gpuFrameTimeCounter(): PerfCounter;
  126314. /**
  126315. * Gets the GPU frame time capture status
  126316. */
  126317. get captureGPUFrameTime(): boolean;
  126318. /**
  126319. * Enable or disable the GPU frame time capture
  126320. */
  126321. set captureGPUFrameTime(value: boolean);
  126322. /**
  126323. * Gets the perf counter used for shader compilation time
  126324. */
  126325. get shaderCompilationTimeCounter(): PerfCounter;
  126326. /**
  126327. * Gets the shader compilation time capture status
  126328. */
  126329. get captureShaderCompilationTime(): boolean;
  126330. /**
  126331. * Enable or disable the shader compilation time capture
  126332. */
  126333. set captureShaderCompilationTime(value: boolean);
  126334. /**
  126335. * Instantiates a new engine instrumentation.
  126336. * This class can be used to get instrumentation data from a Babylon engine
  126337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126338. * @param engine Defines the engine to instrument
  126339. */
  126340. constructor(
  126341. /**
  126342. * Define the instrumented engine.
  126343. */
  126344. engine: Engine);
  126345. /**
  126346. * Dispose and release associated resources.
  126347. */
  126348. dispose(): void;
  126349. }
  126350. }
  126351. declare module BABYLON {
  126352. /**
  126353. * This class can be used to get instrumentation data from a Babylon engine
  126354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126355. */
  126356. export class SceneInstrumentation implements IDisposable {
  126357. /**
  126358. * Defines the scene to instrument
  126359. */
  126360. scene: Scene;
  126361. private _captureActiveMeshesEvaluationTime;
  126362. private _activeMeshesEvaluationTime;
  126363. private _captureRenderTargetsRenderTime;
  126364. private _renderTargetsRenderTime;
  126365. private _captureFrameTime;
  126366. private _frameTime;
  126367. private _captureRenderTime;
  126368. private _renderTime;
  126369. private _captureInterFrameTime;
  126370. private _interFrameTime;
  126371. private _captureParticlesRenderTime;
  126372. private _particlesRenderTime;
  126373. private _captureSpritesRenderTime;
  126374. private _spritesRenderTime;
  126375. private _capturePhysicsTime;
  126376. private _physicsTime;
  126377. private _captureAnimationsTime;
  126378. private _animationsTime;
  126379. private _captureCameraRenderTime;
  126380. private _cameraRenderTime;
  126381. private _onBeforeActiveMeshesEvaluationObserver;
  126382. private _onAfterActiveMeshesEvaluationObserver;
  126383. private _onBeforeRenderTargetsRenderObserver;
  126384. private _onAfterRenderTargetsRenderObserver;
  126385. private _onAfterRenderObserver;
  126386. private _onBeforeDrawPhaseObserver;
  126387. private _onAfterDrawPhaseObserver;
  126388. private _onBeforeAnimationsObserver;
  126389. private _onBeforeParticlesRenderingObserver;
  126390. private _onAfterParticlesRenderingObserver;
  126391. private _onBeforeSpritesRenderingObserver;
  126392. private _onAfterSpritesRenderingObserver;
  126393. private _onBeforePhysicsObserver;
  126394. private _onAfterPhysicsObserver;
  126395. private _onAfterAnimationsObserver;
  126396. private _onBeforeCameraRenderObserver;
  126397. private _onAfterCameraRenderObserver;
  126398. /**
  126399. * Gets the perf counter used for active meshes evaluation time
  126400. */
  126401. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  126402. /**
  126403. * Gets the active meshes evaluation time capture status
  126404. */
  126405. get captureActiveMeshesEvaluationTime(): boolean;
  126406. /**
  126407. * Enable or disable the active meshes evaluation time capture
  126408. */
  126409. set captureActiveMeshesEvaluationTime(value: boolean);
  126410. /**
  126411. * Gets the perf counter used for render targets render time
  126412. */
  126413. get renderTargetsRenderTimeCounter(): PerfCounter;
  126414. /**
  126415. * Gets the render targets render time capture status
  126416. */
  126417. get captureRenderTargetsRenderTime(): boolean;
  126418. /**
  126419. * Enable or disable the render targets render time capture
  126420. */
  126421. set captureRenderTargetsRenderTime(value: boolean);
  126422. /**
  126423. * Gets the perf counter used for particles render time
  126424. */
  126425. get particlesRenderTimeCounter(): PerfCounter;
  126426. /**
  126427. * Gets the particles render time capture status
  126428. */
  126429. get captureParticlesRenderTime(): boolean;
  126430. /**
  126431. * Enable or disable the particles render time capture
  126432. */
  126433. set captureParticlesRenderTime(value: boolean);
  126434. /**
  126435. * Gets the perf counter used for sprites render time
  126436. */
  126437. get spritesRenderTimeCounter(): PerfCounter;
  126438. /**
  126439. * Gets the sprites render time capture status
  126440. */
  126441. get captureSpritesRenderTime(): boolean;
  126442. /**
  126443. * Enable or disable the sprites render time capture
  126444. */
  126445. set captureSpritesRenderTime(value: boolean);
  126446. /**
  126447. * Gets the perf counter used for physics time
  126448. */
  126449. get physicsTimeCounter(): PerfCounter;
  126450. /**
  126451. * Gets the physics time capture status
  126452. */
  126453. get capturePhysicsTime(): boolean;
  126454. /**
  126455. * Enable or disable the physics time capture
  126456. */
  126457. set capturePhysicsTime(value: boolean);
  126458. /**
  126459. * Gets the perf counter used for animations time
  126460. */
  126461. get animationsTimeCounter(): PerfCounter;
  126462. /**
  126463. * Gets the animations time capture status
  126464. */
  126465. get captureAnimationsTime(): boolean;
  126466. /**
  126467. * Enable or disable the animations time capture
  126468. */
  126469. set captureAnimationsTime(value: boolean);
  126470. /**
  126471. * Gets the perf counter used for frame time capture
  126472. */
  126473. get frameTimeCounter(): PerfCounter;
  126474. /**
  126475. * Gets the frame time capture status
  126476. */
  126477. get captureFrameTime(): boolean;
  126478. /**
  126479. * Enable or disable the frame time capture
  126480. */
  126481. set captureFrameTime(value: boolean);
  126482. /**
  126483. * Gets the perf counter used for inter-frames time capture
  126484. */
  126485. get interFrameTimeCounter(): PerfCounter;
  126486. /**
  126487. * Gets the inter-frames time capture status
  126488. */
  126489. get captureInterFrameTime(): boolean;
  126490. /**
  126491. * Enable or disable the inter-frames time capture
  126492. */
  126493. set captureInterFrameTime(value: boolean);
  126494. /**
  126495. * Gets the perf counter used for render time capture
  126496. */
  126497. get renderTimeCounter(): PerfCounter;
  126498. /**
  126499. * Gets the render time capture status
  126500. */
  126501. get captureRenderTime(): boolean;
  126502. /**
  126503. * Enable or disable the render time capture
  126504. */
  126505. set captureRenderTime(value: boolean);
  126506. /**
  126507. * Gets the perf counter used for camera render time capture
  126508. */
  126509. get cameraRenderTimeCounter(): PerfCounter;
  126510. /**
  126511. * Gets the camera render time capture status
  126512. */
  126513. get captureCameraRenderTime(): boolean;
  126514. /**
  126515. * Enable or disable the camera render time capture
  126516. */
  126517. set captureCameraRenderTime(value: boolean);
  126518. /**
  126519. * Gets the perf counter used for draw calls
  126520. */
  126521. get drawCallsCounter(): PerfCounter;
  126522. /**
  126523. * Instantiates a new scene instrumentation.
  126524. * This class can be used to get instrumentation data from a Babylon engine
  126525. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126526. * @param scene Defines the scene to instrument
  126527. */
  126528. constructor(
  126529. /**
  126530. * Defines the scene to instrument
  126531. */
  126532. scene: Scene);
  126533. /**
  126534. * Dispose and release associated resources.
  126535. */
  126536. dispose(): void;
  126537. }
  126538. }
  126539. declare module BABYLON {
  126540. /** @hidden */
  126541. export var glowMapGenerationPixelShader: {
  126542. name: string;
  126543. shader: string;
  126544. };
  126545. }
  126546. declare module BABYLON {
  126547. /** @hidden */
  126548. export var glowMapGenerationVertexShader: {
  126549. name: string;
  126550. shader: string;
  126551. };
  126552. }
  126553. declare module BABYLON {
  126554. /**
  126555. * Effect layer options. This helps customizing the behaviour
  126556. * of the effect layer.
  126557. */
  126558. export interface IEffectLayerOptions {
  126559. /**
  126560. * Multiplication factor apply to the canvas size to compute the render target size
  126561. * used to generated the objects (the smaller the faster).
  126562. */
  126563. mainTextureRatio: number;
  126564. /**
  126565. * Enforces a fixed size texture to ensure effect stability across devices.
  126566. */
  126567. mainTextureFixedSize?: number;
  126568. /**
  126569. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126570. */
  126571. alphaBlendingMode: number;
  126572. /**
  126573. * The camera attached to the layer.
  126574. */
  126575. camera: Nullable<Camera>;
  126576. /**
  126577. * The rendering group to draw the layer in.
  126578. */
  126579. renderingGroupId: number;
  126580. }
  126581. /**
  126582. * The effect layer Helps adding post process effect blended with the main pass.
  126583. *
  126584. * This can be for instance use to generate glow or higlight effects on the scene.
  126585. *
  126586. * The effect layer class can not be used directly and is intented to inherited from to be
  126587. * customized per effects.
  126588. */
  126589. export abstract class EffectLayer {
  126590. private _vertexBuffers;
  126591. private _indexBuffer;
  126592. private _cachedDefines;
  126593. private _effectLayerMapGenerationEffect;
  126594. private _effectLayerOptions;
  126595. private _mergeEffect;
  126596. protected _scene: Scene;
  126597. protected _engine: Engine;
  126598. protected _maxSize: number;
  126599. protected _mainTextureDesiredSize: ISize;
  126600. protected _mainTexture: RenderTargetTexture;
  126601. protected _shouldRender: boolean;
  126602. protected _postProcesses: PostProcess[];
  126603. protected _textures: BaseTexture[];
  126604. protected _emissiveTextureAndColor: {
  126605. texture: Nullable<BaseTexture>;
  126606. color: Color4;
  126607. };
  126608. /**
  126609. * The name of the layer
  126610. */
  126611. name: string;
  126612. /**
  126613. * The clear color of the texture used to generate the glow map.
  126614. */
  126615. neutralColor: Color4;
  126616. /**
  126617. * Specifies whether the highlight layer is enabled or not.
  126618. */
  126619. isEnabled: boolean;
  126620. /**
  126621. * Gets the camera attached to the layer.
  126622. */
  126623. get camera(): Nullable<Camera>;
  126624. /**
  126625. * Gets the rendering group id the layer should render in.
  126626. */
  126627. get renderingGroupId(): number;
  126628. set renderingGroupId(renderingGroupId: number);
  126629. /**
  126630. * An event triggered when the effect layer has been disposed.
  126631. */
  126632. onDisposeObservable: Observable<EffectLayer>;
  126633. /**
  126634. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126635. */
  126636. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126637. /**
  126638. * An event triggered when the generated texture is being merged in the scene.
  126639. */
  126640. onBeforeComposeObservable: Observable<EffectLayer>;
  126641. /**
  126642. * An event triggered when the mesh is rendered into the effect render target.
  126643. */
  126644. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126645. /**
  126646. * An event triggered after the mesh has been rendered into the effect render target.
  126647. */
  126648. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126649. /**
  126650. * An event triggered when the generated texture has been merged in the scene.
  126651. */
  126652. onAfterComposeObservable: Observable<EffectLayer>;
  126653. /**
  126654. * An event triggered when the efffect layer changes its size.
  126655. */
  126656. onSizeChangedObservable: Observable<EffectLayer>;
  126657. /** @hidden */
  126658. static _SceneComponentInitialization: (scene: Scene) => void;
  126659. /**
  126660. * Instantiates a new effect Layer and references it in the scene.
  126661. * @param name The name of the layer
  126662. * @param scene The scene to use the layer in
  126663. */
  126664. constructor(
  126665. /** The Friendly of the effect in the scene */
  126666. name: string, scene: Scene);
  126667. /**
  126668. * Get the effect name of the layer.
  126669. * @return The effect name
  126670. */
  126671. abstract getEffectName(): string;
  126672. /**
  126673. * Checks for the readiness of the element composing the layer.
  126674. * @param subMesh the mesh to check for
  126675. * @param useInstances specify whether or not to use instances to render the mesh
  126676. * @return true if ready otherwise, false
  126677. */
  126678. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126679. /**
  126680. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126681. * @returns true if the effect requires stencil during the main canvas render pass.
  126682. */
  126683. abstract needStencil(): boolean;
  126684. /**
  126685. * Create the merge effect. This is the shader use to blit the information back
  126686. * to the main canvas at the end of the scene rendering.
  126687. * @returns The effect containing the shader used to merge the effect on the main canvas
  126688. */
  126689. protected abstract _createMergeEffect(): Effect;
  126690. /**
  126691. * Creates the render target textures and post processes used in the effect layer.
  126692. */
  126693. protected abstract _createTextureAndPostProcesses(): void;
  126694. /**
  126695. * Implementation specific of rendering the generating effect on the main canvas.
  126696. * @param effect The effect used to render through
  126697. */
  126698. protected abstract _internalRender(effect: Effect): void;
  126699. /**
  126700. * Sets the required values for both the emissive texture and and the main color.
  126701. */
  126702. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126703. /**
  126704. * Free any resources and references associated to a mesh.
  126705. * Internal use
  126706. * @param mesh The mesh to free.
  126707. */
  126708. abstract _disposeMesh(mesh: Mesh): void;
  126709. /**
  126710. * Serializes this layer (Glow or Highlight for example)
  126711. * @returns a serialized layer object
  126712. */
  126713. abstract serialize?(): any;
  126714. /**
  126715. * Initializes the effect layer with the required options.
  126716. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126717. */
  126718. protected _init(options: Partial<IEffectLayerOptions>): void;
  126719. /**
  126720. * Generates the index buffer of the full screen quad blending to the main canvas.
  126721. */
  126722. private _generateIndexBuffer;
  126723. /**
  126724. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126725. */
  126726. private _generateVertexBuffer;
  126727. /**
  126728. * Sets the main texture desired size which is the closest power of two
  126729. * of the engine canvas size.
  126730. */
  126731. private _setMainTextureSize;
  126732. /**
  126733. * Creates the main texture for the effect layer.
  126734. */
  126735. protected _createMainTexture(): void;
  126736. /**
  126737. * Adds specific effects defines.
  126738. * @param defines The defines to add specifics to.
  126739. */
  126740. protected _addCustomEffectDefines(defines: string[]): void;
  126741. /**
  126742. * Checks for the readiness of the element composing the layer.
  126743. * @param subMesh the mesh to check for
  126744. * @param useInstances specify whether or not to use instances to render the mesh
  126745. * @param emissiveTexture the associated emissive texture used to generate the glow
  126746. * @return true if ready otherwise, false
  126747. */
  126748. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126749. /**
  126750. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126751. */
  126752. render(): void;
  126753. /**
  126754. * Determine if a given mesh will be used in the current effect.
  126755. * @param mesh mesh to test
  126756. * @returns true if the mesh will be used
  126757. */
  126758. hasMesh(mesh: AbstractMesh): boolean;
  126759. /**
  126760. * Returns true if the layer contains information to display, otherwise false.
  126761. * @returns true if the glow layer should be rendered
  126762. */
  126763. shouldRender(): boolean;
  126764. /**
  126765. * Returns true if the mesh should render, otherwise false.
  126766. * @param mesh The mesh to render
  126767. * @returns true if it should render otherwise false
  126768. */
  126769. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126770. /**
  126771. * Returns true if the mesh can be rendered, otherwise false.
  126772. * @param mesh The mesh to render
  126773. * @param material The material used on the mesh
  126774. * @returns true if it can be rendered otherwise false
  126775. */
  126776. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126777. /**
  126778. * Returns true if the mesh should render, otherwise false.
  126779. * @param mesh The mesh to render
  126780. * @returns true if it should render otherwise false
  126781. */
  126782. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126783. /**
  126784. * Renders the submesh passed in parameter to the generation map.
  126785. */
  126786. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126787. /**
  126788. * Defines whether the current material of the mesh should be use to render the effect.
  126789. * @param mesh defines the current mesh to render
  126790. */
  126791. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126792. /**
  126793. * Rebuild the required buffers.
  126794. * @hidden Internal use only.
  126795. */
  126796. _rebuild(): void;
  126797. /**
  126798. * Dispose only the render target textures and post process.
  126799. */
  126800. private _disposeTextureAndPostProcesses;
  126801. /**
  126802. * Dispose the highlight layer and free resources.
  126803. */
  126804. dispose(): void;
  126805. /**
  126806. * Gets the class name of the effect layer
  126807. * @returns the string with the class name of the effect layer
  126808. */
  126809. getClassName(): string;
  126810. /**
  126811. * Creates an effect layer from parsed effect layer data
  126812. * @param parsedEffectLayer defines effect layer data
  126813. * @param scene defines the current scene
  126814. * @param rootUrl defines the root URL containing the effect layer information
  126815. * @returns a parsed effect Layer
  126816. */
  126817. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126818. }
  126819. }
  126820. declare module BABYLON {
  126821. interface AbstractScene {
  126822. /**
  126823. * The list of effect layers (highlights/glow) added to the scene
  126824. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126825. * @see http://doc.babylonjs.com/how_to/glow_layer
  126826. */
  126827. effectLayers: Array<EffectLayer>;
  126828. /**
  126829. * Removes the given effect layer from this scene.
  126830. * @param toRemove defines the effect layer to remove
  126831. * @returns the index of the removed effect layer
  126832. */
  126833. removeEffectLayer(toRemove: EffectLayer): number;
  126834. /**
  126835. * Adds the given effect layer to this scene
  126836. * @param newEffectLayer defines the effect layer to add
  126837. */
  126838. addEffectLayer(newEffectLayer: EffectLayer): void;
  126839. }
  126840. /**
  126841. * Defines the layer scene component responsible to manage any effect layers
  126842. * in a given scene.
  126843. */
  126844. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126845. /**
  126846. * The component name helpfull to identify the component in the list of scene components.
  126847. */
  126848. readonly name: string;
  126849. /**
  126850. * The scene the component belongs to.
  126851. */
  126852. scene: Scene;
  126853. private _engine;
  126854. private _renderEffects;
  126855. private _needStencil;
  126856. private _previousStencilState;
  126857. /**
  126858. * Creates a new instance of the component for the given scene
  126859. * @param scene Defines the scene to register the component in
  126860. */
  126861. constructor(scene: Scene);
  126862. /**
  126863. * Registers the component in a given scene
  126864. */
  126865. register(): void;
  126866. /**
  126867. * Rebuilds the elements related to this component in case of
  126868. * context lost for instance.
  126869. */
  126870. rebuild(): void;
  126871. /**
  126872. * Serializes the component data to the specified json object
  126873. * @param serializationObject The object to serialize to
  126874. */
  126875. serialize(serializationObject: any): void;
  126876. /**
  126877. * Adds all the elements from the container to the scene
  126878. * @param container the container holding the elements
  126879. */
  126880. addFromContainer(container: AbstractScene): void;
  126881. /**
  126882. * Removes all the elements in the container from the scene
  126883. * @param container contains the elements to remove
  126884. * @param dispose if the removed element should be disposed (default: false)
  126885. */
  126886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126887. /**
  126888. * Disposes the component and the associated ressources.
  126889. */
  126890. dispose(): void;
  126891. private _isReadyForMesh;
  126892. private _renderMainTexture;
  126893. private _setStencil;
  126894. private _setStencilBack;
  126895. private _draw;
  126896. private _drawCamera;
  126897. private _drawRenderingGroup;
  126898. }
  126899. }
  126900. declare module BABYLON {
  126901. /** @hidden */
  126902. export var glowMapMergePixelShader: {
  126903. name: string;
  126904. shader: string;
  126905. };
  126906. }
  126907. declare module BABYLON {
  126908. /** @hidden */
  126909. export var glowMapMergeVertexShader: {
  126910. name: string;
  126911. shader: string;
  126912. };
  126913. }
  126914. declare module BABYLON {
  126915. interface AbstractScene {
  126916. /**
  126917. * Return a the first highlight layer of the scene with a given name.
  126918. * @param name The name of the highlight layer to look for.
  126919. * @return The highlight layer if found otherwise null.
  126920. */
  126921. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126922. }
  126923. /**
  126924. * Glow layer options. This helps customizing the behaviour
  126925. * of the glow layer.
  126926. */
  126927. export interface IGlowLayerOptions {
  126928. /**
  126929. * Multiplication factor apply to the canvas size to compute the render target size
  126930. * used to generated the glowing objects (the smaller the faster).
  126931. */
  126932. mainTextureRatio: number;
  126933. /**
  126934. * Enforces a fixed size texture to ensure resize independant blur.
  126935. */
  126936. mainTextureFixedSize?: number;
  126937. /**
  126938. * How big is the kernel of the blur texture.
  126939. */
  126940. blurKernelSize: number;
  126941. /**
  126942. * The camera attached to the layer.
  126943. */
  126944. camera: Nullable<Camera>;
  126945. /**
  126946. * Enable MSAA by chosing the number of samples.
  126947. */
  126948. mainTextureSamples?: number;
  126949. /**
  126950. * The rendering group to draw the layer in.
  126951. */
  126952. renderingGroupId: number;
  126953. }
  126954. /**
  126955. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126956. *
  126957. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126958. *
  126959. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126960. */
  126961. export class GlowLayer extends EffectLayer {
  126962. /**
  126963. * Effect Name of the layer.
  126964. */
  126965. static readonly EffectName: string;
  126966. /**
  126967. * The default blur kernel size used for the glow.
  126968. */
  126969. static DefaultBlurKernelSize: number;
  126970. /**
  126971. * The default texture size ratio used for the glow.
  126972. */
  126973. static DefaultTextureRatio: number;
  126974. /**
  126975. * Sets the kernel size of the blur.
  126976. */
  126977. set blurKernelSize(value: number);
  126978. /**
  126979. * Gets the kernel size of the blur.
  126980. */
  126981. get blurKernelSize(): number;
  126982. /**
  126983. * Sets the glow intensity.
  126984. */
  126985. set intensity(value: number);
  126986. /**
  126987. * Gets the glow intensity.
  126988. */
  126989. get intensity(): number;
  126990. private _options;
  126991. private _intensity;
  126992. private _horizontalBlurPostprocess1;
  126993. private _verticalBlurPostprocess1;
  126994. private _horizontalBlurPostprocess2;
  126995. private _verticalBlurPostprocess2;
  126996. private _blurTexture1;
  126997. private _blurTexture2;
  126998. private _postProcesses1;
  126999. private _postProcesses2;
  127000. private _includedOnlyMeshes;
  127001. private _excludedMeshes;
  127002. private _meshesUsingTheirOwnMaterials;
  127003. /**
  127004. * Callback used to let the user override the color selection on a per mesh basis
  127005. */
  127006. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  127007. /**
  127008. * Callback used to let the user override the texture selection on a per mesh basis
  127009. */
  127010. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  127011. /**
  127012. * Instantiates a new glow Layer and references it to the scene.
  127013. * @param name The name of the layer
  127014. * @param scene The scene to use the layer in
  127015. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  127016. */
  127017. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  127018. /**
  127019. * Get the effect name of the layer.
  127020. * @return The effect name
  127021. */
  127022. getEffectName(): string;
  127023. /**
  127024. * Create the merge effect. This is the shader use to blit the information back
  127025. * to the main canvas at the end of the scene rendering.
  127026. */
  127027. protected _createMergeEffect(): Effect;
  127028. /**
  127029. * Creates the render target textures and post processes used in the glow layer.
  127030. */
  127031. protected _createTextureAndPostProcesses(): void;
  127032. /**
  127033. * Checks for the readiness of the element composing the layer.
  127034. * @param subMesh the mesh to check for
  127035. * @param useInstances specify wether or not to use instances to render the mesh
  127036. * @param emissiveTexture the associated emissive texture used to generate the glow
  127037. * @return true if ready otherwise, false
  127038. */
  127039. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127040. /**
  127041. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127042. */
  127043. needStencil(): boolean;
  127044. /**
  127045. * Returns true if the mesh can be rendered, otherwise false.
  127046. * @param mesh The mesh to render
  127047. * @param material The material used on the mesh
  127048. * @returns true if it can be rendered otherwise false
  127049. */
  127050. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127051. /**
  127052. * Implementation specific of rendering the generating effect on the main canvas.
  127053. * @param effect The effect used to render through
  127054. */
  127055. protected _internalRender(effect: Effect): void;
  127056. /**
  127057. * Sets the required values for both the emissive texture and and the main color.
  127058. */
  127059. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127060. /**
  127061. * Returns true if the mesh should render, otherwise false.
  127062. * @param mesh The mesh to render
  127063. * @returns true if it should render otherwise false
  127064. */
  127065. protected _shouldRenderMesh(mesh: Mesh): boolean;
  127066. /**
  127067. * Adds specific effects defines.
  127068. * @param defines The defines to add specifics to.
  127069. */
  127070. protected _addCustomEffectDefines(defines: string[]): void;
  127071. /**
  127072. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  127073. * @param mesh The mesh to exclude from the glow layer
  127074. */
  127075. addExcludedMesh(mesh: Mesh): void;
  127076. /**
  127077. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  127078. * @param mesh The mesh to remove
  127079. */
  127080. removeExcludedMesh(mesh: Mesh): void;
  127081. /**
  127082. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  127083. * @param mesh The mesh to include in the glow layer
  127084. */
  127085. addIncludedOnlyMesh(mesh: Mesh): void;
  127086. /**
  127087. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  127088. * @param mesh The mesh to remove
  127089. */
  127090. removeIncludedOnlyMesh(mesh: Mesh): void;
  127091. /**
  127092. * Determine if a given mesh will be used in the glow layer
  127093. * @param mesh The mesh to test
  127094. * @returns true if the mesh will be highlighted by the current glow layer
  127095. */
  127096. hasMesh(mesh: AbstractMesh): boolean;
  127097. /**
  127098. * Defines whether the current material of the mesh should be use to render the effect.
  127099. * @param mesh defines the current mesh to render
  127100. */
  127101. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127102. /**
  127103. * Add a mesh to be rendered through its own material and not with emissive only.
  127104. * @param mesh The mesh for which we need to use its material
  127105. */
  127106. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  127107. /**
  127108. * Remove a mesh from being rendered through its own material and not with emissive only.
  127109. * @param mesh The mesh for which we need to not use its material
  127110. */
  127111. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  127112. /**
  127113. * Free any resources and references associated to a mesh.
  127114. * Internal use
  127115. * @param mesh The mesh to free.
  127116. * @hidden
  127117. */
  127118. _disposeMesh(mesh: Mesh): void;
  127119. /**
  127120. * Gets the class name of the effect layer
  127121. * @returns the string with the class name of the effect layer
  127122. */
  127123. getClassName(): string;
  127124. /**
  127125. * Serializes this glow layer
  127126. * @returns a serialized glow layer object
  127127. */
  127128. serialize(): any;
  127129. /**
  127130. * Creates a Glow Layer from parsed glow layer data
  127131. * @param parsedGlowLayer defines glow layer data
  127132. * @param scene defines the current scene
  127133. * @param rootUrl defines the root URL containing the glow layer information
  127134. * @returns a parsed Glow Layer
  127135. */
  127136. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  127137. }
  127138. }
  127139. declare module BABYLON {
  127140. /** @hidden */
  127141. export var glowBlurPostProcessPixelShader: {
  127142. name: string;
  127143. shader: string;
  127144. };
  127145. }
  127146. declare module BABYLON {
  127147. interface AbstractScene {
  127148. /**
  127149. * Return a the first highlight layer of the scene with a given name.
  127150. * @param name The name of the highlight layer to look for.
  127151. * @return The highlight layer if found otherwise null.
  127152. */
  127153. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  127154. }
  127155. /**
  127156. * Highlight layer options. This helps customizing the behaviour
  127157. * of the highlight layer.
  127158. */
  127159. export interface IHighlightLayerOptions {
  127160. /**
  127161. * Multiplication factor apply to the canvas size to compute the render target size
  127162. * used to generated the glowing objects (the smaller the faster).
  127163. */
  127164. mainTextureRatio: number;
  127165. /**
  127166. * Enforces a fixed size texture to ensure resize independant blur.
  127167. */
  127168. mainTextureFixedSize?: number;
  127169. /**
  127170. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  127171. * of the picture to blur (the smaller the faster).
  127172. */
  127173. blurTextureSizeRatio: number;
  127174. /**
  127175. * How big in texel of the blur texture is the vertical blur.
  127176. */
  127177. blurVerticalSize: number;
  127178. /**
  127179. * How big in texel of the blur texture is the horizontal blur.
  127180. */
  127181. blurHorizontalSize: number;
  127182. /**
  127183. * Alpha blending mode used to apply the blur. Default is combine.
  127184. */
  127185. alphaBlendingMode: number;
  127186. /**
  127187. * The camera attached to the layer.
  127188. */
  127189. camera: Nullable<Camera>;
  127190. /**
  127191. * Should we display highlight as a solid stroke?
  127192. */
  127193. isStroke?: boolean;
  127194. /**
  127195. * The rendering group to draw the layer in.
  127196. */
  127197. renderingGroupId: number;
  127198. }
  127199. /**
  127200. * The highlight layer Helps adding a glow effect around a mesh.
  127201. *
  127202. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  127203. * glowy meshes to your scene.
  127204. *
  127205. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  127206. */
  127207. export class HighlightLayer extends EffectLayer {
  127208. name: string;
  127209. /**
  127210. * Effect Name of the highlight layer.
  127211. */
  127212. static readonly EffectName: string;
  127213. /**
  127214. * The neutral color used during the preparation of the glow effect.
  127215. * This is black by default as the blend operation is a blend operation.
  127216. */
  127217. static NeutralColor: Color4;
  127218. /**
  127219. * Stencil value used for glowing meshes.
  127220. */
  127221. static GlowingMeshStencilReference: number;
  127222. /**
  127223. * Stencil value used for the other meshes in the scene.
  127224. */
  127225. static NormalMeshStencilReference: number;
  127226. /**
  127227. * Specifies whether or not the inner glow is ACTIVE in the layer.
  127228. */
  127229. innerGlow: boolean;
  127230. /**
  127231. * Specifies whether or not the outer glow is ACTIVE in the layer.
  127232. */
  127233. outerGlow: boolean;
  127234. /**
  127235. * Specifies the horizontal size of the blur.
  127236. */
  127237. set blurHorizontalSize(value: number);
  127238. /**
  127239. * Specifies the vertical size of the blur.
  127240. */
  127241. set blurVerticalSize(value: number);
  127242. /**
  127243. * Gets the horizontal size of the blur.
  127244. */
  127245. get blurHorizontalSize(): number;
  127246. /**
  127247. * Gets the vertical size of the blur.
  127248. */
  127249. get blurVerticalSize(): number;
  127250. /**
  127251. * An event triggered when the highlight layer is being blurred.
  127252. */
  127253. onBeforeBlurObservable: Observable<HighlightLayer>;
  127254. /**
  127255. * An event triggered when the highlight layer has been blurred.
  127256. */
  127257. onAfterBlurObservable: Observable<HighlightLayer>;
  127258. private _instanceGlowingMeshStencilReference;
  127259. private _options;
  127260. private _downSamplePostprocess;
  127261. private _horizontalBlurPostprocess;
  127262. private _verticalBlurPostprocess;
  127263. private _blurTexture;
  127264. private _meshes;
  127265. private _excludedMeshes;
  127266. /**
  127267. * Instantiates a new highlight Layer and references it to the scene..
  127268. * @param name The name of the layer
  127269. * @param scene The scene to use the layer in
  127270. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  127271. */
  127272. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  127273. /**
  127274. * Get the effect name of the layer.
  127275. * @return The effect name
  127276. */
  127277. getEffectName(): string;
  127278. /**
  127279. * Create the merge effect. This is the shader use to blit the information back
  127280. * to the main canvas at the end of the scene rendering.
  127281. */
  127282. protected _createMergeEffect(): Effect;
  127283. /**
  127284. * Creates the render target textures and post processes used in the highlight layer.
  127285. */
  127286. protected _createTextureAndPostProcesses(): void;
  127287. /**
  127288. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  127289. */
  127290. needStencil(): boolean;
  127291. /**
  127292. * Checks for the readiness of the element composing the layer.
  127293. * @param subMesh the mesh to check for
  127294. * @param useInstances specify wether or not to use instances to render the mesh
  127295. * @param emissiveTexture the associated emissive texture used to generate the glow
  127296. * @return true if ready otherwise, false
  127297. */
  127298. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127299. /**
  127300. * Implementation specific of rendering the generating effect on the main canvas.
  127301. * @param effect The effect used to render through
  127302. */
  127303. protected _internalRender(effect: Effect): void;
  127304. /**
  127305. * Returns true if the layer contains information to display, otherwise false.
  127306. */
  127307. shouldRender(): boolean;
  127308. /**
  127309. * Returns true if the mesh should render, otherwise false.
  127310. * @param mesh The mesh to render
  127311. * @returns true if it should render otherwise false
  127312. */
  127313. protected _shouldRenderMesh(mesh: Mesh): boolean;
  127314. /**
  127315. * Sets the required values for both the emissive texture and and the main color.
  127316. */
  127317. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127318. /**
  127319. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  127320. * @param mesh The mesh to exclude from the highlight layer
  127321. */
  127322. addExcludedMesh(mesh: Mesh): void;
  127323. /**
  127324. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  127325. * @param mesh The mesh to highlight
  127326. */
  127327. removeExcludedMesh(mesh: Mesh): void;
  127328. /**
  127329. * Determine if a given mesh will be highlighted by the current HighlightLayer
  127330. * @param mesh mesh to test
  127331. * @returns true if the mesh will be highlighted by the current HighlightLayer
  127332. */
  127333. hasMesh(mesh: AbstractMesh): boolean;
  127334. /**
  127335. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  127336. * @param mesh The mesh to highlight
  127337. * @param color The color of the highlight
  127338. * @param glowEmissiveOnly Extract the glow from the emissive texture
  127339. */
  127340. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  127341. /**
  127342. * Remove a mesh from the highlight layer in order to make it stop glowing.
  127343. * @param mesh The mesh to highlight
  127344. */
  127345. removeMesh(mesh: Mesh): void;
  127346. /**
  127347. * Remove all the meshes currently referenced in the highlight layer
  127348. */
  127349. removeAllMeshes(): void;
  127350. /**
  127351. * Force the stencil to the normal expected value for none glowing parts
  127352. */
  127353. private _defaultStencilReference;
  127354. /**
  127355. * Free any resources and references associated to a mesh.
  127356. * Internal use
  127357. * @param mesh The mesh to free.
  127358. * @hidden
  127359. */
  127360. _disposeMesh(mesh: Mesh): void;
  127361. /**
  127362. * Dispose the highlight layer and free resources.
  127363. */
  127364. dispose(): void;
  127365. /**
  127366. * Gets the class name of the effect layer
  127367. * @returns the string with the class name of the effect layer
  127368. */
  127369. getClassName(): string;
  127370. /**
  127371. * Serializes this Highlight layer
  127372. * @returns a serialized Highlight layer object
  127373. */
  127374. serialize(): any;
  127375. /**
  127376. * Creates a Highlight layer from parsed Highlight layer data
  127377. * @param parsedHightlightLayer defines the Highlight layer data
  127378. * @param scene defines the current scene
  127379. * @param rootUrl defines the root URL containing the Highlight layer information
  127380. * @returns a parsed Highlight layer
  127381. */
  127382. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  127383. }
  127384. }
  127385. declare module BABYLON {
  127386. interface AbstractScene {
  127387. /**
  127388. * The list of layers (background and foreground) of the scene
  127389. */
  127390. layers: Array<Layer>;
  127391. }
  127392. /**
  127393. * Defines the layer scene component responsible to manage any layers
  127394. * in a given scene.
  127395. */
  127396. export class LayerSceneComponent implements ISceneComponent {
  127397. /**
  127398. * The component name helpfull to identify the component in the list of scene components.
  127399. */
  127400. readonly name: string;
  127401. /**
  127402. * The scene the component belongs to.
  127403. */
  127404. scene: Scene;
  127405. private _engine;
  127406. /**
  127407. * Creates a new instance of the component for the given scene
  127408. * @param scene Defines the scene to register the component in
  127409. */
  127410. constructor(scene: Scene);
  127411. /**
  127412. * Registers the component in a given scene
  127413. */
  127414. register(): void;
  127415. /**
  127416. * Rebuilds the elements related to this component in case of
  127417. * context lost for instance.
  127418. */
  127419. rebuild(): void;
  127420. /**
  127421. * Disposes the component and the associated ressources.
  127422. */
  127423. dispose(): void;
  127424. private _draw;
  127425. private _drawCameraPredicate;
  127426. private _drawCameraBackground;
  127427. private _drawCameraForeground;
  127428. private _drawRenderTargetPredicate;
  127429. private _drawRenderTargetBackground;
  127430. private _drawRenderTargetForeground;
  127431. /**
  127432. * Adds all the elements from the container to the scene
  127433. * @param container the container holding the elements
  127434. */
  127435. addFromContainer(container: AbstractScene): void;
  127436. /**
  127437. * Removes all the elements in the container from the scene
  127438. * @param container contains the elements to remove
  127439. * @param dispose if the removed element should be disposed (default: false)
  127440. */
  127441. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127442. }
  127443. }
  127444. declare module BABYLON {
  127445. /** @hidden */
  127446. export var layerPixelShader: {
  127447. name: string;
  127448. shader: string;
  127449. };
  127450. }
  127451. declare module BABYLON {
  127452. /** @hidden */
  127453. export var layerVertexShader: {
  127454. name: string;
  127455. shader: string;
  127456. };
  127457. }
  127458. declare module BABYLON {
  127459. /**
  127460. * This represents a full screen 2d layer.
  127461. * This can be useful to display a picture in the background of your scene for instance.
  127462. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127463. */
  127464. export class Layer {
  127465. /**
  127466. * Define the name of the layer.
  127467. */
  127468. name: string;
  127469. /**
  127470. * Define the texture the layer should display.
  127471. */
  127472. texture: Nullable<Texture>;
  127473. /**
  127474. * Is the layer in background or foreground.
  127475. */
  127476. isBackground: boolean;
  127477. /**
  127478. * Define the color of the layer (instead of texture).
  127479. */
  127480. color: Color4;
  127481. /**
  127482. * Define the scale of the layer in order to zoom in out of the texture.
  127483. */
  127484. scale: Vector2;
  127485. /**
  127486. * Define an offset for the layer in order to shift the texture.
  127487. */
  127488. offset: Vector2;
  127489. /**
  127490. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  127491. */
  127492. alphaBlendingMode: number;
  127493. /**
  127494. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  127495. * Alpha test will not mix with the background color in case of transparency.
  127496. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  127497. */
  127498. alphaTest: boolean;
  127499. /**
  127500. * Define a mask to restrict the layer to only some of the scene cameras.
  127501. */
  127502. layerMask: number;
  127503. /**
  127504. * Define the list of render target the layer is visible into.
  127505. */
  127506. renderTargetTextures: RenderTargetTexture[];
  127507. /**
  127508. * Define if the layer is only used in renderTarget or if it also
  127509. * renders in the main frame buffer of the canvas.
  127510. */
  127511. renderOnlyInRenderTargetTextures: boolean;
  127512. private _scene;
  127513. private _vertexBuffers;
  127514. private _indexBuffer;
  127515. private _effect;
  127516. private _previousDefines;
  127517. /**
  127518. * An event triggered when the layer is disposed.
  127519. */
  127520. onDisposeObservable: Observable<Layer>;
  127521. private _onDisposeObserver;
  127522. /**
  127523. * Back compatibility with callback before the onDisposeObservable existed.
  127524. * The set callback will be triggered when the layer has been disposed.
  127525. */
  127526. set onDispose(callback: () => void);
  127527. /**
  127528. * An event triggered before rendering the scene
  127529. */
  127530. onBeforeRenderObservable: Observable<Layer>;
  127531. private _onBeforeRenderObserver;
  127532. /**
  127533. * Back compatibility with callback before the onBeforeRenderObservable existed.
  127534. * The set callback will be triggered just before rendering the layer.
  127535. */
  127536. set onBeforeRender(callback: () => void);
  127537. /**
  127538. * An event triggered after rendering the scene
  127539. */
  127540. onAfterRenderObservable: Observable<Layer>;
  127541. private _onAfterRenderObserver;
  127542. /**
  127543. * Back compatibility with callback before the onAfterRenderObservable existed.
  127544. * The set callback will be triggered just after rendering the layer.
  127545. */
  127546. set onAfterRender(callback: () => void);
  127547. /**
  127548. * Instantiates a new layer.
  127549. * This represents a full screen 2d layer.
  127550. * This can be useful to display a picture in the background of your scene for instance.
  127551. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127552. * @param name Define the name of the layer in the scene
  127553. * @param imgUrl Define the url of the texture to display in the layer
  127554. * @param scene Define the scene the layer belongs to
  127555. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127556. * @param color Defines a color for the layer
  127557. */
  127558. constructor(
  127559. /**
  127560. * Define the name of the layer.
  127561. */
  127562. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127563. private _createIndexBuffer;
  127564. /** @hidden */
  127565. _rebuild(): void;
  127566. /**
  127567. * Renders the layer in the scene.
  127568. */
  127569. render(): void;
  127570. /**
  127571. * Disposes and releases the associated ressources.
  127572. */
  127573. dispose(): void;
  127574. }
  127575. }
  127576. declare module BABYLON {
  127577. /** @hidden */
  127578. export var lensFlarePixelShader: {
  127579. name: string;
  127580. shader: string;
  127581. };
  127582. }
  127583. declare module BABYLON {
  127584. /** @hidden */
  127585. export var lensFlareVertexShader: {
  127586. name: string;
  127587. shader: string;
  127588. };
  127589. }
  127590. declare module BABYLON {
  127591. /**
  127592. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127593. * It is usually composed of several `lensFlare`.
  127594. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127595. */
  127596. export class LensFlareSystem {
  127597. /**
  127598. * Define the name of the lens flare system
  127599. */
  127600. name: string;
  127601. /**
  127602. * List of lens flares used in this system.
  127603. */
  127604. lensFlares: LensFlare[];
  127605. /**
  127606. * Define a limit from the border the lens flare can be visible.
  127607. */
  127608. borderLimit: number;
  127609. /**
  127610. * Define a viewport border we do not want to see the lens flare in.
  127611. */
  127612. viewportBorder: number;
  127613. /**
  127614. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127615. */
  127616. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127617. /**
  127618. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127619. */
  127620. layerMask: number;
  127621. /**
  127622. * Define the id of the lens flare system in the scene.
  127623. * (equal to name by default)
  127624. */
  127625. id: string;
  127626. private _scene;
  127627. private _emitter;
  127628. private _vertexBuffers;
  127629. private _indexBuffer;
  127630. private _effect;
  127631. private _positionX;
  127632. private _positionY;
  127633. private _isEnabled;
  127634. /** @hidden */
  127635. static _SceneComponentInitialization: (scene: Scene) => void;
  127636. /**
  127637. * Instantiates a lens flare system.
  127638. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127639. * It is usually composed of several `lensFlare`.
  127640. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127641. * @param name Define the name of the lens flare system in the scene
  127642. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127643. * @param scene Define the scene the lens flare system belongs to
  127644. */
  127645. constructor(
  127646. /**
  127647. * Define the name of the lens flare system
  127648. */
  127649. name: string, emitter: any, scene: Scene);
  127650. /**
  127651. * Define if the lens flare system is enabled.
  127652. */
  127653. get isEnabled(): boolean;
  127654. set isEnabled(value: boolean);
  127655. /**
  127656. * Get the scene the effects belongs to.
  127657. * @returns the scene holding the lens flare system
  127658. */
  127659. getScene(): Scene;
  127660. /**
  127661. * Get the emitter of the lens flare system.
  127662. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127663. * @returns the emitter of the lens flare system
  127664. */
  127665. getEmitter(): any;
  127666. /**
  127667. * Set the emitter of the lens flare system.
  127668. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127669. * @param newEmitter Define the new emitter of the system
  127670. */
  127671. setEmitter(newEmitter: any): void;
  127672. /**
  127673. * Get the lens flare system emitter position.
  127674. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127675. * @returns the position
  127676. */
  127677. getEmitterPosition(): Vector3;
  127678. /**
  127679. * @hidden
  127680. */
  127681. computeEffectivePosition(globalViewport: Viewport): boolean;
  127682. /** @hidden */
  127683. _isVisible(): boolean;
  127684. /**
  127685. * @hidden
  127686. */
  127687. render(): boolean;
  127688. /**
  127689. * Dispose and release the lens flare with its associated resources.
  127690. */
  127691. dispose(): void;
  127692. /**
  127693. * Parse a lens flare system from a JSON repressentation
  127694. * @param parsedLensFlareSystem Define the JSON to parse
  127695. * @param scene Define the scene the parsed system should be instantiated in
  127696. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127697. * @returns the parsed system
  127698. */
  127699. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127700. /**
  127701. * Serialize the current Lens Flare System into a JSON representation.
  127702. * @returns the serialized JSON
  127703. */
  127704. serialize(): any;
  127705. }
  127706. }
  127707. declare module BABYLON {
  127708. /**
  127709. * This represents one of the lens effect in a `lensFlareSystem`.
  127710. * It controls one of the indiviual texture used in the effect.
  127711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127712. */
  127713. export class LensFlare {
  127714. /**
  127715. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127716. */
  127717. size: number;
  127718. /**
  127719. * 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.
  127720. */
  127721. position: number;
  127722. /**
  127723. * Define the lens color.
  127724. */
  127725. color: Color3;
  127726. /**
  127727. * Define the lens texture.
  127728. */
  127729. texture: Nullable<Texture>;
  127730. /**
  127731. * Define the alpha mode to render this particular lens.
  127732. */
  127733. alphaMode: number;
  127734. private _system;
  127735. /**
  127736. * Creates a new Lens Flare.
  127737. * This represents one of the lens effect in a `lensFlareSystem`.
  127738. * It controls one of the indiviual texture used in the effect.
  127739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127740. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127741. * @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.
  127742. * @param color Define the lens color
  127743. * @param imgUrl Define the lens texture url
  127744. * @param system Define the `lensFlareSystem` this flare is part of
  127745. * @returns The newly created Lens Flare
  127746. */
  127747. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127748. /**
  127749. * Instantiates a new Lens Flare.
  127750. * This represents one of the lens effect in a `lensFlareSystem`.
  127751. * It controls one of the indiviual texture used in the effect.
  127752. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127753. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127754. * @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.
  127755. * @param color Define the lens color
  127756. * @param imgUrl Define the lens texture url
  127757. * @param system Define the `lensFlareSystem` this flare is part of
  127758. */
  127759. constructor(
  127760. /**
  127761. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127762. */
  127763. size: number,
  127764. /**
  127765. * 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.
  127766. */
  127767. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127768. /**
  127769. * Dispose and release the lens flare with its associated resources.
  127770. */
  127771. dispose(): void;
  127772. }
  127773. }
  127774. declare module BABYLON {
  127775. interface AbstractScene {
  127776. /**
  127777. * The list of lens flare system added to the scene
  127778. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127779. */
  127780. lensFlareSystems: Array<LensFlareSystem>;
  127781. /**
  127782. * Removes the given lens flare system from this scene.
  127783. * @param toRemove The lens flare system to remove
  127784. * @returns The index of the removed lens flare system
  127785. */
  127786. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127787. /**
  127788. * Adds the given lens flare system to this scene
  127789. * @param newLensFlareSystem The lens flare system to add
  127790. */
  127791. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127792. /**
  127793. * Gets a lens flare system using its name
  127794. * @param name defines the name to look for
  127795. * @returns the lens flare system or null if not found
  127796. */
  127797. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127798. /**
  127799. * Gets a lens flare system using its id
  127800. * @param id defines the id to look for
  127801. * @returns the lens flare system or null if not found
  127802. */
  127803. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127804. }
  127805. /**
  127806. * Defines the lens flare scene component responsible to manage any lens flares
  127807. * in a given scene.
  127808. */
  127809. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127810. /**
  127811. * The component name helpfull to identify the component in the list of scene components.
  127812. */
  127813. readonly name: string;
  127814. /**
  127815. * The scene the component belongs to.
  127816. */
  127817. scene: Scene;
  127818. /**
  127819. * Creates a new instance of the component for the given scene
  127820. * @param scene Defines the scene to register the component in
  127821. */
  127822. constructor(scene: Scene);
  127823. /**
  127824. * Registers the component in a given scene
  127825. */
  127826. register(): void;
  127827. /**
  127828. * Rebuilds the elements related to this component in case of
  127829. * context lost for instance.
  127830. */
  127831. rebuild(): void;
  127832. /**
  127833. * Adds all the elements from the container to the scene
  127834. * @param container the container holding the elements
  127835. */
  127836. addFromContainer(container: AbstractScene): void;
  127837. /**
  127838. * Removes all the elements in the container from the scene
  127839. * @param container contains the elements to remove
  127840. * @param dispose if the removed element should be disposed (default: false)
  127841. */
  127842. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127843. /**
  127844. * Serializes the component data to the specified json object
  127845. * @param serializationObject The object to serialize to
  127846. */
  127847. serialize(serializationObject: any): void;
  127848. /**
  127849. * Disposes the component and the associated ressources.
  127850. */
  127851. dispose(): void;
  127852. private _draw;
  127853. }
  127854. }
  127855. declare module BABYLON {
  127856. /** @hidden */
  127857. export var depthPixelShader: {
  127858. name: string;
  127859. shader: string;
  127860. };
  127861. }
  127862. declare module BABYLON {
  127863. /** @hidden */
  127864. export var depthVertexShader: {
  127865. name: string;
  127866. shader: string;
  127867. };
  127868. }
  127869. declare module BABYLON {
  127870. /**
  127871. * This represents a depth renderer in Babylon.
  127872. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127873. */
  127874. export class DepthRenderer {
  127875. private _scene;
  127876. private _depthMap;
  127877. private _effect;
  127878. private readonly _storeNonLinearDepth;
  127879. private readonly _clearColor;
  127880. /** Get if the depth renderer is using packed depth or not */
  127881. readonly isPacked: boolean;
  127882. private _cachedDefines;
  127883. private _camera;
  127884. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127885. enabled: boolean;
  127886. /**
  127887. * Specifiess that the depth renderer will only be used within
  127888. * the camera it is created for.
  127889. * This can help forcing its rendering during the camera processing.
  127890. */
  127891. useOnlyInActiveCamera: boolean;
  127892. /** @hidden */
  127893. static _SceneComponentInitialization: (scene: Scene) => void;
  127894. /**
  127895. * Instantiates a depth renderer
  127896. * @param scene The scene the renderer belongs to
  127897. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127898. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127899. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127900. */
  127901. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127902. /**
  127903. * Creates the depth rendering effect and checks if the effect is ready.
  127904. * @param subMesh The submesh to be used to render the depth map of
  127905. * @param useInstances If multiple world instances should be used
  127906. * @returns if the depth renderer is ready to render the depth map
  127907. */
  127908. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127909. /**
  127910. * Gets the texture which the depth map will be written to.
  127911. * @returns The depth map texture
  127912. */
  127913. getDepthMap(): RenderTargetTexture;
  127914. /**
  127915. * Disposes of the depth renderer.
  127916. */
  127917. dispose(): void;
  127918. }
  127919. }
  127920. declare module BABYLON {
  127921. /** @hidden */
  127922. export var minmaxReduxPixelShader: {
  127923. name: string;
  127924. shader: string;
  127925. };
  127926. }
  127927. declare module BABYLON {
  127928. /**
  127929. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127930. * and maximum values from all values of the texture.
  127931. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127932. * The source values are read from the red channel of the texture.
  127933. */
  127934. export class MinMaxReducer {
  127935. /**
  127936. * Observable triggered when the computation has been performed
  127937. */
  127938. onAfterReductionPerformed: Observable<{
  127939. min: number;
  127940. max: number;
  127941. }>;
  127942. protected _camera: Camera;
  127943. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127944. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127945. protected _postProcessManager: PostProcessManager;
  127946. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127947. protected _forceFullscreenViewport: boolean;
  127948. /**
  127949. * Creates a min/max reducer
  127950. * @param camera The camera to use for the post processes
  127951. */
  127952. constructor(camera: Camera);
  127953. /**
  127954. * Gets the texture used to read the values from.
  127955. */
  127956. get sourceTexture(): Nullable<RenderTargetTexture>;
  127957. /**
  127958. * Sets the source texture to read the values from.
  127959. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127960. * because in such textures '1' value must not be taken into account to compute the maximum
  127961. * as this value is used to clear the texture.
  127962. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127963. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127964. * @param depthRedux Indicates if the texture is a depth texture or not
  127965. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127966. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127967. */
  127968. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127969. /**
  127970. * Defines the refresh rate of the computation.
  127971. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127972. */
  127973. get refreshRate(): number;
  127974. set refreshRate(value: number);
  127975. protected _activated: boolean;
  127976. /**
  127977. * Gets the activation status of the reducer
  127978. */
  127979. get activated(): boolean;
  127980. /**
  127981. * Activates the reduction computation.
  127982. * When activated, the observers registered in onAfterReductionPerformed are
  127983. * called after the compuation is performed
  127984. */
  127985. activate(): void;
  127986. /**
  127987. * Deactivates the reduction computation.
  127988. */
  127989. deactivate(): void;
  127990. /**
  127991. * Disposes the min/max reducer
  127992. * @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.
  127993. */
  127994. dispose(disposeAll?: boolean): void;
  127995. }
  127996. }
  127997. declare module BABYLON {
  127998. /**
  127999. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  128000. */
  128001. export class DepthReducer extends MinMaxReducer {
  128002. private _depthRenderer;
  128003. private _depthRendererId;
  128004. /**
  128005. * Gets the depth renderer used for the computation.
  128006. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  128007. */
  128008. get depthRenderer(): Nullable<DepthRenderer>;
  128009. /**
  128010. * Creates a depth reducer
  128011. * @param camera The camera used to render the depth texture
  128012. */
  128013. constructor(camera: Camera);
  128014. /**
  128015. * Sets the depth renderer to use to generate the depth map
  128016. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  128017. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  128018. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128019. */
  128020. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  128021. /** @hidden */
  128022. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128023. /**
  128024. * Activates the reduction computation.
  128025. * When activated, the observers registered in onAfterReductionPerformed are
  128026. * called after the compuation is performed
  128027. */
  128028. activate(): void;
  128029. /**
  128030. * Deactivates the reduction computation.
  128031. */
  128032. deactivate(): void;
  128033. /**
  128034. * Disposes the depth reducer
  128035. * @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.
  128036. */
  128037. dispose(disposeAll?: boolean): void;
  128038. }
  128039. }
  128040. declare module BABYLON {
  128041. /**
  128042. * A CSM implementation allowing casting shadows on large scenes.
  128043. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  128044. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  128045. */
  128046. export class CascadedShadowGenerator extends ShadowGenerator {
  128047. private static readonly frustumCornersNDCSpace;
  128048. /**
  128049. * Name of the CSM class
  128050. */
  128051. static CLASSNAME: string;
  128052. /**
  128053. * Defines the default number of cascades used by the CSM.
  128054. */
  128055. static readonly DEFAULT_CASCADES_COUNT: number;
  128056. /**
  128057. * Defines the minimum number of cascades used by the CSM.
  128058. */
  128059. static readonly MIN_CASCADES_COUNT: number;
  128060. /**
  128061. * Defines the maximum number of cascades used by the CSM.
  128062. */
  128063. static readonly MAX_CASCADES_COUNT: number;
  128064. protected _validateFilter(filter: number): number;
  128065. /**
  128066. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  128067. */
  128068. penumbraDarkness: number;
  128069. private _numCascades;
  128070. /**
  128071. * Gets or set the number of cascades used by the CSM.
  128072. */
  128073. get numCascades(): number;
  128074. set numCascades(value: number);
  128075. /**
  128076. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  128077. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  128078. */
  128079. stabilizeCascades: boolean;
  128080. private _freezeShadowCastersBoundingInfo;
  128081. private _freezeShadowCastersBoundingInfoObservable;
  128082. /**
  128083. * Enables or disables the shadow casters bounding info computation.
  128084. * If your shadow casters don't move, you can disable this feature.
  128085. * If it is enabled, the bounding box computation is done every frame.
  128086. */
  128087. get freezeShadowCastersBoundingInfo(): boolean;
  128088. set freezeShadowCastersBoundingInfo(freeze: boolean);
  128089. private _scbiMin;
  128090. private _scbiMax;
  128091. protected _computeShadowCastersBoundingInfo(): void;
  128092. protected _shadowCastersBoundingInfo: BoundingInfo;
  128093. /**
  128094. * Gets or sets the shadow casters bounding info.
  128095. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  128096. * so that the system won't overwrite the bounds you provide
  128097. */
  128098. get shadowCastersBoundingInfo(): BoundingInfo;
  128099. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  128100. protected _breaksAreDirty: boolean;
  128101. protected _minDistance: number;
  128102. protected _maxDistance: number;
  128103. /**
  128104. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  128105. *
  128106. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  128107. * If you don't know these values, simply leave them to their defaults and don't call this function.
  128108. * @param min minimal distance for the breaks (default to 0.)
  128109. * @param max maximal distance for the breaks (default to 1.)
  128110. */
  128111. setMinMaxDistance(min: number, max: number): void;
  128112. /** Gets the minimal distance used in the cascade break computation */
  128113. get minDistance(): number;
  128114. /** Gets the maximal distance used in the cascade break computation */
  128115. get maxDistance(): number;
  128116. /**
  128117. * Gets the class name of that object
  128118. * @returns "CascadedShadowGenerator"
  128119. */
  128120. getClassName(): string;
  128121. private _cascadeMinExtents;
  128122. private _cascadeMaxExtents;
  128123. /**
  128124. * Gets a cascade minimum extents
  128125. * @param cascadeIndex index of the cascade
  128126. * @returns the minimum cascade extents
  128127. */
  128128. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  128129. /**
  128130. * Gets a cascade maximum extents
  128131. * @param cascadeIndex index of the cascade
  128132. * @returns the maximum cascade extents
  128133. */
  128134. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  128135. private _cascades;
  128136. private _currentLayer;
  128137. private _viewSpaceFrustumsZ;
  128138. private _viewMatrices;
  128139. private _projectionMatrices;
  128140. private _transformMatrices;
  128141. private _transformMatricesAsArray;
  128142. private _frustumLengths;
  128143. private _lightSizeUVCorrection;
  128144. private _depthCorrection;
  128145. private _frustumCornersWorldSpace;
  128146. private _frustumCenter;
  128147. private _shadowCameraPos;
  128148. private _shadowMaxZ;
  128149. /**
  128150. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  128151. * It defaults to camera.maxZ
  128152. */
  128153. get shadowMaxZ(): number;
  128154. /**
  128155. * Sets the shadow max z distance.
  128156. */
  128157. set shadowMaxZ(value: number);
  128158. protected _debug: boolean;
  128159. /**
  128160. * Gets or sets the debug flag.
  128161. * When enabled, the cascades are materialized by different colors on the screen.
  128162. */
  128163. get debug(): boolean;
  128164. set debug(dbg: boolean);
  128165. private _depthClamp;
  128166. /**
  128167. * Gets or sets the depth clamping value.
  128168. *
  128169. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  128170. * to account for the shadow casters far away.
  128171. *
  128172. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  128173. */
  128174. get depthClamp(): boolean;
  128175. set depthClamp(value: boolean);
  128176. private _cascadeBlendPercentage;
  128177. /**
  128178. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  128179. * It defaults to 0.1 (10% blending).
  128180. */
  128181. get cascadeBlendPercentage(): number;
  128182. set cascadeBlendPercentage(value: number);
  128183. private _lambda;
  128184. /**
  128185. * Gets or set the lambda parameter.
  128186. * This parameter is used to split the camera frustum and create the cascades.
  128187. * 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.
  128188. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  128189. */
  128190. get lambda(): number;
  128191. set lambda(value: number);
  128192. /**
  128193. * Gets the view matrix corresponding to a given cascade
  128194. * @param cascadeNum cascade to retrieve the view matrix from
  128195. * @returns the cascade view matrix
  128196. */
  128197. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  128198. /**
  128199. * Gets the projection matrix corresponding to a given cascade
  128200. * @param cascadeNum cascade to retrieve the projection matrix from
  128201. * @returns the cascade projection matrix
  128202. */
  128203. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  128204. /**
  128205. * Gets the transformation matrix corresponding to a given cascade
  128206. * @param cascadeNum cascade to retrieve the transformation matrix from
  128207. * @returns the cascade transformation matrix
  128208. */
  128209. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  128210. private _depthRenderer;
  128211. /**
  128212. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  128213. *
  128214. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  128215. *
  128216. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  128217. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  128218. * @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
  128219. */
  128220. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  128221. private _depthReducer;
  128222. private _autoCalcDepthBounds;
  128223. /**
  128224. * Gets or sets the autoCalcDepthBounds property.
  128225. *
  128226. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  128227. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  128228. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  128229. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  128230. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  128231. */
  128232. get autoCalcDepthBounds(): boolean;
  128233. set autoCalcDepthBounds(value: boolean);
  128234. /**
  128235. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  128236. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128237. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  128238. * for setting the refresh rate on the renderer yourself!
  128239. */
  128240. get autoCalcDepthBoundsRefreshRate(): number;
  128241. set autoCalcDepthBoundsRefreshRate(value: number);
  128242. /**
  128243. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  128244. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  128245. * you change the camera near/far planes!
  128246. */
  128247. splitFrustum(): void;
  128248. private _splitFrustum;
  128249. private _computeMatrices;
  128250. private _computeFrustumInWorldSpace;
  128251. private _computeCascadeFrustum;
  128252. /** @hidden */
  128253. static _SceneComponentInitialization: (scene: Scene) => void;
  128254. /**
  128255. * Creates a Cascaded Shadow Generator object.
  128256. * A ShadowGenerator is the required tool to use the shadows.
  128257. * Each directional light casting shadows needs to use its own ShadowGenerator.
  128258. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  128259. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  128260. * @param light The directional light object generating the shadows.
  128261. * @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.
  128262. */
  128263. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  128264. protected _initializeGenerator(): void;
  128265. protected _createTargetRenderTexture(): void;
  128266. protected _initializeShadowMap(): void;
  128267. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  128268. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  128269. /**
  128270. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  128271. * @param defines Defines of the material we want to update
  128272. * @param lightIndex Index of the light in the enabled light list of the material
  128273. */
  128274. prepareDefines(defines: any, lightIndex: number): void;
  128275. /**
  128276. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  128277. * defined in the generator but impacting the effect).
  128278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  128279. * @param effect The effect we are binfing the information for
  128280. */
  128281. bindShadowLight(lightIndex: string, effect: Effect): void;
  128282. /**
  128283. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  128284. * (eq to view projection * shadow projection matrices)
  128285. * @returns The transform matrix used to create the shadow map
  128286. */
  128287. getTransformMatrix(): Matrix;
  128288. /**
  128289. * Disposes the ShadowGenerator.
  128290. * Returns nothing.
  128291. */
  128292. dispose(): void;
  128293. /**
  128294. * Serializes the shadow generator setup to a json object.
  128295. * @returns The serialized JSON object
  128296. */
  128297. serialize(): any;
  128298. /**
  128299. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  128300. * @param parsedShadowGenerator The JSON object to parse
  128301. * @param scene The scene to create the shadow map for
  128302. * @returns The parsed shadow generator
  128303. */
  128304. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  128305. }
  128306. }
  128307. declare module BABYLON {
  128308. /**
  128309. * Defines the shadow generator component responsible to manage any shadow generators
  128310. * in a given scene.
  128311. */
  128312. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  128313. /**
  128314. * The component name helpfull to identify the component in the list of scene components.
  128315. */
  128316. readonly name: string;
  128317. /**
  128318. * The scene the component belongs to.
  128319. */
  128320. scene: Scene;
  128321. /**
  128322. * Creates a new instance of the component for the given scene
  128323. * @param scene Defines the scene to register the component in
  128324. */
  128325. constructor(scene: Scene);
  128326. /**
  128327. * Registers the component in a given scene
  128328. */
  128329. register(): void;
  128330. /**
  128331. * Rebuilds the elements related to this component in case of
  128332. * context lost for instance.
  128333. */
  128334. rebuild(): void;
  128335. /**
  128336. * Serializes the component data to the specified json object
  128337. * @param serializationObject The object to serialize to
  128338. */
  128339. serialize(serializationObject: any): void;
  128340. /**
  128341. * Adds all the elements from the container to the scene
  128342. * @param container the container holding the elements
  128343. */
  128344. addFromContainer(container: AbstractScene): void;
  128345. /**
  128346. * Removes all the elements in the container from the scene
  128347. * @param container contains the elements to remove
  128348. * @param dispose if the removed element should be disposed (default: false)
  128349. */
  128350. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128351. /**
  128352. * Rebuilds the elements related to this component in case of
  128353. * context lost for instance.
  128354. */
  128355. dispose(): void;
  128356. private _gatherRenderTargets;
  128357. }
  128358. }
  128359. declare module BABYLON {
  128360. /**
  128361. * A point light is a light defined by an unique point in world space.
  128362. * The light is emitted in every direction from this point.
  128363. * A good example of a point light is a standard light bulb.
  128364. * Documentation: https://doc.babylonjs.com/babylon101/lights
  128365. */
  128366. export class PointLight extends ShadowLight {
  128367. private _shadowAngle;
  128368. /**
  128369. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128370. * This specifies what angle the shadow will use to be created.
  128371. *
  128372. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128373. */
  128374. get shadowAngle(): number;
  128375. /**
  128376. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128377. * This specifies what angle the shadow will use to be created.
  128378. *
  128379. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128380. */
  128381. set shadowAngle(value: number);
  128382. /**
  128383. * Gets the direction if it has been set.
  128384. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128385. */
  128386. get direction(): Vector3;
  128387. /**
  128388. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128389. */
  128390. set direction(value: Vector3);
  128391. /**
  128392. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  128393. * A PointLight emits the light in every direction.
  128394. * It can cast shadows.
  128395. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  128396. * ```javascript
  128397. * var pointLight = new PointLight("pl", camera.position, scene);
  128398. * ```
  128399. * Documentation : https://doc.babylonjs.com/babylon101/lights
  128400. * @param name The light friendly name
  128401. * @param position The position of the point light in the scene
  128402. * @param scene The scene the lights belongs to
  128403. */
  128404. constructor(name: string, position: Vector3, scene: Scene);
  128405. /**
  128406. * Returns the string "PointLight"
  128407. * @returns the class name
  128408. */
  128409. getClassName(): string;
  128410. /**
  128411. * Returns the integer 0.
  128412. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  128413. */
  128414. getTypeID(): number;
  128415. /**
  128416. * Specifies wether or not the shadowmap should be a cube texture.
  128417. * @returns true if the shadowmap needs to be a cube texture.
  128418. */
  128419. needCube(): boolean;
  128420. /**
  128421. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  128422. * @param faceIndex The index of the face we are computed the direction to generate shadow
  128423. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  128424. */
  128425. getShadowDirection(faceIndex?: number): Vector3;
  128426. /**
  128427. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  128428. * - fov = PI / 2
  128429. * - aspect ratio : 1.0
  128430. * - z-near and far equal to the active camera minZ and maxZ.
  128431. * Returns the PointLight.
  128432. */
  128433. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  128434. protected _buildUniformLayout(): void;
  128435. /**
  128436. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  128437. * @param effect The effect to update
  128438. * @param lightIndex The index of the light in the effect to update
  128439. * @returns The point light
  128440. */
  128441. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  128442. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  128443. /**
  128444. * Prepares the list of defines specific to the light type.
  128445. * @param defines the list of defines
  128446. * @param lightIndex defines the index of the light for the effect
  128447. */
  128448. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  128449. }
  128450. }
  128451. declare module BABYLON {
  128452. /**
  128453. * Header information of HDR texture files.
  128454. */
  128455. export interface HDRInfo {
  128456. /**
  128457. * The height of the texture in pixels.
  128458. */
  128459. height: number;
  128460. /**
  128461. * The width of the texture in pixels.
  128462. */
  128463. width: number;
  128464. /**
  128465. * The index of the beginning of the data in the binary file.
  128466. */
  128467. dataPosition: number;
  128468. }
  128469. /**
  128470. * This groups tools to convert HDR texture to native colors array.
  128471. */
  128472. export class HDRTools {
  128473. private static Ldexp;
  128474. private static Rgbe2float;
  128475. private static readStringLine;
  128476. /**
  128477. * Reads header information from an RGBE texture stored in a native array.
  128478. * More information on this format are available here:
  128479. * https://en.wikipedia.org/wiki/RGBE_image_format
  128480. *
  128481. * @param uint8array The binary file stored in native array.
  128482. * @return The header information.
  128483. */
  128484. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  128485. /**
  128486. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  128487. * This RGBE texture needs to store the information as a panorama.
  128488. *
  128489. * More information on this format are available here:
  128490. * https://en.wikipedia.org/wiki/RGBE_image_format
  128491. *
  128492. * @param buffer The binary file stored in an array buffer.
  128493. * @param size The expected size of the extracted cubemap.
  128494. * @return The Cube Map information.
  128495. */
  128496. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  128497. /**
  128498. * Returns the pixels data extracted from an RGBE texture.
  128499. * This pixels will be stored left to right up to down in the R G B order in one array.
  128500. *
  128501. * More information on this format are available here:
  128502. * https://en.wikipedia.org/wiki/RGBE_image_format
  128503. *
  128504. * @param uint8array The binary file stored in an array buffer.
  128505. * @param hdrInfo The header information of the file.
  128506. * @return The pixels data in RGB right to left up to down order.
  128507. */
  128508. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  128509. private static RGBE_ReadPixels_RLE;
  128510. }
  128511. }
  128512. declare module BABYLON {
  128513. /**
  128514. * This represents a texture coming from an HDR input.
  128515. *
  128516. * The only supported format is currently panorama picture stored in RGBE format.
  128517. * Example of such files can be found on HDRLib: http://hdrlib.com/
  128518. */
  128519. export class HDRCubeTexture extends BaseTexture {
  128520. private static _facesMapping;
  128521. private _generateHarmonics;
  128522. private _noMipmap;
  128523. private _textureMatrix;
  128524. private _size;
  128525. private _onLoad;
  128526. private _onError;
  128527. /**
  128528. * The texture URL.
  128529. */
  128530. url: string;
  128531. /**
  128532. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  128533. */
  128534. coordinatesMode: number;
  128535. protected _isBlocking: boolean;
  128536. /**
  128537. * Sets wether or not the texture is blocking during loading.
  128538. */
  128539. set isBlocking(value: boolean);
  128540. /**
  128541. * Gets wether or not the texture is blocking during loading.
  128542. */
  128543. get isBlocking(): boolean;
  128544. protected _rotationY: number;
  128545. /**
  128546. * Sets texture matrix rotation angle around Y axis in radians.
  128547. */
  128548. set rotationY(value: number);
  128549. /**
  128550. * Gets texture matrix rotation angle around Y axis radians.
  128551. */
  128552. get rotationY(): number;
  128553. /**
  128554. * Gets or sets the center of the bounding box associated with the cube texture
  128555. * It must define where the camera used to render the texture was set
  128556. */
  128557. boundingBoxPosition: Vector3;
  128558. private _boundingBoxSize;
  128559. /**
  128560. * Gets or sets the size of the bounding box associated with the cube texture
  128561. * When defined, the cubemap will switch to local mode
  128562. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128563. * @example https://www.babylonjs-playground.com/#RNASML
  128564. */
  128565. set boundingBoxSize(value: Vector3);
  128566. get boundingBoxSize(): Vector3;
  128567. /**
  128568. * Instantiates an HDRTexture from the following parameters.
  128569. *
  128570. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128571. * @param scene The scene the texture will be used in
  128572. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128573. * @param noMipmap Forces to not generate the mipmap if true
  128574. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128575. * @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)
  128576. * @param reserved Reserved flag for internal use.
  128577. */
  128578. 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>);
  128579. /**
  128580. * Get the current class name of the texture useful for serialization or dynamic coding.
  128581. * @returns "HDRCubeTexture"
  128582. */
  128583. getClassName(): string;
  128584. /**
  128585. * Occurs when the file is raw .hdr file.
  128586. */
  128587. private loadTexture;
  128588. clone(): HDRCubeTexture;
  128589. delayLoad(): void;
  128590. /**
  128591. * Get the texture reflection matrix used to rotate/transform the reflection.
  128592. * @returns the reflection matrix
  128593. */
  128594. getReflectionTextureMatrix(): Matrix;
  128595. /**
  128596. * Set the texture reflection matrix used to rotate/transform the reflection.
  128597. * @param value Define the reflection matrix to set
  128598. */
  128599. setReflectionTextureMatrix(value: Matrix): void;
  128600. /**
  128601. * Parses a JSON representation of an HDR Texture in order to create the texture
  128602. * @param parsedTexture Define the JSON representation
  128603. * @param scene Define the scene the texture should be created in
  128604. * @param rootUrl Define the root url in case we need to load relative dependencies
  128605. * @returns the newly created texture after parsing
  128606. */
  128607. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128608. serialize(): any;
  128609. }
  128610. }
  128611. declare module BABYLON {
  128612. /**
  128613. * Class used to control physics engine
  128614. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128615. */
  128616. export class PhysicsEngine implements IPhysicsEngine {
  128617. private _physicsPlugin;
  128618. /**
  128619. * Global value used to control the smallest number supported by the simulation
  128620. */
  128621. static Epsilon: number;
  128622. private _impostors;
  128623. private _joints;
  128624. private _subTimeStep;
  128625. /**
  128626. * Gets the gravity vector used by the simulation
  128627. */
  128628. gravity: Vector3;
  128629. /**
  128630. * Factory used to create the default physics plugin.
  128631. * @returns The default physics plugin
  128632. */
  128633. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128634. /**
  128635. * Creates a new Physics Engine
  128636. * @param gravity defines the gravity vector used by the simulation
  128637. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128638. */
  128639. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128640. /**
  128641. * Sets the gravity vector used by the simulation
  128642. * @param gravity defines the gravity vector to use
  128643. */
  128644. setGravity(gravity: Vector3): void;
  128645. /**
  128646. * Set the time step of the physics engine.
  128647. * Default is 1/60.
  128648. * To slow it down, enter 1/600 for example.
  128649. * To speed it up, 1/30
  128650. * @param newTimeStep defines the new timestep to apply to this world.
  128651. */
  128652. setTimeStep(newTimeStep?: number): void;
  128653. /**
  128654. * Get the time step of the physics engine.
  128655. * @returns the current time step
  128656. */
  128657. getTimeStep(): number;
  128658. /**
  128659. * Set the sub time step of the physics engine.
  128660. * Default is 0 meaning there is no sub steps
  128661. * To increase physics resolution precision, set a small value (like 1 ms)
  128662. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128663. */
  128664. setSubTimeStep(subTimeStep?: number): void;
  128665. /**
  128666. * Get the sub time step of the physics engine.
  128667. * @returns the current sub time step
  128668. */
  128669. getSubTimeStep(): number;
  128670. /**
  128671. * Release all resources
  128672. */
  128673. dispose(): void;
  128674. /**
  128675. * Gets the name of the current physics plugin
  128676. * @returns the name of the plugin
  128677. */
  128678. getPhysicsPluginName(): string;
  128679. /**
  128680. * Adding a new impostor for the impostor tracking.
  128681. * This will be done by the impostor itself.
  128682. * @param impostor the impostor to add
  128683. */
  128684. addImpostor(impostor: PhysicsImpostor): void;
  128685. /**
  128686. * Remove an impostor from the engine.
  128687. * This impostor and its mesh will not longer be updated by the physics engine.
  128688. * @param impostor the impostor to remove
  128689. */
  128690. removeImpostor(impostor: PhysicsImpostor): void;
  128691. /**
  128692. * Add a joint to the physics engine
  128693. * @param mainImpostor defines the main impostor to which the joint is added.
  128694. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128695. * @param joint defines the joint that will connect both impostors.
  128696. */
  128697. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128698. /**
  128699. * Removes a joint from the simulation
  128700. * @param mainImpostor defines the impostor used with the joint
  128701. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128702. * @param joint defines the joint to remove
  128703. */
  128704. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128705. /**
  128706. * Called by the scene. No need to call it.
  128707. * @param delta defines the timespam between frames
  128708. */
  128709. _step(delta: number): void;
  128710. /**
  128711. * Gets the current plugin used to run the simulation
  128712. * @returns current plugin
  128713. */
  128714. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128715. /**
  128716. * Gets the list of physic impostors
  128717. * @returns an array of PhysicsImpostor
  128718. */
  128719. getImpostors(): Array<PhysicsImpostor>;
  128720. /**
  128721. * Gets the impostor for a physics enabled object
  128722. * @param object defines the object impersonated by the impostor
  128723. * @returns the PhysicsImpostor or null if not found
  128724. */
  128725. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128726. /**
  128727. * Gets the impostor for a physics body object
  128728. * @param body defines physics body used by the impostor
  128729. * @returns the PhysicsImpostor or null if not found
  128730. */
  128731. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128732. /**
  128733. * Does a raycast in the physics world
  128734. * @param from when should the ray start?
  128735. * @param to when should the ray end?
  128736. * @returns PhysicsRaycastResult
  128737. */
  128738. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128739. }
  128740. }
  128741. declare module BABYLON {
  128742. /** @hidden */
  128743. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128744. private _useDeltaForWorldStep;
  128745. world: any;
  128746. name: string;
  128747. private _physicsMaterials;
  128748. private _fixedTimeStep;
  128749. private _cannonRaycastResult;
  128750. private _raycastResult;
  128751. private _physicsBodysToRemoveAfterStep;
  128752. BJSCANNON: any;
  128753. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128754. setGravity(gravity: Vector3): void;
  128755. setTimeStep(timeStep: number): void;
  128756. getTimeStep(): number;
  128757. executeStep(delta: number): void;
  128758. private _removeMarkedPhysicsBodiesFromWorld;
  128759. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128760. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128761. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128762. private _processChildMeshes;
  128763. removePhysicsBody(impostor: PhysicsImpostor): void;
  128764. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128765. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128766. private _addMaterial;
  128767. private _checkWithEpsilon;
  128768. private _createShape;
  128769. private _createHeightmap;
  128770. private _minus90X;
  128771. private _plus90X;
  128772. private _tmpPosition;
  128773. private _tmpDeltaPosition;
  128774. private _tmpUnityRotation;
  128775. private _updatePhysicsBodyTransformation;
  128776. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128777. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128778. isSupported(): boolean;
  128779. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128780. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128781. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128782. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128783. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128784. getBodyMass(impostor: PhysicsImpostor): number;
  128785. getBodyFriction(impostor: PhysicsImpostor): number;
  128786. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128787. getBodyRestitution(impostor: PhysicsImpostor): number;
  128788. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128789. sleepBody(impostor: PhysicsImpostor): void;
  128790. wakeUpBody(impostor: PhysicsImpostor): void;
  128791. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128792. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128793. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128794. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128795. getRadius(impostor: PhysicsImpostor): number;
  128796. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128797. dispose(): void;
  128798. private _extendNamespace;
  128799. /**
  128800. * Does a raycast in the physics world
  128801. * @param from when should the ray start?
  128802. * @param to when should the ray end?
  128803. * @returns PhysicsRaycastResult
  128804. */
  128805. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128806. }
  128807. }
  128808. declare module BABYLON {
  128809. /** @hidden */
  128810. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128811. world: any;
  128812. name: string;
  128813. BJSOIMO: any;
  128814. private _raycastResult;
  128815. constructor(iterations?: number, oimoInjection?: any);
  128816. setGravity(gravity: Vector3): void;
  128817. setTimeStep(timeStep: number): void;
  128818. getTimeStep(): number;
  128819. private _tmpImpostorsArray;
  128820. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128821. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128822. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128823. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128824. private _tmpPositionVector;
  128825. removePhysicsBody(impostor: PhysicsImpostor): void;
  128826. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128827. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128828. isSupported(): boolean;
  128829. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128830. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128831. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128832. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128833. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128834. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128835. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128836. getBodyMass(impostor: PhysicsImpostor): number;
  128837. getBodyFriction(impostor: PhysicsImpostor): number;
  128838. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128839. getBodyRestitution(impostor: PhysicsImpostor): number;
  128840. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128841. sleepBody(impostor: PhysicsImpostor): void;
  128842. wakeUpBody(impostor: PhysicsImpostor): void;
  128843. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128844. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128845. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128846. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128847. getRadius(impostor: PhysicsImpostor): number;
  128848. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128849. dispose(): void;
  128850. /**
  128851. * Does a raycast in the physics world
  128852. * @param from when should the ray start?
  128853. * @param to when should the ray end?
  128854. * @returns PhysicsRaycastResult
  128855. */
  128856. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128857. }
  128858. }
  128859. declare module BABYLON {
  128860. /**
  128861. * Class containing static functions to help procedurally build meshes
  128862. */
  128863. export class RibbonBuilder {
  128864. /**
  128865. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128866. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128867. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128868. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128869. * * 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
  128870. * * 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
  128871. * * 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
  128872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128875. * * 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
  128876. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128877. * * 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
  128878. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128880. * @param name defines the name of the mesh
  128881. * @param options defines the options used to create the mesh
  128882. * @param scene defines the hosting scene
  128883. * @returns the ribbon mesh
  128884. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128885. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128886. */
  128887. static CreateRibbon(name: string, options: {
  128888. pathArray: Vector3[][];
  128889. closeArray?: boolean;
  128890. closePath?: boolean;
  128891. offset?: number;
  128892. updatable?: boolean;
  128893. sideOrientation?: number;
  128894. frontUVs?: Vector4;
  128895. backUVs?: Vector4;
  128896. instance?: Mesh;
  128897. invertUV?: boolean;
  128898. uvs?: Vector2[];
  128899. colors?: Color4[];
  128900. }, scene?: Nullable<Scene>): Mesh;
  128901. }
  128902. }
  128903. declare module BABYLON {
  128904. /**
  128905. * Class containing static functions to help procedurally build meshes
  128906. */
  128907. export class ShapeBuilder {
  128908. /**
  128909. * 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.
  128910. * * 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.
  128911. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128912. * * 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.
  128913. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128914. * * 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
  128915. * * 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
  128916. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128921. * @param name defines the name of the mesh
  128922. * @param options defines the options used to create the mesh
  128923. * @param scene defines the hosting scene
  128924. * @returns the extruded shape mesh
  128925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128927. */
  128928. static ExtrudeShape(name: string, options: {
  128929. shape: Vector3[];
  128930. path: Vector3[];
  128931. scale?: number;
  128932. rotation?: number;
  128933. cap?: number;
  128934. updatable?: boolean;
  128935. sideOrientation?: number;
  128936. frontUVs?: Vector4;
  128937. backUVs?: Vector4;
  128938. instance?: Mesh;
  128939. invertUV?: boolean;
  128940. }, scene?: Nullable<Scene>): Mesh;
  128941. /**
  128942. * Creates an custom extruded shape mesh.
  128943. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128944. * * 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.
  128945. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128946. * * 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
  128947. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128948. * * 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
  128949. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128950. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128951. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128952. * * 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
  128953. * * 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
  128954. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128959. * @param name defines the name of the mesh
  128960. * @param options defines the options used to create the mesh
  128961. * @param scene defines the hosting scene
  128962. * @returns the custom extruded shape mesh
  128963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128964. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128966. */
  128967. static ExtrudeShapeCustom(name: string, options: {
  128968. shape: Vector3[];
  128969. path: Vector3[];
  128970. scaleFunction?: any;
  128971. rotationFunction?: any;
  128972. ribbonCloseArray?: boolean;
  128973. ribbonClosePath?: boolean;
  128974. cap?: number;
  128975. updatable?: boolean;
  128976. sideOrientation?: number;
  128977. frontUVs?: Vector4;
  128978. backUVs?: Vector4;
  128979. instance?: Mesh;
  128980. invertUV?: boolean;
  128981. }, scene?: Nullable<Scene>): Mesh;
  128982. private static _ExtrudeShapeGeneric;
  128983. }
  128984. }
  128985. declare module BABYLON {
  128986. /**
  128987. * AmmoJS Physics plugin
  128988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128989. * @see https://github.com/kripken/ammo.js/
  128990. */
  128991. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128992. private _useDeltaForWorldStep;
  128993. /**
  128994. * Reference to the Ammo library
  128995. */
  128996. bjsAMMO: any;
  128997. /**
  128998. * Created ammoJS world which physics bodies are added to
  128999. */
  129000. world: any;
  129001. /**
  129002. * Name of the plugin
  129003. */
  129004. name: string;
  129005. private _timeStep;
  129006. private _fixedTimeStep;
  129007. private _maxSteps;
  129008. private _tmpQuaternion;
  129009. private _tmpAmmoTransform;
  129010. private _tmpAmmoQuaternion;
  129011. private _tmpAmmoConcreteContactResultCallback;
  129012. private _collisionConfiguration;
  129013. private _dispatcher;
  129014. private _overlappingPairCache;
  129015. private _solver;
  129016. private _softBodySolver;
  129017. private _tmpAmmoVectorA;
  129018. private _tmpAmmoVectorB;
  129019. private _tmpAmmoVectorC;
  129020. private _tmpAmmoVectorD;
  129021. private _tmpContactCallbackResult;
  129022. private _tmpAmmoVectorRCA;
  129023. private _tmpAmmoVectorRCB;
  129024. private _raycastResult;
  129025. private static readonly DISABLE_COLLISION_FLAG;
  129026. private static readonly KINEMATIC_FLAG;
  129027. private static readonly DISABLE_DEACTIVATION_FLAG;
  129028. /**
  129029. * Initializes the ammoJS plugin
  129030. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  129031. * @param ammoInjection can be used to inject your own ammo reference
  129032. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  129033. */
  129034. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  129035. /**
  129036. * Sets the gravity of the physics world (m/(s^2))
  129037. * @param gravity Gravity to set
  129038. */
  129039. setGravity(gravity: Vector3): void;
  129040. /**
  129041. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  129042. * @param timeStep timestep to use in seconds
  129043. */
  129044. setTimeStep(timeStep: number): void;
  129045. /**
  129046. * 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)
  129047. * @param fixedTimeStep fixedTimeStep to use in seconds
  129048. */
  129049. setFixedTimeStep(fixedTimeStep: number): void;
  129050. /**
  129051. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  129052. * @param maxSteps the maximum number of steps by the physics engine per frame
  129053. */
  129054. setMaxSteps(maxSteps: number): void;
  129055. /**
  129056. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  129057. * @returns the current timestep in seconds
  129058. */
  129059. getTimeStep(): number;
  129060. /**
  129061. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  129062. */
  129063. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  129064. private _isImpostorInContact;
  129065. private _isImpostorPairInContact;
  129066. private _stepSimulation;
  129067. /**
  129068. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  129069. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  129070. * After the step the babylon meshes are set to the position of the physics imposters
  129071. * @param delta amount of time to step forward
  129072. * @param impostors array of imposters to update before/after the step
  129073. */
  129074. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129075. /**
  129076. * Update babylon mesh to match physics world object
  129077. * @param impostor imposter to match
  129078. */
  129079. private _afterSoftStep;
  129080. /**
  129081. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  129082. * @param impostor imposter to match
  129083. */
  129084. private _ropeStep;
  129085. /**
  129086. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  129087. * @param impostor imposter to match
  129088. */
  129089. private _softbodyOrClothStep;
  129090. private _tmpVector;
  129091. private _tmpMatrix;
  129092. /**
  129093. * Applies an impulse on the imposter
  129094. * @param impostor imposter to apply impulse to
  129095. * @param force amount of force to be applied to the imposter
  129096. * @param contactPoint the location to apply the impulse on the imposter
  129097. */
  129098. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129099. /**
  129100. * Applies a force on the imposter
  129101. * @param impostor imposter to apply force
  129102. * @param force amount of force to be applied to the imposter
  129103. * @param contactPoint the location to apply the force on the imposter
  129104. */
  129105. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129106. /**
  129107. * Creates a physics body using the plugin
  129108. * @param impostor the imposter to create the physics body on
  129109. */
  129110. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129111. /**
  129112. * Removes the physics body from the imposter and disposes of the body's memory
  129113. * @param impostor imposter to remove the physics body from
  129114. */
  129115. removePhysicsBody(impostor: PhysicsImpostor): void;
  129116. /**
  129117. * Generates a joint
  129118. * @param impostorJoint the imposter joint to create the joint with
  129119. */
  129120. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129121. /**
  129122. * Removes a joint
  129123. * @param impostorJoint the imposter joint to remove the joint from
  129124. */
  129125. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129126. private _addMeshVerts;
  129127. /**
  129128. * Initialise the soft body vertices to match its object's (mesh) vertices
  129129. * Softbody vertices (nodes) are in world space and to match this
  129130. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  129131. * @param impostor to create the softbody for
  129132. */
  129133. private _softVertexData;
  129134. /**
  129135. * Create an impostor's soft body
  129136. * @param impostor to create the softbody for
  129137. */
  129138. private _createSoftbody;
  129139. /**
  129140. * Create cloth for an impostor
  129141. * @param impostor to create the softbody for
  129142. */
  129143. private _createCloth;
  129144. /**
  129145. * Create rope for an impostor
  129146. * @param impostor to create the softbody for
  129147. */
  129148. private _createRope;
  129149. /**
  129150. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  129151. * @param impostor to create the custom physics shape for
  129152. */
  129153. private _createCustom;
  129154. private _addHullVerts;
  129155. private _createShape;
  129156. /**
  129157. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  129158. * @param impostor imposter containing the physics body and babylon object
  129159. */
  129160. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129161. /**
  129162. * Sets the babylon object's position/rotation from the physics body's position/rotation
  129163. * @param impostor imposter containing the physics body and babylon object
  129164. * @param newPosition new position
  129165. * @param newRotation new rotation
  129166. */
  129167. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129168. /**
  129169. * If this plugin is supported
  129170. * @returns true if its supported
  129171. */
  129172. isSupported(): boolean;
  129173. /**
  129174. * Sets the linear velocity of the physics body
  129175. * @param impostor imposter to set the velocity on
  129176. * @param velocity velocity to set
  129177. */
  129178. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129179. /**
  129180. * Sets the angular velocity of the physics body
  129181. * @param impostor imposter to set the velocity on
  129182. * @param velocity velocity to set
  129183. */
  129184. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129185. /**
  129186. * gets the linear velocity
  129187. * @param impostor imposter to get linear velocity from
  129188. * @returns linear velocity
  129189. */
  129190. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129191. /**
  129192. * gets the angular velocity
  129193. * @param impostor imposter to get angular velocity from
  129194. * @returns angular velocity
  129195. */
  129196. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129197. /**
  129198. * Sets the mass of physics body
  129199. * @param impostor imposter to set the mass on
  129200. * @param mass mass to set
  129201. */
  129202. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129203. /**
  129204. * Gets the mass of the physics body
  129205. * @param impostor imposter to get the mass from
  129206. * @returns mass
  129207. */
  129208. getBodyMass(impostor: PhysicsImpostor): number;
  129209. /**
  129210. * Gets friction of the impostor
  129211. * @param impostor impostor to get friction from
  129212. * @returns friction value
  129213. */
  129214. getBodyFriction(impostor: PhysicsImpostor): number;
  129215. /**
  129216. * Sets friction of the impostor
  129217. * @param impostor impostor to set friction on
  129218. * @param friction friction value
  129219. */
  129220. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129221. /**
  129222. * Gets restitution of the impostor
  129223. * @param impostor impostor to get restitution from
  129224. * @returns restitution value
  129225. */
  129226. getBodyRestitution(impostor: PhysicsImpostor): number;
  129227. /**
  129228. * Sets resitution of the impostor
  129229. * @param impostor impostor to set resitution on
  129230. * @param restitution resitution value
  129231. */
  129232. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129233. /**
  129234. * Gets pressure inside the impostor
  129235. * @param impostor impostor to get pressure from
  129236. * @returns pressure value
  129237. */
  129238. getBodyPressure(impostor: PhysicsImpostor): number;
  129239. /**
  129240. * Sets pressure inside a soft body impostor
  129241. * Cloth and rope must remain 0 pressure
  129242. * @param impostor impostor to set pressure on
  129243. * @param pressure pressure value
  129244. */
  129245. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  129246. /**
  129247. * Gets stiffness of the impostor
  129248. * @param impostor impostor to get stiffness from
  129249. * @returns pressure value
  129250. */
  129251. getBodyStiffness(impostor: PhysicsImpostor): number;
  129252. /**
  129253. * Sets stiffness of the impostor
  129254. * @param impostor impostor to set stiffness on
  129255. * @param stiffness stiffness value from 0 to 1
  129256. */
  129257. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  129258. /**
  129259. * Gets velocityIterations of the impostor
  129260. * @param impostor impostor to get velocity iterations from
  129261. * @returns velocityIterations value
  129262. */
  129263. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  129264. /**
  129265. * Sets velocityIterations of the impostor
  129266. * @param impostor impostor to set velocity iterations on
  129267. * @param velocityIterations velocityIterations value
  129268. */
  129269. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  129270. /**
  129271. * Gets positionIterations of the impostor
  129272. * @param impostor impostor to get position iterations from
  129273. * @returns positionIterations value
  129274. */
  129275. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  129276. /**
  129277. * Sets positionIterations of the impostor
  129278. * @param impostor impostor to set position on
  129279. * @param positionIterations positionIterations value
  129280. */
  129281. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  129282. /**
  129283. * Append an anchor to a cloth object
  129284. * @param impostor is the cloth impostor to add anchor to
  129285. * @param otherImpostor is the rigid impostor to anchor to
  129286. * @param width ratio across width from 0 to 1
  129287. * @param height ratio up height from 0 to 1
  129288. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  129289. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  129290. */
  129291. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  129292. /**
  129293. * Append an hook to a rope object
  129294. * @param impostor is the rope impostor to add hook to
  129295. * @param otherImpostor is the rigid impostor to hook to
  129296. * @param length ratio along the rope from 0 to 1
  129297. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  129298. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  129299. */
  129300. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  129301. /**
  129302. * Sleeps the physics body and stops it from being active
  129303. * @param impostor impostor to sleep
  129304. */
  129305. sleepBody(impostor: PhysicsImpostor): void;
  129306. /**
  129307. * Activates the physics body
  129308. * @param impostor impostor to activate
  129309. */
  129310. wakeUpBody(impostor: PhysicsImpostor): void;
  129311. /**
  129312. * Updates the distance parameters of the joint
  129313. * @param joint joint to update
  129314. * @param maxDistance maximum distance of the joint
  129315. * @param minDistance minimum distance of the joint
  129316. */
  129317. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129318. /**
  129319. * Sets a motor on the joint
  129320. * @param joint joint to set motor on
  129321. * @param speed speed of the motor
  129322. * @param maxForce maximum force of the motor
  129323. * @param motorIndex index of the motor
  129324. */
  129325. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129326. /**
  129327. * Sets the motors limit
  129328. * @param joint joint to set limit on
  129329. * @param upperLimit upper limit
  129330. * @param lowerLimit lower limit
  129331. */
  129332. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129333. /**
  129334. * Syncs the position and rotation of a mesh with the impostor
  129335. * @param mesh mesh to sync
  129336. * @param impostor impostor to update the mesh with
  129337. */
  129338. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129339. /**
  129340. * Gets the radius of the impostor
  129341. * @param impostor impostor to get radius from
  129342. * @returns the radius
  129343. */
  129344. getRadius(impostor: PhysicsImpostor): number;
  129345. /**
  129346. * Gets the box size of the impostor
  129347. * @param impostor impostor to get box size from
  129348. * @param result the resulting box size
  129349. */
  129350. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129351. /**
  129352. * Disposes of the impostor
  129353. */
  129354. dispose(): void;
  129355. /**
  129356. * Does a raycast in the physics world
  129357. * @param from when should the ray start?
  129358. * @param to when should the ray end?
  129359. * @returns PhysicsRaycastResult
  129360. */
  129361. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129362. }
  129363. }
  129364. declare module BABYLON {
  129365. interface AbstractScene {
  129366. /**
  129367. * The list of reflection probes added to the scene
  129368. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129369. */
  129370. reflectionProbes: Array<ReflectionProbe>;
  129371. /**
  129372. * Removes the given reflection probe from this scene.
  129373. * @param toRemove The reflection probe to remove
  129374. * @returns The index of the removed reflection probe
  129375. */
  129376. removeReflectionProbe(toRemove: ReflectionProbe): number;
  129377. /**
  129378. * Adds the given reflection probe to this scene.
  129379. * @param newReflectionProbe The reflection probe to add
  129380. */
  129381. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  129382. }
  129383. /**
  129384. * Class used to generate realtime reflection / refraction cube textures
  129385. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129386. */
  129387. export class ReflectionProbe {
  129388. /** defines the name of the probe */
  129389. name: string;
  129390. private _scene;
  129391. private _renderTargetTexture;
  129392. private _projectionMatrix;
  129393. private _viewMatrix;
  129394. private _target;
  129395. private _add;
  129396. private _attachedMesh;
  129397. private _invertYAxis;
  129398. /** Gets or sets probe position (center of the cube map) */
  129399. position: Vector3;
  129400. /**
  129401. * Creates a new reflection probe
  129402. * @param name defines the name of the probe
  129403. * @param size defines the texture resolution (for each face)
  129404. * @param scene defines the hosting scene
  129405. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  129406. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  129407. */
  129408. constructor(
  129409. /** defines the name of the probe */
  129410. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  129411. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  129412. get samples(): number;
  129413. set samples(value: number);
  129414. /** Gets or sets the refresh rate to use (on every frame by default) */
  129415. get refreshRate(): number;
  129416. set refreshRate(value: number);
  129417. /**
  129418. * Gets the hosting scene
  129419. * @returns a Scene
  129420. */
  129421. getScene(): Scene;
  129422. /** Gets the internal CubeTexture used to render to */
  129423. get cubeTexture(): RenderTargetTexture;
  129424. /** Gets the list of meshes to render */
  129425. get renderList(): Nullable<AbstractMesh[]>;
  129426. /**
  129427. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  129428. * @param mesh defines the mesh to attach to
  129429. */
  129430. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129431. /**
  129432. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  129433. * @param renderingGroupId The rendering group id corresponding to its index
  129434. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  129435. */
  129436. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  129437. /**
  129438. * Clean all associated resources
  129439. */
  129440. dispose(): void;
  129441. /**
  129442. * Converts the reflection probe information to a readable string for debug purpose.
  129443. * @param fullDetails Supports for multiple levels of logging within scene loading
  129444. * @returns the human readable reflection probe info
  129445. */
  129446. toString(fullDetails?: boolean): string;
  129447. /**
  129448. * Get the class name of the relfection probe.
  129449. * @returns "ReflectionProbe"
  129450. */
  129451. getClassName(): string;
  129452. /**
  129453. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  129454. * @returns The JSON representation of the texture
  129455. */
  129456. serialize(): any;
  129457. /**
  129458. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  129459. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  129460. * @param scene Define the scene the parsed reflection probe should be instantiated in
  129461. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  129462. * @returns The parsed reflection probe if successful
  129463. */
  129464. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  129465. }
  129466. }
  129467. declare module BABYLON {
  129468. /** @hidden */
  129469. export var _BabylonLoaderRegistered: boolean;
  129470. /**
  129471. * Helps setting up some configuration for the babylon file loader.
  129472. */
  129473. export class BabylonFileLoaderConfiguration {
  129474. /**
  129475. * The loader does not allow injecting custom physix engine into the plugins.
  129476. * Unfortunately in ES6, we need to manually inject them into the plugin.
  129477. * So you could set this variable to your engine import to make it work.
  129478. */
  129479. static LoaderInjectedPhysicsEngine: any;
  129480. }
  129481. }
  129482. declare module BABYLON {
  129483. /**
  129484. * The Physically based simple base material of BJS.
  129485. *
  129486. * This enables better naming and convention enforcements on top of the pbrMaterial.
  129487. * It is used as the base class for both the specGloss and metalRough conventions.
  129488. */
  129489. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  129490. /**
  129491. * Number of Simultaneous lights allowed on the material.
  129492. */
  129493. maxSimultaneousLights: number;
  129494. /**
  129495. * If sets to true, disables all the lights affecting the material.
  129496. */
  129497. disableLighting: boolean;
  129498. /**
  129499. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  129500. */
  129501. environmentTexture: BaseTexture;
  129502. /**
  129503. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  129504. */
  129505. invertNormalMapX: boolean;
  129506. /**
  129507. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  129508. */
  129509. invertNormalMapY: boolean;
  129510. /**
  129511. * Normal map used in the model.
  129512. */
  129513. normalTexture: BaseTexture;
  129514. /**
  129515. * Emissivie color used to self-illuminate the model.
  129516. */
  129517. emissiveColor: Color3;
  129518. /**
  129519. * Emissivie texture used to self-illuminate the model.
  129520. */
  129521. emissiveTexture: BaseTexture;
  129522. /**
  129523. * Occlusion Channel Strenght.
  129524. */
  129525. occlusionStrength: number;
  129526. /**
  129527. * Occlusion Texture of the material (adding extra occlusion effects).
  129528. */
  129529. occlusionTexture: BaseTexture;
  129530. /**
  129531. * Defines the alpha limits in alpha test mode.
  129532. */
  129533. alphaCutOff: number;
  129534. /**
  129535. * Gets the current double sided mode.
  129536. */
  129537. get doubleSided(): boolean;
  129538. /**
  129539. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  129540. */
  129541. set doubleSided(value: boolean);
  129542. /**
  129543. * Stores the pre-calculated light information of a mesh in a texture.
  129544. */
  129545. lightmapTexture: BaseTexture;
  129546. /**
  129547. * If true, the light map contains occlusion information instead of lighting info.
  129548. */
  129549. useLightmapAsShadowmap: boolean;
  129550. /**
  129551. * Instantiates a new PBRMaterial instance.
  129552. *
  129553. * @param name The material name
  129554. * @param scene The scene the material will be use in.
  129555. */
  129556. constructor(name: string, scene: Scene);
  129557. getClassName(): string;
  129558. }
  129559. }
  129560. declare module BABYLON {
  129561. /**
  129562. * The PBR material of BJS following the metal roughness convention.
  129563. *
  129564. * This fits to the PBR convention in the GLTF definition:
  129565. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129566. */
  129567. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129568. /**
  129569. * The base color has two different interpretations depending on the value of metalness.
  129570. * When the material is a metal, the base color is the specific measured reflectance value
  129571. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129572. * of the material.
  129573. */
  129574. baseColor: Color3;
  129575. /**
  129576. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129577. * well as opacity information in the alpha channel.
  129578. */
  129579. baseTexture: BaseTexture;
  129580. /**
  129581. * Specifies the metallic scalar value of the material.
  129582. * Can also be used to scale the metalness values of the metallic texture.
  129583. */
  129584. metallic: number;
  129585. /**
  129586. * Specifies the roughness scalar value of the material.
  129587. * Can also be used to scale the roughness values of the metallic texture.
  129588. */
  129589. roughness: number;
  129590. /**
  129591. * Texture containing both the metallic value in the B channel and the
  129592. * roughness value in the G channel to keep better precision.
  129593. */
  129594. metallicRoughnessTexture: BaseTexture;
  129595. /**
  129596. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129597. *
  129598. * @param name The material name
  129599. * @param scene The scene the material will be use in.
  129600. */
  129601. constructor(name: string, scene: Scene);
  129602. /**
  129603. * Return the currrent class name of the material.
  129604. */
  129605. getClassName(): string;
  129606. /**
  129607. * Makes a duplicate of the current material.
  129608. * @param name - name to use for the new material.
  129609. */
  129610. clone(name: string): PBRMetallicRoughnessMaterial;
  129611. /**
  129612. * Serialize the material to a parsable JSON object.
  129613. */
  129614. serialize(): any;
  129615. /**
  129616. * Parses a JSON object correponding to the serialize function.
  129617. */
  129618. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129619. }
  129620. }
  129621. declare module BABYLON {
  129622. /**
  129623. * The PBR material of BJS following the specular glossiness convention.
  129624. *
  129625. * This fits to the PBR convention in the GLTF definition:
  129626. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129627. */
  129628. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129629. /**
  129630. * Specifies the diffuse color of the material.
  129631. */
  129632. diffuseColor: Color3;
  129633. /**
  129634. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129635. * channel.
  129636. */
  129637. diffuseTexture: BaseTexture;
  129638. /**
  129639. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129640. */
  129641. specularColor: Color3;
  129642. /**
  129643. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129644. */
  129645. glossiness: number;
  129646. /**
  129647. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129648. */
  129649. specularGlossinessTexture: BaseTexture;
  129650. /**
  129651. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129652. *
  129653. * @param name The material name
  129654. * @param scene The scene the material will be use in.
  129655. */
  129656. constructor(name: string, scene: Scene);
  129657. /**
  129658. * Return the currrent class name of the material.
  129659. */
  129660. getClassName(): string;
  129661. /**
  129662. * Makes a duplicate of the current material.
  129663. * @param name - name to use for the new material.
  129664. */
  129665. clone(name: string): PBRSpecularGlossinessMaterial;
  129666. /**
  129667. * Serialize the material to a parsable JSON object.
  129668. */
  129669. serialize(): any;
  129670. /**
  129671. * Parses a JSON object correponding to the serialize function.
  129672. */
  129673. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129674. }
  129675. }
  129676. declare module BABYLON {
  129677. /**
  129678. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129679. * It can help converting any input color in a desired output one. This can then be used to create effects
  129680. * from sepia, black and white to sixties or futuristic rendering...
  129681. *
  129682. * The only supported format is currently 3dl.
  129683. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129684. */
  129685. export class ColorGradingTexture extends BaseTexture {
  129686. /**
  129687. * The current texture matrix. (will always be identity in color grading texture)
  129688. */
  129689. private _textureMatrix;
  129690. /**
  129691. * The texture URL.
  129692. */
  129693. url: string;
  129694. /**
  129695. * Empty line regex stored for GC.
  129696. */
  129697. private static _noneEmptyLineRegex;
  129698. private _engine;
  129699. /**
  129700. * Instantiates a ColorGradingTexture from the following parameters.
  129701. *
  129702. * @param url The location of the color gradind data (currently only supporting 3dl)
  129703. * @param scene The scene the texture will be used in
  129704. */
  129705. constructor(url: string, scene: Scene);
  129706. /**
  129707. * Returns the texture matrix used in most of the material.
  129708. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129709. */
  129710. getTextureMatrix(): Matrix;
  129711. /**
  129712. * Occurs when the file being loaded is a .3dl LUT file.
  129713. */
  129714. private load3dlTexture;
  129715. /**
  129716. * Starts the loading process of the texture.
  129717. */
  129718. private loadTexture;
  129719. /**
  129720. * Clones the color gradind texture.
  129721. */
  129722. clone(): ColorGradingTexture;
  129723. /**
  129724. * Called during delayed load for textures.
  129725. */
  129726. delayLoad(): void;
  129727. /**
  129728. * Parses a color grading texture serialized by Babylon.
  129729. * @param parsedTexture The texture information being parsedTexture
  129730. * @param scene The scene to load the texture in
  129731. * @param rootUrl The root url of the data assets to load
  129732. * @return A color gradind texture
  129733. */
  129734. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129735. /**
  129736. * Serializes the LUT texture to json format.
  129737. */
  129738. serialize(): any;
  129739. }
  129740. }
  129741. declare module BABYLON {
  129742. /**
  129743. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129744. */
  129745. export class EquiRectangularCubeTexture extends BaseTexture {
  129746. /** The six faces of the cube. */
  129747. private static _FacesMapping;
  129748. private _noMipmap;
  129749. private _onLoad;
  129750. private _onError;
  129751. /** The size of the cubemap. */
  129752. private _size;
  129753. /** The buffer of the image. */
  129754. private _buffer;
  129755. /** The width of the input image. */
  129756. private _width;
  129757. /** The height of the input image. */
  129758. private _height;
  129759. /** The URL to the image. */
  129760. url: string;
  129761. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129762. coordinatesMode: number;
  129763. /**
  129764. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129765. * @param url The location of the image
  129766. * @param scene The scene the texture will be used in
  129767. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129768. * @param noMipmap Forces to not generate the mipmap if true
  129769. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129770. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129771. * @param onLoad — defines a callback called when texture is loaded
  129772. * @param onError — defines a callback called if there is an error
  129773. */
  129774. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129775. /**
  129776. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129777. */
  129778. private loadImage;
  129779. /**
  129780. * Convert the image buffer into a cubemap and create a CubeTexture.
  129781. */
  129782. private loadTexture;
  129783. /**
  129784. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129785. * @param buffer The ArrayBuffer that should be converted.
  129786. * @returns The buffer as Float32Array.
  129787. */
  129788. private getFloat32ArrayFromArrayBuffer;
  129789. /**
  129790. * Get the current class name of the texture useful for serialization or dynamic coding.
  129791. * @returns "EquiRectangularCubeTexture"
  129792. */
  129793. getClassName(): string;
  129794. /**
  129795. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129796. * @returns A clone of the current EquiRectangularCubeTexture.
  129797. */
  129798. clone(): EquiRectangularCubeTexture;
  129799. }
  129800. }
  129801. declare module BABYLON {
  129802. /**
  129803. * Based on jsTGALoader - Javascript loader for TGA file
  129804. * By Vincent Thibault
  129805. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129806. */
  129807. export class TGATools {
  129808. private static _TYPE_INDEXED;
  129809. private static _TYPE_RGB;
  129810. private static _TYPE_GREY;
  129811. private static _TYPE_RLE_INDEXED;
  129812. private static _TYPE_RLE_RGB;
  129813. private static _TYPE_RLE_GREY;
  129814. private static _ORIGIN_MASK;
  129815. private static _ORIGIN_SHIFT;
  129816. private static _ORIGIN_BL;
  129817. private static _ORIGIN_BR;
  129818. private static _ORIGIN_UL;
  129819. private static _ORIGIN_UR;
  129820. /**
  129821. * Gets the header of a TGA file
  129822. * @param data defines the TGA data
  129823. * @returns the header
  129824. */
  129825. static GetTGAHeader(data: Uint8Array): any;
  129826. /**
  129827. * Uploads TGA content to a Babylon Texture
  129828. * @hidden
  129829. */
  129830. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129831. /** @hidden */
  129832. 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;
  129833. /** @hidden */
  129834. 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;
  129835. /** @hidden */
  129836. 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;
  129837. /** @hidden */
  129838. 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;
  129839. /** @hidden */
  129840. 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;
  129841. /** @hidden */
  129842. 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;
  129843. }
  129844. }
  129845. declare module BABYLON {
  129846. /**
  129847. * Implementation of the TGA Texture Loader.
  129848. * @hidden
  129849. */
  129850. export class _TGATextureLoader implements IInternalTextureLoader {
  129851. /**
  129852. * Defines wether the loader supports cascade loading the different faces.
  129853. */
  129854. readonly supportCascades: boolean;
  129855. /**
  129856. * This returns if the loader support the current file information.
  129857. * @param extension defines the file extension of the file being loaded
  129858. * @returns true if the loader can load the specified file
  129859. */
  129860. canLoad(extension: string): boolean;
  129861. /**
  129862. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129863. * @param data contains the texture data
  129864. * @param texture defines the BabylonJS internal texture
  129865. * @param createPolynomials will be true if polynomials have been requested
  129866. * @param onLoad defines the callback to trigger once the texture is ready
  129867. * @param onError defines the callback to trigger in case of error
  129868. */
  129869. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129870. /**
  129871. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129872. * @param data contains the texture data
  129873. * @param texture defines the BabylonJS internal texture
  129874. * @param callback defines the method to call once ready to upload
  129875. */
  129876. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129877. }
  129878. }
  129879. declare module BABYLON {
  129880. /**
  129881. * Info about the .basis files
  129882. */
  129883. class BasisFileInfo {
  129884. /**
  129885. * If the file has alpha
  129886. */
  129887. hasAlpha: boolean;
  129888. /**
  129889. * Info about each image of the basis file
  129890. */
  129891. images: Array<{
  129892. levels: Array<{
  129893. width: number;
  129894. height: number;
  129895. transcodedPixels: ArrayBufferView;
  129896. }>;
  129897. }>;
  129898. }
  129899. /**
  129900. * Result of transcoding a basis file
  129901. */
  129902. class TranscodeResult {
  129903. /**
  129904. * Info about the .basis file
  129905. */
  129906. fileInfo: BasisFileInfo;
  129907. /**
  129908. * Format to use when loading the file
  129909. */
  129910. format: number;
  129911. }
  129912. /**
  129913. * Configuration options for the Basis transcoder
  129914. */
  129915. export class BasisTranscodeConfiguration {
  129916. /**
  129917. * Supported compression formats used to determine the supported output format of the transcoder
  129918. */
  129919. supportedCompressionFormats?: {
  129920. /**
  129921. * etc1 compression format
  129922. */
  129923. etc1?: boolean;
  129924. /**
  129925. * s3tc compression format
  129926. */
  129927. s3tc?: boolean;
  129928. /**
  129929. * pvrtc compression format
  129930. */
  129931. pvrtc?: boolean;
  129932. /**
  129933. * etc2 compression format
  129934. */
  129935. etc2?: boolean;
  129936. };
  129937. /**
  129938. * If mipmap levels should be loaded for transcoded images (Default: true)
  129939. */
  129940. loadMipmapLevels?: boolean;
  129941. /**
  129942. * Index of a single image to load (Default: all images)
  129943. */
  129944. loadSingleImage?: number;
  129945. }
  129946. /**
  129947. * Used to load .Basis files
  129948. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129949. */
  129950. export class BasisTools {
  129951. private static _IgnoreSupportedFormats;
  129952. /**
  129953. * URL to use when loading the basis transcoder
  129954. */
  129955. static JSModuleURL: string;
  129956. /**
  129957. * URL to use when loading the wasm module for the transcoder
  129958. */
  129959. static WasmModuleURL: string;
  129960. /**
  129961. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129962. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129963. * @returns internal format corresponding to the Basis format
  129964. */
  129965. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129966. private static _WorkerPromise;
  129967. private static _Worker;
  129968. private static _actionId;
  129969. private static _CreateWorkerAsync;
  129970. /**
  129971. * Transcodes a loaded image file to compressed pixel data
  129972. * @param data image data to transcode
  129973. * @param config configuration options for the transcoding
  129974. * @returns a promise resulting in the transcoded image
  129975. */
  129976. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129977. /**
  129978. * Loads a texture from the transcode result
  129979. * @param texture texture load to
  129980. * @param transcodeResult the result of transcoding the basis file to load from
  129981. */
  129982. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129983. }
  129984. }
  129985. declare module BABYLON {
  129986. /**
  129987. * Loader for .basis file format
  129988. */
  129989. export class _BasisTextureLoader implements IInternalTextureLoader {
  129990. /**
  129991. * Defines whether the loader supports cascade loading the different faces.
  129992. */
  129993. readonly supportCascades: boolean;
  129994. /**
  129995. * This returns if the loader support the current file information.
  129996. * @param extension defines the file extension of the file being loaded
  129997. * @returns true if the loader can load the specified file
  129998. */
  129999. canLoad(extension: string): boolean;
  130000. /**
  130001. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130002. * @param data contains the texture data
  130003. * @param texture defines the BabylonJS internal texture
  130004. * @param createPolynomials will be true if polynomials have been requested
  130005. * @param onLoad defines the callback to trigger once the texture is ready
  130006. * @param onError defines the callback to trigger in case of error
  130007. */
  130008. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130009. /**
  130010. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130011. * @param data contains the texture data
  130012. * @param texture defines the BabylonJS internal texture
  130013. * @param callback defines the method to call once ready to upload
  130014. */
  130015. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130016. }
  130017. }
  130018. declare module BABYLON {
  130019. /**
  130020. * 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.
  130021. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130022. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130023. */
  130024. export class CustomProceduralTexture extends ProceduralTexture {
  130025. private _animate;
  130026. private _time;
  130027. private _config;
  130028. private _texturePath;
  130029. /**
  130030. * Instantiates a new Custom Procedural Texture.
  130031. * 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.
  130032. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130033. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130034. * @param name Define the name of the texture
  130035. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  130036. * @param size Define the size of the texture to create
  130037. * @param scene Define the scene the texture belongs to
  130038. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  130039. * @param generateMipMaps Define if the texture should creates mip maps or not
  130040. */
  130041. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  130042. private _loadJson;
  130043. /**
  130044. * Is the texture ready to be used ? (rendered at least once)
  130045. * @returns true if ready, otherwise, false.
  130046. */
  130047. isReady(): boolean;
  130048. /**
  130049. * Render the texture to its associated render target.
  130050. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  130051. */
  130052. render(useCameraPostProcess?: boolean): void;
  130053. /**
  130054. * Update the list of dependant textures samplers in the shader.
  130055. */
  130056. updateTextures(): void;
  130057. /**
  130058. * Update the uniform values of the procedural texture in the shader.
  130059. */
  130060. updateShaderUniforms(): void;
  130061. /**
  130062. * Define if the texture animates or not.
  130063. */
  130064. get animate(): boolean;
  130065. set animate(value: boolean);
  130066. }
  130067. }
  130068. declare module BABYLON {
  130069. /** @hidden */
  130070. export var noisePixelShader: {
  130071. name: string;
  130072. shader: string;
  130073. };
  130074. }
  130075. declare module BABYLON {
  130076. /**
  130077. * Class used to generate noise procedural textures
  130078. */
  130079. export class NoiseProceduralTexture extends ProceduralTexture {
  130080. private _time;
  130081. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  130082. brightness: number;
  130083. /** Defines the number of octaves to process */
  130084. octaves: number;
  130085. /** Defines the level of persistence (0.8 by default) */
  130086. persistence: number;
  130087. /** Gets or sets animation speed factor (default is 1) */
  130088. animationSpeedFactor: number;
  130089. /**
  130090. * Creates a new NoiseProceduralTexture
  130091. * @param name defines the name fo the texture
  130092. * @param size defines the size of the texture (default is 256)
  130093. * @param scene defines the hosting scene
  130094. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  130095. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  130096. */
  130097. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  130098. private _updateShaderUniforms;
  130099. protected _getDefines(): string;
  130100. /** Generate the current state of the procedural texture */
  130101. render(useCameraPostProcess?: boolean): void;
  130102. /**
  130103. * Serializes this noise procedural texture
  130104. * @returns a serialized noise procedural texture object
  130105. */
  130106. serialize(): any;
  130107. /**
  130108. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  130109. * @param parsedTexture defines parsed texture data
  130110. * @param scene defines the current scene
  130111. * @param rootUrl defines the root URL containing noise procedural texture information
  130112. * @returns a parsed NoiseProceduralTexture
  130113. */
  130114. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  130115. }
  130116. }
  130117. declare module BABYLON {
  130118. /**
  130119. * Raw cube texture where the raw buffers are passed in
  130120. */
  130121. export class RawCubeTexture extends CubeTexture {
  130122. /**
  130123. * Creates a cube texture where the raw buffers are passed in.
  130124. * @param scene defines the scene the texture is attached to
  130125. * @param data defines the array of data to use to create each face
  130126. * @param size defines the size of the textures
  130127. * @param format defines the format of the data
  130128. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  130129. * @param generateMipMaps defines if the engine should generate the mip levels
  130130. * @param invertY defines if data must be stored with Y axis inverted
  130131. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130132. * @param compression defines the compression used (null by default)
  130133. */
  130134. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  130135. /**
  130136. * Updates the raw cube texture.
  130137. * @param data defines the data to store
  130138. * @param format defines the data format
  130139. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130140. * @param invertY defines if data must be stored with Y axis inverted
  130141. * @param compression defines the compression used (null by default)
  130142. * @param level defines which level of the texture to update
  130143. */
  130144. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  130145. /**
  130146. * Updates a raw cube texture with RGBD encoded data.
  130147. * @param data defines the array of data [mipmap][face] to use to create each face
  130148. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  130149. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130150. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130151. * @returns a promsie that resolves when the operation is complete
  130152. */
  130153. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  130154. /**
  130155. * Clones the raw cube texture.
  130156. * @return a new cube texture
  130157. */
  130158. clone(): CubeTexture;
  130159. /** @hidden */
  130160. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  130161. }
  130162. }
  130163. declare module BABYLON {
  130164. /**
  130165. * Class used to store 3D textures containing user data
  130166. */
  130167. export class RawTexture3D extends Texture {
  130168. /** Gets or sets the texture format to use */
  130169. format: number;
  130170. private _engine;
  130171. /**
  130172. * Create a new RawTexture3D
  130173. * @param data defines the data of the texture
  130174. * @param width defines the width of the texture
  130175. * @param height defines the height of the texture
  130176. * @param depth defines the depth of the texture
  130177. * @param format defines the texture format to use
  130178. * @param scene defines the hosting scene
  130179. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  130180. * @param invertY defines if texture must be stored with Y axis inverted
  130181. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130182. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130183. */
  130184. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  130185. /** Gets or sets the texture format to use */
  130186. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  130187. /**
  130188. * Update the texture with new data
  130189. * @param data defines the data to store in the texture
  130190. */
  130191. update(data: ArrayBufferView): void;
  130192. }
  130193. }
  130194. declare module BABYLON {
  130195. /**
  130196. * Class used to store 2D array textures containing user data
  130197. */
  130198. export class RawTexture2DArray extends Texture {
  130199. /** Gets or sets the texture format to use */
  130200. format: number;
  130201. private _engine;
  130202. /**
  130203. * Create a new RawTexture2DArray
  130204. * @param data defines the data of the texture
  130205. * @param width defines the width of the texture
  130206. * @param height defines the height of the texture
  130207. * @param depth defines the number of layers of the texture
  130208. * @param format defines the texture format to use
  130209. * @param scene defines the hosting scene
  130210. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  130211. * @param invertY defines if texture must be stored with Y axis inverted
  130212. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130213. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130214. */
  130215. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  130216. /** Gets or sets the texture format to use */
  130217. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  130218. /**
  130219. * Update the texture with new data
  130220. * @param data defines the data to store in the texture
  130221. */
  130222. update(data: ArrayBufferView): void;
  130223. }
  130224. }
  130225. declare module BABYLON {
  130226. /**
  130227. * Creates a refraction texture used by refraction channel of the standard material.
  130228. * It is like a mirror but to see through a material.
  130229. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130230. */
  130231. export class RefractionTexture extends RenderTargetTexture {
  130232. /**
  130233. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  130234. * 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.
  130235. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130236. */
  130237. refractionPlane: Plane;
  130238. /**
  130239. * Define how deep under the surface we should see.
  130240. */
  130241. depth: number;
  130242. /**
  130243. * Creates a refraction texture used by refraction channel of the standard material.
  130244. * It is like a mirror but to see through a material.
  130245. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130246. * @param name Define the texture name
  130247. * @param size Define the size of the underlying texture
  130248. * @param scene Define the scene the refraction belongs to
  130249. * @param generateMipMaps Define if we need to generate mips level for the refraction
  130250. */
  130251. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  130252. /**
  130253. * Clone the refraction texture.
  130254. * @returns the cloned texture
  130255. */
  130256. clone(): RefractionTexture;
  130257. /**
  130258. * Serialize the texture to a JSON representation you could use in Parse later on
  130259. * @returns the serialized JSON representation
  130260. */
  130261. serialize(): any;
  130262. }
  130263. }
  130264. declare module BABYLON {
  130265. /**
  130266. * Defines the options related to the creation of an HtmlElementTexture
  130267. */
  130268. export interface IHtmlElementTextureOptions {
  130269. /**
  130270. * Defines wether mip maps should be created or not.
  130271. */
  130272. generateMipMaps?: boolean;
  130273. /**
  130274. * Defines the sampling mode of the texture.
  130275. */
  130276. samplingMode?: number;
  130277. /**
  130278. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  130279. */
  130280. engine: Nullable<ThinEngine>;
  130281. /**
  130282. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  130283. */
  130284. scene: Nullable<Scene>;
  130285. }
  130286. /**
  130287. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  130288. * To be as efficient as possible depending on your constraints nothing aside the first upload
  130289. * is automatically managed.
  130290. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  130291. * in your application.
  130292. *
  130293. * As the update is not automatic, you need to call them manually.
  130294. */
  130295. export class HtmlElementTexture extends BaseTexture {
  130296. /**
  130297. * The texture URL.
  130298. */
  130299. element: HTMLVideoElement | HTMLCanvasElement;
  130300. private static readonly DefaultOptions;
  130301. private _textureMatrix;
  130302. private _engine;
  130303. private _isVideo;
  130304. private _generateMipMaps;
  130305. private _samplingMode;
  130306. /**
  130307. * Instantiates a HtmlElementTexture from the following parameters.
  130308. *
  130309. * @param name Defines the name of the texture
  130310. * @param element Defines the video or canvas the texture is filled with
  130311. * @param options Defines the other none mandatory texture creation options
  130312. */
  130313. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  130314. private _createInternalTexture;
  130315. /**
  130316. * Returns the texture matrix used in most of the material.
  130317. */
  130318. getTextureMatrix(): Matrix;
  130319. /**
  130320. * Updates the content of the texture.
  130321. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  130322. */
  130323. update(invertY?: Nullable<boolean>): void;
  130324. }
  130325. }
  130326. declare module BABYLON {
  130327. /**
  130328. * Defines the basic options interface of a TexturePacker Frame
  130329. */
  130330. export interface ITexturePackerFrame {
  130331. /**
  130332. * The frame ID
  130333. */
  130334. id: number;
  130335. /**
  130336. * The frames Scale
  130337. */
  130338. scale: Vector2;
  130339. /**
  130340. * The Frames offset
  130341. */
  130342. offset: Vector2;
  130343. }
  130344. /**
  130345. * This is a support class for frame Data on texture packer sets.
  130346. */
  130347. export class TexturePackerFrame implements ITexturePackerFrame {
  130348. /**
  130349. * The frame ID
  130350. */
  130351. id: number;
  130352. /**
  130353. * The frames Scale
  130354. */
  130355. scale: Vector2;
  130356. /**
  130357. * The Frames offset
  130358. */
  130359. offset: Vector2;
  130360. /**
  130361. * Initializes a texture package frame.
  130362. * @param id The numerical frame identifier
  130363. * @param scale Scalar Vector2 for UV frame
  130364. * @param offset Vector2 for the frame position in UV units.
  130365. * @returns TexturePackerFrame
  130366. */
  130367. constructor(id: number, scale: Vector2, offset: Vector2);
  130368. }
  130369. }
  130370. declare module BABYLON {
  130371. /**
  130372. * Defines the basic options interface of a TexturePacker
  130373. */
  130374. export interface ITexturePackerOptions {
  130375. /**
  130376. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  130377. */
  130378. map?: string[];
  130379. /**
  130380. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130381. */
  130382. uvsIn?: string;
  130383. /**
  130384. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130385. */
  130386. uvsOut?: string;
  130387. /**
  130388. * number representing the layout style. Defaults to LAYOUT_STRIP
  130389. */
  130390. layout?: number;
  130391. /**
  130392. * number of columns if using custom column count layout(2). This defaults to 4.
  130393. */
  130394. colnum?: number;
  130395. /**
  130396. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  130397. */
  130398. updateInputMeshes?: boolean;
  130399. /**
  130400. * boolean flag to dispose all the source textures. Defaults to true.
  130401. */
  130402. disposeSources?: boolean;
  130403. /**
  130404. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  130405. */
  130406. fillBlanks?: boolean;
  130407. /**
  130408. * string value representing the context fill style color. Defaults to 'black'.
  130409. */
  130410. customFillColor?: string;
  130411. /**
  130412. * Width and Height Value of each Frame in the TexturePacker Sets
  130413. */
  130414. frameSize?: number;
  130415. /**
  130416. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  130417. */
  130418. paddingRatio?: number;
  130419. /**
  130420. * Number that declares the fill method for the padding gutter.
  130421. */
  130422. paddingMode?: number;
  130423. /**
  130424. * If in SUBUV_COLOR padding mode what color to use.
  130425. */
  130426. paddingColor?: Color3 | Color4;
  130427. }
  130428. /**
  130429. * Defines the basic interface of a TexturePacker JSON File
  130430. */
  130431. export interface ITexturePackerJSON {
  130432. /**
  130433. * The frame ID
  130434. */
  130435. name: string;
  130436. /**
  130437. * The base64 channel data
  130438. */
  130439. sets: any;
  130440. /**
  130441. * The options of the Packer
  130442. */
  130443. options: ITexturePackerOptions;
  130444. /**
  130445. * The frame data of the Packer
  130446. */
  130447. frames: Array<number>;
  130448. }
  130449. /**
  130450. * This is a support class that generates a series of packed texture sets.
  130451. * @see https://doc.babylonjs.com/babylon101/materials
  130452. */
  130453. export class TexturePacker {
  130454. /** Packer Layout Constant 0 */
  130455. static readonly LAYOUT_STRIP: number;
  130456. /** Packer Layout Constant 1 */
  130457. static readonly LAYOUT_POWER2: number;
  130458. /** Packer Layout Constant 2 */
  130459. static readonly LAYOUT_COLNUM: number;
  130460. /** Packer Layout Constant 0 */
  130461. static readonly SUBUV_WRAP: number;
  130462. /** Packer Layout Constant 1 */
  130463. static readonly SUBUV_EXTEND: number;
  130464. /** Packer Layout Constant 2 */
  130465. static readonly SUBUV_COLOR: number;
  130466. /** The Name of the Texture Package */
  130467. name: string;
  130468. /** The scene scope of the TexturePacker */
  130469. scene: Scene;
  130470. /** The Meshes to target */
  130471. meshes: AbstractMesh[];
  130472. /** Arguments passed with the Constructor */
  130473. options: ITexturePackerOptions;
  130474. /** The promise that is started upon initialization */
  130475. promise: Nullable<Promise<TexturePacker | string>>;
  130476. /** The Container object for the channel sets that are generated */
  130477. sets: object;
  130478. /** The Container array for the frames that are generated */
  130479. frames: TexturePackerFrame[];
  130480. /** The expected number of textures the system is parsing. */
  130481. private _expecting;
  130482. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  130483. private _paddingValue;
  130484. /**
  130485. * Initializes a texture package series from an array of meshes or a single mesh.
  130486. * @param name The name of the package
  130487. * @param meshes The target meshes to compose the package from
  130488. * @param options The arguments that texture packer should follow while building.
  130489. * @param scene The scene which the textures are scoped to.
  130490. * @returns TexturePacker
  130491. */
  130492. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  130493. /**
  130494. * Starts the package process
  130495. * @param resolve The promises resolution function
  130496. * @returns TexturePacker
  130497. */
  130498. private _createFrames;
  130499. /**
  130500. * Calculates the Size of the Channel Sets
  130501. * @returns Vector2
  130502. */
  130503. private _calculateSize;
  130504. /**
  130505. * Calculates the UV data for the frames.
  130506. * @param baseSize the base frameSize
  130507. * @param padding the base frame padding
  130508. * @param dtSize size of the Dynamic Texture for that channel
  130509. * @param dtUnits is 1/dtSize
  130510. * @param update flag to update the input meshes
  130511. */
  130512. private _calculateMeshUVFrames;
  130513. /**
  130514. * Calculates the frames Offset.
  130515. * @param index of the frame
  130516. * @returns Vector2
  130517. */
  130518. private _getFrameOffset;
  130519. /**
  130520. * Updates a Mesh to the frame data
  130521. * @param mesh that is the target
  130522. * @param frameID or the frame index
  130523. */
  130524. private _updateMeshUV;
  130525. /**
  130526. * Updates a Meshes materials to use the texture packer channels
  130527. * @param m is the mesh to target
  130528. * @param force all channels on the packer to be set.
  130529. */
  130530. private _updateTextureReferences;
  130531. /**
  130532. * Public method to set a Mesh to a frame
  130533. * @param m that is the target
  130534. * @param frameID or the frame index
  130535. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130536. */
  130537. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130538. /**
  130539. * Starts the async promise to compile the texture packer.
  130540. * @returns Promise<void>
  130541. */
  130542. processAsync(): Promise<void>;
  130543. /**
  130544. * Disposes all textures associated with this packer
  130545. */
  130546. dispose(): void;
  130547. /**
  130548. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130549. * @param imageType is the image type to use.
  130550. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130551. */
  130552. download(imageType?: string, quality?: number): void;
  130553. /**
  130554. * Public method to load a texturePacker JSON file.
  130555. * @param data of the JSON file in string format.
  130556. */
  130557. updateFromJSON(data: string): void;
  130558. }
  130559. }
  130560. declare module BABYLON {
  130561. /**
  130562. * Enum used to define the target of a block
  130563. */
  130564. export enum NodeMaterialBlockTargets {
  130565. /** Vertex shader */
  130566. Vertex = 1,
  130567. /** Fragment shader */
  130568. Fragment = 2,
  130569. /** Neutral */
  130570. Neutral = 4,
  130571. /** Vertex and Fragment */
  130572. VertexAndFragment = 3
  130573. }
  130574. }
  130575. declare module BABYLON {
  130576. /**
  130577. * Defines the kind of connection point for node based material
  130578. */
  130579. export enum NodeMaterialBlockConnectionPointTypes {
  130580. /** Float */
  130581. Float = 1,
  130582. /** Int */
  130583. Int = 2,
  130584. /** Vector2 */
  130585. Vector2 = 4,
  130586. /** Vector3 */
  130587. Vector3 = 8,
  130588. /** Vector4 */
  130589. Vector4 = 16,
  130590. /** Color3 */
  130591. Color3 = 32,
  130592. /** Color4 */
  130593. Color4 = 64,
  130594. /** Matrix */
  130595. Matrix = 128,
  130596. /** Detect type based on connection */
  130597. AutoDetect = 1024,
  130598. /** Output type that will be defined by input type */
  130599. BasedOnInput = 2048
  130600. }
  130601. }
  130602. declare module BABYLON {
  130603. /**
  130604. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130605. */
  130606. export enum NodeMaterialBlockConnectionPointMode {
  130607. /** Value is an uniform */
  130608. Uniform = 0,
  130609. /** Value is a mesh attribute */
  130610. Attribute = 1,
  130611. /** Value is a varying between vertex and fragment shaders */
  130612. Varying = 2,
  130613. /** Mode is undefined */
  130614. Undefined = 3
  130615. }
  130616. }
  130617. declare module BABYLON {
  130618. /**
  130619. * Enum used to define system values e.g. values automatically provided by the system
  130620. */
  130621. export enum NodeMaterialSystemValues {
  130622. /** World */
  130623. World = 1,
  130624. /** View */
  130625. View = 2,
  130626. /** Projection */
  130627. Projection = 3,
  130628. /** ViewProjection */
  130629. ViewProjection = 4,
  130630. /** WorldView */
  130631. WorldView = 5,
  130632. /** WorldViewProjection */
  130633. WorldViewProjection = 6,
  130634. /** CameraPosition */
  130635. CameraPosition = 7,
  130636. /** Fog Color */
  130637. FogColor = 8,
  130638. /** Delta time */
  130639. DeltaTime = 9
  130640. }
  130641. }
  130642. declare module BABYLON {
  130643. /**
  130644. * Root class for all node material optimizers
  130645. */
  130646. export class NodeMaterialOptimizer {
  130647. /**
  130648. * Function used to optimize a NodeMaterial graph
  130649. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130650. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130651. */
  130652. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130653. }
  130654. }
  130655. declare module BABYLON {
  130656. /**
  130657. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130658. */
  130659. export class TransformBlock extends NodeMaterialBlock {
  130660. /**
  130661. * Defines the value to use to complement W value to transform it to a Vector4
  130662. */
  130663. complementW: number;
  130664. /**
  130665. * Defines the value to use to complement z value to transform it to a Vector4
  130666. */
  130667. complementZ: number;
  130668. /**
  130669. * Creates a new TransformBlock
  130670. * @param name defines the block name
  130671. */
  130672. constructor(name: string);
  130673. /**
  130674. * Gets the current class name
  130675. * @returns the class name
  130676. */
  130677. getClassName(): string;
  130678. /**
  130679. * Gets the vector input
  130680. */
  130681. get vector(): NodeMaterialConnectionPoint;
  130682. /**
  130683. * Gets the output component
  130684. */
  130685. get output(): NodeMaterialConnectionPoint;
  130686. /**
  130687. * Gets the xyz output component
  130688. */
  130689. get xyz(): NodeMaterialConnectionPoint;
  130690. /**
  130691. * Gets the matrix transform input
  130692. */
  130693. get transform(): NodeMaterialConnectionPoint;
  130694. protected _buildBlock(state: NodeMaterialBuildState): this;
  130695. serialize(): any;
  130696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130697. protected _dumpPropertiesCode(): string;
  130698. }
  130699. }
  130700. declare module BABYLON {
  130701. /**
  130702. * Block used to output the vertex position
  130703. */
  130704. export class VertexOutputBlock extends NodeMaterialBlock {
  130705. /**
  130706. * Creates a new VertexOutputBlock
  130707. * @param name defines the block name
  130708. */
  130709. constructor(name: string);
  130710. /**
  130711. * Gets the current class name
  130712. * @returns the class name
  130713. */
  130714. getClassName(): string;
  130715. /**
  130716. * Gets the vector input component
  130717. */
  130718. get vector(): NodeMaterialConnectionPoint;
  130719. protected _buildBlock(state: NodeMaterialBuildState): this;
  130720. }
  130721. }
  130722. declare module BABYLON {
  130723. /**
  130724. * Block used to output the final color
  130725. */
  130726. export class FragmentOutputBlock extends NodeMaterialBlock {
  130727. /**
  130728. * Create a new FragmentOutputBlock
  130729. * @param name defines the block name
  130730. */
  130731. constructor(name: string);
  130732. /**
  130733. * Gets the current class name
  130734. * @returns the class name
  130735. */
  130736. getClassName(): string;
  130737. /**
  130738. * Gets the rgba input component
  130739. */
  130740. get rgba(): NodeMaterialConnectionPoint;
  130741. /**
  130742. * Gets the rgb input component
  130743. */
  130744. get rgb(): NodeMaterialConnectionPoint;
  130745. /**
  130746. * Gets the a input component
  130747. */
  130748. get a(): NodeMaterialConnectionPoint;
  130749. protected _buildBlock(state: NodeMaterialBuildState): this;
  130750. }
  130751. }
  130752. declare module BABYLON {
  130753. /**
  130754. * Block used to read a reflection texture from a sampler
  130755. */
  130756. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130757. private _define3DName;
  130758. private _defineCubicName;
  130759. private _defineExplicitName;
  130760. private _defineProjectionName;
  130761. private _defineLocalCubicName;
  130762. private _defineSphericalName;
  130763. private _definePlanarName;
  130764. private _defineEquirectangularName;
  130765. private _defineMirroredEquirectangularFixedName;
  130766. private _defineEquirectangularFixedName;
  130767. private _defineSkyboxName;
  130768. private _cubeSamplerName;
  130769. private _2DSamplerName;
  130770. private _positionUVWName;
  130771. private _directionWName;
  130772. private _reflectionCoordsName;
  130773. private _reflection2DCoordsName;
  130774. private _reflectionColorName;
  130775. private _reflectionMatrixName;
  130776. /**
  130777. * Gets or sets the texture associated with the node
  130778. */
  130779. texture: Nullable<BaseTexture>;
  130780. /**
  130781. * Create a new TextureBlock
  130782. * @param name defines the block name
  130783. */
  130784. constructor(name: string);
  130785. /**
  130786. * Gets the current class name
  130787. * @returns the class name
  130788. */
  130789. getClassName(): string;
  130790. /**
  130791. * Gets the world position input component
  130792. */
  130793. get position(): NodeMaterialConnectionPoint;
  130794. /**
  130795. * Gets the world position input component
  130796. */
  130797. get worldPosition(): NodeMaterialConnectionPoint;
  130798. /**
  130799. * Gets the world normal input component
  130800. */
  130801. get worldNormal(): NodeMaterialConnectionPoint;
  130802. /**
  130803. * Gets the world input component
  130804. */
  130805. get world(): NodeMaterialConnectionPoint;
  130806. /**
  130807. * Gets the camera (or eye) position component
  130808. */
  130809. get cameraPosition(): NodeMaterialConnectionPoint;
  130810. /**
  130811. * Gets the view input component
  130812. */
  130813. get view(): NodeMaterialConnectionPoint;
  130814. /**
  130815. * Gets the rgb output component
  130816. */
  130817. get rgb(): NodeMaterialConnectionPoint;
  130818. /**
  130819. * Gets the r output component
  130820. */
  130821. get r(): NodeMaterialConnectionPoint;
  130822. /**
  130823. * Gets the g output component
  130824. */
  130825. get g(): NodeMaterialConnectionPoint;
  130826. /**
  130827. * Gets the b output component
  130828. */
  130829. get b(): NodeMaterialConnectionPoint;
  130830. autoConfigure(material: NodeMaterial): void;
  130831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130832. isReady(): boolean;
  130833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130834. private _injectVertexCode;
  130835. private _writeOutput;
  130836. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130837. protected _dumpPropertiesCode(): string;
  130838. serialize(): any;
  130839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130840. }
  130841. }
  130842. declare module BABYLON {
  130843. /**
  130844. * Interface used to configure the node material editor
  130845. */
  130846. export interface INodeMaterialEditorOptions {
  130847. /** Define the URl to load node editor script */
  130848. editorURL?: string;
  130849. }
  130850. /** @hidden */
  130851. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130852. NORMAL: boolean;
  130853. TANGENT: boolean;
  130854. UV1: boolean;
  130855. /** BONES */
  130856. NUM_BONE_INFLUENCERS: number;
  130857. BonesPerMesh: number;
  130858. BONETEXTURE: boolean;
  130859. /** MORPH TARGETS */
  130860. MORPHTARGETS: boolean;
  130861. MORPHTARGETS_NORMAL: boolean;
  130862. MORPHTARGETS_TANGENT: boolean;
  130863. MORPHTARGETS_UV: boolean;
  130864. NUM_MORPH_INFLUENCERS: number;
  130865. /** IMAGE PROCESSING */
  130866. IMAGEPROCESSING: boolean;
  130867. VIGNETTE: boolean;
  130868. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130869. VIGNETTEBLENDMODEOPAQUE: boolean;
  130870. TONEMAPPING: boolean;
  130871. TONEMAPPING_ACES: boolean;
  130872. CONTRAST: boolean;
  130873. EXPOSURE: boolean;
  130874. COLORCURVES: boolean;
  130875. COLORGRADING: boolean;
  130876. COLORGRADING3D: boolean;
  130877. SAMPLER3DGREENDEPTH: boolean;
  130878. SAMPLER3DBGRMAP: boolean;
  130879. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130880. /** MISC. */
  130881. BUMPDIRECTUV: number;
  130882. constructor();
  130883. setValue(name: string, value: boolean): void;
  130884. }
  130885. /**
  130886. * Class used to configure NodeMaterial
  130887. */
  130888. export interface INodeMaterialOptions {
  130889. /**
  130890. * Defines if blocks should emit comments
  130891. */
  130892. emitComments: boolean;
  130893. }
  130894. /**
  130895. * Class used to create a node based material built by assembling shader blocks
  130896. */
  130897. export class NodeMaterial extends PushMaterial {
  130898. private static _BuildIdGenerator;
  130899. private _options;
  130900. private _vertexCompilationState;
  130901. private _fragmentCompilationState;
  130902. private _sharedData;
  130903. private _buildId;
  130904. private _buildWasSuccessful;
  130905. private _cachedWorldViewMatrix;
  130906. private _cachedWorldViewProjectionMatrix;
  130907. private _optimizers;
  130908. private _animationFrame;
  130909. /** Define the Url to load node editor script */
  130910. static EditorURL: string;
  130911. /** Define the Url to load snippets */
  130912. static SnippetUrl: string;
  130913. private BJSNODEMATERIALEDITOR;
  130914. /** Get the inspector from bundle or global */
  130915. private _getGlobalNodeMaterialEditor;
  130916. /**
  130917. * Gets or sets data used by visual editor
  130918. * @see https://nme.babylonjs.com
  130919. */
  130920. editorData: any;
  130921. /**
  130922. * 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)
  130923. */
  130924. ignoreAlpha: boolean;
  130925. /**
  130926. * Defines the maximum number of lights that can be used in the material
  130927. */
  130928. maxSimultaneousLights: number;
  130929. /**
  130930. * Observable raised when the material is built
  130931. */
  130932. onBuildObservable: Observable<NodeMaterial>;
  130933. /**
  130934. * Gets or sets the root nodes of the material vertex shader
  130935. */
  130936. _vertexOutputNodes: NodeMaterialBlock[];
  130937. /**
  130938. * Gets or sets the root nodes of the material fragment (pixel) shader
  130939. */
  130940. _fragmentOutputNodes: NodeMaterialBlock[];
  130941. /** Gets or sets options to control the node material overall behavior */
  130942. get options(): INodeMaterialOptions;
  130943. set options(options: INodeMaterialOptions);
  130944. /**
  130945. * Default configuration related to image processing available in the standard Material.
  130946. */
  130947. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130948. /**
  130949. * Gets the image processing configuration used either in this material.
  130950. */
  130951. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130952. /**
  130953. * Sets the Default image processing configuration used either in the this material.
  130954. *
  130955. * If sets to null, the scene one is in use.
  130956. */
  130957. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130958. /**
  130959. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130960. */
  130961. attachedBlocks: NodeMaterialBlock[];
  130962. /**
  130963. * Create a new node based material
  130964. * @param name defines the material name
  130965. * @param scene defines the hosting scene
  130966. * @param options defines creation option
  130967. */
  130968. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130969. /**
  130970. * Gets the current class name of the material e.g. "NodeMaterial"
  130971. * @returns the class name
  130972. */
  130973. getClassName(): string;
  130974. /**
  130975. * Keep track of the image processing observer to allow dispose and replace.
  130976. */
  130977. private _imageProcessingObserver;
  130978. /**
  130979. * Attaches a new image processing configuration to the Standard Material.
  130980. * @param configuration
  130981. */
  130982. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130983. /**
  130984. * Get a block by its name
  130985. * @param name defines the name of the block to retrieve
  130986. * @returns the required block or null if not found
  130987. */
  130988. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130989. /**
  130990. * Get a block by its name
  130991. * @param predicate defines the predicate used to find the good candidate
  130992. * @returns the required block or null if not found
  130993. */
  130994. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130995. /**
  130996. * Get an input block by its name
  130997. * @param predicate defines the predicate used to find the good candidate
  130998. * @returns the required input block or null if not found
  130999. */
  131000. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  131001. /**
  131002. * Gets the list of input blocks attached to this material
  131003. * @returns an array of InputBlocks
  131004. */
  131005. getInputBlocks(): InputBlock[];
  131006. /**
  131007. * Adds a new optimizer to the list of optimizers
  131008. * @param optimizer defines the optimizers to add
  131009. * @returns the current material
  131010. */
  131011. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131012. /**
  131013. * Remove an optimizer from the list of optimizers
  131014. * @param optimizer defines the optimizers to remove
  131015. * @returns the current material
  131016. */
  131017. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131018. /**
  131019. * Add a new block to the list of output nodes
  131020. * @param node defines the node to add
  131021. * @returns the current material
  131022. */
  131023. addOutputNode(node: NodeMaterialBlock): this;
  131024. /**
  131025. * Remove a block from the list of root nodes
  131026. * @param node defines the node to remove
  131027. * @returns the current material
  131028. */
  131029. removeOutputNode(node: NodeMaterialBlock): this;
  131030. private _addVertexOutputNode;
  131031. private _removeVertexOutputNode;
  131032. private _addFragmentOutputNode;
  131033. private _removeFragmentOutputNode;
  131034. /**
  131035. * Specifies if the material will require alpha blending
  131036. * @returns a boolean specifying if alpha blending is needed
  131037. */
  131038. needAlphaBlending(): boolean;
  131039. /**
  131040. * Specifies if this material should be rendered in alpha test mode
  131041. * @returns a boolean specifying if an alpha test is needed.
  131042. */
  131043. needAlphaTesting(): boolean;
  131044. private _initializeBlock;
  131045. private _resetDualBlocks;
  131046. /**
  131047. * Remove a block from the current node material
  131048. * @param block defines the block to remove
  131049. */
  131050. removeBlock(block: NodeMaterialBlock): void;
  131051. /**
  131052. * Build the material and generates the inner effect
  131053. * @param verbose defines if the build should log activity
  131054. */
  131055. build(verbose?: boolean): void;
  131056. /**
  131057. * Runs an otpimization phase to try to improve the shader code
  131058. */
  131059. optimize(): void;
  131060. private _prepareDefinesForAttributes;
  131061. /**
  131062. * Get if the submesh is ready to be used and all its information available.
  131063. * Child classes can use it to update shaders
  131064. * @param mesh defines the mesh to check
  131065. * @param subMesh defines which submesh to check
  131066. * @param useInstances specifies that instances should be used
  131067. * @returns a boolean indicating that the submesh is ready or not
  131068. */
  131069. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131070. /**
  131071. * Get a string representing the shaders built by the current node graph
  131072. */
  131073. get compiledShaders(): string;
  131074. /**
  131075. * Binds the world matrix to the material
  131076. * @param world defines the world transformation matrix
  131077. */
  131078. bindOnlyWorldMatrix(world: Matrix): void;
  131079. /**
  131080. * Binds the submesh to this material by preparing the effect and shader to draw
  131081. * @param world defines the world transformation matrix
  131082. * @param mesh defines the mesh containing the submesh
  131083. * @param subMesh defines the submesh to bind the material to
  131084. */
  131085. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131086. /**
  131087. * Gets the active textures from the material
  131088. * @returns an array of textures
  131089. */
  131090. getActiveTextures(): BaseTexture[];
  131091. /**
  131092. * Gets the list of texture blocks
  131093. * @returns an array of texture blocks
  131094. */
  131095. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  131096. /**
  131097. * Specifies if the material uses a texture
  131098. * @param texture defines the texture to check against the material
  131099. * @returns a boolean specifying if the material uses the texture
  131100. */
  131101. hasTexture(texture: BaseTexture): boolean;
  131102. /**
  131103. * Disposes the material
  131104. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  131105. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  131106. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  131107. */
  131108. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  131109. /** Creates the node editor window. */
  131110. private _createNodeEditor;
  131111. /**
  131112. * Launch the node material editor
  131113. * @param config Define the configuration of the editor
  131114. * @return a promise fulfilled when the node editor is visible
  131115. */
  131116. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  131117. /**
  131118. * Clear the current material
  131119. */
  131120. clear(): void;
  131121. /**
  131122. * Clear the current material and set it to a default state
  131123. */
  131124. setToDefault(): void;
  131125. /**
  131126. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  131127. * @param url defines the url to load from
  131128. * @returns a promise that will fullfil when the material is fully loaded
  131129. */
  131130. loadAsync(url: string): Promise<void>;
  131131. private _gatherBlocks;
  131132. /**
  131133. * Generate a string containing the code declaration required to create an equivalent of this material
  131134. * @returns a string
  131135. */
  131136. generateCode(): string;
  131137. /**
  131138. * Serializes this material in a JSON representation
  131139. * @returns the serialized material object
  131140. */
  131141. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  131142. private _restoreConnections;
  131143. /**
  131144. * Clear the current graph and load a new one from a serialization object
  131145. * @param source defines the JSON representation of the material
  131146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131147. */
  131148. loadFromSerialization(source: any, rootUrl?: string): void;
  131149. /**
  131150. * Creates a node material from parsed material data
  131151. * @param source defines the JSON representation of the material
  131152. * @param scene defines the hosting scene
  131153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131154. * @returns a new node material
  131155. */
  131156. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  131157. /**
  131158. * Creates a node material from a snippet saved in a remote file
  131159. * @param name defines the name of the material to create
  131160. * @param url defines the url to load from
  131161. * @param scene defines the hosting scene
  131162. * @returns a promise that will resolve to the new node material
  131163. */
  131164. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  131165. /**
  131166. * Creates a node material from a snippet saved by the node material editor
  131167. * @param snippetId defines the snippet to load
  131168. * @param scene defines the hosting scene
  131169. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131170. * @returns a promise that will resolve to the new node material
  131171. */
  131172. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  131173. /**
  131174. * Creates a new node material set to default basic configuration
  131175. * @param name defines the name of the material
  131176. * @param scene defines the hosting scene
  131177. * @returns a new NodeMaterial
  131178. */
  131179. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  131180. }
  131181. }
  131182. declare module BABYLON {
  131183. /**
  131184. * Block used to read a texture from a sampler
  131185. */
  131186. export class TextureBlock extends NodeMaterialBlock {
  131187. private _defineName;
  131188. private _linearDefineName;
  131189. private _tempTextureRead;
  131190. private _samplerName;
  131191. private _transformedUVName;
  131192. private _textureTransformName;
  131193. private _textureInfoName;
  131194. private _mainUVName;
  131195. private _mainUVDefineName;
  131196. /**
  131197. * Gets or sets the texture associated with the node
  131198. */
  131199. texture: Nullable<Texture>;
  131200. /**
  131201. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  131202. */
  131203. convertToGammaSpace: boolean;
  131204. /**
  131205. * Create a new TextureBlock
  131206. * @param name defines the block name
  131207. */
  131208. constructor(name: string);
  131209. /**
  131210. * Gets the current class name
  131211. * @returns the class name
  131212. */
  131213. getClassName(): string;
  131214. /**
  131215. * Gets the uv input component
  131216. */
  131217. get uv(): NodeMaterialConnectionPoint;
  131218. /**
  131219. * Gets the rgba output component
  131220. */
  131221. get rgba(): NodeMaterialConnectionPoint;
  131222. /**
  131223. * Gets the rgb output component
  131224. */
  131225. get rgb(): NodeMaterialConnectionPoint;
  131226. /**
  131227. * Gets the r output component
  131228. */
  131229. get r(): NodeMaterialConnectionPoint;
  131230. /**
  131231. * Gets the g output component
  131232. */
  131233. get g(): NodeMaterialConnectionPoint;
  131234. /**
  131235. * Gets the b output component
  131236. */
  131237. get b(): NodeMaterialConnectionPoint;
  131238. /**
  131239. * Gets the a output component
  131240. */
  131241. get a(): NodeMaterialConnectionPoint;
  131242. get target(): NodeMaterialBlockTargets;
  131243. autoConfigure(material: NodeMaterial): void;
  131244. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131246. isReady(): boolean;
  131247. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131248. private get _isMixed();
  131249. private _injectVertexCode;
  131250. private _writeTextureRead;
  131251. private _writeOutput;
  131252. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131253. protected _dumpPropertiesCode(): string;
  131254. serialize(): any;
  131255. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131256. }
  131257. }
  131258. declare module BABYLON {
  131259. /**
  131260. * Class used to store shared data between 2 NodeMaterialBuildState
  131261. */
  131262. export class NodeMaterialBuildStateSharedData {
  131263. /**
  131264. * Gets the list of emitted varyings
  131265. */
  131266. temps: string[];
  131267. /**
  131268. * Gets the list of emitted varyings
  131269. */
  131270. varyings: string[];
  131271. /**
  131272. * Gets the varying declaration string
  131273. */
  131274. varyingDeclaration: string;
  131275. /**
  131276. * Input blocks
  131277. */
  131278. inputBlocks: InputBlock[];
  131279. /**
  131280. * Input blocks
  131281. */
  131282. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  131283. /**
  131284. * Bindable blocks (Blocks that need to set data to the effect)
  131285. */
  131286. bindableBlocks: NodeMaterialBlock[];
  131287. /**
  131288. * List of blocks that can provide a compilation fallback
  131289. */
  131290. blocksWithFallbacks: NodeMaterialBlock[];
  131291. /**
  131292. * List of blocks that can provide a define update
  131293. */
  131294. blocksWithDefines: NodeMaterialBlock[];
  131295. /**
  131296. * List of blocks that can provide a repeatable content
  131297. */
  131298. repeatableContentBlocks: NodeMaterialBlock[];
  131299. /**
  131300. * List of blocks that can provide a dynamic list of uniforms
  131301. */
  131302. dynamicUniformBlocks: NodeMaterialBlock[];
  131303. /**
  131304. * List of blocks that can block the isReady function for the material
  131305. */
  131306. blockingBlocks: NodeMaterialBlock[];
  131307. /**
  131308. * Gets the list of animated inputs
  131309. */
  131310. animatedInputs: InputBlock[];
  131311. /**
  131312. * Build Id used to avoid multiple recompilations
  131313. */
  131314. buildId: number;
  131315. /** List of emitted variables */
  131316. variableNames: {
  131317. [key: string]: number;
  131318. };
  131319. /** List of emitted defines */
  131320. defineNames: {
  131321. [key: string]: number;
  131322. };
  131323. /** Should emit comments? */
  131324. emitComments: boolean;
  131325. /** Emit build activity */
  131326. verbose: boolean;
  131327. /** Gets or sets the hosting scene */
  131328. scene: Scene;
  131329. /**
  131330. * Gets the compilation hints emitted at compilation time
  131331. */
  131332. hints: {
  131333. needWorldViewMatrix: boolean;
  131334. needWorldViewProjectionMatrix: boolean;
  131335. needAlphaBlending: boolean;
  131336. needAlphaTesting: boolean;
  131337. };
  131338. /**
  131339. * List of compilation checks
  131340. */
  131341. checks: {
  131342. emitVertex: boolean;
  131343. emitFragment: boolean;
  131344. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  131345. };
  131346. /** Creates a new shared data */
  131347. constructor();
  131348. /**
  131349. * Emits console errors and exceptions if there is a failing check
  131350. */
  131351. emitErrors(): void;
  131352. }
  131353. }
  131354. declare module BABYLON {
  131355. /**
  131356. * Class used to store node based material build state
  131357. */
  131358. export class NodeMaterialBuildState {
  131359. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  131360. supportUniformBuffers: boolean;
  131361. /**
  131362. * Gets the list of emitted attributes
  131363. */
  131364. attributes: string[];
  131365. /**
  131366. * Gets the list of emitted uniforms
  131367. */
  131368. uniforms: string[];
  131369. /**
  131370. * Gets the list of emitted constants
  131371. */
  131372. constants: string[];
  131373. /**
  131374. * Gets the list of emitted samplers
  131375. */
  131376. samplers: string[];
  131377. /**
  131378. * Gets the list of emitted functions
  131379. */
  131380. functions: {
  131381. [key: string]: string;
  131382. };
  131383. /**
  131384. * Gets the list of emitted extensions
  131385. */
  131386. extensions: {
  131387. [key: string]: string;
  131388. };
  131389. /**
  131390. * Gets the target of the compilation state
  131391. */
  131392. target: NodeMaterialBlockTargets;
  131393. /**
  131394. * Gets the list of emitted counters
  131395. */
  131396. counters: {
  131397. [key: string]: number;
  131398. };
  131399. /**
  131400. * Shared data between multiple NodeMaterialBuildState instances
  131401. */
  131402. sharedData: NodeMaterialBuildStateSharedData;
  131403. /** @hidden */
  131404. _vertexState: NodeMaterialBuildState;
  131405. /** @hidden */
  131406. _attributeDeclaration: string;
  131407. /** @hidden */
  131408. _uniformDeclaration: string;
  131409. /** @hidden */
  131410. _constantDeclaration: string;
  131411. /** @hidden */
  131412. _samplerDeclaration: string;
  131413. /** @hidden */
  131414. _varyingTransfer: string;
  131415. private _repeatableContentAnchorIndex;
  131416. /** @hidden */
  131417. _builtCompilationString: string;
  131418. /**
  131419. * Gets the emitted compilation strings
  131420. */
  131421. compilationString: string;
  131422. /**
  131423. * Finalize the compilation strings
  131424. * @param state defines the current compilation state
  131425. */
  131426. finalize(state: NodeMaterialBuildState): void;
  131427. /** @hidden */
  131428. get _repeatableContentAnchor(): string;
  131429. /** @hidden */
  131430. _getFreeVariableName(prefix: string): string;
  131431. /** @hidden */
  131432. _getFreeDefineName(prefix: string): string;
  131433. /** @hidden */
  131434. _excludeVariableName(name: string): void;
  131435. /** @hidden */
  131436. _emit2DSampler(name: string): void;
  131437. /** @hidden */
  131438. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  131439. /** @hidden */
  131440. _emitExtension(name: string, extension: string): void;
  131441. /** @hidden */
  131442. _emitFunction(name: string, code: string, comments: string): void;
  131443. /** @hidden */
  131444. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  131445. replaceStrings?: {
  131446. search: RegExp;
  131447. replace: string;
  131448. }[];
  131449. repeatKey?: string;
  131450. }): string;
  131451. /** @hidden */
  131452. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  131453. repeatKey?: string;
  131454. removeAttributes?: boolean;
  131455. removeUniforms?: boolean;
  131456. removeVaryings?: boolean;
  131457. removeIfDef?: boolean;
  131458. replaceStrings?: {
  131459. search: RegExp;
  131460. replace: string;
  131461. }[];
  131462. }, storeKey?: string): void;
  131463. /** @hidden */
  131464. _registerTempVariable(name: string): boolean;
  131465. /** @hidden */
  131466. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  131467. /** @hidden */
  131468. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  131469. /** @hidden */
  131470. _emitFloat(value: number): string;
  131471. }
  131472. }
  131473. declare module BABYLON {
  131474. /**
  131475. * Defines a block that can be used inside a node based material
  131476. */
  131477. export class NodeMaterialBlock {
  131478. private _buildId;
  131479. private _buildTarget;
  131480. private _target;
  131481. private _isFinalMerger;
  131482. private _isInput;
  131483. protected _isUnique: boolean;
  131484. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  131485. inputsAreExclusive: boolean;
  131486. /** @hidden */
  131487. _codeVariableName: string;
  131488. /** @hidden */
  131489. _inputs: NodeMaterialConnectionPoint[];
  131490. /** @hidden */
  131491. _outputs: NodeMaterialConnectionPoint[];
  131492. /** @hidden */
  131493. _preparationId: number;
  131494. /**
  131495. * Gets or sets the name of the block
  131496. */
  131497. name: string;
  131498. /**
  131499. * Gets or sets the unique id of the node
  131500. */
  131501. uniqueId: number;
  131502. /**
  131503. * Gets or sets the comments associated with this block
  131504. */
  131505. comments: string;
  131506. /**
  131507. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  131508. */
  131509. get isUnique(): boolean;
  131510. /**
  131511. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131512. */
  131513. get isFinalMerger(): boolean;
  131514. /**
  131515. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131516. */
  131517. get isInput(): boolean;
  131518. /**
  131519. * Gets or sets the build Id
  131520. */
  131521. get buildId(): number;
  131522. set buildId(value: number);
  131523. /**
  131524. * Gets or sets the target of the block
  131525. */
  131526. get target(): NodeMaterialBlockTargets;
  131527. set target(value: NodeMaterialBlockTargets);
  131528. /**
  131529. * Gets the list of input points
  131530. */
  131531. get inputs(): NodeMaterialConnectionPoint[];
  131532. /** Gets the list of output points */
  131533. get outputs(): NodeMaterialConnectionPoint[];
  131534. /**
  131535. * Find an input by its name
  131536. * @param name defines the name of the input to look for
  131537. * @returns the input or null if not found
  131538. */
  131539. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131540. /**
  131541. * Find an output by its name
  131542. * @param name defines the name of the outputto look for
  131543. * @returns the output or null if not found
  131544. */
  131545. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131546. /**
  131547. * Creates a new NodeMaterialBlock
  131548. * @param name defines the block name
  131549. * @param target defines the target of that block (Vertex by default)
  131550. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131551. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131552. */
  131553. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131554. /**
  131555. * Initialize the block and prepare the context for build
  131556. * @param state defines the state that will be used for the build
  131557. */
  131558. initialize(state: NodeMaterialBuildState): void;
  131559. /**
  131560. * Bind data to effect. Will only be called for blocks with isBindable === true
  131561. * @param effect defines the effect to bind data to
  131562. * @param nodeMaterial defines the hosting NodeMaterial
  131563. * @param mesh defines the mesh that will be rendered
  131564. */
  131565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131566. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131567. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131568. protected _writeFloat(value: number): string;
  131569. /**
  131570. * Gets the current class name e.g. "NodeMaterialBlock"
  131571. * @returns the class name
  131572. */
  131573. getClassName(): string;
  131574. /**
  131575. * Register a new input. Must be called inside a block constructor
  131576. * @param name defines the connection point name
  131577. * @param type defines the connection point type
  131578. * @param isOptional defines a boolean indicating that this input can be omitted
  131579. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131580. * @returns the current block
  131581. */
  131582. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131583. /**
  131584. * Register a new output. Must be called inside a block constructor
  131585. * @param name defines the connection point name
  131586. * @param type defines the connection point type
  131587. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131588. * @returns the current block
  131589. */
  131590. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131591. /**
  131592. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131593. * @param forOutput defines an optional connection point to check compatibility with
  131594. * @returns the first available input or null
  131595. */
  131596. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131597. /**
  131598. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131599. * @param forBlock defines an optional block to check compatibility with
  131600. * @returns the first available input or null
  131601. */
  131602. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131603. /**
  131604. * Gets the sibling of the given output
  131605. * @param current defines the current output
  131606. * @returns the next output in the list or null
  131607. */
  131608. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131609. /**
  131610. * Connect current block with another block
  131611. * @param other defines the block to connect with
  131612. * @param options define the various options to help pick the right connections
  131613. * @returns the current block
  131614. */
  131615. connectTo(other: NodeMaterialBlock, options?: {
  131616. input?: string;
  131617. output?: string;
  131618. outputSwizzle?: string;
  131619. }): this | undefined;
  131620. protected _buildBlock(state: NodeMaterialBuildState): void;
  131621. /**
  131622. * Add uniforms, samplers and uniform buffers at compilation time
  131623. * @param state defines the state to update
  131624. * @param nodeMaterial defines the node material requesting the update
  131625. * @param defines defines the material defines to update
  131626. * @param uniformBuffers defines the list of uniform buffer names
  131627. */
  131628. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131629. /**
  131630. * Add potential fallbacks if shader compilation fails
  131631. * @param mesh defines the mesh to be rendered
  131632. * @param fallbacks defines the current prioritized list of fallbacks
  131633. */
  131634. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131635. /**
  131636. * Initialize defines for shader compilation
  131637. * @param mesh defines the mesh to be rendered
  131638. * @param nodeMaterial defines the node material requesting the update
  131639. * @param defines defines the material defines to update
  131640. * @param useInstances specifies that instances should be used
  131641. */
  131642. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131643. /**
  131644. * Update defines for shader compilation
  131645. * @param mesh defines the mesh to be rendered
  131646. * @param nodeMaterial defines the node material requesting the update
  131647. * @param defines defines the material defines to update
  131648. * @param useInstances specifies that instances should be used
  131649. */
  131650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131651. /**
  131652. * Lets the block try to connect some inputs automatically
  131653. * @param material defines the hosting NodeMaterial
  131654. */
  131655. autoConfigure(material: NodeMaterial): void;
  131656. /**
  131657. * Function called when a block is declared as repeatable content generator
  131658. * @param vertexShaderState defines the current compilation state for the vertex shader
  131659. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131660. * @param mesh defines the mesh to be rendered
  131661. * @param defines defines the material defines to update
  131662. */
  131663. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131664. /**
  131665. * Checks if the block is ready
  131666. * @param mesh defines the mesh to be rendered
  131667. * @param nodeMaterial defines the node material requesting the update
  131668. * @param defines defines the material defines to update
  131669. * @param useInstances specifies that instances should be used
  131670. * @returns true if the block is ready
  131671. */
  131672. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131673. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131674. private _processBuild;
  131675. /**
  131676. * Compile the current node and generate the shader code
  131677. * @param state defines the current compilation state (uniforms, samplers, current string)
  131678. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131679. * @returns true if already built
  131680. */
  131681. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131682. protected _inputRename(name: string): string;
  131683. protected _outputRename(name: string): string;
  131684. protected _dumpPropertiesCode(): string;
  131685. /** @hidden */
  131686. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131687. /** @hidden */
  131688. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131689. /**
  131690. * Clone the current block to a new identical block
  131691. * @param scene defines the hosting scene
  131692. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131693. * @returns a copy of the current block
  131694. */
  131695. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131696. /**
  131697. * Serializes this block in a JSON representation
  131698. * @returns the serialized block object
  131699. */
  131700. serialize(): any;
  131701. /** @hidden */
  131702. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131703. /**
  131704. * Release resources
  131705. */
  131706. dispose(): void;
  131707. }
  131708. }
  131709. declare module BABYLON {
  131710. /**
  131711. * Enum defining the type of animations supported by InputBlock
  131712. */
  131713. export enum AnimatedInputBlockTypes {
  131714. /** No animation */
  131715. None = 0,
  131716. /** Time based animation. Will only work for floats */
  131717. Time = 1
  131718. }
  131719. }
  131720. declare module BABYLON {
  131721. /**
  131722. * Block used to expose an input value
  131723. */
  131724. export class InputBlock extends NodeMaterialBlock {
  131725. private _mode;
  131726. private _associatedVariableName;
  131727. private _storedValue;
  131728. private _valueCallback;
  131729. private _type;
  131730. private _animationType;
  131731. /** Gets or set a value used to limit the range of float values */
  131732. min: number;
  131733. /** Gets or set a value used to limit the range of float values */
  131734. max: number;
  131735. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131736. isBoolean: boolean;
  131737. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131738. matrixMode: number;
  131739. /** @hidden */
  131740. _systemValue: Nullable<NodeMaterialSystemValues>;
  131741. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131742. visibleInInspector: boolean;
  131743. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131744. isConstant: boolean;
  131745. /** Gets or sets the group to use to display this block in the Inspector */
  131746. groupInInspector: string;
  131747. /** Gets an observable raised when the value is changed */
  131748. onValueChangedObservable: Observable<InputBlock>;
  131749. /**
  131750. * Gets or sets the connection point type (default is float)
  131751. */
  131752. get type(): NodeMaterialBlockConnectionPointTypes;
  131753. /**
  131754. * Creates a new InputBlock
  131755. * @param name defines the block name
  131756. * @param target defines the target of that block (Vertex by default)
  131757. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131758. */
  131759. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131760. /**
  131761. * Gets the output component
  131762. */
  131763. get output(): NodeMaterialConnectionPoint;
  131764. /**
  131765. * Set the source of this connection point to a vertex attribute
  131766. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131767. * @returns the current connection point
  131768. */
  131769. setAsAttribute(attributeName?: string): InputBlock;
  131770. /**
  131771. * Set the source of this connection point to a system value
  131772. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131773. * @returns the current connection point
  131774. */
  131775. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131776. /**
  131777. * Gets or sets the value of that point.
  131778. * Please note that this value will be ignored if valueCallback is defined
  131779. */
  131780. get value(): any;
  131781. set value(value: any);
  131782. /**
  131783. * Gets or sets a callback used to get the value of that point.
  131784. * Please note that setting this value will force the connection point to ignore the value property
  131785. */
  131786. get valueCallback(): () => any;
  131787. set valueCallback(value: () => any);
  131788. /**
  131789. * Gets or sets the associated variable name in the shader
  131790. */
  131791. get associatedVariableName(): string;
  131792. set associatedVariableName(value: string);
  131793. /** Gets or sets the type of animation applied to the input */
  131794. get animationType(): AnimatedInputBlockTypes;
  131795. set animationType(value: AnimatedInputBlockTypes);
  131796. /**
  131797. * Gets a boolean indicating that this connection point not defined yet
  131798. */
  131799. get isUndefined(): boolean;
  131800. /**
  131801. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131802. * In this case the connection point name must be the name of the uniform to use.
  131803. * Can only be set on inputs
  131804. */
  131805. get isUniform(): boolean;
  131806. set isUniform(value: boolean);
  131807. /**
  131808. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131809. * In this case the connection point name must be the name of the attribute to use
  131810. * Can only be set on inputs
  131811. */
  131812. get isAttribute(): boolean;
  131813. set isAttribute(value: boolean);
  131814. /**
  131815. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131816. * Can only be set on exit points
  131817. */
  131818. get isVarying(): boolean;
  131819. set isVarying(value: boolean);
  131820. /**
  131821. * Gets a boolean indicating that the current connection point is a system value
  131822. */
  131823. get isSystemValue(): boolean;
  131824. /**
  131825. * Gets or sets the current well known value or null if not defined as a system value
  131826. */
  131827. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131828. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131829. /**
  131830. * Gets the current class name
  131831. * @returns the class name
  131832. */
  131833. getClassName(): string;
  131834. /**
  131835. * Animate the input if animationType !== None
  131836. * @param scene defines the rendering scene
  131837. */
  131838. animate(scene: Scene): void;
  131839. private _emitDefine;
  131840. initialize(state: NodeMaterialBuildState): void;
  131841. /**
  131842. * Set the input block to its default value (based on its type)
  131843. */
  131844. setDefaultValue(): void;
  131845. private _emitConstant;
  131846. private _emit;
  131847. /** @hidden */
  131848. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131849. /** @hidden */
  131850. _transmit(effect: Effect, scene: Scene): void;
  131851. protected _buildBlock(state: NodeMaterialBuildState): void;
  131852. protected _dumpPropertiesCode(): string;
  131853. dispose(): void;
  131854. serialize(): any;
  131855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131856. }
  131857. }
  131858. declare module BABYLON {
  131859. /**
  131860. * Enum used to define the compatibility state between two connection points
  131861. */
  131862. export enum NodeMaterialConnectionPointCompatibilityStates {
  131863. /** Points are compatibles */
  131864. Compatible = 0,
  131865. /** Points are incompatible because of their types */
  131866. TypeIncompatible = 1,
  131867. /** Points are incompatible because of their targets (vertex vs fragment) */
  131868. TargetIncompatible = 2
  131869. }
  131870. /**
  131871. * Defines the direction of a connection point
  131872. */
  131873. export enum NodeMaterialConnectionPointDirection {
  131874. /** Input */
  131875. Input = 0,
  131876. /** Output */
  131877. Output = 1
  131878. }
  131879. /**
  131880. * Defines a connection point for a block
  131881. */
  131882. export class NodeMaterialConnectionPoint {
  131883. /** @hidden */
  131884. _ownerBlock: NodeMaterialBlock;
  131885. /** @hidden */
  131886. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131887. private _endpoints;
  131888. private _associatedVariableName;
  131889. private _direction;
  131890. /** @hidden */
  131891. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131892. /** @hidden */
  131893. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131894. private _type;
  131895. /** @hidden */
  131896. _enforceAssociatedVariableName: boolean;
  131897. /** Gets the direction of the point */
  131898. get direction(): NodeMaterialConnectionPointDirection;
  131899. /**
  131900. * Gets or sets the additional types supported by this connection point
  131901. */
  131902. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131903. /**
  131904. * Gets or sets the additional types excluded by this connection point
  131905. */
  131906. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131907. /**
  131908. * Observable triggered when this point is connected
  131909. */
  131910. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131911. /**
  131912. * Gets or sets the associated variable name in the shader
  131913. */
  131914. get associatedVariableName(): string;
  131915. set associatedVariableName(value: string);
  131916. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131917. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131918. /**
  131919. * Gets or sets the connection point type (default is float)
  131920. */
  131921. get type(): NodeMaterialBlockConnectionPointTypes;
  131922. set type(value: NodeMaterialBlockConnectionPointTypes);
  131923. /**
  131924. * Gets or sets the connection point name
  131925. */
  131926. name: string;
  131927. /**
  131928. * Gets or sets a boolean indicating that this connection point can be omitted
  131929. */
  131930. isOptional: boolean;
  131931. /**
  131932. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131933. */
  131934. define: string;
  131935. /** @hidden */
  131936. _prioritizeVertex: boolean;
  131937. private _target;
  131938. /** Gets or sets the target of that connection point */
  131939. get target(): NodeMaterialBlockTargets;
  131940. set target(value: NodeMaterialBlockTargets);
  131941. /**
  131942. * Gets a boolean indicating that the current point is connected
  131943. */
  131944. get isConnected(): boolean;
  131945. /**
  131946. * Gets a boolean indicating that the current point is connected to an input block
  131947. */
  131948. get isConnectedToInputBlock(): boolean;
  131949. /**
  131950. * Gets a the connected input block (if any)
  131951. */
  131952. get connectInputBlock(): Nullable<InputBlock>;
  131953. /** Get the other side of the connection (if any) */
  131954. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131955. /** Get the block that owns this connection point */
  131956. get ownerBlock(): NodeMaterialBlock;
  131957. /** Get the block connected on the other side of this connection (if any) */
  131958. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131959. /** Get the block connected on the endpoints of this connection (if any) */
  131960. get connectedBlocks(): Array<NodeMaterialBlock>;
  131961. /** Gets the list of connected endpoints */
  131962. get endpoints(): NodeMaterialConnectionPoint[];
  131963. /** Gets a boolean indicating if that output point is connected to at least one input */
  131964. get hasEndpoints(): boolean;
  131965. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131966. get isConnectedInVertexShader(): boolean;
  131967. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131968. get isConnectedInFragmentShader(): boolean;
  131969. /**
  131970. * Creates a new connection point
  131971. * @param name defines the connection point name
  131972. * @param ownerBlock defines the block hosting this connection point
  131973. * @param direction defines the direction of the connection point
  131974. */
  131975. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131976. /**
  131977. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131978. * @returns the class name
  131979. */
  131980. getClassName(): string;
  131981. /**
  131982. * Gets a boolean indicating if the current point can be connected to another point
  131983. * @param connectionPoint defines the other connection point
  131984. * @returns a boolean
  131985. */
  131986. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131987. /**
  131988. * Gets a number indicating if the current point can be connected to another point
  131989. * @param connectionPoint defines the other connection point
  131990. * @returns a number defining the compatibility state
  131991. */
  131992. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131993. /**
  131994. * Connect this point to another connection point
  131995. * @param connectionPoint defines the other connection point
  131996. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131997. * @returns the current connection point
  131998. */
  131999. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  132000. /**
  132001. * Disconnect this point from one of his endpoint
  132002. * @param endpoint defines the other connection point
  132003. * @returns the current connection point
  132004. */
  132005. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  132006. /**
  132007. * Serializes this point in a JSON representation
  132008. * @returns the serialized point object
  132009. */
  132010. serialize(): any;
  132011. /**
  132012. * Release resources
  132013. */
  132014. dispose(): void;
  132015. }
  132016. }
  132017. declare module BABYLON {
  132018. /**
  132019. * Block used to add support for vertex skinning (bones)
  132020. */
  132021. export class BonesBlock extends NodeMaterialBlock {
  132022. /**
  132023. * Creates a new BonesBlock
  132024. * @param name defines the block name
  132025. */
  132026. constructor(name: string);
  132027. /**
  132028. * Initialize the block and prepare the context for build
  132029. * @param state defines the state that will be used for the build
  132030. */
  132031. initialize(state: NodeMaterialBuildState): void;
  132032. /**
  132033. * Gets the current class name
  132034. * @returns the class name
  132035. */
  132036. getClassName(): string;
  132037. /**
  132038. * Gets the matrix indices input component
  132039. */
  132040. get matricesIndices(): NodeMaterialConnectionPoint;
  132041. /**
  132042. * Gets the matrix weights input component
  132043. */
  132044. get matricesWeights(): NodeMaterialConnectionPoint;
  132045. /**
  132046. * Gets the extra matrix indices input component
  132047. */
  132048. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  132049. /**
  132050. * Gets the extra matrix weights input component
  132051. */
  132052. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  132053. /**
  132054. * Gets the world input component
  132055. */
  132056. get world(): NodeMaterialConnectionPoint;
  132057. /**
  132058. * Gets the output component
  132059. */
  132060. get output(): NodeMaterialConnectionPoint;
  132061. autoConfigure(material: NodeMaterial): void;
  132062. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132063. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132065. protected _buildBlock(state: NodeMaterialBuildState): this;
  132066. }
  132067. }
  132068. declare module BABYLON {
  132069. /**
  132070. * Block used to add support for instances
  132071. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  132072. */
  132073. export class InstancesBlock extends NodeMaterialBlock {
  132074. /**
  132075. * Creates a new InstancesBlock
  132076. * @param name defines the block name
  132077. */
  132078. constructor(name: string);
  132079. /**
  132080. * Gets the current class name
  132081. * @returns the class name
  132082. */
  132083. getClassName(): string;
  132084. /**
  132085. * Gets the first world row input component
  132086. */
  132087. get world0(): NodeMaterialConnectionPoint;
  132088. /**
  132089. * Gets the second world row input component
  132090. */
  132091. get world1(): NodeMaterialConnectionPoint;
  132092. /**
  132093. * Gets the third world row input component
  132094. */
  132095. get world2(): NodeMaterialConnectionPoint;
  132096. /**
  132097. * Gets the forth world row input component
  132098. */
  132099. get world3(): NodeMaterialConnectionPoint;
  132100. /**
  132101. * Gets the world input component
  132102. */
  132103. get world(): NodeMaterialConnectionPoint;
  132104. /**
  132105. * Gets the output component
  132106. */
  132107. get output(): NodeMaterialConnectionPoint;
  132108. /**
  132109. * Gets the isntanceID component
  132110. */
  132111. get instanceID(): NodeMaterialConnectionPoint;
  132112. autoConfigure(material: NodeMaterial): void;
  132113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132114. protected _buildBlock(state: NodeMaterialBuildState): this;
  132115. }
  132116. }
  132117. declare module BABYLON {
  132118. /**
  132119. * Block used to add morph targets support to vertex shader
  132120. */
  132121. export class MorphTargetsBlock extends NodeMaterialBlock {
  132122. private _repeatableContentAnchor;
  132123. /**
  132124. * Create a new MorphTargetsBlock
  132125. * @param name defines the block name
  132126. */
  132127. constructor(name: string);
  132128. /**
  132129. * Gets the current class name
  132130. * @returns the class name
  132131. */
  132132. getClassName(): string;
  132133. /**
  132134. * Gets the position input component
  132135. */
  132136. get position(): NodeMaterialConnectionPoint;
  132137. /**
  132138. * Gets the normal input component
  132139. */
  132140. get normal(): NodeMaterialConnectionPoint;
  132141. /**
  132142. * Gets the tangent input component
  132143. */
  132144. get tangent(): NodeMaterialConnectionPoint;
  132145. /**
  132146. * Gets the tangent input component
  132147. */
  132148. get uv(): NodeMaterialConnectionPoint;
  132149. /**
  132150. * Gets the position output component
  132151. */
  132152. get positionOutput(): NodeMaterialConnectionPoint;
  132153. /**
  132154. * Gets the normal output component
  132155. */
  132156. get normalOutput(): NodeMaterialConnectionPoint;
  132157. /**
  132158. * Gets the tangent output component
  132159. */
  132160. get tangentOutput(): NodeMaterialConnectionPoint;
  132161. /**
  132162. * Gets the tangent output component
  132163. */
  132164. get uvOutput(): NodeMaterialConnectionPoint;
  132165. initialize(state: NodeMaterialBuildState): void;
  132166. autoConfigure(material: NodeMaterial): void;
  132167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132169. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132170. protected _buildBlock(state: NodeMaterialBuildState): this;
  132171. }
  132172. }
  132173. declare module BABYLON {
  132174. /**
  132175. * Block used to get data information from a light
  132176. */
  132177. export class LightInformationBlock extends NodeMaterialBlock {
  132178. private _lightDataUniformName;
  132179. private _lightColorUniformName;
  132180. private _lightTypeDefineName;
  132181. /**
  132182. * Gets or sets the light associated with this block
  132183. */
  132184. light: Nullable<Light>;
  132185. /**
  132186. * Creates a new LightInformationBlock
  132187. * @param name defines the block name
  132188. */
  132189. constructor(name: string);
  132190. /**
  132191. * Gets the current class name
  132192. * @returns the class name
  132193. */
  132194. getClassName(): string;
  132195. /**
  132196. * Gets the world position input component
  132197. */
  132198. get worldPosition(): NodeMaterialConnectionPoint;
  132199. /**
  132200. * Gets the direction output component
  132201. */
  132202. get direction(): NodeMaterialConnectionPoint;
  132203. /**
  132204. * Gets the direction output component
  132205. */
  132206. get color(): NodeMaterialConnectionPoint;
  132207. /**
  132208. * Gets the direction output component
  132209. */
  132210. get intensity(): NodeMaterialConnectionPoint;
  132211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132212. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132213. protected _buildBlock(state: NodeMaterialBuildState): this;
  132214. serialize(): any;
  132215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132216. }
  132217. }
  132218. declare module BABYLON {
  132219. /**
  132220. * Block used to add image processing support to fragment shader
  132221. */
  132222. export class ImageProcessingBlock extends NodeMaterialBlock {
  132223. /**
  132224. * Create a new ImageProcessingBlock
  132225. * @param name defines the block name
  132226. */
  132227. constructor(name: string);
  132228. /**
  132229. * Gets the current class name
  132230. * @returns the class name
  132231. */
  132232. getClassName(): string;
  132233. /**
  132234. * Gets the color input component
  132235. */
  132236. get color(): NodeMaterialConnectionPoint;
  132237. /**
  132238. * Gets the output component
  132239. */
  132240. get output(): NodeMaterialConnectionPoint;
  132241. /**
  132242. * Initialize the block and prepare the context for build
  132243. * @param state defines the state that will be used for the build
  132244. */
  132245. initialize(state: NodeMaterialBuildState): void;
  132246. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  132247. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132248. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132249. protected _buildBlock(state: NodeMaterialBuildState): this;
  132250. }
  132251. }
  132252. declare module BABYLON {
  132253. /**
  132254. * Block used to pertub normals based on a normal map
  132255. */
  132256. export class PerturbNormalBlock extends NodeMaterialBlock {
  132257. private _tangentSpaceParameterName;
  132258. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132259. invertX: boolean;
  132260. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  132261. invertY: boolean;
  132262. /**
  132263. * Create a new PerturbNormalBlock
  132264. * @param name defines the block name
  132265. */
  132266. constructor(name: string);
  132267. /**
  132268. * Gets the current class name
  132269. * @returns the class name
  132270. */
  132271. getClassName(): string;
  132272. /**
  132273. * Gets the world position input component
  132274. */
  132275. get worldPosition(): NodeMaterialConnectionPoint;
  132276. /**
  132277. * Gets the world normal input component
  132278. */
  132279. get worldNormal(): NodeMaterialConnectionPoint;
  132280. /**
  132281. * Gets the world tangent input component
  132282. */
  132283. get worldTangent(): NodeMaterialConnectionPoint;
  132284. /**
  132285. * Gets the uv input component
  132286. */
  132287. get uv(): NodeMaterialConnectionPoint;
  132288. /**
  132289. * Gets the normal map color input component
  132290. */
  132291. get normalMapColor(): NodeMaterialConnectionPoint;
  132292. /**
  132293. * Gets the strength input component
  132294. */
  132295. get strength(): NodeMaterialConnectionPoint;
  132296. /**
  132297. * Gets the output component
  132298. */
  132299. get output(): NodeMaterialConnectionPoint;
  132300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132302. autoConfigure(material: NodeMaterial): void;
  132303. protected _buildBlock(state: NodeMaterialBuildState): this;
  132304. protected _dumpPropertiesCode(): string;
  132305. serialize(): any;
  132306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132307. }
  132308. }
  132309. declare module BABYLON {
  132310. /**
  132311. * Block used to discard a pixel if a value is smaller than a cutoff
  132312. */
  132313. export class DiscardBlock extends NodeMaterialBlock {
  132314. /**
  132315. * Create a new DiscardBlock
  132316. * @param name defines the block name
  132317. */
  132318. constructor(name: string);
  132319. /**
  132320. * Gets the current class name
  132321. * @returns the class name
  132322. */
  132323. getClassName(): string;
  132324. /**
  132325. * Gets the color input component
  132326. */
  132327. get value(): NodeMaterialConnectionPoint;
  132328. /**
  132329. * Gets the cutoff input component
  132330. */
  132331. get cutoff(): NodeMaterialConnectionPoint;
  132332. protected _buildBlock(state: NodeMaterialBuildState): this;
  132333. }
  132334. }
  132335. declare module BABYLON {
  132336. /**
  132337. * Block used to test if the fragment shader is front facing
  132338. */
  132339. export class FrontFacingBlock extends NodeMaterialBlock {
  132340. /**
  132341. * Creates a new FrontFacingBlock
  132342. * @param name defines the block name
  132343. */
  132344. constructor(name: string);
  132345. /**
  132346. * Gets the current class name
  132347. * @returns the class name
  132348. */
  132349. getClassName(): string;
  132350. /**
  132351. * Gets the output component
  132352. */
  132353. get output(): NodeMaterialConnectionPoint;
  132354. protected _buildBlock(state: NodeMaterialBuildState): this;
  132355. }
  132356. }
  132357. declare module BABYLON {
  132358. /**
  132359. * Block used to get the derivative value on x and y of a given input
  132360. */
  132361. export class DerivativeBlock extends NodeMaterialBlock {
  132362. /**
  132363. * Create a new DerivativeBlock
  132364. * @param name defines the block name
  132365. */
  132366. constructor(name: string);
  132367. /**
  132368. * Gets the current class name
  132369. * @returns the class name
  132370. */
  132371. getClassName(): string;
  132372. /**
  132373. * Gets the input component
  132374. */
  132375. get input(): NodeMaterialConnectionPoint;
  132376. /**
  132377. * Gets the derivative output on x
  132378. */
  132379. get dx(): NodeMaterialConnectionPoint;
  132380. /**
  132381. * Gets the derivative output on y
  132382. */
  132383. get dy(): NodeMaterialConnectionPoint;
  132384. protected _buildBlock(state: NodeMaterialBuildState): this;
  132385. }
  132386. }
  132387. declare module BABYLON {
  132388. /**
  132389. * Block used to add support for scene fog
  132390. */
  132391. export class FogBlock extends NodeMaterialBlock {
  132392. private _fogDistanceName;
  132393. private _fogParameters;
  132394. /**
  132395. * Create a new FogBlock
  132396. * @param name defines the block name
  132397. */
  132398. constructor(name: string);
  132399. /**
  132400. * Gets the current class name
  132401. * @returns the class name
  132402. */
  132403. getClassName(): string;
  132404. /**
  132405. * Gets the world position input component
  132406. */
  132407. get worldPosition(): NodeMaterialConnectionPoint;
  132408. /**
  132409. * Gets the view input component
  132410. */
  132411. get view(): NodeMaterialConnectionPoint;
  132412. /**
  132413. * Gets the color input component
  132414. */
  132415. get input(): NodeMaterialConnectionPoint;
  132416. /**
  132417. * Gets the fog color input component
  132418. */
  132419. get fogColor(): NodeMaterialConnectionPoint;
  132420. /**
  132421. * Gets the output component
  132422. */
  132423. get output(): NodeMaterialConnectionPoint;
  132424. autoConfigure(material: NodeMaterial): void;
  132425. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132426. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132427. protected _buildBlock(state: NodeMaterialBuildState): this;
  132428. }
  132429. }
  132430. declare module BABYLON {
  132431. /**
  132432. * Block used to add light in the fragment shader
  132433. */
  132434. export class LightBlock extends NodeMaterialBlock {
  132435. private _lightId;
  132436. /**
  132437. * Gets or sets the light associated with this block
  132438. */
  132439. light: Nullable<Light>;
  132440. /**
  132441. * Create a new LightBlock
  132442. * @param name defines the block name
  132443. */
  132444. constructor(name: string);
  132445. /**
  132446. * Gets the current class name
  132447. * @returns the class name
  132448. */
  132449. getClassName(): string;
  132450. /**
  132451. * Gets the world position input component
  132452. */
  132453. get worldPosition(): NodeMaterialConnectionPoint;
  132454. /**
  132455. * Gets the world normal input component
  132456. */
  132457. get worldNormal(): NodeMaterialConnectionPoint;
  132458. /**
  132459. * Gets the camera (or eye) position component
  132460. */
  132461. get cameraPosition(): NodeMaterialConnectionPoint;
  132462. /**
  132463. * Gets the glossiness component
  132464. */
  132465. get glossiness(): NodeMaterialConnectionPoint;
  132466. /**
  132467. * Gets the glossinness power component
  132468. */
  132469. get glossPower(): NodeMaterialConnectionPoint;
  132470. /**
  132471. * Gets the diffuse color component
  132472. */
  132473. get diffuseColor(): NodeMaterialConnectionPoint;
  132474. /**
  132475. * Gets the specular color component
  132476. */
  132477. get specularColor(): NodeMaterialConnectionPoint;
  132478. /**
  132479. * Gets the diffuse output component
  132480. */
  132481. get diffuseOutput(): NodeMaterialConnectionPoint;
  132482. /**
  132483. * Gets the specular output component
  132484. */
  132485. get specularOutput(): NodeMaterialConnectionPoint;
  132486. /**
  132487. * Gets the shadow output component
  132488. */
  132489. get shadow(): NodeMaterialConnectionPoint;
  132490. autoConfigure(material: NodeMaterial): void;
  132491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132492. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132494. private _injectVertexCode;
  132495. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132496. serialize(): any;
  132497. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132498. }
  132499. }
  132500. declare module BABYLON {
  132501. /**
  132502. * Block used to multiply 2 values
  132503. */
  132504. export class MultiplyBlock extends NodeMaterialBlock {
  132505. /**
  132506. * Creates a new MultiplyBlock
  132507. * @param name defines the block name
  132508. */
  132509. constructor(name: string);
  132510. /**
  132511. * Gets the current class name
  132512. * @returns the class name
  132513. */
  132514. getClassName(): string;
  132515. /**
  132516. * Gets the left operand input component
  132517. */
  132518. get left(): NodeMaterialConnectionPoint;
  132519. /**
  132520. * Gets the right operand input component
  132521. */
  132522. get right(): NodeMaterialConnectionPoint;
  132523. /**
  132524. * Gets the output component
  132525. */
  132526. get output(): NodeMaterialConnectionPoint;
  132527. protected _buildBlock(state: NodeMaterialBuildState): this;
  132528. }
  132529. }
  132530. declare module BABYLON {
  132531. /**
  132532. * Block used to add 2 vectors
  132533. */
  132534. export class AddBlock extends NodeMaterialBlock {
  132535. /**
  132536. * Creates a new AddBlock
  132537. * @param name defines the block name
  132538. */
  132539. constructor(name: string);
  132540. /**
  132541. * Gets the current class name
  132542. * @returns the class name
  132543. */
  132544. getClassName(): string;
  132545. /**
  132546. * Gets the left operand input component
  132547. */
  132548. get left(): NodeMaterialConnectionPoint;
  132549. /**
  132550. * Gets the right operand input component
  132551. */
  132552. get right(): NodeMaterialConnectionPoint;
  132553. /**
  132554. * Gets the output component
  132555. */
  132556. get output(): NodeMaterialConnectionPoint;
  132557. protected _buildBlock(state: NodeMaterialBuildState): this;
  132558. }
  132559. }
  132560. declare module BABYLON {
  132561. /**
  132562. * Block used to scale a vector by a float
  132563. */
  132564. export class ScaleBlock extends NodeMaterialBlock {
  132565. /**
  132566. * Creates a new ScaleBlock
  132567. * @param name defines the block name
  132568. */
  132569. constructor(name: string);
  132570. /**
  132571. * Gets the current class name
  132572. * @returns the class name
  132573. */
  132574. getClassName(): string;
  132575. /**
  132576. * Gets the input component
  132577. */
  132578. get input(): NodeMaterialConnectionPoint;
  132579. /**
  132580. * Gets the factor input component
  132581. */
  132582. get factor(): NodeMaterialConnectionPoint;
  132583. /**
  132584. * Gets the output component
  132585. */
  132586. get output(): NodeMaterialConnectionPoint;
  132587. protected _buildBlock(state: NodeMaterialBuildState): this;
  132588. }
  132589. }
  132590. declare module BABYLON {
  132591. /**
  132592. * Block used to clamp a float
  132593. */
  132594. export class ClampBlock extends NodeMaterialBlock {
  132595. /** Gets or sets the minimum range */
  132596. minimum: number;
  132597. /** Gets or sets the maximum range */
  132598. maximum: number;
  132599. /**
  132600. * Creates a new ClampBlock
  132601. * @param name defines the block name
  132602. */
  132603. constructor(name: string);
  132604. /**
  132605. * Gets the current class name
  132606. * @returns the class name
  132607. */
  132608. getClassName(): string;
  132609. /**
  132610. * Gets the value input component
  132611. */
  132612. get value(): NodeMaterialConnectionPoint;
  132613. /**
  132614. * Gets the output component
  132615. */
  132616. get output(): NodeMaterialConnectionPoint;
  132617. protected _buildBlock(state: NodeMaterialBuildState): this;
  132618. protected _dumpPropertiesCode(): string;
  132619. serialize(): any;
  132620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132621. }
  132622. }
  132623. declare module BABYLON {
  132624. /**
  132625. * Block used to apply a cross product between 2 vectors
  132626. */
  132627. export class CrossBlock extends NodeMaterialBlock {
  132628. /**
  132629. * Creates a new CrossBlock
  132630. * @param name defines the block name
  132631. */
  132632. constructor(name: string);
  132633. /**
  132634. * Gets the current class name
  132635. * @returns the class name
  132636. */
  132637. getClassName(): string;
  132638. /**
  132639. * Gets the left operand input component
  132640. */
  132641. get left(): NodeMaterialConnectionPoint;
  132642. /**
  132643. * Gets the right operand input component
  132644. */
  132645. get right(): NodeMaterialConnectionPoint;
  132646. /**
  132647. * Gets the output component
  132648. */
  132649. get output(): NodeMaterialConnectionPoint;
  132650. protected _buildBlock(state: NodeMaterialBuildState): this;
  132651. }
  132652. }
  132653. declare module BABYLON {
  132654. /**
  132655. * Block used to apply a dot product between 2 vectors
  132656. */
  132657. export class DotBlock extends NodeMaterialBlock {
  132658. /**
  132659. * Creates a new DotBlock
  132660. * @param name defines the block name
  132661. */
  132662. constructor(name: string);
  132663. /**
  132664. * Gets the current class name
  132665. * @returns the class name
  132666. */
  132667. getClassName(): string;
  132668. /**
  132669. * Gets the left operand input component
  132670. */
  132671. get left(): NodeMaterialConnectionPoint;
  132672. /**
  132673. * Gets the right operand input component
  132674. */
  132675. get right(): NodeMaterialConnectionPoint;
  132676. /**
  132677. * Gets the output component
  132678. */
  132679. get output(): NodeMaterialConnectionPoint;
  132680. protected _buildBlock(state: NodeMaterialBuildState): this;
  132681. }
  132682. }
  132683. declare module BABYLON {
  132684. /**
  132685. * Block used to remap a float from a range to a new one
  132686. */
  132687. export class RemapBlock extends NodeMaterialBlock {
  132688. /**
  132689. * Gets or sets the source range
  132690. */
  132691. sourceRange: Vector2;
  132692. /**
  132693. * Gets or sets the target range
  132694. */
  132695. targetRange: Vector2;
  132696. /**
  132697. * Creates a new RemapBlock
  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 input component
  132708. */
  132709. get input(): NodeMaterialConnectionPoint;
  132710. /**
  132711. * Gets the source min input component
  132712. */
  132713. get sourceMin(): NodeMaterialConnectionPoint;
  132714. /**
  132715. * Gets the source max input component
  132716. */
  132717. get sourceMax(): NodeMaterialConnectionPoint;
  132718. /**
  132719. * Gets the target min input component
  132720. */
  132721. get targetMin(): NodeMaterialConnectionPoint;
  132722. /**
  132723. * Gets the target max input component
  132724. */
  132725. get targetMax(): NodeMaterialConnectionPoint;
  132726. /**
  132727. * Gets the output component
  132728. */
  132729. get output(): NodeMaterialConnectionPoint;
  132730. protected _buildBlock(state: NodeMaterialBuildState): this;
  132731. protected _dumpPropertiesCode(): string;
  132732. serialize(): any;
  132733. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132734. }
  132735. }
  132736. declare module BABYLON {
  132737. /**
  132738. * Block used to normalize a vector
  132739. */
  132740. export class NormalizeBlock extends NodeMaterialBlock {
  132741. /**
  132742. * Creates a new NormalizeBlock
  132743. * @param name defines the block name
  132744. */
  132745. constructor(name: string);
  132746. /**
  132747. * Gets the current class name
  132748. * @returns the class name
  132749. */
  132750. getClassName(): string;
  132751. /**
  132752. * Gets the input component
  132753. */
  132754. get input(): NodeMaterialConnectionPoint;
  132755. /**
  132756. * Gets the output component
  132757. */
  132758. get output(): NodeMaterialConnectionPoint;
  132759. protected _buildBlock(state: NodeMaterialBuildState): this;
  132760. }
  132761. }
  132762. declare module BABYLON {
  132763. /**
  132764. * Operations supported by the Trigonometry block
  132765. */
  132766. export enum TrigonometryBlockOperations {
  132767. /** Cos */
  132768. Cos = 0,
  132769. /** Sin */
  132770. Sin = 1,
  132771. /** Abs */
  132772. Abs = 2,
  132773. /** Exp */
  132774. Exp = 3,
  132775. /** Exp2 */
  132776. Exp2 = 4,
  132777. /** Round */
  132778. Round = 5,
  132779. /** Floor */
  132780. Floor = 6,
  132781. /** Ceiling */
  132782. Ceiling = 7,
  132783. /** Square root */
  132784. Sqrt = 8,
  132785. /** Log */
  132786. Log = 9,
  132787. /** Tangent */
  132788. Tan = 10,
  132789. /** Arc tangent */
  132790. ArcTan = 11,
  132791. /** Arc cosinus */
  132792. ArcCos = 12,
  132793. /** Arc sinus */
  132794. ArcSin = 13,
  132795. /** Fraction */
  132796. Fract = 14,
  132797. /** Sign */
  132798. Sign = 15,
  132799. /** To radians (from degrees) */
  132800. Radians = 16,
  132801. /** To degrees (from radians) */
  132802. Degrees = 17
  132803. }
  132804. /**
  132805. * Block used to apply trigonometry operation to floats
  132806. */
  132807. export class TrigonometryBlock extends NodeMaterialBlock {
  132808. /**
  132809. * Gets or sets the operation applied by the block
  132810. */
  132811. operation: TrigonometryBlockOperations;
  132812. /**
  132813. * Creates a new TrigonometryBlock
  132814. * @param name defines the block name
  132815. */
  132816. constructor(name: string);
  132817. /**
  132818. * Gets the current class name
  132819. * @returns the class name
  132820. */
  132821. getClassName(): string;
  132822. /**
  132823. * Gets the input component
  132824. */
  132825. get input(): NodeMaterialConnectionPoint;
  132826. /**
  132827. * Gets the output component
  132828. */
  132829. get output(): NodeMaterialConnectionPoint;
  132830. protected _buildBlock(state: NodeMaterialBuildState): this;
  132831. serialize(): any;
  132832. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132833. protected _dumpPropertiesCode(): string;
  132834. }
  132835. }
  132836. declare module BABYLON {
  132837. /**
  132838. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132839. */
  132840. export class ColorMergerBlock extends NodeMaterialBlock {
  132841. /**
  132842. * Create a new ColorMergerBlock
  132843. * @param name defines the block name
  132844. */
  132845. constructor(name: string);
  132846. /**
  132847. * Gets the current class name
  132848. * @returns the class name
  132849. */
  132850. getClassName(): string;
  132851. /**
  132852. * Gets the rgb component (input)
  132853. */
  132854. get rgbIn(): NodeMaterialConnectionPoint;
  132855. /**
  132856. * Gets the r component (input)
  132857. */
  132858. get r(): NodeMaterialConnectionPoint;
  132859. /**
  132860. * Gets the g component (input)
  132861. */
  132862. get g(): NodeMaterialConnectionPoint;
  132863. /**
  132864. * Gets the b component (input)
  132865. */
  132866. get b(): NodeMaterialConnectionPoint;
  132867. /**
  132868. * Gets the a component (input)
  132869. */
  132870. get a(): NodeMaterialConnectionPoint;
  132871. /**
  132872. * Gets the rgba component (output)
  132873. */
  132874. get rgba(): NodeMaterialConnectionPoint;
  132875. /**
  132876. * Gets the rgb component (output)
  132877. */
  132878. get rgbOut(): NodeMaterialConnectionPoint;
  132879. /**
  132880. * Gets the rgb component (output)
  132881. * @deprecated Please use rgbOut instead.
  132882. */
  132883. get rgb(): NodeMaterialConnectionPoint;
  132884. protected _buildBlock(state: NodeMaterialBuildState): this;
  132885. }
  132886. }
  132887. declare module BABYLON {
  132888. /**
  132889. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132890. */
  132891. export class VectorMergerBlock extends NodeMaterialBlock {
  132892. /**
  132893. * Create a new VectorMergerBlock
  132894. * @param name defines the block name
  132895. */
  132896. constructor(name: string);
  132897. /**
  132898. * Gets the current class name
  132899. * @returns the class name
  132900. */
  132901. getClassName(): string;
  132902. /**
  132903. * Gets the xyz component (input)
  132904. */
  132905. get xyzIn(): NodeMaterialConnectionPoint;
  132906. /**
  132907. * Gets the xy component (input)
  132908. */
  132909. get xyIn(): NodeMaterialConnectionPoint;
  132910. /**
  132911. * Gets the x component (input)
  132912. */
  132913. get x(): NodeMaterialConnectionPoint;
  132914. /**
  132915. * Gets the y component (input)
  132916. */
  132917. get y(): NodeMaterialConnectionPoint;
  132918. /**
  132919. * Gets the z component (input)
  132920. */
  132921. get z(): NodeMaterialConnectionPoint;
  132922. /**
  132923. * Gets the w component (input)
  132924. */
  132925. get w(): NodeMaterialConnectionPoint;
  132926. /**
  132927. * Gets the xyzw component (output)
  132928. */
  132929. get xyzw(): NodeMaterialConnectionPoint;
  132930. /**
  132931. * Gets the xyz component (output)
  132932. */
  132933. get xyzOut(): NodeMaterialConnectionPoint;
  132934. /**
  132935. * Gets the xy component (output)
  132936. */
  132937. get xyOut(): NodeMaterialConnectionPoint;
  132938. /**
  132939. * Gets the xy component (output)
  132940. * @deprecated Please use xyOut instead.
  132941. */
  132942. get xy(): NodeMaterialConnectionPoint;
  132943. /**
  132944. * Gets the xyz component (output)
  132945. * @deprecated Please use xyzOut instead.
  132946. */
  132947. get xyz(): NodeMaterialConnectionPoint;
  132948. protected _buildBlock(state: NodeMaterialBuildState): this;
  132949. }
  132950. }
  132951. declare module BABYLON {
  132952. /**
  132953. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132954. */
  132955. export class ColorSplitterBlock extends NodeMaterialBlock {
  132956. /**
  132957. * Create a new ColorSplitterBlock
  132958. * @param name defines the block name
  132959. */
  132960. constructor(name: string);
  132961. /**
  132962. * Gets the current class name
  132963. * @returns the class name
  132964. */
  132965. getClassName(): string;
  132966. /**
  132967. * Gets the rgba component (input)
  132968. */
  132969. get rgba(): NodeMaterialConnectionPoint;
  132970. /**
  132971. * Gets the rgb component (input)
  132972. */
  132973. get rgbIn(): NodeMaterialConnectionPoint;
  132974. /**
  132975. * Gets the rgb component (output)
  132976. */
  132977. get rgbOut(): NodeMaterialConnectionPoint;
  132978. /**
  132979. * Gets the r component (output)
  132980. */
  132981. get r(): NodeMaterialConnectionPoint;
  132982. /**
  132983. * Gets the g component (output)
  132984. */
  132985. get g(): NodeMaterialConnectionPoint;
  132986. /**
  132987. * Gets the b component (output)
  132988. */
  132989. get b(): NodeMaterialConnectionPoint;
  132990. /**
  132991. * Gets the a component (output)
  132992. */
  132993. get a(): NodeMaterialConnectionPoint;
  132994. protected _inputRename(name: string): string;
  132995. protected _outputRename(name: string): string;
  132996. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132997. }
  132998. }
  132999. declare module BABYLON {
  133000. /**
  133001. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  133002. */
  133003. export class VectorSplitterBlock extends NodeMaterialBlock {
  133004. /**
  133005. * Create a new VectorSplitterBlock
  133006. * @param name defines the block name
  133007. */
  133008. constructor(name: string);
  133009. /**
  133010. * Gets the current class name
  133011. * @returns the class name
  133012. */
  133013. getClassName(): string;
  133014. /**
  133015. * Gets the xyzw component (input)
  133016. */
  133017. get xyzw(): NodeMaterialConnectionPoint;
  133018. /**
  133019. * Gets the xyz component (input)
  133020. */
  133021. get xyzIn(): NodeMaterialConnectionPoint;
  133022. /**
  133023. * Gets the xy component (input)
  133024. */
  133025. get xyIn(): NodeMaterialConnectionPoint;
  133026. /**
  133027. * Gets the xyz component (output)
  133028. */
  133029. get xyzOut(): NodeMaterialConnectionPoint;
  133030. /**
  133031. * Gets the xy component (output)
  133032. */
  133033. get xyOut(): NodeMaterialConnectionPoint;
  133034. /**
  133035. * Gets the x component (output)
  133036. */
  133037. get x(): NodeMaterialConnectionPoint;
  133038. /**
  133039. * Gets the y component (output)
  133040. */
  133041. get y(): NodeMaterialConnectionPoint;
  133042. /**
  133043. * Gets the z component (output)
  133044. */
  133045. get z(): NodeMaterialConnectionPoint;
  133046. /**
  133047. * Gets the w component (output)
  133048. */
  133049. get w(): NodeMaterialConnectionPoint;
  133050. protected _inputRename(name: string): string;
  133051. protected _outputRename(name: string): string;
  133052. protected _buildBlock(state: NodeMaterialBuildState): this;
  133053. }
  133054. }
  133055. declare module BABYLON {
  133056. /**
  133057. * Block used to lerp between 2 values
  133058. */
  133059. export class LerpBlock extends NodeMaterialBlock {
  133060. /**
  133061. * Creates a new LerpBlock
  133062. * @param name defines the block name
  133063. */
  133064. constructor(name: string);
  133065. /**
  133066. * Gets the current class name
  133067. * @returns the class name
  133068. */
  133069. getClassName(): string;
  133070. /**
  133071. * Gets the left operand input component
  133072. */
  133073. get left(): NodeMaterialConnectionPoint;
  133074. /**
  133075. * Gets the right operand input component
  133076. */
  133077. get right(): NodeMaterialConnectionPoint;
  133078. /**
  133079. * Gets the gradient operand input component
  133080. */
  133081. get gradient(): NodeMaterialConnectionPoint;
  133082. /**
  133083. * Gets the output component
  133084. */
  133085. get output(): NodeMaterialConnectionPoint;
  133086. protected _buildBlock(state: NodeMaterialBuildState): this;
  133087. }
  133088. }
  133089. declare module BABYLON {
  133090. /**
  133091. * Block used to divide 2 vectors
  133092. */
  133093. export class DivideBlock extends NodeMaterialBlock {
  133094. /**
  133095. * Creates a new DivideBlock
  133096. * @param name defines the block name
  133097. */
  133098. constructor(name: string);
  133099. /**
  133100. * Gets the current class name
  133101. * @returns the class name
  133102. */
  133103. getClassName(): string;
  133104. /**
  133105. * Gets the left operand input component
  133106. */
  133107. get left(): NodeMaterialConnectionPoint;
  133108. /**
  133109. * Gets the right operand input component
  133110. */
  133111. get right(): NodeMaterialConnectionPoint;
  133112. /**
  133113. * Gets the output component
  133114. */
  133115. get output(): NodeMaterialConnectionPoint;
  133116. protected _buildBlock(state: NodeMaterialBuildState): this;
  133117. }
  133118. }
  133119. declare module BABYLON {
  133120. /**
  133121. * Block used to subtract 2 vectors
  133122. */
  133123. export class SubtractBlock extends NodeMaterialBlock {
  133124. /**
  133125. * Creates a new SubtractBlock
  133126. * @param name defines the block name
  133127. */
  133128. constructor(name: string);
  133129. /**
  133130. * Gets the current class name
  133131. * @returns the class name
  133132. */
  133133. getClassName(): string;
  133134. /**
  133135. * Gets the left operand input component
  133136. */
  133137. get left(): NodeMaterialConnectionPoint;
  133138. /**
  133139. * Gets the right operand input component
  133140. */
  133141. get right(): NodeMaterialConnectionPoint;
  133142. /**
  133143. * Gets the output component
  133144. */
  133145. get output(): NodeMaterialConnectionPoint;
  133146. protected _buildBlock(state: NodeMaterialBuildState): this;
  133147. }
  133148. }
  133149. declare module BABYLON {
  133150. /**
  133151. * Block used to step a value
  133152. */
  133153. export class StepBlock extends NodeMaterialBlock {
  133154. /**
  133155. * Creates a new StepBlock
  133156. * @param name defines the block name
  133157. */
  133158. constructor(name: string);
  133159. /**
  133160. * Gets the current class name
  133161. * @returns the class name
  133162. */
  133163. getClassName(): string;
  133164. /**
  133165. * Gets the value operand input component
  133166. */
  133167. get value(): NodeMaterialConnectionPoint;
  133168. /**
  133169. * Gets the edge operand input component
  133170. */
  133171. get edge(): NodeMaterialConnectionPoint;
  133172. /**
  133173. * Gets the output component
  133174. */
  133175. get output(): NodeMaterialConnectionPoint;
  133176. protected _buildBlock(state: NodeMaterialBuildState): this;
  133177. }
  133178. }
  133179. declare module BABYLON {
  133180. /**
  133181. * Block used to get the opposite (1 - x) of a value
  133182. */
  133183. export class OneMinusBlock extends NodeMaterialBlock {
  133184. /**
  133185. * Creates a new OneMinusBlock
  133186. * @param name defines the block name
  133187. */
  133188. constructor(name: string);
  133189. /**
  133190. * Gets the current class name
  133191. * @returns the class name
  133192. */
  133193. getClassName(): string;
  133194. /**
  133195. * Gets the input component
  133196. */
  133197. get input(): 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 view direction
  133208. */
  133209. export class ViewDirectionBlock extends NodeMaterialBlock {
  133210. /**
  133211. * Creates a new ViewDirectionBlock
  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 world position component
  133222. */
  133223. get worldPosition(): NodeMaterialConnectionPoint;
  133224. /**
  133225. * Gets the camera position component
  133226. */
  133227. get cameraPosition(): NodeMaterialConnectionPoint;
  133228. /**
  133229. * Gets the output component
  133230. */
  133231. get output(): NodeMaterialConnectionPoint;
  133232. autoConfigure(material: NodeMaterial): void;
  133233. protected _buildBlock(state: NodeMaterialBuildState): this;
  133234. }
  133235. }
  133236. declare module BABYLON {
  133237. /**
  133238. * Block used to compute fresnel value
  133239. */
  133240. export class FresnelBlock extends NodeMaterialBlock {
  133241. /**
  133242. * Create a new FresnelBlock
  133243. * @param name defines the block name
  133244. */
  133245. constructor(name: string);
  133246. /**
  133247. * Gets the current class name
  133248. * @returns the class name
  133249. */
  133250. getClassName(): string;
  133251. /**
  133252. * Gets the world normal input component
  133253. */
  133254. get worldNormal(): NodeMaterialConnectionPoint;
  133255. /**
  133256. * Gets the view direction input component
  133257. */
  133258. get viewDirection(): NodeMaterialConnectionPoint;
  133259. /**
  133260. * Gets the bias input component
  133261. */
  133262. get bias(): NodeMaterialConnectionPoint;
  133263. /**
  133264. * Gets the camera (or eye) position component
  133265. */
  133266. get power(): NodeMaterialConnectionPoint;
  133267. /**
  133268. * Gets the fresnel output component
  133269. */
  133270. get fresnel(): NodeMaterialConnectionPoint;
  133271. autoConfigure(material: NodeMaterial): void;
  133272. protected _buildBlock(state: NodeMaterialBuildState): this;
  133273. }
  133274. }
  133275. declare module BABYLON {
  133276. /**
  133277. * Block used to get the max of 2 values
  133278. */
  133279. export class MaxBlock extends NodeMaterialBlock {
  133280. /**
  133281. * Creates a new MaxBlock
  133282. * @param name defines the block name
  133283. */
  133284. constructor(name: string);
  133285. /**
  133286. * Gets the current class name
  133287. * @returns the class name
  133288. */
  133289. getClassName(): string;
  133290. /**
  133291. * Gets the left operand input component
  133292. */
  133293. get left(): NodeMaterialConnectionPoint;
  133294. /**
  133295. * Gets the right operand input component
  133296. */
  133297. get right(): NodeMaterialConnectionPoint;
  133298. /**
  133299. * Gets the output component
  133300. */
  133301. get output(): NodeMaterialConnectionPoint;
  133302. protected _buildBlock(state: NodeMaterialBuildState): this;
  133303. }
  133304. }
  133305. declare module BABYLON {
  133306. /**
  133307. * Block used to get the min of 2 values
  133308. */
  133309. export class MinBlock extends NodeMaterialBlock {
  133310. /**
  133311. * Creates a new MinBlock
  133312. * @param name defines the block name
  133313. */
  133314. constructor(name: string);
  133315. /**
  133316. * Gets the current class name
  133317. * @returns the class name
  133318. */
  133319. getClassName(): string;
  133320. /**
  133321. * Gets the left operand input component
  133322. */
  133323. get left(): NodeMaterialConnectionPoint;
  133324. /**
  133325. * Gets the right operand input component
  133326. */
  133327. get right(): NodeMaterialConnectionPoint;
  133328. /**
  133329. * Gets the output component
  133330. */
  133331. get output(): NodeMaterialConnectionPoint;
  133332. protected _buildBlock(state: NodeMaterialBuildState): this;
  133333. }
  133334. }
  133335. declare module BABYLON {
  133336. /**
  133337. * Block used to get the distance between 2 values
  133338. */
  133339. export class DistanceBlock extends NodeMaterialBlock {
  133340. /**
  133341. * Creates a new DistanceBlock
  133342. * @param name defines the block name
  133343. */
  133344. constructor(name: string);
  133345. /**
  133346. * Gets the current class name
  133347. * @returns the class name
  133348. */
  133349. getClassName(): string;
  133350. /**
  133351. * Gets the left operand input component
  133352. */
  133353. get left(): NodeMaterialConnectionPoint;
  133354. /**
  133355. * Gets the right operand input component
  133356. */
  133357. get right(): NodeMaterialConnectionPoint;
  133358. /**
  133359. * Gets the output component
  133360. */
  133361. get output(): NodeMaterialConnectionPoint;
  133362. protected _buildBlock(state: NodeMaterialBuildState): this;
  133363. }
  133364. }
  133365. declare module BABYLON {
  133366. /**
  133367. * Block used to get the length of a vector
  133368. */
  133369. export class LengthBlock extends NodeMaterialBlock {
  133370. /**
  133371. * Creates a new LengthBlock
  133372. * @param name defines the block name
  133373. */
  133374. constructor(name: string);
  133375. /**
  133376. * Gets the current class name
  133377. * @returns the class name
  133378. */
  133379. getClassName(): string;
  133380. /**
  133381. * Gets the value input component
  133382. */
  133383. get value(): NodeMaterialConnectionPoint;
  133384. /**
  133385. * Gets the output component
  133386. */
  133387. get output(): NodeMaterialConnectionPoint;
  133388. protected _buildBlock(state: NodeMaterialBuildState): this;
  133389. }
  133390. }
  133391. declare module BABYLON {
  133392. /**
  133393. * Block used to get negative version of a value (i.e. x * -1)
  133394. */
  133395. export class NegateBlock extends NodeMaterialBlock {
  133396. /**
  133397. * Creates a new NegateBlock
  133398. * @param name defines the block name
  133399. */
  133400. constructor(name: string);
  133401. /**
  133402. * Gets the current class name
  133403. * @returns the class name
  133404. */
  133405. getClassName(): string;
  133406. /**
  133407. * Gets the value input component
  133408. */
  133409. get value(): NodeMaterialConnectionPoint;
  133410. /**
  133411. * Gets the output component
  133412. */
  133413. get output(): NodeMaterialConnectionPoint;
  133414. protected _buildBlock(state: NodeMaterialBuildState): this;
  133415. }
  133416. }
  133417. declare module BABYLON {
  133418. /**
  133419. * Block used to get the value of the first parameter raised to the power of the second
  133420. */
  133421. export class PowBlock extends NodeMaterialBlock {
  133422. /**
  133423. * Creates a new PowBlock
  133424. * @param name defines the block name
  133425. */
  133426. constructor(name: string);
  133427. /**
  133428. * Gets the current class name
  133429. * @returns the class name
  133430. */
  133431. getClassName(): string;
  133432. /**
  133433. * Gets the value operand input component
  133434. */
  133435. get value(): NodeMaterialConnectionPoint;
  133436. /**
  133437. * Gets the power operand input component
  133438. */
  133439. get power(): NodeMaterialConnectionPoint;
  133440. /**
  133441. * Gets the output component
  133442. */
  133443. get output(): NodeMaterialConnectionPoint;
  133444. protected _buildBlock(state: NodeMaterialBuildState): this;
  133445. }
  133446. }
  133447. declare module BABYLON {
  133448. /**
  133449. * Block used to get a random number
  133450. */
  133451. export class RandomNumberBlock extends NodeMaterialBlock {
  133452. /**
  133453. * Creates a new RandomNumberBlock
  133454. * @param name defines the block name
  133455. */
  133456. constructor(name: string);
  133457. /**
  133458. * Gets the current class name
  133459. * @returns the class name
  133460. */
  133461. getClassName(): string;
  133462. /**
  133463. * Gets the seed input component
  133464. */
  133465. get seed(): NodeMaterialConnectionPoint;
  133466. /**
  133467. * Gets the output component
  133468. */
  133469. get output(): NodeMaterialConnectionPoint;
  133470. protected _buildBlock(state: NodeMaterialBuildState): this;
  133471. }
  133472. }
  133473. declare module BABYLON {
  133474. /**
  133475. * Block used to compute arc tangent of 2 values
  133476. */
  133477. export class ArcTan2Block extends NodeMaterialBlock {
  133478. /**
  133479. * Creates a new ArcTan2Block
  133480. * @param name defines the block name
  133481. */
  133482. constructor(name: string);
  133483. /**
  133484. * Gets the current class name
  133485. * @returns the class name
  133486. */
  133487. getClassName(): string;
  133488. /**
  133489. * Gets the x operand input component
  133490. */
  133491. get x(): NodeMaterialConnectionPoint;
  133492. /**
  133493. * Gets the y operand input component
  133494. */
  133495. get y(): NodeMaterialConnectionPoint;
  133496. /**
  133497. * Gets the output component
  133498. */
  133499. get output(): NodeMaterialConnectionPoint;
  133500. protected _buildBlock(state: NodeMaterialBuildState): this;
  133501. }
  133502. }
  133503. declare module BABYLON {
  133504. /**
  133505. * Block used to smooth step a value
  133506. */
  133507. export class SmoothStepBlock extends NodeMaterialBlock {
  133508. /**
  133509. * Creates a new SmoothStepBlock
  133510. * @param name defines the block name
  133511. */
  133512. constructor(name: string);
  133513. /**
  133514. * Gets the current class name
  133515. * @returns the class name
  133516. */
  133517. getClassName(): string;
  133518. /**
  133519. * Gets the value operand input component
  133520. */
  133521. get value(): NodeMaterialConnectionPoint;
  133522. /**
  133523. * Gets the first edge operand input component
  133524. */
  133525. get edge0(): NodeMaterialConnectionPoint;
  133526. /**
  133527. * Gets the second edge operand input component
  133528. */
  133529. get edge1(): NodeMaterialConnectionPoint;
  133530. /**
  133531. * Gets the output component
  133532. */
  133533. get output(): NodeMaterialConnectionPoint;
  133534. protected _buildBlock(state: NodeMaterialBuildState): this;
  133535. }
  133536. }
  133537. declare module BABYLON {
  133538. /**
  133539. * Block used to get the reciprocal (1 / x) of a value
  133540. */
  133541. export class ReciprocalBlock extends NodeMaterialBlock {
  133542. /**
  133543. * Creates a new ReciprocalBlock
  133544. * @param name defines the block name
  133545. */
  133546. constructor(name: string);
  133547. /**
  133548. * Gets the current class name
  133549. * @returns the class name
  133550. */
  133551. getClassName(): string;
  133552. /**
  133553. * Gets the input component
  133554. */
  133555. get input(): NodeMaterialConnectionPoint;
  133556. /**
  133557. * Gets the output component
  133558. */
  133559. get output(): NodeMaterialConnectionPoint;
  133560. protected _buildBlock(state: NodeMaterialBuildState): this;
  133561. }
  133562. }
  133563. declare module BABYLON {
  133564. /**
  133565. * Block used to replace a color by another one
  133566. */
  133567. export class ReplaceColorBlock extends NodeMaterialBlock {
  133568. /**
  133569. * Creates a new ReplaceColorBlock
  133570. * @param name defines the block name
  133571. */
  133572. constructor(name: string);
  133573. /**
  133574. * Gets the current class name
  133575. * @returns the class name
  133576. */
  133577. getClassName(): string;
  133578. /**
  133579. * Gets the value input component
  133580. */
  133581. get value(): NodeMaterialConnectionPoint;
  133582. /**
  133583. * Gets the reference input component
  133584. */
  133585. get reference(): NodeMaterialConnectionPoint;
  133586. /**
  133587. * Gets the distance input component
  133588. */
  133589. get distance(): NodeMaterialConnectionPoint;
  133590. /**
  133591. * Gets the replacement input component
  133592. */
  133593. get replacement(): NodeMaterialConnectionPoint;
  133594. /**
  133595. * Gets the output component
  133596. */
  133597. get output(): NodeMaterialConnectionPoint;
  133598. protected _buildBlock(state: NodeMaterialBuildState): this;
  133599. }
  133600. }
  133601. declare module BABYLON {
  133602. /**
  133603. * Block used to posterize a value
  133604. * @see https://en.wikipedia.org/wiki/Posterization
  133605. */
  133606. export class PosterizeBlock extends NodeMaterialBlock {
  133607. /**
  133608. * Creates a new PosterizeBlock
  133609. * @param name defines the block name
  133610. */
  133611. constructor(name: string);
  133612. /**
  133613. * Gets the current class name
  133614. * @returns the class name
  133615. */
  133616. getClassName(): string;
  133617. /**
  133618. * Gets the value input component
  133619. */
  133620. get value(): NodeMaterialConnectionPoint;
  133621. /**
  133622. * Gets the steps input component
  133623. */
  133624. get steps(): NodeMaterialConnectionPoint;
  133625. /**
  133626. * Gets the output component
  133627. */
  133628. get output(): NodeMaterialConnectionPoint;
  133629. protected _buildBlock(state: NodeMaterialBuildState): this;
  133630. }
  133631. }
  133632. declare module BABYLON {
  133633. /**
  133634. * Operations supported by the Wave block
  133635. */
  133636. export enum WaveBlockKind {
  133637. /** SawTooth */
  133638. SawTooth = 0,
  133639. /** Square */
  133640. Square = 1,
  133641. /** Triangle */
  133642. Triangle = 2
  133643. }
  133644. /**
  133645. * Block used to apply wave operation to floats
  133646. */
  133647. export class WaveBlock extends NodeMaterialBlock {
  133648. /**
  133649. * Gets or sets the kibnd of wave to be applied by the block
  133650. */
  133651. kind: WaveBlockKind;
  133652. /**
  133653. * Creates a new WaveBlock
  133654. * @param name defines the block name
  133655. */
  133656. constructor(name: string);
  133657. /**
  133658. * Gets the current class name
  133659. * @returns the class name
  133660. */
  133661. getClassName(): string;
  133662. /**
  133663. * Gets the input component
  133664. */
  133665. get input(): NodeMaterialConnectionPoint;
  133666. /**
  133667. * Gets the output component
  133668. */
  133669. get output(): NodeMaterialConnectionPoint;
  133670. protected _buildBlock(state: NodeMaterialBuildState): this;
  133671. serialize(): any;
  133672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133673. }
  133674. }
  133675. declare module BABYLON {
  133676. /**
  133677. * Class used to store a color step for the GradientBlock
  133678. */
  133679. export class GradientBlockColorStep {
  133680. /**
  133681. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133682. */
  133683. step: number;
  133684. /**
  133685. * Gets or sets the color associated with this step
  133686. */
  133687. color: Color3;
  133688. /**
  133689. * Creates a new GradientBlockColorStep
  133690. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133691. * @param color defines the color associated with this step
  133692. */
  133693. constructor(
  133694. /**
  133695. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133696. */
  133697. step: number,
  133698. /**
  133699. * Gets or sets the color associated with this step
  133700. */
  133701. color: Color3);
  133702. }
  133703. /**
  133704. * Block used to return a color from a gradient based on an input value between 0 and 1
  133705. */
  133706. export class GradientBlock extends NodeMaterialBlock {
  133707. /**
  133708. * Gets or sets the list of color steps
  133709. */
  133710. colorSteps: GradientBlockColorStep[];
  133711. /**
  133712. * Creates a new GradientBlock
  133713. * @param name defines the block name
  133714. */
  133715. constructor(name: string);
  133716. /**
  133717. * Gets the current class name
  133718. * @returns the class name
  133719. */
  133720. getClassName(): string;
  133721. /**
  133722. * Gets the gradient input component
  133723. */
  133724. get gradient(): NodeMaterialConnectionPoint;
  133725. /**
  133726. * Gets the output component
  133727. */
  133728. get output(): NodeMaterialConnectionPoint;
  133729. private _writeColorConstant;
  133730. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133731. serialize(): any;
  133732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133733. protected _dumpPropertiesCode(): string;
  133734. }
  133735. }
  133736. declare module BABYLON {
  133737. /**
  133738. * Block used to normalize lerp between 2 values
  133739. */
  133740. export class NLerpBlock extends NodeMaterialBlock {
  133741. /**
  133742. * Creates a new NLerpBlock
  133743. * @param name defines the block name
  133744. */
  133745. constructor(name: string);
  133746. /**
  133747. * Gets the current class name
  133748. * @returns the class name
  133749. */
  133750. getClassName(): string;
  133751. /**
  133752. * Gets the left operand input component
  133753. */
  133754. get left(): NodeMaterialConnectionPoint;
  133755. /**
  133756. * Gets the right operand input component
  133757. */
  133758. get right(): NodeMaterialConnectionPoint;
  133759. /**
  133760. * Gets the gradient operand input component
  133761. */
  133762. get gradient(): NodeMaterialConnectionPoint;
  133763. /**
  133764. * Gets the output component
  133765. */
  133766. get output(): NodeMaterialConnectionPoint;
  133767. protected _buildBlock(state: NodeMaterialBuildState): this;
  133768. }
  133769. }
  133770. declare module BABYLON {
  133771. /**
  133772. * block used to Generate a Worley Noise 3D Noise Pattern
  133773. */
  133774. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133775. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133776. manhattanDistance: boolean;
  133777. /**
  133778. * Creates a new WorleyNoise3DBlock
  133779. * @param name defines the block name
  133780. */
  133781. constructor(name: string);
  133782. /**
  133783. * Gets the current class name
  133784. * @returns the class name
  133785. */
  133786. getClassName(): string;
  133787. /**
  133788. * Gets the seed input component
  133789. */
  133790. get seed(): NodeMaterialConnectionPoint;
  133791. /**
  133792. * Gets the jitter input component
  133793. */
  133794. get jitter(): NodeMaterialConnectionPoint;
  133795. /**
  133796. * Gets the output component
  133797. */
  133798. get output(): NodeMaterialConnectionPoint;
  133799. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133800. /**
  133801. * Exposes the properties to the UI?
  133802. */
  133803. protected _dumpPropertiesCode(): string;
  133804. /**
  133805. * Exposes the properties to the Seralize?
  133806. */
  133807. serialize(): any;
  133808. /**
  133809. * Exposes the properties to the deseralize?
  133810. */
  133811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133812. }
  133813. }
  133814. declare module BABYLON {
  133815. /**
  133816. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133817. */
  133818. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133819. /**
  133820. * Creates a new SimplexPerlin3DBlock
  133821. * @param name defines the block name
  133822. */
  133823. constructor(name: string);
  133824. /**
  133825. * Gets the current class name
  133826. * @returns the class name
  133827. */
  133828. getClassName(): string;
  133829. /**
  133830. * Gets the seed operand input component
  133831. */
  133832. get seed(): NodeMaterialConnectionPoint;
  133833. /**
  133834. * Gets the output component
  133835. */
  133836. get output(): NodeMaterialConnectionPoint;
  133837. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133838. }
  133839. }
  133840. declare module BABYLON {
  133841. /**
  133842. * Block used to blend normals
  133843. */
  133844. export class NormalBlendBlock extends NodeMaterialBlock {
  133845. /**
  133846. * Creates a new NormalBlendBlock
  133847. * @param name defines the block name
  133848. */
  133849. constructor(name: string);
  133850. /**
  133851. * Gets the current class name
  133852. * @returns the class name
  133853. */
  133854. getClassName(): string;
  133855. /**
  133856. * Gets the first input component
  133857. */
  133858. get normalMap0(): NodeMaterialConnectionPoint;
  133859. /**
  133860. * Gets the second input component
  133861. */
  133862. get normalMap1(): NodeMaterialConnectionPoint;
  133863. /**
  133864. * Gets the output component
  133865. */
  133866. get output(): NodeMaterialConnectionPoint;
  133867. protected _buildBlock(state: NodeMaterialBuildState): this;
  133868. }
  133869. }
  133870. declare module BABYLON {
  133871. /**
  133872. * Block used to rotate a 2d vector by a given angle
  133873. */
  133874. export class Rotate2dBlock extends NodeMaterialBlock {
  133875. /**
  133876. * Creates a new Rotate2dBlock
  133877. * @param name defines the block name
  133878. */
  133879. constructor(name: string);
  133880. /**
  133881. * Gets the current class name
  133882. * @returns the class name
  133883. */
  133884. getClassName(): string;
  133885. /**
  133886. * Gets the input vector
  133887. */
  133888. get input(): NodeMaterialConnectionPoint;
  133889. /**
  133890. * Gets the input angle
  133891. */
  133892. get angle(): NodeMaterialConnectionPoint;
  133893. /**
  133894. * Gets the output component
  133895. */
  133896. get output(): NodeMaterialConnectionPoint;
  133897. autoConfigure(material: NodeMaterial): void;
  133898. protected _buildBlock(state: NodeMaterialBuildState): this;
  133899. }
  133900. }
  133901. declare module BABYLON {
  133902. /**
  133903. * Block used to get the reflected vector from a direction and a normal
  133904. */
  133905. export class ReflectBlock extends NodeMaterialBlock {
  133906. /**
  133907. * Creates a new ReflectBlock
  133908. * @param name defines the block name
  133909. */
  133910. constructor(name: string);
  133911. /**
  133912. * Gets the current class name
  133913. * @returns the class name
  133914. */
  133915. getClassName(): string;
  133916. /**
  133917. * Gets the incident component
  133918. */
  133919. get incident(): NodeMaterialConnectionPoint;
  133920. /**
  133921. * Gets the normal component
  133922. */
  133923. get normal(): NodeMaterialConnectionPoint;
  133924. /**
  133925. * Gets the output component
  133926. */
  133927. get output(): NodeMaterialConnectionPoint;
  133928. protected _buildBlock(state: NodeMaterialBuildState): this;
  133929. }
  133930. }
  133931. declare module BABYLON {
  133932. /**
  133933. * Block used to get the refracted vector from a direction and a normal
  133934. */
  133935. export class RefractBlock extends NodeMaterialBlock {
  133936. /**
  133937. * Creates a new RefractBlock
  133938. * @param name defines the block name
  133939. */
  133940. constructor(name: string);
  133941. /**
  133942. * Gets the current class name
  133943. * @returns the class name
  133944. */
  133945. getClassName(): string;
  133946. /**
  133947. * Gets the incident component
  133948. */
  133949. get incident(): NodeMaterialConnectionPoint;
  133950. /**
  133951. * Gets the normal component
  133952. */
  133953. get normal(): NodeMaterialConnectionPoint;
  133954. /**
  133955. * Gets the index of refraction component
  133956. */
  133957. get ior(): NodeMaterialConnectionPoint;
  133958. /**
  133959. * Gets the output component
  133960. */
  133961. get output(): NodeMaterialConnectionPoint;
  133962. protected _buildBlock(state: NodeMaterialBuildState): this;
  133963. }
  133964. }
  133965. declare module BABYLON {
  133966. /**
  133967. * Block used to desaturate a color
  133968. */
  133969. export class DesaturateBlock extends NodeMaterialBlock {
  133970. /**
  133971. * Creates a new DesaturateBlock
  133972. * @param name defines the block name
  133973. */
  133974. constructor(name: string);
  133975. /**
  133976. * Gets the current class name
  133977. * @returns the class name
  133978. */
  133979. getClassName(): string;
  133980. /**
  133981. * Gets the color operand input component
  133982. */
  133983. get color(): NodeMaterialConnectionPoint;
  133984. /**
  133985. * Gets the level operand input component
  133986. */
  133987. get level(): NodeMaterialConnectionPoint;
  133988. /**
  133989. * Gets the output component
  133990. */
  133991. get output(): NodeMaterialConnectionPoint;
  133992. protected _buildBlock(state: NodeMaterialBuildState): this;
  133993. }
  133994. }
  133995. declare module BABYLON {
  133996. /**
  133997. * Effect Render Options
  133998. */
  133999. export interface IEffectRendererOptions {
  134000. /**
  134001. * Defines the vertices positions.
  134002. */
  134003. positions?: number[];
  134004. /**
  134005. * Defines the indices.
  134006. */
  134007. indices?: number[];
  134008. }
  134009. /**
  134010. * Helper class to render one or more effects
  134011. */
  134012. export class EffectRenderer {
  134013. private engine;
  134014. private static _DefaultOptions;
  134015. private _vertexBuffers;
  134016. private _indexBuffer;
  134017. private _ringBufferIndex;
  134018. private _ringScreenBuffer;
  134019. private _fullscreenViewport;
  134020. private _getNextFrameBuffer;
  134021. /**
  134022. * Creates an effect renderer
  134023. * @param engine the engine to use for rendering
  134024. * @param options defines the options of the effect renderer
  134025. */
  134026. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  134027. /**
  134028. * Sets the current viewport in normalized coordinates 0-1
  134029. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  134030. */
  134031. setViewport(viewport?: Viewport): void;
  134032. /**
  134033. * Binds the embedded attributes buffer to the effect.
  134034. * @param effect Defines the effect to bind the attributes for
  134035. */
  134036. bindBuffers(effect: Effect): void;
  134037. /**
  134038. * Sets the current effect wrapper to use during draw.
  134039. * The effect needs to be ready before calling this api.
  134040. * This also sets the default full screen position attribute.
  134041. * @param effectWrapper Defines the effect to draw with
  134042. */
  134043. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  134044. /**
  134045. * Draws a full screen quad.
  134046. */
  134047. draw(): void;
  134048. /**
  134049. * renders one or more effects to a specified texture
  134050. * @param effectWrappers list of effects to renderer
  134051. * @param outputTexture texture to draw to, if null it will render to the screen
  134052. */
  134053. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  134054. /**
  134055. * Disposes of the effect renderer
  134056. */
  134057. dispose(): void;
  134058. }
  134059. /**
  134060. * Options to create an EffectWrapper
  134061. */
  134062. interface EffectWrapperCreationOptions {
  134063. /**
  134064. * Engine to use to create the effect
  134065. */
  134066. engine: ThinEngine;
  134067. /**
  134068. * Fragment shader for the effect
  134069. */
  134070. fragmentShader: string;
  134071. /**
  134072. * Vertex shader for the effect
  134073. */
  134074. vertexShader?: string;
  134075. /**
  134076. * Attributes to use in the shader
  134077. */
  134078. attributeNames?: Array<string>;
  134079. /**
  134080. * Uniforms to use in the shader
  134081. */
  134082. uniformNames?: Array<string>;
  134083. /**
  134084. * Texture sampler names to use in the shader
  134085. */
  134086. samplerNames?: Array<string>;
  134087. /**
  134088. * The friendly name of the effect displayed in Spector.
  134089. */
  134090. name?: string;
  134091. }
  134092. /**
  134093. * Wraps an effect to be used for rendering
  134094. */
  134095. export class EffectWrapper {
  134096. /**
  134097. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  134098. */
  134099. onApplyObservable: Observable<{}>;
  134100. /**
  134101. * The underlying effect
  134102. */
  134103. effect: Effect;
  134104. /**
  134105. * Creates an effect to be renderer
  134106. * @param creationOptions options to create the effect
  134107. */
  134108. constructor(creationOptions: EffectWrapperCreationOptions);
  134109. /**
  134110. * Disposes of the effect wrapper
  134111. */
  134112. dispose(): void;
  134113. }
  134114. }
  134115. declare module BABYLON {
  134116. /**
  134117. * Helper class to push actions to a pool of workers.
  134118. */
  134119. export class WorkerPool implements IDisposable {
  134120. private _workerInfos;
  134121. private _pendingActions;
  134122. /**
  134123. * Constructor
  134124. * @param workers Array of workers to use for actions
  134125. */
  134126. constructor(workers: Array<Worker>);
  134127. /**
  134128. * Terminates all workers and clears any pending actions.
  134129. */
  134130. dispose(): void;
  134131. /**
  134132. * Pushes an action to the worker pool. If all the workers are active, the action will be
  134133. * pended until a worker has completed its action.
  134134. * @param action The action to perform. Call onComplete when the action is complete.
  134135. */
  134136. push(action: (worker: Worker, onComplete: () => void) => void): void;
  134137. private _execute;
  134138. }
  134139. }
  134140. declare module BABYLON {
  134141. /**
  134142. * Configuration for Draco compression
  134143. */
  134144. export interface IDracoCompressionConfiguration {
  134145. /**
  134146. * Configuration for the decoder.
  134147. */
  134148. decoder: {
  134149. /**
  134150. * The url to the WebAssembly module.
  134151. */
  134152. wasmUrl?: string;
  134153. /**
  134154. * The url to the WebAssembly binary.
  134155. */
  134156. wasmBinaryUrl?: string;
  134157. /**
  134158. * The url to the fallback JavaScript module.
  134159. */
  134160. fallbackUrl?: string;
  134161. };
  134162. }
  134163. /**
  134164. * Draco compression (https://google.github.io/draco/)
  134165. *
  134166. * This class wraps the Draco module.
  134167. *
  134168. * **Encoder**
  134169. *
  134170. * The encoder is not currently implemented.
  134171. *
  134172. * **Decoder**
  134173. *
  134174. * 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.
  134175. *
  134176. * To update the configuration, use the following code:
  134177. * ```javascript
  134178. * DracoCompression.Configuration = {
  134179. * decoder: {
  134180. * wasmUrl: "<url to the WebAssembly library>",
  134181. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  134182. * fallbackUrl: "<url to the fallback JavaScript library>",
  134183. * }
  134184. * };
  134185. * ```
  134186. *
  134187. * 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.
  134188. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  134189. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  134190. *
  134191. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  134192. * ```javascript
  134193. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  134194. * ```
  134195. *
  134196. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  134197. */
  134198. export class DracoCompression implements IDisposable {
  134199. private _workerPoolPromise?;
  134200. private _decoderModulePromise?;
  134201. /**
  134202. * The configuration. Defaults to the following urls:
  134203. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  134204. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  134205. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  134206. */
  134207. static Configuration: IDracoCompressionConfiguration;
  134208. /**
  134209. * Returns true if the decoder configuration is available.
  134210. */
  134211. static get DecoderAvailable(): boolean;
  134212. /**
  134213. * Default number of workers to create when creating the draco compression object.
  134214. */
  134215. static DefaultNumWorkers: number;
  134216. private static GetDefaultNumWorkers;
  134217. private static _Default;
  134218. /**
  134219. * Default instance for the draco compression object.
  134220. */
  134221. static get Default(): DracoCompression;
  134222. /**
  134223. * Constructor
  134224. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  134225. */
  134226. constructor(numWorkers?: number);
  134227. /**
  134228. * Stop all async operations and release resources.
  134229. */
  134230. dispose(): void;
  134231. /**
  134232. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  134233. * @returns a promise that resolves when ready
  134234. */
  134235. whenReadyAsync(): Promise<void>;
  134236. /**
  134237. * Decode Draco compressed mesh data to vertex data.
  134238. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  134239. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  134240. * @returns A promise that resolves with the decoded vertex data
  134241. */
  134242. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  134243. [kind: string]: number;
  134244. }): Promise<VertexData>;
  134245. }
  134246. }
  134247. declare module BABYLON {
  134248. /**
  134249. * Class for building Constructive Solid Geometry
  134250. */
  134251. export class CSG {
  134252. private polygons;
  134253. /**
  134254. * The world matrix
  134255. */
  134256. matrix: Matrix;
  134257. /**
  134258. * Stores the position
  134259. */
  134260. position: Vector3;
  134261. /**
  134262. * Stores the rotation
  134263. */
  134264. rotation: Vector3;
  134265. /**
  134266. * Stores the rotation quaternion
  134267. */
  134268. rotationQuaternion: Nullable<Quaternion>;
  134269. /**
  134270. * Stores the scaling vector
  134271. */
  134272. scaling: Vector3;
  134273. /**
  134274. * Convert the Mesh to CSG
  134275. * @param mesh The Mesh to convert to CSG
  134276. * @returns A new CSG from the Mesh
  134277. */
  134278. static FromMesh(mesh: Mesh): CSG;
  134279. /**
  134280. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  134281. * @param polygons Polygons used to construct a CSG solid
  134282. */
  134283. private static FromPolygons;
  134284. /**
  134285. * Clones, or makes a deep copy, of the CSG
  134286. * @returns A new CSG
  134287. */
  134288. clone(): CSG;
  134289. /**
  134290. * Unions this CSG with another CSG
  134291. * @param csg The CSG to union against this CSG
  134292. * @returns The unioned CSG
  134293. */
  134294. union(csg: CSG): CSG;
  134295. /**
  134296. * Unions this CSG with another CSG in place
  134297. * @param csg The CSG to union against this CSG
  134298. */
  134299. unionInPlace(csg: CSG): void;
  134300. /**
  134301. * Subtracts this CSG with another CSG
  134302. * @param csg The CSG to subtract against this CSG
  134303. * @returns A new CSG
  134304. */
  134305. subtract(csg: CSG): CSG;
  134306. /**
  134307. * Subtracts this CSG with another CSG in place
  134308. * @param csg The CSG to subtact against this CSG
  134309. */
  134310. subtractInPlace(csg: CSG): void;
  134311. /**
  134312. * Intersect this CSG with another CSG
  134313. * @param csg The CSG to intersect against this CSG
  134314. * @returns A new CSG
  134315. */
  134316. intersect(csg: CSG): CSG;
  134317. /**
  134318. * Intersects this CSG with another CSG in place
  134319. * @param csg The CSG to intersect against this CSG
  134320. */
  134321. intersectInPlace(csg: CSG): void;
  134322. /**
  134323. * Return a new CSG solid with solid and empty space switched. This solid is
  134324. * not modified.
  134325. * @returns A new CSG solid with solid and empty space switched
  134326. */
  134327. inverse(): CSG;
  134328. /**
  134329. * Inverses the CSG in place
  134330. */
  134331. inverseInPlace(): void;
  134332. /**
  134333. * This is used to keep meshes transformations so they can be restored
  134334. * when we build back a Babylon Mesh
  134335. * NB : All CSG operations are performed in world coordinates
  134336. * @param csg The CSG to copy the transform attributes from
  134337. * @returns This CSG
  134338. */
  134339. copyTransformAttributes(csg: CSG): CSG;
  134340. /**
  134341. * Build Raw mesh from CSG
  134342. * Coordinates here are in world space
  134343. * @param name The name of the mesh geometry
  134344. * @param scene The Scene
  134345. * @param keepSubMeshes Specifies if the submeshes should be kept
  134346. * @returns A new Mesh
  134347. */
  134348. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  134349. /**
  134350. * Build Mesh from CSG taking material and transforms into account
  134351. * @param name The name of the Mesh
  134352. * @param material The material of the Mesh
  134353. * @param scene The Scene
  134354. * @param keepSubMeshes Specifies if submeshes should be kept
  134355. * @returns The new Mesh
  134356. */
  134357. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  134358. }
  134359. }
  134360. declare module BABYLON {
  134361. /**
  134362. * Class used to create a trail following a mesh
  134363. */
  134364. export class TrailMesh extends Mesh {
  134365. private _generator;
  134366. private _autoStart;
  134367. private _running;
  134368. private _diameter;
  134369. private _length;
  134370. private _sectionPolygonPointsCount;
  134371. private _sectionVectors;
  134372. private _sectionNormalVectors;
  134373. private _beforeRenderObserver;
  134374. /**
  134375. * @constructor
  134376. * @param name The value used by scene.getMeshByName() to do a lookup.
  134377. * @param generator The mesh or transform node to generate a trail.
  134378. * @param scene The scene to add this mesh to.
  134379. * @param diameter Diameter of trailing mesh. Default is 1.
  134380. * @param length Length of trailing mesh. Default is 60.
  134381. * @param autoStart Automatically start trailing mesh. Default true.
  134382. */
  134383. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  134384. /**
  134385. * "TrailMesh"
  134386. * @returns "TrailMesh"
  134387. */
  134388. getClassName(): string;
  134389. private _createMesh;
  134390. /**
  134391. * Start trailing mesh.
  134392. */
  134393. start(): void;
  134394. /**
  134395. * Stop trailing mesh.
  134396. */
  134397. stop(): void;
  134398. /**
  134399. * Update trailing mesh geometry.
  134400. */
  134401. update(): void;
  134402. /**
  134403. * Returns a new TrailMesh object.
  134404. * @param name is a string, the name given to the new mesh
  134405. * @param newGenerator use new generator object for cloned trail mesh
  134406. * @returns a new mesh
  134407. */
  134408. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  134409. /**
  134410. * Serializes this trail mesh
  134411. * @param serializationObject object to write serialization to
  134412. */
  134413. serialize(serializationObject: any): void;
  134414. /**
  134415. * Parses a serialized trail mesh
  134416. * @param parsedMesh the serialized mesh
  134417. * @param scene the scene to create the trail mesh in
  134418. * @returns the created trail mesh
  134419. */
  134420. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  134421. }
  134422. }
  134423. declare module BABYLON {
  134424. /**
  134425. * Class containing static functions to help procedurally build meshes
  134426. */
  134427. export class TiledBoxBuilder {
  134428. /**
  134429. * Creates a box mesh
  134430. * 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)
  134431. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134435. * @param name defines the name of the mesh
  134436. * @param options defines the options used to create the mesh
  134437. * @param scene defines the hosting scene
  134438. * @returns the box mesh
  134439. */
  134440. static CreateTiledBox(name: string, options: {
  134441. pattern?: number;
  134442. width?: number;
  134443. height?: number;
  134444. depth?: number;
  134445. tileSize?: number;
  134446. tileWidth?: number;
  134447. tileHeight?: number;
  134448. alignHorizontal?: number;
  134449. alignVertical?: number;
  134450. faceUV?: Vector4[];
  134451. faceColors?: Color4[];
  134452. sideOrientation?: number;
  134453. updatable?: boolean;
  134454. }, scene?: Nullable<Scene>): Mesh;
  134455. }
  134456. }
  134457. declare module BABYLON {
  134458. /**
  134459. * Class containing static functions to help procedurally build meshes
  134460. */
  134461. export class TorusKnotBuilder {
  134462. /**
  134463. * Creates a torus knot mesh
  134464. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134465. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134466. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134467. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134471. * @param name defines the name of the mesh
  134472. * @param options defines the options used to create the mesh
  134473. * @param scene defines the hosting scene
  134474. * @returns the torus knot mesh
  134475. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134476. */
  134477. static CreateTorusKnot(name: string, options: {
  134478. radius?: number;
  134479. tube?: number;
  134480. radialSegments?: number;
  134481. tubularSegments?: number;
  134482. p?: number;
  134483. q?: number;
  134484. updatable?: boolean;
  134485. sideOrientation?: number;
  134486. frontUVs?: Vector4;
  134487. backUVs?: Vector4;
  134488. }, scene: any): Mesh;
  134489. }
  134490. }
  134491. declare module BABYLON {
  134492. /**
  134493. * Polygon
  134494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  134495. */
  134496. export class Polygon {
  134497. /**
  134498. * Creates a rectangle
  134499. * @param xmin bottom X coord
  134500. * @param ymin bottom Y coord
  134501. * @param xmax top X coord
  134502. * @param ymax top Y coord
  134503. * @returns points that make the resulting rectation
  134504. */
  134505. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  134506. /**
  134507. * Creates a circle
  134508. * @param radius radius of circle
  134509. * @param cx scale in x
  134510. * @param cy scale in y
  134511. * @param numberOfSides number of sides that make up the circle
  134512. * @returns points that make the resulting circle
  134513. */
  134514. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134515. /**
  134516. * Creates a polygon from input string
  134517. * @param input Input polygon data
  134518. * @returns the parsed points
  134519. */
  134520. static Parse(input: string): Vector2[];
  134521. /**
  134522. * Starts building a polygon from x and y coordinates
  134523. * @param x x coordinate
  134524. * @param y y coordinate
  134525. * @returns the started path2
  134526. */
  134527. static StartingAt(x: number, y: number): Path2;
  134528. }
  134529. /**
  134530. * Builds a polygon
  134531. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134532. */
  134533. export class PolygonMeshBuilder {
  134534. private _points;
  134535. private _outlinepoints;
  134536. private _holes;
  134537. private _name;
  134538. private _scene;
  134539. private _epoints;
  134540. private _eholes;
  134541. private _addToepoint;
  134542. /**
  134543. * Babylon reference to the earcut plugin.
  134544. */
  134545. bjsEarcut: any;
  134546. /**
  134547. * Creates a PolygonMeshBuilder
  134548. * @param name name of the builder
  134549. * @param contours Path of the polygon
  134550. * @param scene scene to add to when creating the mesh
  134551. * @param earcutInjection can be used to inject your own earcut reference
  134552. */
  134553. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134554. /**
  134555. * Adds a whole within the polygon
  134556. * @param hole Array of points defining the hole
  134557. * @returns this
  134558. */
  134559. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134560. /**
  134561. * Creates the polygon
  134562. * @param updatable If the mesh should be updatable
  134563. * @param depth The depth of the mesh created
  134564. * @returns the created mesh
  134565. */
  134566. build(updatable?: boolean, depth?: number): Mesh;
  134567. /**
  134568. * Creates the polygon
  134569. * @param depth The depth of the mesh created
  134570. * @returns the created VertexData
  134571. */
  134572. buildVertexData(depth?: number): VertexData;
  134573. /**
  134574. * Adds a side to the polygon
  134575. * @param positions points that make the polygon
  134576. * @param normals normals of the polygon
  134577. * @param uvs uvs of the polygon
  134578. * @param indices indices of the polygon
  134579. * @param bounds bounds of the polygon
  134580. * @param points points of the polygon
  134581. * @param depth depth of the polygon
  134582. * @param flip flip of the polygon
  134583. */
  134584. private addSide;
  134585. }
  134586. }
  134587. declare module BABYLON {
  134588. /**
  134589. * Class containing static functions to help procedurally build meshes
  134590. */
  134591. export class PolygonBuilder {
  134592. /**
  134593. * Creates a polygon mesh
  134594. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134595. * * 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
  134596. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134599. * * Remember you can only change the shape positions, not their number when updating a polygon
  134600. * @param name defines the name of the mesh
  134601. * @param options defines the options used to create the mesh
  134602. * @param scene defines the hosting scene
  134603. * @param earcutInjection can be used to inject your own earcut reference
  134604. * @returns the polygon mesh
  134605. */
  134606. static CreatePolygon(name: string, options: {
  134607. shape: Vector3[];
  134608. holes?: Vector3[][];
  134609. depth?: number;
  134610. faceUV?: Vector4[];
  134611. faceColors?: Color4[];
  134612. updatable?: boolean;
  134613. sideOrientation?: number;
  134614. frontUVs?: Vector4;
  134615. backUVs?: Vector4;
  134616. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134617. /**
  134618. * Creates an extruded polygon mesh, with depth in the Y direction.
  134619. * * 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)
  134620. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134621. * @param name defines the name of the mesh
  134622. * @param options defines the options used to create the mesh
  134623. * @param scene defines the hosting scene
  134624. * @param earcutInjection can be used to inject your own earcut reference
  134625. * @returns the polygon mesh
  134626. */
  134627. static ExtrudePolygon(name: string, options: {
  134628. shape: Vector3[];
  134629. holes?: Vector3[][];
  134630. depth?: number;
  134631. faceUV?: Vector4[];
  134632. faceColors?: Color4[];
  134633. updatable?: boolean;
  134634. sideOrientation?: number;
  134635. frontUVs?: Vector4;
  134636. backUVs?: Vector4;
  134637. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134638. }
  134639. }
  134640. declare module BABYLON {
  134641. /**
  134642. * Class containing static functions to help procedurally build meshes
  134643. */
  134644. export class LatheBuilder {
  134645. /**
  134646. * Creates lathe mesh.
  134647. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134648. * * 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
  134649. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134650. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134651. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134652. * * 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
  134653. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134654. * * 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
  134655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134659. * @param name defines the name of the mesh
  134660. * @param options defines the options used to create the mesh
  134661. * @param scene defines the hosting scene
  134662. * @returns the lathe mesh
  134663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134664. */
  134665. static CreateLathe(name: string, options: {
  134666. shape: Vector3[];
  134667. radius?: number;
  134668. tessellation?: number;
  134669. clip?: number;
  134670. arc?: number;
  134671. closed?: boolean;
  134672. updatable?: boolean;
  134673. sideOrientation?: number;
  134674. frontUVs?: Vector4;
  134675. backUVs?: Vector4;
  134676. cap?: number;
  134677. invertUV?: boolean;
  134678. }, scene?: Nullable<Scene>): Mesh;
  134679. }
  134680. }
  134681. declare module BABYLON {
  134682. /**
  134683. * Class containing static functions to help procedurally build meshes
  134684. */
  134685. export class TiledPlaneBuilder {
  134686. /**
  134687. * Creates a tiled plane mesh
  134688. * * The parameter `pattern` will, depending on value, do nothing or
  134689. * * * flip (reflect about central vertical) alternate tiles across and up
  134690. * * * flip every tile on alternate rows
  134691. * * * rotate (180 degs) alternate tiles across and up
  134692. * * * rotate every tile on alternate rows
  134693. * * * flip and rotate alternate tiles across and up
  134694. * * * flip and rotate every tile on alternate rows
  134695. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134696. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134699. * * 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)
  134700. * * 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)
  134701. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134702. * @param name defines the name of the mesh
  134703. * @param options defines the options used to create the mesh
  134704. * @param scene defines the hosting scene
  134705. * @returns the box mesh
  134706. */
  134707. static CreateTiledPlane(name: string, options: {
  134708. pattern?: number;
  134709. tileSize?: number;
  134710. tileWidth?: number;
  134711. tileHeight?: number;
  134712. size?: number;
  134713. width?: number;
  134714. height?: number;
  134715. alignHorizontal?: number;
  134716. alignVertical?: number;
  134717. sideOrientation?: number;
  134718. frontUVs?: Vector4;
  134719. backUVs?: Vector4;
  134720. updatable?: boolean;
  134721. }, scene?: Nullable<Scene>): Mesh;
  134722. }
  134723. }
  134724. declare module BABYLON {
  134725. /**
  134726. * Class containing static functions to help procedurally build meshes
  134727. */
  134728. export class TubeBuilder {
  134729. /**
  134730. * Creates a tube mesh.
  134731. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134732. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134733. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134734. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134735. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134736. * * 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)
  134737. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134738. * * 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
  134739. * * 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
  134740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134744. * @param name defines the name of the mesh
  134745. * @param options defines the options used to create the mesh
  134746. * @param scene defines the hosting scene
  134747. * @returns the tube mesh
  134748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134749. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134750. */
  134751. static CreateTube(name: string, options: {
  134752. path: Vector3[];
  134753. radius?: number;
  134754. tessellation?: number;
  134755. radiusFunction?: {
  134756. (i: number, distance: number): number;
  134757. };
  134758. cap?: number;
  134759. arc?: number;
  134760. updatable?: boolean;
  134761. sideOrientation?: number;
  134762. frontUVs?: Vector4;
  134763. backUVs?: Vector4;
  134764. instance?: Mesh;
  134765. invertUV?: boolean;
  134766. }, scene?: Nullable<Scene>): Mesh;
  134767. }
  134768. }
  134769. declare module BABYLON {
  134770. /**
  134771. * Class containing static functions to help procedurally build meshes
  134772. */
  134773. export class IcoSphereBuilder {
  134774. /**
  134775. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134776. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134777. * * 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`)
  134778. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134779. * * 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
  134780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134783. * @param name defines the name of the mesh
  134784. * @param options defines the options used to create the mesh
  134785. * @param scene defines the hosting scene
  134786. * @returns the icosahedron mesh
  134787. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134788. */
  134789. static CreateIcoSphere(name: string, options: {
  134790. radius?: number;
  134791. radiusX?: number;
  134792. radiusY?: number;
  134793. radiusZ?: number;
  134794. flat?: boolean;
  134795. subdivisions?: number;
  134796. sideOrientation?: number;
  134797. frontUVs?: Vector4;
  134798. backUVs?: Vector4;
  134799. updatable?: boolean;
  134800. }, scene?: Nullable<Scene>): Mesh;
  134801. }
  134802. }
  134803. declare module BABYLON {
  134804. /**
  134805. * Class containing static functions to help procedurally build meshes
  134806. */
  134807. export class DecalBuilder {
  134808. /**
  134809. * Creates a decal mesh.
  134810. * 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
  134811. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134812. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134813. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134814. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134815. * @param name defines the name of the mesh
  134816. * @param sourceMesh defines the mesh where the decal must be applied
  134817. * @param options defines the options used to create the mesh
  134818. * @param scene defines the hosting scene
  134819. * @returns the decal mesh
  134820. * @see https://doc.babylonjs.com/how_to/decals
  134821. */
  134822. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134823. position?: Vector3;
  134824. normal?: Vector3;
  134825. size?: Vector3;
  134826. angle?: number;
  134827. }): Mesh;
  134828. }
  134829. }
  134830. declare module BABYLON {
  134831. /**
  134832. * Class containing static functions to help procedurally build meshes
  134833. */
  134834. export class MeshBuilder {
  134835. /**
  134836. * Creates a box mesh
  134837. * * The parameter `size` sets the size (float) of each box side (default 1)
  134838. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134839. * * 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)
  134840. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134844. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134845. * @param name defines the name of the mesh
  134846. * @param options defines the options used to create the mesh
  134847. * @param scene defines the hosting scene
  134848. * @returns the box mesh
  134849. */
  134850. static CreateBox(name: string, options: {
  134851. size?: number;
  134852. width?: number;
  134853. height?: number;
  134854. depth?: number;
  134855. faceUV?: Vector4[];
  134856. faceColors?: Color4[];
  134857. sideOrientation?: number;
  134858. frontUVs?: Vector4;
  134859. backUVs?: Vector4;
  134860. wrap?: boolean;
  134861. topBaseAt?: number;
  134862. bottomBaseAt?: number;
  134863. updatable?: boolean;
  134864. }, scene?: Nullable<Scene>): Mesh;
  134865. /**
  134866. * Creates a tiled box mesh
  134867. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134869. * @param name defines the name of the mesh
  134870. * @param options defines the options used to create the mesh
  134871. * @param scene defines the hosting scene
  134872. * @returns the tiled box mesh
  134873. */
  134874. static CreateTiledBox(name: string, options: {
  134875. pattern?: number;
  134876. size?: number;
  134877. width?: number;
  134878. height?: number;
  134879. depth: number;
  134880. tileSize?: number;
  134881. tileWidth?: number;
  134882. tileHeight?: number;
  134883. faceUV?: Vector4[];
  134884. faceColors?: Color4[];
  134885. alignHorizontal?: number;
  134886. alignVertical?: number;
  134887. sideOrientation?: number;
  134888. updatable?: boolean;
  134889. }, scene?: Nullable<Scene>): Mesh;
  134890. /**
  134891. * Creates a sphere mesh
  134892. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134893. * * 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`)
  134894. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134895. * * 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
  134896. * * 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)
  134897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134900. * @param name defines the name of the mesh
  134901. * @param options defines the options used to create the mesh
  134902. * @param scene defines the hosting scene
  134903. * @returns the sphere mesh
  134904. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134905. */
  134906. static CreateSphere(name: string, options: {
  134907. segments?: number;
  134908. diameter?: number;
  134909. diameterX?: number;
  134910. diameterY?: number;
  134911. diameterZ?: number;
  134912. arc?: number;
  134913. slice?: number;
  134914. sideOrientation?: number;
  134915. frontUVs?: Vector4;
  134916. backUVs?: Vector4;
  134917. updatable?: boolean;
  134918. }, scene?: Nullable<Scene>): Mesh;
  134919. /**
  134920. * Creates a plane polygonal mesh. By default, this is a disc
  134921. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134922. * * 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
  134923. * * 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
  134924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134927. * @param name defines the name of the mesh
  134928. * @param options defines the options used to create the mesh
  134929. * @param scene defines the hosting scene
  134930. * @returns the plane polygonal mesh
  134931. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134932. */
  134933. static CreateDisc(name: string, options: {
  134934. radius?: number;
  134935. tessellation?: number;
  134936. arc?: number;
  134937. updatable?: boolean;
  134938. sideOrientation?: number;
  134939. frontUVs?: Vector4;
  134940. backUVs?: Vector4;
  134941. }, scene?: Nullable<Scene>): Mesh;
  134942. /**
  134943. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134944. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134945. * * 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`)
  134946. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134947. * * 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
  134948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134951. * @param name defines the name of the mesh
  134952. * @param options defines the options used to create the mesh
  134953. * @param scene defines the hosting scene
  134954. * @returns the icosahedron mesh
  134955. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134956. */
  134957. static CreateIcoSphere(name: string, options: {
  134958. radius?: number;
  134959. radiusX?: number;
  134960. radiusY?: number;
  134961. radiusZ?: number;
  134962. flat?: boolean;
  134963. subdivisions?: number;
  134964. sideOrientation?: number;
  134965. frontUVs?: Vector4;
  134966. backUVs?: Vector4;
  134967. updatable?: boolean;
  134968. }, scene?: Nullable<Scene>): Mesh;
  134969. /**
  134970. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134971. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134972. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134973. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134974. * * 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
  134975. * * 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
  134976. * * 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
  134977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134979. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134980. * * 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
  134981. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134982. * * 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
  134983. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134985. * @param name defines the name of the mesh
  134986. * @param options defines the options used to create the mesh
  134987. * @param scene defines the hosting scene
  134988. * @returns the ribbon mesh
  134989. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134990. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134991. */
  134992. static CreateRibbon(name: string, options: {
  134993. pathArray: Vector3[][];
  134994. closeArray?: boolean;
  134995. closePath?: boolean;
  134996. offset?: number;
  134997. updatable?: boolean;
  134998. sideOrientation?: number;
  134999. frontUVs?: Vector4;
  135000. backUVs?: Vector4;
  135001. instance?: Mesh;
  135002. invertUV?: boolean;
  135003. uvs?: Vector2[];
  135004. colors?: Color4[];
  135005. }, scene?: Nullable<Scene>): Mesh;
  135006. /**
  135007. * Creates a cylinder or a cone mesh
  135008. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  135009. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  135010. * * 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.
  135011. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  135012. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  135013. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  135014. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  135015. * * 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).
  135016. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  135017. * * 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).
  135018. * * 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
  135019. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  135020. * * 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
  135021. * * 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.
  135022. * * If `enclose` is false, a ring surface is one element.
  135023. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  135024. * * 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
  135025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135028. * @param name defines the name of the mesh
  135029. * @param options defines the options used to create the mesh
  135030. * @param scene defines the hosting scene
  135031. * @returns the cylinder mesh
  135032. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  135033. */
  135034. static CreateCylinder(name: string, options: {
  135035. height?: number;
  135036. diameterTop?: number;
  135037. diameterBottom?: number;
  135038. diameter?: number;
  135039. tessellation?: number;
  135040. subdivisions?: number;
  135041. arc?: number;
  135042. faceColors?: Color4[];
  135043. faceUV?: Vector4[];
  135044. updatable?: boolean;
  135045. hasRings?: boolean;
  135046. enclose?: boolean;
  135047. cap?: number;
  135048. sideOrientation?: number;
  135049. frontUVs?: Vector4;
  135050. backUVs?: Vector4;
  135051. }, scene?: Nullable<Scene>): Mesh;
  135052. /**
  135053. * Creates a torus mesh
  135054. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  135055. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  135056. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  135057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135060. * @param name defines the name of the mesh
  135061. * @param options defines the options used to create the mesh
  135062. * @param scene defines the hosting scene
  135063. * @returns the torus mesh
  135064. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  135065. */
  135066. static CreateTorus(name: string, options: {
  135067. diameter?: number;
  135068. thickness?: number;
  135069. tessellation?: number;
  135070. updatable?: boolean;
  135071. sideOrientation?: number;
  135072. frontUVs?: Vector4;
  135073. backUVs?: Vector4;
  135074. }, scene?: Nullable<Scene>): Mesh;
  135075. /**
  135076. * Creates a torus knot mesh
  135077. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135078. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135079. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135080. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135084. * @param name defines the name of the mesh
  135085. * @param options defines the options used to create the mesh
  135086. * @param scene defines the hosting scene
  135087. * @returns the torus knot mesh
  135088. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135089. */
  135090. static CreateTorusKnot(name: string, options: {
  135091. radius?: number;
  135092. tube?: number;
  135093. radialSegments?: number;
  135094. tubularSegments?: number;
  135095. p?: number;
  135096. q?: number;
  135097. updatable?: boolean;
  135098. sideOrientation?: number;
  135099. frontUVs?: Vector4;
  135100. backUVs?: Vector4;
  135101. }, scene?: Nullable<Scene>): Mesh;
  135102. /**
  135103. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  135104. * * 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
  135105. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  135106. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  135107. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  135108. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  135109. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  135110. * * 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
  135111. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  135112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  135114. * @param name defines the name of the new line system
  135115. * @param options defines the options used to create the line system
  135116. * @param scene defines the hosting scene
  135117. * @returns a new line system mesh
  135118. */
  135119. static CreateLineSystem(name: string, options: {
  135120. lines: Vector3[][];
  135121. updatable?: boolean;
  135122. instance?: Nullable<LinesMesh>;
  135123. colors?: Nullable<Color4[][]>;
  135124. useVertexAlpha?: boolean;
  135125. }, scene: Nullable<Scene>): LinesMesh;
  135126. /**
  135127. * Creates a line mesh
  135128. * 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
  135129. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  135130. * * The parameter `points` is an array successive Vector3
  135131. * * 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
  135132. * * The optional parameter `colors` is an array of successive Color4, one per line point
  135133. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  135134. * * When updating an instance, remember that only point positions can change, not the number of points
  135135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  135137. * @param name defines the name of the new line system
  135138. * @param options defines the options used to create the line system
  135139. * @param scene defines the hosting scene
  135140. * @returns a new line mesh
  135141. */
  135142. static CreateLines(name: string, options: {
  135143. points: Vector3[];
  135144. updatable?: boolean;
  135145. instance?: Nullable<LinesMesh>;
  135146. colors?: Color4[];
  135147. useVertexAlpha?: boolean;
  135148. }, scene?: Nullable<Scene>): LinesMesh;
  135149. /**
  135150. * Creates a dashed line mesh
  135151. * * 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
  135152. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  135153. * * The parameter `points` is an array successive Vector3
  135154. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  135155. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  135156. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  135157. * * 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
  135158. * * When updating an instance, remember that only point positions can change, not the number of points
  135159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135160. * @param name defines the name of the mesh
  135161. * @param options defines the options used to create the mesh
  135162. * @param scene defines the hosting scene
  135163. * @returns the dashed line mesh
  135164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  135165. */
  135166. static CreateDashedLines(name: string, options: {
  135167. points: Vector3[];
  135168. dashSize?: number;
  135169. gapSize?: number;
  135170. dashNb?: number;
  135171. updatable?: boolean;
  135172. instance?: LinesMesh;
  135173. }, scene?: Nullable<Scene>): LinesMesh;
  135174. /**
  135175. * 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.
  135176. * * 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.
  135177. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135178. * * 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.
  135179. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135180. * * 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
  135181. * * 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
  135182. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135187. * @param name defines the name of the mesh
  135188. * @param options defines the options used to create the mesh
  135189. * @param scene defines the hosting scene
  135190. * @returns the extruded shape mesh
  135191. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135193. */
  135194. static ExtrudeShape(name: string, options: {
  135195. shape: Vector3[];
  135196. path: Vector3[];
  135197. scale?: number;
  135198. rotation?: number;
  135199. cap?: number;
  135200. updatable?: boolean;
  135201. sideOrientation?: number;
  135202. frontUVs?: Vector4;
  135203. backUVs?: Vector4;
  135204. instance?: Mesh;
  135205. invertUV?: boolean;
  135206. }, scene?: Nullable<Scene>): Mesh;
  135207. /**
  135208. * Creates an custom extruded shape mesh.
  135209. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135210. * * 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.
  135211. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135212. * * 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
  135213. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135214. * * 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
  135215. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135216. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135217. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135218. * * 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
  135219. * * 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
  135220. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135223. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135225. * @param name defines the name of the mesh
  135226. * @param options defines the options used to create the mesh
  135227. * @param scene defines the hosting scene
  135228. * @returns the custom extruded shape mesh
  135229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135232. */
  135233. static ExtrudeShapeCustom(name: string, options: {
  135234. shape: Vector3[];
  135235. path: Vector3[];
  135236. scaleFunction?: any;
  135237. rotationFunction?: any;
  135238. ribbonCloseArray?: boolean;
  135239. ribbonClosePath?: boolean;
  135240. cap?: number;
  135241. updatable?: boolean;
  135242. sideOrientation?: number;
  135243. frontUVs?: Vector4;
  135244. backUVs?: Vector4;
  135245. instance?: Mesh;
  135246. invertUV?: boolean;
  135247. }, scene?: Nullable<Scene>): Mesh;
  135248. /**
  135249. * Creates lathe mesh.
  135250. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135251. * * 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
  135252. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135253. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135254. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135255. * * 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
  135256. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135257. * * 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
  135258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135260. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135262. * @param name defines the name of the mesh
  135263. * @param options defines the options used to create the mesh
  135264. * @param scene defines the hosting scene
  135265. * @returns the lathe mesh
  135266. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135267. */
  135268. static CreateLathe(name: string, options: {
  135269. shape: Vector3[];
  135270. radius?: number;
  135271. tessellation?: number;
  135272. clip?: number;
  135273. arc?: number;
  135274. closed?: boolean;
  135275. updatable?: boolean;
  135276. sideOrientation?: number;
  135277. frontUVs?: Vector4;
  135278. backUVs?: Vector4;
  135279. cap?: number;
  135280. invertUV?: boolean;
  135281. }, scene?: Nullable<Scene>): Mesh;
  135282. /**
  135283. * Creates a tiled plane mesh
  135284. * * You can set a limited pattern arrangement with the tiles
  135285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135288. * @param name defines the name of the mesh
  135289. * @param options defines the options used to create the mesh
  135290. * @param scene defines the hosting scene
  135291. * @returns the plane mesh
  135292. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135293. */
  135294. static CreateTiledPlane(name: string, options: {
  135295. pattern?: number;
  135296. tileSize?: number;
  135297. tileWidth?: number;
  135298. tileHeight?: number;
  135299. size?: number;
  135300. width?: number;
  135301. height?: number;
  135302. alignHorizontal?: number;
  135303. alignVertical?: number;
  135304. sideOrientation?: number;
  135305. frontUVs?: Vector4;
  135306. backUVs?: Vector4;
  135307. updatable?: boolean;
  135308. }, scene?: Nullable<Scene>): Mesh;
  135309. /**
  135310. * Creates a plane mesh
  135311. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  135312. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  135313. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  135314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135317. * @param name defines the name of the mesh
  135318. * @param options defines the options used to create the mesh
  135319. * @param scene defines the hosting scene
  135320. * @returns the plane mesh
  135321. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135322. */
  135323. static CreatePlane(name: string, options: {
  135324. size?: number;
  135325. width?: number;
  135326. height?: number;
  135327. sideOrientation?: number;
  135328. frontUVs?: Vector4;
  135329. backUVs?: Vector4;
  135330. updatable?: boolean;
  135331. sourcePlane?: Plane;
  135332. }, scene?: Nullable<Scene>): Mesh;
  135333. /**
  135334. * Creates a ground mesh
  135335. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  135336. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  135337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135338. * @param name defines the name of the mesh
  135339. * @param options defines the options used to create the mesh
  135340. * @param scene defines the hosting scene
  135341. * @returns the ground mesh
  135342. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  135343. */
  135344. static CreateGround(name: string, options: {
  135345. width?: number;
  135346. height?: number;
  135347. subdivisions?: number;
  135348. subdivisionsX?: number;
  135349. subdivisionsY?: number;
  135350. updatable?: boolean;
  135351. }, scene?: Nullable<Scene>): Mesh;
  135352. /**
  135353. * Creates a tiled ground mesh
  135354. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  135355. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  135356. * * 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
  135357. * * 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
  135358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135359. * @param name defines the name of the mesh
  135360. * @param options defines the options used to create the mesh
  135361. * @param scene defines the hosting scene
  135362. * @returns the tiled ground mesh
  135363. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  135364. */
  135365. static CreateTiledGround(name: string, options: {
  135366. xmin: number;
  135367. zmin: number;
  135368. xmax: number;
  135369. zmax: number;
  135370. subdivisions?: {
  135371. w: number;
  135372. h: number;
  135373. };
  135374. precision?: {
  135375. w: number;
  135376. h: number;
  135377. };
  135378. updatable?: boolean;
  135379. }, scene?: Nullable<Scene>): Mesh;
  135380. /**
  135381. * Creates a ground mesh from a height map
  135382. * * The parameter `url` sets the URL of the height map image resource.
  135383. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  135384. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  135385. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  135386. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  135387. * * 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.
  135388. * * 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).
  135389. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  135390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135391. * @param name defines the name of the mesh
  135392. * @param url defines the url to the height map
  135393. * @param options defines the options used to create the mesh
  135394. * @param scene defines the hosting scene
  135395. * @returns the ground mesh
  135396. * @see https://doc.babylonjs.com/babylon101/height_map
  135397. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  135398. */
  135399. static CreateGroundFromHeightMap(name: string, url: string, options: {
  135400. width?: number;
  135401. height?: number;
  135402. subdivisions?: number;
  135403. minHeight?: number;
  135404. maxHeight?: number;
  135405. colorFilter?: Color3;
  135406. alphaFilter?: number;
  135407. updatable?: boolean;
  135408. onReady?: (mesh: GroundMesh) => void;
  135409. }, scene?: Nullable<Scene>): GroundMesh;
  135410. /**
  135411. * Creates a polygon mesh
  135412. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135413. * * 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
  135414. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135417. * * Remember you can only change the shape positions, not their number when updating a polygon
  135418. * @param name defines the name of the mesh
  135419. * @param options defines the options used to create the mesh
  135420. * @param scene defines the hosting scene
  135421. * @param earcutInjection can be used to inject your own earcut reference
  135422. * @returns the polygon mesh
  135423. */
  135424. static CreatePolygon(name: string, options: {
  135425. shape: Vector3[];
  135426. holes?: Vector3[][];
  135427. depth?: number;
  135428. faceUV?: Vector4[];
  135429. faceColors?: Color4[];
  135430. updatable?: boolean;
  135431. sideOrientation?: number;
  135432. frontUVs?: Vector4;
  135433. backUVs?: Vector4;
  135434. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135435. /**
  135436. * Creates an extruded polygon mesh, with depth in the Y direction.
  135437. * * 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)
  135438. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135439. * @param name defines the name of the mesh
  135440. * @param options defines the options used to create the mesh
  135441. * @param scene defines the hosting scene
  135442. * @param earcutInjection can be used to inject your own earcut reference
  135443. * @returns the polygon mesh
  135444. */
  135445. static ExtrudePolygon(name: string, options: {
  135446. shape: Vector3[];
  135447. holes?: Vector3[][];
  135448. depth?: number;
  135449. faceUV?: Vector4[];
  135450. faceColors?: Color4[];
  135451. updatable?: boolean;
  135452. sideOrientation?: number;
  135453. frontUVs?: Vector4;
  135454. backUVs?: Vector4;
  135455. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135456. /**
  135457. * Creates a tube mesh.
  135458. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135459. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135460. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135461. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135462. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135463. * * 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)
  135464. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135465. * * 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
  135466. * * 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
  135467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135471. * @param name defines the name of the mesh
  135472. * @param options defines the options used to create the mesh
  135473. * @param scene defines the hosting scene
  135474. * @returns the tube mesh
  135475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135476. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135477. */
  135478. static CreateTube(name: string, options: {
  135479. path: Vector3[];
  135480. radius?: number;
  135481. tessellation?: number;
  135482. radiusFunction?: {
  135483. (i: number, distance: number): number;
  135484. };
  135485. cap?: number;
  135486. arc?: number;
  135487. updatable?: boolean;
  135488. sideOrientation?: number;
  135489. frontUVs?: Vector4;
  135490. backUVs?: Vector4;
  135491. instance?: Mesh;
  135492. invertUV?: boolean;
  135493. }, scene?: Nullable<Scene>): Mesh;
  135494. /**
  135495. * Creates a polyhedron mesh
  135496. * * 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
  135497. * * The parameter `size` (positive float, default 1) sets the polygon size
  135498. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135499. * * 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`
  135500. * * 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
  135501. * * 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)`)
  135502. * * 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
  135503. * * 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
  135504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135507. * @param name defines the name of the mesh
  135508. * @param options defines the options used to create the mesh
  135509. * @param scene defines the hosting scene
  135510. * @returns the polyhedron mesh
  135511. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135512. */
  135513. static CreatePolyhedron(name: string, options: {
  135514. type?: number;
  135515. size?: number;
  135516. sizeX?: number;
  135517. sizeY?: number;
  135518. sizeZ?: number;
  135519. custom?: any;
  135520. faceUV?: Vector4[];
  135521. faceColors?: Color4[];
  135522. flat?: boolean;
  135523. updatable?: boolean;
  135524. sideOrientation?: number;
  135525. frontUVs?: Vector4;
  135526. backUVs?: Vector4;
  135527. }, scene?: Nullable<Scene>): Mesh;
  135528. /**
  135529. * Creates a decal mesh.
  135530. * 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
  135531. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135532. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135533. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135534. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135535. * @param name defines the name of the mesh
  135536. * @param sourceMesh defines the mesh where the decal must be applied
  135537. * @param options defines the options used to create the mesh
  135538. * @param scene defines the hosting scene
  135539. * @returns the decal mesh
  135540. * @see https://doc.babylonjs.com/how_to/decals
  135541. */
  135542. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135543. position?: Vector3;
  135544. normal?: Vector3;
  135545. size?: Vector3;
  135546. angle?: number;
  135547. }): Mesh;
  135548. }
  135549. }
  135550. declare module BABYLON {
  135551. /**
  135552. * A simplifier interface for future simplification implementations
  135553. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135554. */
  135555. export interface ISimplifier {
  135556. /**
  135557. * Simplification of a given mesh according to the given settings.
  135558. * Since this requires computation, it is assumed that the function runs async.
  135559. * @param settings The settings of the simplification, including quality and distance
  135560. * @param successCallback A callback that will be called after the mesh was simplified.
  135561. * @param errorCallback in case of an error, this callback will be called. optional.
  135562. */
  135563. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135564. }
  135565. /**
  135566. * Expected simplification settings.
  135567. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135568. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135569. */
  135570. export interface ISimplificationSettings {
  135571. /**
  135572. * Gets or sets the expected quality
  135573. */
  135574. quality: number;
  135575. /**
  135576. * Gets or sets the distance when this optimized version should be used
  135577. */
  135578. distance: number;
  135579. /**
  135580. * Gets an already optimized mesh
  135581. */
  135582. optimizeMesh?: boolean;
  135583. }
  135584. /**
  135585. * Class used to specify simplification options
  135586. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135587. */
  135588. export class SimplificationSettings implements ISimplificationSettings {
  135589. /** expected quality */
  135590. quality: number;
  135591. /** distance when this optimized version should be used */
  135592. distance: number;
  135593. /** already optimized mesh */
  135594. optimizeMesh?: boolean | undefined;
  135595. /**
  135596. * Creates a SimplificationSettings
  135597. * @param quality expected quality
  135598. * @param distance distance when this optimized version should be used
  135599. * @param optimizeMesh already optimized mesh
  135600. */
  135601. constructor(
  135602. /** expected quality */
  135603. quality: number,
  135604. /** distance when this optimized version should be used */
  135605. distance: number,
  135606. /** already optimized mesh */
  135607. optimizeMesh?: boolean | undefined);
  135608. }
  135609. /**
  135610. * Interface used to define a simplification task
  135611. */
  135612. export interface ISimplificationTask {
  135613. /**
  135614. * Array of settings
  135615. */
  135616. settings: Array<ISimplificationSettings>;
  135617. /**
  135618. * Simplification type
  135619. */
  135620. simplificationType: SimplificationType;
  135621. /**
  135622. * Mesh to simplify
  135623. */
  135624. mesh: Mesh;
  135625. /**
  135626. * Callback called on success
  135627. */
  135628. successCallback?: () => void;
  135629. /**
  135630. * Defines if parallel processing can be used
  135631. */
  135632. parallelProcessing: boolean;
  135633. }
  135634. /**
  135635. * Queue used to order the simplification tasks
  135636. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135637. */
  135638. export class SimplificationQueue {
  135639. private _simplificationArray;
  135640. /**
  135641. * Gets a boolean indicating that the process is still running
  135642. */
  135643. running: boolean;
  135644. /**
  135645. * Creates a new queue
  135646. */
  135647. constructor();
  135648. /**
  135649. * Adds a new simplification task
  135650. * @param task defines a task to add
  135651. */
  135652. addTask(task: ISimplificationTask): void;
  135653. /**
  135654. * Execute next task
  135655. */
  135656. executeNext(): void;
  135657. /**
  135658. * Execute a simplification task
  135659. * @param task defines the task to run
  135660. */
  135661. runSimplification(task: ISimplificationTask): void;
  135662. private getSimplifier;
  135663. }
  135664. /**
  135665. * The implemented types of simplification
  135666. * At the moment only Quadratic Error Decimation is implemented
  135667. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135668. */
  135669. export enum SimplificationType {
  135670. /** Quadratic error decimation */
  135671. QUADRATIC = 0
  135672. }
  135673. /**
  135674. * An implementation of the Quadratic Error simplification algorithm.
  135675. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  135676. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  135677. * @author RaananW
  135678. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135679. */
  135680. export class QuadraticErrorSimplification implements ISimplifier {
  135681. private _mesh;
  135682. private triangles;
  135683. private vertices;
  135684. private references;
  135685. private _reconstructedMesh;
  135686. /** Gets or sets the number pf sync interations */
  135687. syncIterations: number;
  135688. /** Gets or sets the aggressiveness of the simplifier */
  135689. aggressiveness: number;
  135690. /** Gets or sets the number of allowed iterations for decimation */
  135691. decimationIterations: number;
  135692. /** Gets or sets the espilon to use for bounding box computation */
  135693. boundingBoxEpsilon: number;
  135694. /**
  135695. * Creates a new QuadraticErrorSimplification
  135696. * @param _mesh defines the target mesh
  135697. */
  135698. constructor(_mesh: Mesh);
  135699. /**
  135700. * Simplification of a given mesh according to the given settings.
  135701. * Since this requires computation, it is assumed that the function runs async.
  135702. * @param settings The settings of the simplification, including quality and distance
  135703. * @param successCallback A callback that will be called after the mesh was simplified.
  135704. */
  135705. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  135706. private runDecimation;
  135707. private initWithMesh;
  135708. private init;
  135709. private reconstructMesh;
  135710. private initDecimatedMesh;
  135711. private isFlipped;
  135712. private updateTriangles;
  135713. private identifyBorder;
  135714. private updateMesh;
  135715. private vertexError;
  135716. private calculateError;
  135717. }
  135718. }
  135719. declare module BABYLON {
  135720. interface Scene {
  135721. /** @hidden (Backing field) */
  135722. _simplificationQueue: SimplificationQueue;
  135723. /**
  135724. * Gets or sets the simplification queue attached to the scene
  135725. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135726. */
  135727. simplificationQueue: SimplificationQueue;
  135728. }
  135729. interface Mesh {
  135730. /**
  135731. * Simplify the mesh according to the given array of settings.
  135732. * Function will return immediately and will simplify async
  135733. * @param settings a collection of simplification settings
  135734. * @param parallelProcessing should all levels calculate parallel or one after the other
  135735. * @param simplificationType the type of simplification to run
  135736. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135737. * @returns the current mesh
  135738. */
  135739. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135740. }
  135741. /**
  135742. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135743. * created in a scene
  135744. */
  135745. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135746. /**
  135747. * The component name helpfull to identify the component in the list of scene components.
  135748. */
  135749. readonly name: string;
  135750. /**
  135751. * The scene the component belongs to.
  135752. */
  135753. scene: Scene;
  135754. /**
  135755. * Creates a new instance of the component for the given scene
  135756. * @param scene Defines the scene to register the component in
  135757. */
  135758. constructor(scene: Scene);
  135759. /**
  135760. * Registers the component in a given scene
  135761. */
  135762. register(): void;
  135763. /**
  135764. * Rebuilds the elements related to this component in case of
  135765. * context lost for instance.
  135766. */
  135767. rebuild(): void;
  135768. /**
  135769. * Disposes the component and the associated ressources
  135770. */
  135771. dispose(): void;
  135772. private _beforeCameraUpdate;
  135773. }
  135774. }
  135775. declare module BABYLON {
  135776. /**
  135777. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135778. */
  135779. export interface INavigationEnginePlugin {
  135780. /**
  135781. * plugin name
  135782. */
  135783. name: string;
  135784. /**
  135785. * Creates a navigation mesh
  135786. * @param meshes array of all the geometry used to compute the navigatio mesh
  135787. * @param parameters bunch of parameters used to filter geometry
  135788. */
  135789. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135790. /**
  135791. * Create a navigation mesh debug mesh
  135792. * @param scene is where the mesh will be added
  135793. * @returns debug display mesh
  135794. */
  135795. createDebugNavMesh(scene: Scene): Mesh;
  135796. /**
  135797. * Get a navigation mesh constrained position, closest to the parameter position
  135798. * @param position world position
  135799. * @returns the closest point to position constrained by the navigation mesh
  135800. */
  135801. getClosestPoint(position: Vector3): Vector3;
  135802. /**
  135803. * Get a navigation mesh constrained position, closest to the parameter position
  135804. * @param position world position
  135805. * @param result output the closest point to position constrained by the navigation mesh
  135806. */
  135807. getClosestPointToRef(position: Vector3, result: Vector3): void;
  135808. /**
  135809. * Get a navigation mesh constrained position, within a particular radius
  135810. * @param position world position
  135811. * @param maxRadius the maximum distance to the constrained world position
  135812. * @returns the closest point to position constrained by the navigation mesh
  135813. */
  135814. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135815. /**
  135816. * Get a navigation mesh constrained position, within a particular radius
  135817. * @param position world position
  135818. * @param maxRadius the maximum distance to the constrained world position
  135819. * @param result output the closest point to position constrained by the navigation mesh
  135820. */
  135821. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  135822. /**
  135823. * Compute the final position from a segment made of destination-position
  135824. * @param position world position
  135825. * @param destination world position
  135826. * @returns the resulting point along the navmesh
  135827. */
  135828. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135829. /**
  135830. * Compute the final position from a segment made of destination-position
  135831. * @param position world position
  135832. * @param destination world position
  135833. * @param result output the resulting point along the navmesh
  135834. */
  135835. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  135836. /**
  135837. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135838. * @param start world position
  135839. * @param end world position
  135840. * @returns array containing world position composing the path
  135841. */
  135842. computePath(start: Vector3, end: Vector3): Vector3[];
  135843. /**
  135844. * If this plugin is supported
  135845. * @returns true if plugin is supported
  135846. */
  135847. isSupported(): boolean;
  135848. /**
  135849. * Create a new Crowd so you can add agents
  135850. * @param maxAgents the maximum agent count in the crowd
  135851. * @param maxAgentRadius the maximum radius an agent can have
  135852. * @param scene to attach the crowd to
  135853. * @returns the crowd you can add agents to
  135854. */
  135855. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135856. /**
  135857. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135858. * The queries will try to find a solution within those bounds
  135859. * default is (1,1,1)
  135860. * @param extent x,y,z value that define the extent around the queries point of reference
  135861. */
  135862. setDefaultQueryExtent(extent: Vector3): void;
  135863. /**
  135864. * Get the Bounding box extent specified by setDefaultQueryExtent
  135865. * @returns the box extent values
  135866. */
  135867. getDefaultQueryExtent(): Vector3;
  135868. /**
  135869. * build the navmesh from a previously saved state using getNavmeshData
  135870. * @param data the Uint8Array returned by getNavmeshData
  135871. */
  135872. buildFromNavmeshData(data: Uint8Array): void;
  135873. /**
  135874. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  135875. * @returns data the Uint8Array that can be saved and reused
  135876. */
  135877. getNavmeshData(): Uint8Array;
  135878. /**
  135879. * Get the Bounding box extent result specified by setDefaultQueryExtent
  135880. * @param result output the box extent values
  135881. */
  135882. getDefaultQueryExtentToRef(result: Vector3): void;
  135883. /**
  135884. * Release all resources
  135885. */
  135886. dispose(): void;
  135887. }
  135888. /**
  135889. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135890. */
  135891. export interface ICrowd {
  135892. /**
  135893. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135894. * You can attach anything to that node. The node position is updated in the scene update tick.
  135895. * @param pos world position that will be constrained by the navigation mesh
  135896. * @param parameters agent parameters
  135897. * @param transform hooked to the agent that will be update by the scene
  135898. * @returns agent index
  135899. */
  135900. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135901. /**
  135902. * Returns the agent position in world space
  135903. * @param index agent index returned by addAgent
  135904. * @returns world space position
  135905. */
  135906. getAgentPosition(index: number): Vector3;
  135907. /**
  135908. * Gets the agent position result in world space
  135909. * @param index agent index returned by addAgent
  135910. * @param result output world space position
  135911. */
  135912. getAgentPositionToRef(index: number, result: Vector3): void;
  135913. /**
  135914. * Gets the agent velocity in world space
  135915. * @param index agent index returned by addAgent
  135916. * @returns world space velocity
  135917. */
  135918. getAgentVelocity(index: number): Vector3;
  135919. /**
  135920. * Gets the agent velocity result in world space
  135921. * @param index agent index returned by addAgent
  135922. * @param result output world space velocity
  135923. */
  135924. getAgentVelocityToRef(index: number, result: Vector3): void;
  135925. /**
  135926. * remove a particular agent previously created
  135927. * @param index agent index returned by addAgent
  135928. */
  135929. removeAgent(index: number): void;
  135930. /**
  135931. * get the list of all agents attached to this crowd
  135932. * @returns list of agent indices
  135933. */
  135934. getAgents(): number[];
  135935. /**
  135936. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135937. * @param deltaTime in seconds
  135938. */
  135939. update(deltaTime: number): void;
  135940. /**
  135941. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135942. * @param index agent index returned by addAgent
  135943. * @param destination targeted world position
  135944. */
  135945. agentGoto(index: number, destination: Vector3): void;
  135946. /**
  135947. * Teleport the agent to a new position
  135948. * @param index agent index returned by addAgent
  135949. * @param destination targeted world position
  135950. */
  135951. agentTeleport(index: number, destination: Vector3): void;
  135952. /**
  135953. * Update agent parameters
  135954. * @param index agent index returned by addAgent
  135955. * @param parameters agent parameters
  135956. */
  135957. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135958. /**
  135959. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135960. * The queries will try to find a solution within those bounds
  135961. * default is (1,1,1)
  135962. * @param extent x,y,z value that define the extent around the queries point of reference
  135963. */
  135964. setDefaultQueryExtent(extent: Vector3): void;
  135965. /**
  135966. * Get the Bounding box extent specified by setDefaultQueryExtent
  135967. * @returns the box extent values
  135968. */
  135969. getDefaultQueryExtent(): Vector3;
  135970. /**
  135971. * Get the Bounding box extent result specified by setDefaultQueryExtent
  135972. * @param result output the box extent values
  135973. */
  135974. getDefaultQueryExtentToRef(result: Vector3): void;
  135975. /**
  135976. * Release all resources
  135977. */
  135978. dispose(): void;
  135979. }
  135980. /**
  135981. * Configures an agent
  135982. */
  135983. export interface IAgentParameters {
  135984. /**
  135985. * Agent radius. [Limit: >= 0]
  135986. */
  135987. radius: number;
  135988. /**
  135989. * Agent height. [Limit: > 0]
  135990. */
  135991. height: number;
  135992. /**
  135993. * Maximum allowed acceleration. [Limit: >= 0]
  135994. */
  135995. maxAcceleration: number;
  135996. /**
  135997. * Maximum allowed speed. [Limit: >= 0]
  135998. */
  135999. maxSpeed: number;
  136000. /**
  136001. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  136002. */
  136003. collisionQueryRange: number;
  136004. /**
  136005. * The path visibility optimization range. [Limit: > 0]
  136006. */
  136007. pathOptimizationRange: number;
  136008. /**
  136009. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  136010. */
  136011. separationWeight: number;
  136012. }
  136013. /**
  136014. * Configures the navigation mesh creation
  136015. */
  136016. export interface INavMeshParameters {
  136017. /**
  136018. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  136019. */
  136020. cs: number;
  136021. /**
  136022. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  136023. */
  136024. ch: number;
  136025. /**
  136026. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  136027. */
  136028. walkableSlopeAngle: number;
  136029. /**
  136030. * Minimum floor to 'ceiling' height that will still allow the floor area to
  136031. * be considered walkable. [Limit: >= 3] [Units: vx]
  136032. */
  136033. walkableHeight: number;
  136034. /**
  136035. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  136036. */
  136037. walkableClimb: number;
  136038. /**
  136039. * The distance to erode/shrink the walkable area of the heightfield away from
  136040. * obstructions. [Limit: >=0] [Units: vx]
  136041. */
  136042. walkableRadius: number;
  136043. /**
  136044. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  136045. */
  136046. maxEdgeLen: number;
  136047. /**
  136048. * The maximum distance a simplfied contour's border edges should deviate
  136049. * the original raw contour. [Limit: >=0] [Units: vx]
  136050. */
  136051. maxSimplificationError: number;
  136052. /**
  136053. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  136054. */
  136055. minRegionArea: number;
  136056. /**
  136057. * Any regions with a span count smaller than this value will, if possible,
  136058. * be merged with larger regions. [Limit: >=0] [Units: vx]
  136059. */
  136060. mergeRegionArea: number;
  136061. /**
  136062. * The maximum number of vertices allowed for polygons generated during the
  136063. * contour to polygon conversion process. [Limit: >= 3]
  136064. */
  136065. maxVertsPerPoly: number;
  136066. /**
  136067. * Sets the sampling distance to use when generating the detail mesh.
  136068. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  136069. */
  136070. detailSampleDist: number;
  136071. /**
  136072. * The maximum distance the detail mesh surface should deviate from heightfield
  136073. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  136074. */
  136075. detailSampleMaxError: number;
  136076. }
  136077. }
  136078. declare module BABYLON {
  136079. /**
  136080. * RecastJS navigation plugin
  136081. */
  136082. export class RecastJSPlugin implements INavigationEnginePlugin {
  136083. /**
  136084. * Reference to the Recast library
  136085. */
  136086. bjsRECAST: any;
  136087. /**
  136088. * plugin name
  136089. */
  136090. name: string;
  136091. /**
  136092. * the first navmesh created. We might extend this to support multiple navmeshes
  136093. */
  136094. navMesh: any;
  136095. /**
  136096. * Initializes the recastJS plugin
  136097. * @param recastInjection can be used to inject your own recast reference
  136098. */
  136099. constructor(recastInjection?: any);
  136100. /**
  136101. * Creates a navigation mesh
  136102. * @param meshes array of all the geometry used to compute the navigatio mesh
  136103. * @param parameters bunch of parameters used to filter geometry
  136104. */
  136105. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136106. /**
  136107. * Create a navigation mesh debug mesh
  136108. * @param scene is where the mesh will be added
  136109. * @returns debug display mesh
  136110. */
  136111. createDebugNavMesh(scene: Scene): Mesh;
  136112. /**
  136113. * Get a navigation mesh constrained position, closest to the parameter position
  136114. * @param position world position
  136115. * @returns the closest point to position constrained by the navigation mesh
  136116. */
  136117. getClosestPoint(position: Vector3): Vector3;
  136118. /**
  136119. * Get a navigation mesh constrained position, closest to the parameter position
  136120. * @param position world position
  136121. * @param result output the closest point to position constrained by the navigation mesh
  136122. */
  136123. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136124. /**
  136125. * Get a navigation mesh constrained position, within a particular radius
  136126. * @param position world position
  136127. * @param maxRadius the maximum distance to the constrained world position
  136128. * @returns the closest point to position constrained by the navigation mesh
  136129. */
  136130. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136131. /**
  136132. * Get a navigation mesh constrained position, within a particular radius
  136133. * @param position world position
  136134. * @param maxRadius the maximum distance to the constrained world position
  136135. * @param result output the closest point to position constrained by the navigation mesh
  136136. */
  136137. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136138. /**
  136139. * Compute the final position from a segment made of destination-position
  136140. * @param position world position
  136141. * @param destination world position
  136142. * @returns the resulting point along the navmesh
  136143. */
  136144. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136145. /**
  136146. * Compute the final position from a segment made of destination-position
  136147. * @param position world position
  136148. * @param destination world position
  136149. * @param result output the resulting point along the navmesh
  136150. */
  136151. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136152. /**
  136153. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136154. * @param start world position
  136155. * @param end world position
  136156. * @returns array containing world position composing the path
  136157. */
  136158. computePath(start: Vector3, end: Vector3): Vector3[];
  136159. /**
  136160. * Create a new Crowd so you can add agents
  136161. * @param maxAgents the maximum agent count in the crowd
  136162. * @param maxAgentRadius the maximum radius an agent can have
  136163. * @param scene to attach the crowd to
  136164. * @returns the crowd you can add agents to
  136165. */
  136166. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136167. /**
  136168. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136169. * The queries will try to find a solution within those bounds
  136170. * default is (1,1,1)
  136171. * @param extent x,y,z value that define the extent around the queries point of reference
  136172. */
  136173. setDefaultQueryExtent(extent: Vector3): void;
  136174. /**
  136175. * Get the Bounding box extent specified by setDefaultQueryExtent
  136176. * @returns the box extent values
  136177. */
  136178. getDefaultQueryExtent(): Vector3;
  136179. /**
  136180. * build the navmesh from a previously saved state using getNavmeshData
  136181. * @param data the Uint8Array returned by getNavmeshData
  136182. */
  136183. buildFromNavmeshData(data: Uint8Array): void;
  136184. /**
  136185. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136186. * @returns data the Uint8Array that can be saved and reused
  136187. */
  136188. getNavmeshData(): Uint8Array;
  136189. /**
  136190. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136191. * @param result output the box extent values
  136192. */
  136193. getDefaultQueryExtentToRef(result: Vector3): void;
  136194. /**
  136195. * Disposes
  136196. */
  136197. dispose(): void;
  136198. /**
  136199. * If this plugin is supported
  136200. * @returns true if plugin is supported
  136201. */
  136202. isSupported(): boolean;
  136203. }
  136204. /**
  136205. * Recast detour crowd implementation
  136206. */
  136207. export class RecastJSCrowd implements ICrowd {
  136208. /**
  136209. * Recast/detour plugin
  136210. */
  136211. bjsRECASTPlugin: RecastJSPlugin;
  136212. /**
  136213. * Link to the detour crowd
  136214. */
  136215. recastCrowd: any;
  136216. /**
  136217. * One transform per agent
  136218. */
  136219. transforms: TransformNode[];
  136220. /**
  136221. * All agents created
  136222. */
  136223. agents: number[];
  136224. /**
  136225. * Link to the scene is kept to unregister the crowd from the scene
  136226. */
  136227. private _scene;
  136228. /**
  136229. * Observer for crowd updates
  136230. */
  136231. private _onBeforeAnimationsObserver;
  136232. /**
  136233. * Constructor
  136234. * @param plugin recastJS plugin
  136235. * @param maxAgents the maximum agent count in the crowd
  136236. * @param maxAgentRadius the maximum radius an agent can have
  136237. * @param scene to attach the crowd to
  136238. * @returns the crowd you can add agents to
  136239. */
  136240. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  136241. /**
  136242. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136243. * You can attach anything to that node. The node position is updated in the scene update tick.
  136244. * @param pos world position that will be constrained by the navigation mesh
  136245. * @param parameters agent parameters
  136246. * @param transform hooked to the agent that will be update by the scene
  136247. * @returns agent index
  136248. */
  136249. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136250. /**
  136251. * Returns the agent position in world space
  136252. * @param index agent index returned by addAgent
  136253. * @returns world space position
  136254. */
  136255. getAgentPosition(index: number): Vector3;
  136256. /**
  136257. * Returns the agent position result in world space
  136258. * @param index agent index returned by addAgent
  136259. * @param result output world space position
  136260. */
  136261. getAgentPositionToRef(index: number, result: Vector3): void;
  136262. /**
  136263. * Returns the agent velocity in world space
  136264. * @param index agent index returned by addAgent
  136265. * @returns world space velocity
  136266. */
  136267. getAgentVelocity(index: number): Vector3;
  136268. /**
  136269. * Returns the agent velocity result in world space
  136270. * @param index agent index returned by addAgent
  136271. * @param result output world space velocity
  136272. */
  136273. getAgentVelocityToRef(index: number, result: Vector3): void;
  136274. /**
  136275. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136276. * @param index agent index returned by addAgent
  136277. * @param destination targeted world position
  136278. */
  136279. agentGoto(index: number, destination: Vector3): void;
  136280. /**
  136281. * Teleport the agent to a new position
  136282. * @param index agent index returned by addAgent
  136283. * @param destination targeted world position
  136284. */
  136285. agentTeleport(index: number, destination: Vector3): void;
  136286. /**
  136287. * Update agent parameters
  136288. * @param index agent index returned by addAgent
  136289. * @param parameters agent parameters
  136290. */
  136291. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136292. /**
  136293. * remove a particular agent previously created
  136294. * @param index agent index returned by addAgent
  136295. */
  136296. removeAgent(index: number): void;
  136297. /**
  136298. * get the list of all agents attached to this crowd
  136299. * @returns list of agent indices
  136300. */
  136301. getAgents(): number[];
  136302. /**
  136303. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136304. * @param deltaTime in seconds
  136305. */
  136306. update(deltaTime: number): void;
  136307. /**
  136308. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136309. * The queries will try to find a solution within those bounds
  136310. * default is (1,1,1)
  136311. * @param extent x,y,z value that define the extent around the queries point of reference
  136312. */
  136313. setDefaultQueryExtent(extent: Vector3): void;
  136314. /**
  136315. * Get the Bounding box extent specified by setDefaultQueryExtent
  136316. * @returns the box extent values
  136317. */
  136318. getDefaultQueryExtent(): Vector3;
  136319. /**
  136320. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136321. * @param result output the box extent values
  136322. */
  136323. getDefaultQueryExtentToRef(result: Vector3): void;
  136324. /**
  136325. * Release all resources
  136326. */
  136327. dispose(): void;
  136328. }
  136329. }
  136330. declare module BABYLON {
  136331. /**
  136332. * Class used to enable access to IndexedDB
  136333. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  136334. */
  136335. export class Database implements IOfflineProvider {
  136336. private _callbackManifestChecked;
  136337. private _currentSceneUrl;
  136338. private _db;
  136339. private _enableSceneOffline;
  136340. private _enableTexturesOffline;
  136341. private _manifestVersionFound;
  136342. private _mustUpdateRessources;
  136343. private _hasReachedQuota;
  136344. private _isSupported;
  136345. private _idbFactory;
  136346. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  136347. private static IsUASupportingBlobStorage;
  136348. /**
  136349. * Gets a boolean indicating if Database storate is enabled (off by default)
  136350. */
  136351. static IDBStorageEnabled: boolean;
  136352. /**
  136353. * Gets a boolean indicating if scene must be saved in the database
  136354. */
  136355. get enableSceneOffline(): boolean;
  136356. /**
  136357. * Gets a boolean indicating if textures must be saved in the database
  136358. */
  136359. get enableTexturesOffline(): boolean;
  136360. /**
  136361. * Creates a new Database
  136362. * @param urlToScene defines the url to load the scene
  136363. * @param callbackManifestChecked defines the callback to use when manifest is checked
  136364. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  136365. */
  136366. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  136367. private static _ParseURL;
  136368. private static _ReturnFullUrlLocation;
  136369. private _checkManifestFile;
  136370. /**
  136371. * Open the database and make it available
  136372. * @param successCallback defines the callback to call on success
  136373. * @param errorCallback defines the callback to call on error
  136374. */
  136375. open(successCallback: () => void, errorCallback: () => void): void;
  136376. /**
  136377. * Loads an image from the database
  136378. * @param url defines the url to load from
  136379. * @param image defines the target DOM image
  136380. */
  136381. loadImage(url: string, image: HTMLImageElement): void;
  136382. private _loadImageFromDBAsync;
  136383. private _saveImageIntoDBAsync;
  136384. private _checkVersionFromDB;
  136385. private _loadVersionFromDBAsync;
  136386. private _saveVersionIntoDBAsync;
  136387. /**
  136388. * Loads a file from database
  136389. * @param url defines the URL to load from
  136390. * @param sceneLoaded defines a callback to call on success
  136391. * @param progressCallBack defines a callback to call when progress changed
  136392. * @param errorCallback defines a callback to call on error
  136393. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  136394. */
  136395. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  136396. private _loadFileAsync;
  136397. private _saveFileAsync;
  136398. /**
  136399. * Validates if xhr data is correct
  136400. * @param xhr defines the request to validate
  136401. * @param dataType defines the expected data type
  136402. * @returns true if data is correct
  136403. */
  136404. private static _ValidateXHRData;
  136405. }
  136406. }
  136407. declare module BABYLON {
  136408. /** @hidden */
  136409. export var gpuUpdateParticlesPixelShader: {
  136410. name: string;
  136411. shader: string;
  136412. };
  136413. }
  136414. declare module BABYLON {
  136415. /** @hidden */
  136416. export var gpuUpdateParticlesVertexShader: {
  136417. name: string;
  136418. shader: string;
  136419. };
  136420. }
  136421. declare module BABYLON {
  136422. /** @hidden */
  136423. export var clipPlaneFragmentDeclaration2: {
  136424. name: string;
  136425. shader: string;
  136426. };
  136427. }
  136428. declare module BABYLON {
  136429. /** @hidden */
  136430. export var gpuRenderParticlesPixelShader: {
  136431. name: string;
  136432. shader: string;
  136433. };
  136434. }
  136435. declare module BABYLON {
  136436. /** @hidden */
  136437. export var clipPlaneVertexDeclaration2: {
  136438. name: string;
  136439. shader: string;
  136440. };
  136441. }
  136442. declare module BABYLON {
  136443. /** @hidden */
  136444. export var gpuRenderParticlesVertexShader: {
  136445. name: string;
  136446. shader: string;
  136447. };
  136448. }
  136449. declare module BABYLON {
  136450. /**
  136451. * This represents a GPU particle system in Babylon
  136452. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  136453. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  136454. */
  136455. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  136456. /**
  136457. * The layer mask we are rendering the particles through.
  136458. */
  136459. layerMask: number;
  136460. private _capacity;
  136461. private _activeCount;
  136462. private _currentActiveCount;
  136463. private _accumulatedCount;
  136464. private _renderEffect;
  136465. private _updateEffect;
  136466. private _buffer0;
  136467. private _buffer1;
  136468. private _spriteBuffer;
  136469. private _updateVAO;
  136470. private _renderVAO;
  136471. private _targetIndex;
  136472. private _sourceBuffer;
  136473. private _targetBuffer;
  136474. private _engine;
  136475. private _currentRenderId;
  136476. private _started;
  136477. private _stopped;
  136478. private _timeDelta;
  136479. private _randomTexture;
  136480. private _randomTexture2;
  136481. private _attributesStrideSize;
  136482. private _updateEffectOptions;
  136483. private _randomTextureSize;
  136484. private _actualFrame;
  136485. private readonly _rawTextureWidth;
  136486. /**
  136487. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  136488. */
  136489. static get IsSupported(): boolean;
  136490. /**
  136491. * An event triggered when the system is disposed.
  136492. */
  136493. onDisposeObservable: Observable<GPUParticleSystem>;
  136494. /**
  136495. * Gets the maximum number of particles active at the same time.
  136496. * @returns The max number of active particles.
  136497. */
  136498. getCapacity(): number;
  136499. /**
  136500. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  136501. * to override the particles.
  136502. */
  136503. forceDepthWrite: boolean;
  136504. /**
  136505. * Gets or set the number of active particles
  136506. */
  136507. get activeParticleCount(): number;
  136508. set activeParticleCount(value: number);
  136509. private _preWarmDone;
  136510. /**
  136511. * Specifies if the particles are updated in emitter local space or world space.
  136512. * This is always false for GPU particles
  136513. */
  136514. get isLocal(): boolean;
  136515. set isLocal(value: boolean);
  136516. /**
  136517. * Is this system ready to be used/rendered
  136518. * @return true if the system is ready
  136519. */
  136520. isReady(): boolean;
  136521. /**
  136522. * Gets if the system has been started. (Note: this will still be true after stop is called)
  136523. * @returns True if it has been started, otherwise false.
  136524. */
  136525. isStarted(): boolean;
  136526. /**
  136527. * Starts the particle system and begins to emit
  136528. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  136529. */
  136530. start(delay?: number): void;
  136531. /**
  136532. * Stops the particle system.
  136533. */
  136534. stop(): void;
  136535. /**
  136536. * Remove all active particles
  136537. */
  136538. reset(): void;
  136539. /**
  136540. * Returns the string "GPUParticleSystem"
  136541. * @returns a string containing the class name
  136542. */
  136543. getClassName(): string;
  136544. private _colorGradientsTexture;
  136545. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  136546. /**
  136547. * Adds a new color gradient
  136548. * @param gradient defines the gradient to use (between 0 and 1)
  136549. * @param color1 defines the color to affect to the specified gradient
  136550. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  136551. * @returns the current particle system
  136552. */
  136553. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  136554. /**
  136555. * Remove a specific color gradient
  136556. * @param gradient defines the gradient to remove
  136557. * @returns the current particle system
  136558. */
  136559. removeColorGradient(gradient: number): GPUParticleSystem;
  136560. private _angularSpeedGradientsTexture;
  136561. private _sizeGradientsTexture;
  136562. private _velocityGradientsTexture;
  136563. private _limitVelocityGradientsTexture;
  136564. private _dragGradientsTexture;
  136565. private _addFactorGradient;
  136566. /**
  136567. * Adds a new size gradient
  136568. * @param gradient defines the gradient to use (between 0 and 1)
  136569. * @param factor defines the size factor to affect to the specified gradient
  136570. * @returns the current particle system
  136571. */
  136572. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  136573. /**
  136574. * Remove a specific size gradient
  136575. * @param gradient defines the gradient to remove
  136576. * @returns the current particle system
  136577. */
  136578. removeSizeGradient(gradient: number): GPUParticleSystem;
  136579. /**
  136580. * Adds a new angular speed gradient
  136581. * @param gradient defines the gradient to use (between 0 and 1)
  136582. * @param factor defines the angular speed to affect to the specified gradient
  136583. * @returns the current particle system
  136584. */
  136585. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  136586. /**
  136587. * Remove a specific angular speed gradient
  136588. * @param gradient defines the gradient to remove
  136589. * @returns the current particle system
  136590. */
  136591. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  136592. /**
  136593. * Adds a new velocity gradient
  136594. * @param gradient defines the gradient to use (between 0 and 1)
  136595. * @param factor defines the velocity to affect to the specified gradient
  136596. * @returns the current particle system
  136597. */
  136598. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136599. /**
  136600. * Remove a specific velocity gradient
  136601. * @param gradient defines the gradient to remove
  136602. * @returns the current particle system
  136603. */
  136604. removeVelocityGradient(gradient: number): GPUParticleSystem;
  136605. /**
  136606. * Adds a new limit velocity gradient
  136607. * @param gradient defines the gradient to use (between 0 and 1)
  136608. * @param factor defines the limit velocity value to affect to the specified gradient
  136609. * @returns the current particle system
  136610. */
  136611. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136612. /**
  136613. * Remove a specific limit velocity gradient
  136614. * @param gradient defines the gradient to remove
  136615. * @returns the current particle system
  136616. */
  136617. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  136618. /**
  136619. * Adds a new drag gradient
  136620. * @param gradient defines the gradient to use (between 0 and 1)
  136621. * @param factor defines the drag value to affect to the specified gradient
  136622. * @returns the current particle system
  136623. */
  136624. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  136625. /**
  136626. * Remove a specific drag gradient
  136627. * @param gradient defines the gradient to remove
  136628. * @returns the current particle system
  136629. */
  136630. removeDragGradient(gradient: number): GPUParticleSystem;
  136631. /**
  136632. * Not supported by GPUParticleSystem
  136633. * @param gradient defines the gradient to use (between 0 and 1)
  136634. * @param factor defines the emit rate value to affect to the specified gradient
  136635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136636. * @returns the current particle system
  136637. */
  136638. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136639. /**
  136640. * Not supported by GPUParticleSystem
  136641. * @param gradient defines the gradient to remove
  136642. * @returns the current particle system
  136643. */
  136644. removeEmitRateGradient(gradient: number): IParticleSystem;
  136645. /**
  136646. * Not supported by GPUParticleSystem
  136647. * @param gradient defines the gradient to use (between 0 and 1)
  136648. * @param factor defines the start size value to affect to the specified gradient
  136649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136650. * @returns the current particle system
  136651. */
  136652. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136653. /**
  136654. * Not supported by GPUParticleSystem
  136655. * @param gradient defines the gradient to remove
  136656. * @returns the current particle system
  136657. */
  136658. removeStartSizeGradient(gradient: number): IParticleSystem;
  136659. /**
  136660. * Not supported by GPUParticleSystem
  136661. * @param gradient defines the gradient to use (between 0 and 1)
  136662. * @param min defines the color remap minimal range
  136663. * @param max defines the color remap maximal range
  136664. * @returns the current particle system
  136665. */
  136666. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136667. /**
  136668. * Not supported by GPUParticleSystem
  136669. * @param gradient defines the gradient to remove
  136670. * @returns the current particle system
  136671. */
  136672. removeColorRemapGradient(): IParticleSystem;
  136673. /**
  136674. * Not supported by GPUParticleSystem
  136675. * @param gradient defines the gradient to use (between 0 and 1)
  136676. * @param min defines the alpha remap minimal range
  136677. * @param max defines the alpha remap maximal range
  136678. * @returns the current particle system
  136679. */
  136680. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136681. /**
  136682. * Not supported by GPUParticleSystem
  136683. * @param gradient defines the gradient to remove
  136684. * @returns the current particle system
  136685. */
  136686. removeAlphaRemapGradient(): IParticleSystem;
  136687. /**
  136688. * Not supported by GPUParticleSystem
  136689. * @param gradient defines the gradient to use (between 0 and 1)
  136690. * @param color defines the color to affect to the specified gradient
  136691. * @returns the current particle system
  136692. */
  136693. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136694. /**
  136695. * Not supported by GPUParticleSystem
  136696. * @param gradient defines the gradient to remove
  136697. * @returns the current particle system
  136698. */
  136699. removeRampGradient(): IParticleSystem;
  136700. /**
  136701. * Not supported by GPUParticleSystem
  136702. * @returns the list of ramp gradients
  136703. */
  136704. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136705. /**
  136706. * Not supported by GPUParticleSystem
  136707. * Gets or sets a boolean indicating that ramp gradients must be used
  136708. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136709. */
  136710. get useRampGradients(): boolean;
  136711. set useRampGradients(value: boolean);
  136712. /**
  136713. * Not supported by GPUParticleSystem
  136714. * @param gradient defines the gradient to use (between 0 and 1)
  136715. * @param factor defines the life time factor to affect to the specified gradient
  136716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136717. * @returns the current particle system
  136718. */
  136719. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136720. /**
  136721. * Not supported by GPUParticleSystem
  136722. * @param gradient defines the gradient to remove
  136723. * @returns the current particle system
  136724. */
  136725. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136726. /**
  136727. * Instantiates a GPU particle system.
  136728. * 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.
  136729. * @param name The name of the particle system
  136730. * @param options The options used to create the system
  136731. * @param scene The scene the particle system belongs to
  136732. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136733. */
  136734. constructor(name: string, options: Partial<{
  136735. capacity: number;
  136736. randomTextureSize: number;
  136737. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136738. protected _reset(): void;
  136739. private _createUpdateVAO;
  136740. private _createRenderVAO;
  136741. private _initialize;
  136742. /** @hidden */
  136743. _recreateUpdateEffect(): void;
  136744. /** @hidden */
  136745. _recreateRenderEffect(): void;
  136746. /**
  136747. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136748. * @param preWarm defines if we are in the pre-warmimg phase
  136749. */
  136750. animate(preWarm?: boolean): void;
  136751. private _createFactorGradientTexture;
  136752. private _createSizeGradientTexture;
  136753. private _createAngularSpeedGradientTexture;
  136754. private _createVelocityGradientTexture;
  136755. private _createLimitVelocityGradientTexture;
  136756. private _createDragGradientTexture;
  136757. private _createColorGradientTexture;
  136758. /**
  136759. * Renders the particle system in its current state
  136760. * @param preWarm defines if the system should only update the particles but not render them
  136761. * @returns the current number of particles
  136762. */
  136763. render(preWarm?: boolean): number;
  136764. /**
  136765. * Rebuilds the particle system
  136766. */
  136767. rebuild(): void;
  136768. private _releaseBuffers;
  136769. private _releaseVAOs;
  136770. /**
  136771. * Disposes the particle system and free the associated resources
  136772. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136773. */
  136774. dispose(disposeTexture?: boolean): void;
  136775. /**
  136776. * Clones the particle system.
  136777. * @param name The name of the cloned object
  136778. * @param newEmitter The new emitter to use
  136779. * @returns the cloned particle system
  136780. */
  136781. clone(name: string, newEmitter: any): GPUParticleSystem;
  136782. /**
  136783. * Serializes the particle system to a JSON object.
  136784. * @returns the JSON object
  136785. */
  136786. serialize(): any;
  136787. /**
  136788. * Parses a JSON object to create a GPU particle system.
  136789. * @param parsedParticleSystem The JSON object to parse
  136790. * @param scene The scene to create the particle system in
  136791. * @param rootUrl The root url to use to load external dependencies like texture
  136792. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136793. * @returns the parsed GPU particle system
  136794. */
  136795. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136796. }
  136797. }
  136798. declare module BABYLON {
  136799. /**
  136800. * Represents a set of particle systems working together to create a specific effect
  136801. */
  136802. export class ParticleSystemSet implements IDisposable {
  136803. /**
  136804. * Gets or sets base Assets URL
  136805. */
  136806. static BaseAssetsUrl: string;
  136807. private _emitterCreationOptions;
  136808. private _emitterNode;
  136809. /**
  136810. * Gets the particle system list
  136811. */
  136812. systems: IParticleSystem[];
  136813. /**
  136814. * Gets the emitter node used with this set
  136815. */
  136816. get emitterNode(): Nullable<TransformNode>;
  136817. /**
  136818. * Creates a new emitter mesh as a sphere
  136819. * @param options defines the options used to create the sphere
  136820. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136821. * @param scene defines the hosting scene
  136822. */
  136823. setEmitterAsSphere(options: {
  136824. diameter: number;
  136825. segments: number;
  136826. color: Color3;
  136827. }, renderingGroupId: number, scene: Scene): void;
  136828. /**
  136829. * Starts all particle systems of the set
  136830. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136831. */
  136832. start(emitter?: AbstractMesh): void;
  136833. /**
  136834. * Release all associated resources
  136835. */
  136836. dispose(): void;
  136837. /**
  136838. * Serialize the set into a JSON compatible object
  136839. * @returns a JSON compatible representation of the set
  136840. */
  136841. serialize(): any;
  136842. /**
  136843. * Parse a new ParticleSystemSet from a serialized source
  136844. * @param data defines a JSON compatible representation of the set
  136845. * @param scene defines the hosting scene
  136846. * @param gpu defines if we want GPU particles or CPU particles
  136847. * @returns a new ParticleSystemSet
  136848. */
  136849. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136850. }
  136851. }
  136852. declare module BABYLON {
  136853. /**
  136854. * This class is made for on one-liner static method to help creating particle system set.
  136855. */
  136856. export class ParticleHelper {
  136857. /**
  136858. * Gets or sets base Assets URL
  136859. */
  136860. static BaseAssetsUrl: string;
  136861. /**
  136862. * Create a default particle system that you can tweak
  136863. * @param emitter defines the emitter to use
  136864. * @param capacity defines the system capacity (default is 500 particles)
  136865. * @param scene defines the hosting scene
  136866. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136867. * @returns the new Particle system
  136868. */
  136869. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136870. /**
  136871. * This is the main static method (one-liner) of this helper to create different particle systems
  136872. * @param type This string represents the type to the particle system to create
  136873. * @param scene The scene where the particle system should live
  136874. * @param gpu If the system will use gpu
  136875. * @returns the ParticleSystemSet created
  136876. */
  136877. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136878. /**
  136879. * Static function used to export a particle system to a ParticleSystemSet variable.
  136880. * Please note that the emitter shape is not exported
  136881. * @param systems defines the particle systems to export
  136882. * @returns the created particle system set
  136883. */
  136884. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136885. }
  136886. }
  136887. declare module BABYLON {
  136888. interface Engine {
  136889. /**
  136890. * Create an effect to use with particle systems.
  136891. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136892. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136893. * @param uniformsNames defines a list of attribute names
  136894. * @param samplers defines an array of string used to represent textures
  136895. * @param defines defines the string containing the defines to use to compile the shaders
  136896. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136897. * @param onCompiled defines a function to call when the effect creation is successful
  136898. * @param onError defines a function to call when the effect creation has failed
  136899. * @returns the new Effect
  136900. */
  136901. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136902. }
  136903. interface Mesh {
  136904. /**
  136905. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136906. * @returns an array of IParticleSystem
  136907. */
  136908. getEmittedParticleSystems(): IParticleSystem[];
  136909. /**
  136910. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136911. * @returns an array of IParticleSystem
  136912. */
  136913. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136914. }
  136915. /**
  136916. * @hidden
  136917. */
  136918. export var _IDoNeedToBeInTheBuild: number;
  136919. }
  136920. declare module BABYLON {
  136921. /** Defines the 4 color options */
  136922. export enum PointColor {
  136923. /** color value */
  136924. Color = 2,
  136925. /** uv value */
  136926. UV = 1,
  136927. /** random value */
  136928. Random = 0,
  136929. /** stated value */
  136930. Stated = 3
  136931. }
  136932. /**
  136933. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136934. * 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.
  136935. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136936. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136937. *
  136938. * Full documentation here : TO BE ENTERED
  136939. */
  136940. export class PointsCloudSystem implements IDisposable {
  136941. /**
  136942. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136943. * Example : var p = SPS.particles[i];
  136944. */
  136945. particles: CloudPoint[];
  136946. /**
  136947. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136948. */
  136949. nbParticles: number;
  136950. /**
  136951. * This a counter for your own usage. It's not set by any SPS functions.
  136952. */
  136953. counter: number;
  136954. /**
  136955. * The PCS name. This name is also given to the underlying mesh.
  136956. */
  136957. name: string;
  136958. /**
  136959. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136960. */
  136961. mesh: Mesh;
  136962. /**
  136963. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136964. * Please read :
  136965. */
  136966. vars: any;
  136967. /**
  136968. * @hidden
  136969. */
  136970. _size: number;
  136971. private _scene;
  136972. private _promises;
  136973. private _positions;
  136974. private _indices;
  136975. private _normals;
  136976. private _colors;
  136977. private _uvs;
  136978. private _indices32;
  136979. private _positions32;
  136980. private _colors32;
  136981. private _uvs32;
  136982. private _updatable;
  136983. private _isVisibilityBoxLocked;
  136984. private _alwaysVisible;
  136985. private _groups;
  136986. private _groupCounter;
  136987. private _computeParticleColor;
  136988. private _computeParticleTexture;
  136989. private _computeParticleRotation;
  136990. private _computeBoundingBox;
  136991. private _isReady;
  136992. /**
  136993. * Creates a PCS (Points Cloud System) object
  136994. * @param name (String) is the PCS name, this will be the underlying mesh name
  136995. * @param pointSize (number) is the size for each point
  136996. * @param scene (Scene) is the scene in which the PCS is added
  136997. * @param options defines the options of the PCS e.g.
  136998. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136999. */
  137000. constructor(name: string, pointSize: number, scene: Scene, options?: {
  137001. updatable?: boolean;
  137002. });
  137003. /**
  137004. * Builds the PCS underlying mesh. Returns a standard Mesh.
  137005. * If no points were added to the PCS, the returned mesh is just a single point.
  137006. * @returns a promise for the created mesh
  137007. */
  137008. buildMeshAsync(): Promise<Mesh>;
  137009. /**
  137010. * @hidden
  137011. */
  137012. private _buildMesh;
  137013. private _addParticle;
  137014. private _randomUnitVector;
  137015. private _getColorIndicesForCoord;
  137016. private _setPointsColorOrUV;
  137017. private _colorFromTexture;
  137018. private _calculateDensity;
  137019. /**
  137020. * Adds points to the PCS in random positions within a unit sphere
  137021. * @param nb (positive integer) the number of particles to be created from this model
  137022. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  137023. * @returns the number of groups in the system
  137024. */
  137025. addPoints(nb: number, pointFunction?: any): number;
  137026. /**
  137027. * Adds points to the PCS from the surface of the model shape
  137028. * @param mesh is any Mesh object that will be used as a surface model for the points
  137029. * @param nb (positive integer) the number of particles to be created from this model
  137030. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  137031. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  137032. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  137033. * @returns the number of groups in the system
  137034. */
  137035. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  137036. /**
  137037. * Adds points to the PCS inside the model shape
  137038. * @param mesh is any Mesh object that will be used as a surface model for the points
  137039. * @param nb (positive integer) the number of particles to be created from this model
  137040. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  137041. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  137042. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  137043. * @returns the number of groups in the system
  137044. */
  137045. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  137046. /**
  137047. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  137048. * This method calls `updateParticle()` for each particle of the SPS.
  137049. * For an animated SPS, it is usually called within the render loop.
  137050. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  137051. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  137052. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  137053. * @returns the PCS.
  137054. */
  137055. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  137056. /**
  137057. * Disposes the PCS.
  137058. */
  137059. dispose(): void;
  137060. /**
  137061. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  137062. * doc :
  137063. * @returns the PCS.
  137064. */
  137065. refreshVisibleSize(): PointsCloudSystem;
  137066. /**
  137067. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  137068. * @param size the size (float) of the visibility box
  137069. * note : this doesn't lock the PCS mesh bounding box.
  137070. * doc :
  137071. */
  137072. setVisibilityBox(size: number): void;
  137073. /**
  137074. * Gets whether the PCS is always visible or not
  137075. * doc :
  137076. */
  137077. get isAlwaysVisible(): boolean;
  137078. /**
  137079. * Sets the PCS as always visible or not
  137080. * doc :
  137081. */
  137082. set isAlwaysVisible(val: boolean);
  137083. /**
  137084. * Tells to `setParticles()` to compute the particle rotations or not
  137085. * Default value : false. The PCS is faster when it's set to false
  137086. * Note : particle rotations are only applied to parent particles
  137087. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  137088. */
  137089. set computeParticleRotation(val: boolean);
  137090. /**
  137091. * Tells to `setParticles()` to compute the particle colors or not.
  137092. * Default value : true. The PCS is faster when it's set to false.
  137093. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  137094. */
  137095. set computeParticleColor(val: boolean);
  137096. set computeParticleTexture(val: boolean);
  137097. /**
  137098. * Gets if `setParticles()` computes the particle colors or not.
  137099. * Default value : false. The PCS is faster when it's set to false.
  137100. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  137101. */
  137102. get computeParticleColor(): boolean;
  137103. /**
  137104. * Gets if `setParticles()` computes the particle textures or not.
  137105. * Default value : false. The PCS is faster when it's set to false.
  137106. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  137107. */
  137108. get computeParticleTexture(): boolean;
  137109. /**
  137110. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  137111. */
  137112. set computeBoundingBox(val: boolean);
  137113. /**
  137114. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  137115. */
  137116. get computeBoundingBox(): boolean;
  137117. /**
  137118. * This function does nothing. It may be overwritten to set all the particle first values.
  137119. * The PCS doesn't call this function, you may have to call it by your own.
  137120. * doc :
  137121. */
  137122. initParticles(): void;
  137123. /**
  137124. * This function does nothing. It may be overwritten to recycle a particle
  137125. * The PCS doesn't call this function, you can to call it
  137126. * doc :
  137127. * @param particle The particle to recycle
  137128. * @returns the recycled particle
  137129. */
  137130. recycleParticle(particle: CloudPoint): CloudPoint;
  137131. /**
  137132. * Updates a particle : this function should be overwritten by the user.
  137133. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  137134. * doc :
  137135. * @example : just set a particle position or velocity and recycle conditions
  137136. * @param particle The particle to update
  137137. * @returns the updated particle
  137138. */
  137139. updateParticle(particle: CloudPoint): CloudPoint;
  137140. /**
  137141. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  137142. * This does nothing and may be overwritten by the user.
  137143. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  137144. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  137145. * @param update the boolean update value actually passed to setParticles()
  137146. */
  137147. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  137148. /**
  137149. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  137150. * This will be passed three parameters.
  137151. * This does nothing and may be overwritten by the user.
  137152. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  137153. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  137154. * @param update the boolean update value actually passed to setParticles()
  137155. */
  137156. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  137157. }
  137158. }
  137159. declare module BABYLON {
  137160. /**
  137161. * Represents one particle of a points cloud system.
  137162. */
  137163. export class CloudPoint {
  137164. /**
  137165. * particle global index
  137166. */
  137167. idx: number;
  137168. /**
  137169. * The color of the particle
  137170. */
  137171. color: Nullable<Color4>;
  137172. /**
  137173. * The world space position of the particle.
  137174. */
  137175. position: Vector3;
  137176. /**
  137177. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  137178. */
  137179. rotation: Vector3;
  137180. /**
  137181. * The world space rotation quaternion of the particle.
  137182. */
  137183. rotationQuaternion: Nullable<Quaternion>;
  137184. /**
  137185. * The uv of the particle.
  137186. */
  137187. uv: Nullable<Vector2>;
  137188. /**
  137189. * The current speed of the particle.
  137190. */
  137191. velocity: Vector3;
  137192. /**
  137193. * The pivot point in the particle local space.
  137194. */
  137195. pivot: Vector3;
  137196. /**
  137197. * Must the particle be translated from its pivot point in its local space ?
  137198. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  137199. * Default : false
  137200. */
  137201. translateFromPivot: boolean;
  137202. /**
  137203. * Index of this particle in the global "positions" array (Internal use)
  137204. * @hidden
  137205. */
  137206. _pos: number;
  137207. /**
  137208. * @hidden Index of this particle in the global "indices" array (Internal use)
  137209. */
  137210. _ind: number;
  137211. /**
  137212. * Group this particle belongs to
  137213. */
  137214. _group: PointsGroup;
  137215. /**
  137216. * Group id of this particle
  137217. */
  137218. groupId: number;
  137219. /**
  137220. * Index of the particle in its group id (Internal use)
  137221. */
  137222. idxInGroup: number;
  137223. /**
  137224. * @hidden Particle BoundingInfo object (Internal use)
  137225. */
  137226. _boundingInfo: BoundingInfo;
  137227. /**
  137228. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  137229. */
  137230. _pcs: PointsCloudSystem;
  137231. /**
  137232. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  137233. */
  137234. _stillInvisible: boolean;
  137235. /**
  137236. * @hidden Last computed particle rotation matrix
  137237. */
  137238. _rotationMatrix: number[];
  137239. /**
  137240. * Parent particle Id, if any.
  137241. * Default null.
  137242. */
  137243. parentId: Nullable<number>;
  137244. /**
  137245. * @hidden Internal global position in the PCS.
  137246. */
  137247. _globalPosition: Vector3;
  137248. /**
  137249. * Creates a Point Cloud object.
  137250. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  137251. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  137252. * @param group (PointsGroup) is the group the particle belongs to
  137253. * @param groupId (integer) is the group identifier in the PCS.
  137254. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  137255. * @param pcs defines the PCS it is associated to
  137256. */
  137257. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  137258. /**
  137259. * get point size
  137260. */
  137261. get size(): Vector3;
  137262. /**
  137263. * Set point size
  137264. */
  137265. set size(scale: Vector3);
  137266. /**
  137267. * Legacy support, changed quaternion to rotationQuaternion
  137268. */
  137269. get quaternion(): Nullable<Quaternion>;
  137270. /**
  137271. * Legacy support, changed quaternion to rotationQuaternion
  137272. */
  137273. set quaternion(q: Nullable<Quaternion>);
  137274. /**
  137275. * Returns a boolean. True if the particle intersects a mesh, else false
  137276. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  137277. * @param target is the object (point or mesh) what the intersection is computed against
  137278. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  137279. * @returns true if it intersects
  137280. */
  137281. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  137282. /**
  137283. * get the rotation matrix of the particle
  137284. * @hidden
  137285. */
  137286. getRotationMatrix(m: Matrix): void;
  137287. }
  137288. /**
  137289. * Represents a group of points in a points cloud system
  137290. * * PCS internal tool, don't use it manually.
  137291. */
  137292. export class PointsGroup {
  137293. /**
  137294. * The group id
  137295. * @hidden
  137296. */
  137297. groupID: number;
  137298. /**
  137299. * image data for group (internal use)
  137300. * @hidden
  137301. */
  137302. _groupImageData: Nullable<ArrayBufferView>;
  137303. /**
  137304. * Image Width (internal use)
  137305. * @hidden
  137306. */
  137307. _groupImgWidth: number;
  137308. /**
  137309. * Image Height (internal use)
  137310. * @hidden
  137311. */
  137312. _groupImgHeight: number;
  137313. /**
  137314. * Custom position function (internal use)
  137315. * @hidden
  137316. */
  137317. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  137318. /**
  137319. * density per facet for surface points
  137320. * @hidden
  137321. */
  137322. _groupDensity: number[];
  137323. /**
  137324. * Only when points are colored by texture carries pointer to texture list array
  137325. * @hidden
  137326. */
  137327. _textureNb: number;
  137328. /**
  137329. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  137330. * PCS internal tool, don't use it manually.
  137331. * @hidden
  137332. */
  137333. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  137334. }
  137335. }
  137336. declare module BABYLON {
  137337. interface Scene {
  137338. /** @hidden (Backing field) */
  137339. _physicsEngine: Nullable<IPhysicsEngine>;
  137340. /** @hidden */
  137341. _physicsTimeAccumulator: number;
  137342. /**
  137343. * Gets the current physics engine
  137344. * @returns a IPhysicsEngine or null if none attached
  137345. */
  137346. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  137347. /**
  137348. * Enables physics to the current scene
  137349. * @param gravity defines the scene's gravity for the physics engine
  137350. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  137351. * @return a boolean indicating if the physics engine was initialized
  137352. */
  137353. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  137354. /**
  137355. * Disables and disposes the physics engine associated with the scene
  137356. */
  137357. disablePhysicsEngine(): void;
  137358. /**
  137359. * Gets a boolean indicating if there is an active physics engine
  137360. * @returns a boolean indicating if there is an active physics engine
  137361. */
  137362. isPhysicsEnabled(): boolean;
  137363. /**
  137364. * Deletes a physics compound impostor
  137365. * @param compound defines the compound to delete
  137366. */
  137367. deleteCompoundImpostor(compound: any): void;
  137368. /**
  137369. * An event triggered when physic simulation is about to be run
  137370. */
  137371. onBeforePhysicsObservable: Observable<Scene>;
  137372. /**
  137373. * An event triggered when physic simulation has been done
  137374. */
  137375. onAfterPhysicsObservable: Observable<Scene>;
  137376. }
  137377. interface AbstractMesh {
  137378. /** @hidden */
  137379. _physicsImpostor: Nullable<PhysicsImpostor>;
  137380. /**
  137381. * Gets or sets impostor used for physic simulation
  137382. * @see http://doc.babylonjs.com/features/physics_engine
  137383. */
  137384. physicsImpostor: Nullable<PhysicsImpostor>;
  137385. /**
  137386. * Gets the current physics impostor
  137387. * @see http://doc.babylonjs.com/features/physics_engine
  137388. * @returns a physics impostor or null
  137389. */
  137390. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  137391. /** Apply a physic impulse to the mesh
  137392. * @param force defines the force to apply
  137393. * @param contactPoint defines where to apply the force
  137394. * @returns the current mesh
  137395. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  137396. */
  137397. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  137398. /**
  137399. * Creates a physic joint between two meshes
  137400. * @param otherMesh defines the other mesh to use
  137401. * @param pivot1 defines the pivot to use on this mesh
  137402. * @param pivot2 defines the pivot to use on the other mesh
  137403. * @param options defines additional options (can be plugin dependent)
  137404. * @returns the current mesh
  137405. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  137406. */
  137407. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  137408. /** @hidden */
  137409. _disposePhysicsObserver: Nullable<Observer<Node>>;
  137410. }
  137411. /**
  137412. * Defines the physics engine scene component responsible to manage a physics engine
  137413. */
  137414. export class PhysicsEngineSceneComponent implements ISceneComponent {
  137415. /**
  137416. * The component name helpful to identify the component in the list of scene components.
  137417. */
  137418. readonly name: string;
  137419. /**
  137420. * The scene the component belongs to.
  137421. */
  137422. scene: Scene;
  137423. /**
  137424. * Creates a new instance of the component for the given scene
  137425. * @param scene Defines the scene to register the component in
  137426. */
  137427. constructor(scene: Scene);
  137428. /**
  137429. * Registers the component in a given scene
  137430. */
  137431. register(): void;
  137432. /**
  137433. * Rebuilds the elements related to this component in case of
  137434. * context lost for instance.
  137435. */
  137436. rebuild(): void;
  137437. /**
  137438. * Disposes the component and the associated ressources
  137439. */
  137440. dispose(): void;
  137441. }
  137442. }
  137443. declare module BABYLON {
  137444. /**
  137445. * A helper for physics simulations
  137446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137447. */
  137448. export class PhysicsHelper {
  137449. private _scene;
  137450. private _physicsEngine;
  137451. /**
  137452. * Initializes the Physics helper
  137453. * @param scene Babylon.js scene
  137454. */
  137455. constructor(scene: Scene);
  137456. /**
  137457. * Applies a radial explosion impulse
  137458. * @param origin the origin of the explosion
  137459. * @param radiusOrEventOptions the radius or the options of radial explosion
  137460. * @param strength the explosion strength
  137461. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137462. * @returns A physics radial explosion event, or null
  137463. */
  137464. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  137465. /**
  137466. * Applies a radial explosion force
  137467. * @param origin the origin of the explosion
  137468. * @param radiusOrEventOptions the radius or the options of radial explosion
  137469. * @param strength the explosion strength
  137470. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137471. * @returns A physics radial explosion event, or null
  137472. */
  137473. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  137474. /**
  137475. * Creates a gravitational field
  137476. * @param origin the origin of the explosion
  137477. * @param radiusOrEventOptions the radius or the options of radial explosion
  137478. * @param strength the explosion strength
  137479. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137480. * @returns A physics gravitational field event, or null
  137481. */
  137482. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  137483. /**
  137484. * Creates a physics updraft event
  137485. * @param origin the origin of the updraft
  137486. * @param radiusOrEventOptions the radius or the options of the updraft
  137487. * @param strength the strength of the updraft
  137488. * @param height the height of the updraft
  137489. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  137490. * @returns A physics updraft event, or null
  137491. */
  137492. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  137493. /**
  137494. * Creates a physics vortex event
  137495. * @param origin the of the vortex
  137496. * @param radiusOrEventOptions the radius or the options of the vortex
  137497. * @param strength the strength of the vortex
  137498. * @param height the height of the vortex
  137499. * @returns a Physics vortex event, or null
  137500. * A physics vortex event or null
  137501. */
  137502. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  137503. }
  137504. /**
  137505. * Represents a physics radial explosion event
  137506. */
  137507. class PhysicsRadialExplosionEvent {
  137508. private _scene;
  137509. private _options;
  137510. private _sphere;
  137511. private _dataFetched;
  137512. /**
  137513. * Initializes a radial explosioin event
  137514. * @param _scene BabylonJS scene
  137515. * @param _options The options for the vortex event
  137516. */
  137517. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  137518. /**
  137519. * Returns the data related to the radial explosion event (sphere).
  137520. * @returns The radial explosion event data
  137521. */
  137522. getData(): PhysicsRadialExplosionEventData;
  137523. /**
  137524. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  137525. * @param impostor A physics imposter
  137526. * @param origin the origin of the explosion
  137527. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  137528. */
  137529. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  137530. /**
  137531. * Triggers affecterd impostors callbacks
  137532. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  137533. */
  137534. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  137535. /**
  137536. * Disposes the sphere.
  137537. * @param force Specifies if the sphere should be disposed by force
  137538. */
  137539. dispose(force?: boolean): void;
  137540. /*** Helpers ***/
  137541. private _prepareSphere;
  137542. private _intersectsWithSphere;
  137543. }
  137544. /**
  137545. * Represents a gravitational field event
  137546. */
  137547. class PhysicsGravitationalFieldEvent {
  137548. private _physicsHelper;
  137549. private _scene;
  137550. private _origin;
  137551. private _options;
  137552. private _tickCallback;
  137553. private _sphere;
  137554. private _dataFetched;
  137555. /**
  137556. * Initializes the physics gravitational field event
  137557. * @param _physicsHelper A physics helper
  137558. * @param _scene BabylonJS scene
  137559. * @param _origin The origin position of the gravitational field event
  137560. * @param _options The options for the vortex event
  137561. */
  137562. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  137563. /**
  137564. * Returns the data related to the gravitational field event (sphere).
  137565. * @returns A gravitational field event
  137566. */
  137567. getData(): PhysicsGravitationalFieldEventData;
  137568. /**
  137569. * Enables the gravitational field.
  137570. */
  137571. enable(): void;
  137572. /**
  137573. * Disables the gravitational field.
  137574. */
  137575. disable(): void;
  137576. /**
  137577. * Disposes the sphere.
  137578. * @param force The force to dispose from the gravitational field event
  137579. */
  137580. dispose(force?: boolean): void;
  137581. private _tick;
  137582. }
  137583. /**
  137584. * Represents a physics updraft event
  137585. */
  137586. class PhysicsUpdraftEvent {
  137587. private _scene;
  137588. private _origin;
  137589. private _options;
  137590. private _physicsEngine;
  137591. private _originTop;
  137592. private _originDirection;
  137593. private _tickCallback;
  137594. private _cylinder;
  137595. private _cylinderPosition;
  137596. private _dataFetched;
  137597. /**
  137598. * Initializes the physics updraft event
  137599. * @param _scene BabylonJS scene
  137600. * @param _origin The origin position of the updraft
  137601. * @param _options The options for the updraft event
  137602. */
  137603. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  137604. /**
  137605. * Returns the data related to the updraft event (cylinder).
  137606. * @returns A physics updraft event
  137607. */
  137608. getData(): PhysicsUpdraftEventData;
  137609. /**
  137610. * Enables the updraft.
  137611. */
  137612. enable(): void;
  137613. /**
  137614. * Disables the updraft.
  137615. */
  137616. disable(): void;
  137617. /**
  137618. * Disposes the cylinder.
  137619. * @param force Specifies if the updraft should be disposed by force
  137620. */
  137621. dispose(force?: boolean): void;
  137622. private getImpostorHitData;
  137623. private _tick;
  137624. /*** Helpers ***/
  137625. private _prepareCylinder;
  137626. private _intersectsWithCylinder;
  137627. }
  137628. /**
  137629. * Represents a physics vortex event
  137630. */
  137631. class PhysicsVortexEvent {
  137632. private _scene;
  137633. private _origin;
  137634. private _options;
  137635. private _physicsEngine;
  137636. private _originTop;
  137637. private _tickCallback;
  137638. private _cylinder;
  137639. private _cylinderPosition;
  137640. private _dataFetched;
  137641. /**
  137642. * Initializes the physics vortex event
  137643. * @param _scene The BabylonJS scene
  137644. * @param _origin The origin position of the vortex
  137645. * @param _options The options for the vortex event
  137646. */
  137647. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  137648. /**
  137649. * Returns the data related to the vortex event (cylinder).
  137650. * @returns The physics vortex event data
  137651. */
  137652. getData(): PhysicsVortexEventData;
  137653. /**
  137654. * Enables the vortex.
  137655. */
  137656. enable(): void;
  137657. /**
  137658. * Disables the cortex.
  137659. */
  137660. disable(): void;
  137661. /**
  137662. * Disposes the sphere.
  137663. * @param force
  137664. */
  137665. dispose(force?: boolean): void;
  137666. private getImpostorHitData;
  137667. private _tick;
  137668. /*** Helpers ***/
  137669. private _prepareCylinder;
  137670. private _intersectsWithCylinder;
  137671. }
  137672. /**
  137673. * Options fot the radial explosion event
  137674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137675. */
  137676. export class PhysicsRadialExplosionEventOptions {
  137677. /**
  137678. * The radius of the sphere for the radial explosion.
  137679. */
  137680. radius: number;
  137681. /**
  137682. * The strenth of the explosion.
  137683. */
  137684. strength: number;
  137685. /**
  137686. * The strenght of the force in correspondence to the distance of the affected object
  137687. */
  137688. falloff: PhysicsRadialImpulseFalloff;
  137689. /**
  137690. * Sphere options for the radial explosion.
  137691. */
  137692. sphere: {
  137693. segments: number;
  137694. diameter: number;
  137695. };
  137696. /**
  137697. * Sphere options for the radial explosion.
  137698. */
  137699. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137700. }
  137701. /**
  137702. * Options fot the updraft event
  137703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137704. */
  137705. export class PhysicsUpdraftEventOptions {
  137706. /**
  137707. * The radius of the cylinder for the vortex
  137708. */
  137709. radius: number;
  137710. /**
  137711. * The strenth of the updraft.
  137712. */
  137713. strength: number;
  137714. /**
  137715. * The height of the cylinder for the updraft.
  137716. */
  137717. height: number;
  137718. /**
  137719. * The mode for the the updraft.
  137720. */
  137721. updraftMode: PhysicsUpdraftMode;
  137722. }
  137723. /**
  137724. * Options fot the vortex event
  137725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137726. */
  137727. export class PhysicsVortexEventOptions {
  137728. /**
  137729. * The radius of the cylinder for the vortex
  137730. */
  137731. radius: number;
  137732. /**
  137733. * The strenth of the vortex.
  137734. */
  137735. strength: number;
  137736. /**
  137737. * The height of the cylinder for the vortex.
  137738. */
  137739. height: number;
  137740. /**
  137741. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137742. */
  137743. centripetalForceThreshold: number;
  137744. /**
  137745. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137746. */
  137747. centripetalForceMultiplier: number;
  137748. /**
  137749. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137750. */
  137751. centrifugalForceMultiplier: number;
  137752. /**
  137753. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137754. */
  137755. updraftForceMultiplier: number;
  137756. }
  137757. /**
  137758. * The strenght of the force in correspondence to the distance of the affected object
  137759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137760. */
  137761. export enum PhysicsRadialImpulseFalloff {
  137762. /** Defines that impulse is constant in strength across it's whole radius */
  137763. Constant = 0,
  137764. /** Defines that impulse gets weaker if it's further from the origin */
  137765. Linear = 1
  137766. }
  137767. /**
  137768. * The strength of the force in correspondence to the distance of the affected object
  137769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137770. */
  137771. export enum PhysicsUpdraftMode {
  137772. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137773. Center = 0,
  137774. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137775. Perpendicular = 1
  137776. }
  137777. /**
  137778. * Interface for a physics hit data
  137779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137780. */
  137781. export interface PhysicsHitData {
  137782. /**
  137783. * The force applied at the contact point
  137784. */
  137785. force: Vector3;
  137786. /**
  137787. * The contact point
  137788. */
  137789. contactPoint: Vector3;
  137790. /**
  137791. * The distance from the origin to the contact point
  137792. */
  137793. distanceFromOrigin: number;
  137794. }
  137795. /**
  137796. * Interface for radial explosion event data
  137797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137798. */
  137799. export interface PhysicsRadialExplosionEventData {
  137800. /**
  137801. * A sphere used for the radial explosion event
  137802. */
  137803. sphere: Mesh;
  137804. }
  137805. /**
  137806. * Interface for gravitational field event data
  137807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137808. */
  137809. export interface PhysicsGravitationalFieldEventData {
  137810. /**
  137811. * A sphere mesh used for the gravitational field event
  137812. */
  137813. sphere: Mesh;
  137814. }
  137815. /**
  137816. * Interface for updraft event data
  137817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137818. */
  137819. export interface PhysicsUpdraftEventData {
  137820. /**
  137821. * A cylinder used for the updraft event
  137822. */
  137823. cylinder: Mesh;
  137824. }
  137825. /**
  137826. * Interface for vortex event data
  137827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137828. */
  137829. export interface PhysicsVortexEventData {
  137830. /**
  137831. * A cylinder used for the vortex event
  137832. */
  137833. cylinder: Mesh;
  137834. }
  137835. /**
  137836. * Interface for an affected physics impostor
  137837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137838. */
  137839. export interface PhysicsAffectedImpostorWithData {
  137840. /**
  137841. * The impostor affected by the effect
  137842. */
  137843. impostor: PhysicsImpostor;
  137844. /**
  137845. * The data about the hit/horce from the explosion
  137846. */
  137847. hitData: PhysicsHitData;
  137848. }
  137849. }
  137850. declare module BABYLON {
  137851. /** @hidden */
  137852. export var blackAndWhitePixelShader: {
  137853. name: string;
  137854. shader: string;
  137855. };
  137856. }
  137857. declare module BABYLON {
  137858. /**
  137859. * Post process used to render in black and white
  137860. */
  137861. export class BlackAndWhitePostProcess extends PostProcess {
  137862. /**
  137863. * Linear about to convert he result to black and white (default: 1)
  137864. */
  137865. degree: number;
  137866. /**
  137867. * Creates a black and white post process
  137868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137869. * @param name The name of the effect.
  137870. * @param options The required width/height ratio to downsize to before computing the render pass.
  137871. * @param camera The camera to apply the render pass to.
  137872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137873. * @param engine The engine which the post process will be applied. (default: current engine)
  137874. * @param reusable If the post process can be reused on the same frame. (default: false)
  137875. */
  137876. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137877. }
  137878. }
  137879. declare module BABYLON {
  137880. /**
  137881. * This represents a set of one or more post processes in Babylon.
  137882. * A post process can be used to apply a shader to a texture after it is rendered.
  137883. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137884. */
  137885. export class PostProcessRenderEffect {
  137886. private _postProcesses;
  137887. private _getPostProcesses;
  137888. private _singleInstance;
  137889. private _cameras;
  137890. private _indicesForCamera;
  137891. /**
  137892. * Name of the effect
  137893. * @hidden
  137894. */
  137895. _name: string;
  137896. /**
  137897. * Instantiates a post process render effect.
  137898. * A post process can be used to apply a shader to a texture after it is rendered.
  137899. * @param engine The engine the effect is tied to
  137900. * @param name The name of the effect
  137901. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137902. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137903. */
  137904. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137905. /**
  137906. * Checks if all the post processes in the effect are supported.
  137907. */
  137908. get isSupported(): boolean;
  137909. /**
  137910. * Updates the current state of the effect
  137911. * @hidden
  137912. */
  137913. _update(): void;
  137914. /**
  137915. * Attaches the effect on cameras
  137916. * @param cameras The camera to attach to.
  137917. * @hidden
  137918. */
  137919. _attachCameras(cameras: Camera): void;
  137920. /**
  137921. * Attaches the effect on cameras
  137922. * @param cameras The camera to attach to.
  137923. * @hidden
  137924. */
  137925. _attachCameras(cameras: Camera[]): void;
  137926. /**
  137927. * Detaches the effect on cameras
  137928. * @param cameras The camera to detatch from.
  137929. * @hidden
  137930. */
  137931. _detachCameras(cameras: Camera): void;
  137932. /**
  137933. * Detatches the effect on cameras
  137934. * @param cameras The camera to detatch from.
  137935. * @hidden
  137936. */
  137937. _detachCameras(cameras: Camera[]): void;
  137938. /**
  137939. * Enables the effect on given cameras
  137940. * @param cameras The camera to enable.
  137941. * @hidden
  137942. */
  137943. _enable(cameras: Camera): void;
  137944. /**
  137945. * Enables the effect on given cameras
  137946. * @param cameras The camera to enable.
  137947. * @hidden
  137948. */
  137949. _enable(cameras: Nullable<Camera[]>): void;
  137950. /**
  137951. * Disables the effect on the given cameras
  137952. * @param cameras The camera to disable.
  137953. * @hidden
  137954. */
  137955. _disable(cameras: Camera): void;
  137956. /**
  137957. * Disables the effect on the given cameras
  137958. * @param cameras The camera to disable.
  137959. * @hidden
  137960. */
  137961. _disable(cameras: Nullable<Camera[]>): void;
  137962. /**
  137963. * Gets a list of the post processes contained in the effect.
  137964. * @param camera The camera to get the post processes on.
  137965. * @returns The list of the post processes in the effect.
  137966. */
  137967. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137968. }
  137969. }
  137970. declare module BABYLON {
  137971. /** @hidden */
  137972. export var extractHighlightsPixelShader: {
  137973. name: string;
  137974. shader: string;
  137975. };
  137976. }
  137977. declare module BABYLON {
  137978. /**
  137979. * 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.
  137980. */
  137981. export class ExtractHighlightsPostProcess extends PostProcess {
  137982. /**
  137983. * The luminance threshold, pixels below this value will be set to black.
  137984. */
  137985. threshold: number;
  137986. /** @hidden */
  137987. _exposure: number;
  137988. /**
  137989. * Post process which has the input texture to be used when performing highlight extraction
  137990. * @hidden
  137991. */
  137992. _inputPostProcess: Nullable<PostProcess>;
  137993. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137994. }
  137995. }
  137996. declare module BABYLON {
  137997. /** @hidden */
  137998. export var bloomMergePixelShader: {
  137999. name: string;
  138000. shader: string;
  138001. };
  138002. }
  138003. declare module BABYLON {
  138004. /**
  138005. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  138006. */
  138007. export class BloomMergePostProcess extends PostProcess {
  138008. /** Weight of the bloom to be added to the original input. */
  138009. weight: number;
  138010. /**
  138011. * Creates a new instance of @see BloomMergePostProcess
  138012. * @param name The name of the effect.
  138013. * @param originalFromInput Post process which's input will be used for the merge.
  138014. * @param blurred Blurred highlights post process which's output will be used.
  138015. * @param weight Weight of the bloom to be added to the original input.
  138016. * @param options The required width/height ratio to downsize to before computing the render pass.
  138017. * @param camera The camera to apply the render pass to.
  138018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138019. * @param engine The engine which the post process will be applied. (default: current engine)
  138020. * @param reusable If the post process can be reused on the same frame. (default: false)
  138021. * @param textureType Type of textures used when performing the post process. (default: 0)
  138022. * @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)
  138023. */
  138024. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  138025. /** Weight of the bloom to be added to the original input. */
  138026. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138027. }
  138028. }
  138029. declare module BABYLON {
  138030. /**
  138031. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  138032. */
  138033. export class BloomEffect extends PostProcessRenderEffect {
  138034. private bloomScale;
  138035. /**
  138036. * @hidden Internal
  138037. */
  138038. _effects: Array<PostProcess>;
  138039. /**
  138040. * @hidden Internal
  138041. */
  138042. _downscale: ExtractHighlightsPostProcess;
  138043. private _blurX;
  138044. private _blurY;
  138045. private _merge;
  138046. /**
  138047. * The luminance threshold to find bright areas of the image to bloom.
  138048. */
  138049. get threshold(): number;
  138050. set threshold(value: number);
  138051. /**
  138052. * The strength of the bloom.
  138053. */
  138054. get weight(): number;
  138055. set weight(value: number);
  138056. /**
  138057. * Specifies the size of the bloom blur kernel, relative to the final output size
  138058. */
  138059. get kernel(): number;
  138060. set kernel(value: number);
  138061. /**
  138062. * Creates a new instance of @see BloomEffect
  138063. * @param scene The scene the effect belongs to.
  138064. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  138065. * @param bloomKernel The size of the kernel to be used when applying the blur.
  138066. * @param bloomWeight The the strength of bloom.
  138067. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  138068. * @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)
  138069. */
  138070. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  138071. /**
  138072. * Disposes each of the internal effects for a given camera.
  138073. * @param camera The camera to dispose the effect on.
  138074. */
  138075. disposeEffects(camera: Camera): void;
  138076. /**
  138077. * @hidden Internal
  138078. */
  138079. _updateEffects(): void;
  138080. /**
  138081. * Internal
  138082. * @returns if all the contained post processes are ready.
  138083. * @hidden
  138084. */
  138085. _isReady(): boolean;
  138086. }
  138087. }
  138088. declare module BABYLON {
  138089. /** @hidden */
  138090. export var chromaticAberrationPixelShader: {
  138091. name: string;
  138092. shader: string;
  138093. };
  138094. }
  138095. declare module BABYLON {
  138096. /**
  138097. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  138098. */
  138099. export class ChromaticAberrationPostProcess extends PostProcess {
  138100. /**
  138101. * The amount of seperation of rgb channels (default: 30)
  138102. */
  138103. aberrationAmount: number;
  138104. /**
  138105. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  138106. */
  138107. radialIntensity: number;
  138108. /**
  138109. * 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))
  138110. */
  138111. direction: Vector2;
  138112. /**
  138113. * 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))
  138114. */
  138115. centerPosition: Vector2;
  138116. /**
  138117. * Creates a new instance ChromaticAberrationPostProcess
  138118. * @param name The name of the effect.
  138119. * @param screenWidth The width of the screen to apply the effect on.
  138120. * @param screenHeight The height of the screen to apply the effect on.
  138121. * @param options The required width/height ratio to downsize to before computing the render pass.
  138122. * @param camera The camera to apply the render pass to.
  138123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138124. * @param engine The engine which the post process will be applied. (default: current engine)
  138125. * @param reusable If the post process can be reused on the same frame. (default: false)
  138126. * @param textureType Type of textures used when performing the post process. (default: 0)
  138127. * @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)
  138128. */
  138129. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138130. }
  138131. }
  138132. declare module BABYLON {
  138133. /** @hidden */
  138134. export var circleOfConfusionPixelShader: {
  138135. name: string;
  138136. shader: string;
  138137. };
  138138. }
  138139. declare module BABYLON {
  138140. /**
  138141. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  138142. */
  138143. export class CircleOfConfusionPostProcess extends PostProcess {
  138144. /**
  138145. * 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.
  138146. */
  138147. lensSize: number;
  138148. /**
  138149. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  138150. */
  138151. fStop: number;
  138152. /**
  138153. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  138154. */
  138155. focusDistance: number;
  138156. /**
  138157. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  138158. */
  138159. focalLength: number;
  138160. private _depthTexture;
  138161. /**
  138162. * Creates a new instance CircleOfConfusionPostProcess
  138163. * @param name The name of the effect.
  138164. * @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.
  138165. * @param options The required width/height ratio to downsize to before computing the render pass.
  138166. * @param camera The camera to apply the render pass to.
  138167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138168. * @param engine The engine which the post process will be applied. (default: current engine)
  138169. * @param reusable If the post process can be reused on the same frame. (default: false)
  138170. * @param textureType Type of textures used when performing the post process. (default: 0)
  138171. * @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)
  138172. */
  138173. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138174. /**
  138175. * 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.
  138176. */
  138177. set depthTexture(value: RenderTargetTexture);
  138178. }
  138179. }
  138180. declare module BABYLON {
  138181. /** @hidden */
  138182. export var colorCorrectionPixelShader: {
  138183. name: string;
  138184. shader: string;
  138185. };
  138186. }
  138187. declare module BABYLON {
  138188. /**
  138189. *
  138190. * This post-process allows the modification of rendered colors by using
  138191. * a 'look-up table' (LUT). This effect is also called Color Grading.
  138192. *
  138193. * The object needs to be provided an url to a texture containing the color
  138194. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  138195. * Use an image editing software to tweak the LUT to match your needs.
  138196. *
  138197. * For an example of a color LUT, see here:
  138198. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  138199. * For explanations on color grading, see here:
  138200. * @see http://udn.epicgames.com/Three/ColorGrading.html
  138201. *
  138202. */
  138203. export class ColorCorrectionPostProcess extends PostProcess {
  138204. private _colorTableTexture;
  138205. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138206. }
  138207. }
  138208. declare module BABYLON {
  138209. /** @hidden */
  138210. export var convolutionPixelShader: {
  138211. name: string;
  138212. shader: string;
  138213. };
  138214. }
  138215. declare module BABYLON {
  138216. /**
  138217. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  138218. * input texture to perform effects such as edge detection or sharpening
  138219. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138220. */
  138221. export class ConvolutionPostProcess extends PostProcess {
  138222. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  138223. kernel: number[];
  138224. /**
  138225. * Creates a new instance ConvolutionPostProcess
  138226. * @param name The name of the effect.
  138227. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  138228. * @param options The required width/height ratio to downsize to before computing the render pass.
  138229. * @param camera The camera to apply the render pass to.
  138230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138231. * @param engine The engine which the post process will be applied. (default: current engine)
  138232. * @param reusable If the post process can be reused on the same frame. (default: false)
  138233. * @param textureType Type of textures used when performing the post process. (default: 0)
  138234. */
  138235. constructor(name: string,
  138236. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  138237. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138238. /**
  138239. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138240. */
  138241. static EdgeDetect0Kernel: number[];
  138242. /**
  138243. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138244. */
  138245. static EdgeDetect1Kernel: number[];
  138246. /**
  138247. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138248. */
  138249. static EdgeDetect2Kernel: number[];
  138250. /**
  138251. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138252. */
  138253. static SharpenKernel: number[];
  138254. /**
  138255. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138256. */
  138257. static EmbossKernel: number[];
  138258. /**
  138259. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138260. */
  138261. static GaussianKernel: number[];
  138262. }
  138263. }
  138264. declare module BABYLON {
  138265. /**
  138266. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  138267. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  138268. * based on samples that have a large difference in distance than the center pixel.
  138269. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  138270. */
  138271. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  138272. direction: Vector2;
  138273. /**
  138274. * Creates a new instance CircleOfConfusionPostProcess
  138275. * @param name The name of the effect.
  138276. * @param scene The scene the effect belongs to.
  138277. * @param direction The direction the blur should be applied.
  138278. * @param kernel The size of the kernel used to blur.
  138279. * @param options The required width/height ratio to downsize to before computing the render pass.
  138280. * @param camera The camera to apply the render pass to.
  138281. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  138282. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  138283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138284. * @param engine The engine which the post process will be applied. (default: current engine)
  138285. * @param reusable If the post process can be reused on the same frame. (default: false)
  138286. * @param textureType Type of textures used when performing the post process. (default: 0)
  138287. * @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)
  138288. */
  138289. 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);
  138290. }
  138291. }
  138292. declare module BABYLON {
  138293. /** @hidden */
  138294. export var depthOfFieldMergePixelShader: {
  138295. name: string;
  138296. shader: string;
  138297. };
  138298. }
  138299. declare module BABYLON {
  138300. /**
  138301. * Options to be set when merging outputs from the default pipeline.
  138302. */
  138303. export class DepthOfFieldMergePostProcessOptions {
  138304. /**
  138305. * The original image to merge on top of
  138306. */
  138307. originalFromInput: PostProcess;
  138308. /**
  138309. * Parameters to perform the merge of the depth of field effect
  138310. */
  138311. depthOfField?: {
  138312. circleOfConfusion: PostProcess;
  138313. blurSteps: Array<PostProcess>;
  138314. };
  138315. /**
  138316. * Parameters to perform the merge of bloom effect
  138317. */
  138318. bloom?: {
  138319. blurred: PostProcess;
  138320. weight: number;
  138321. };
  138322. }
  138323. /**
  138324. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  138325. */
  138326. export class DepthOfFieldMergePostProcess extends PostProcess {
  138327. private blurSteps;
  138328. /**
  138329. * Creates a new instance of DepthOfFieldMergePostProcess
  138330. * @param name The name of the effect.
  138331. * @param originalFromInput Post process which's input will be used for the merge.
  138332. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  138333. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  138334. * @param options The required width/height ratio to downsize to before computing the render pass.
  138335. * @param camera The camera to apply the render pass to.
  138336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138337. * @param engine The engine which the post process will be applied. (default: current engine)
  138338. * @param reusable If the post process can be reused on the same frame. (default: false)
  138339. * @param textureType Type of textures used when performing the post process. (default: 0)
  138340. * @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)
  138341. */
  138342. 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);
  138343. /**
  138344. * Updates the effect with the current post process compile time values and recompiles the shader.
  138345. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  138346. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  138347. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  138348. * @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
  138349. * @param onCompiled Called when the shader has been compiled.
  138350. * @param onError Called if there is an error when compiling a shader.
  138351. */
  138352. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  138353. }
  138354. }
  138355. declare module BABYLON {
  138356. /**
  138357. * Specifies the level of max blur that should be applied when using the depth of field effect
  138358. */
  138359. export enum DepthOfFieldEffectBlurLevel {
  138360. /**
  138361. * Subtle blur
  138362. */
  138363. Low = 0,
  138364. /**
  138365. * Medium blur
  138366. */
  138367. Medium = 1,
  138368. /**
  138369. * Large blur
  138370. */
  138371. High = 2
  138372. }
  138373. /**
  138374. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  138375. */
  138376. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  138377. private _circleOfConfusion;
  138378. /**
  138379. * @hidden Internal, blurs from high to low
  138380. */
  138381. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  138382. private _depthOfFieldBlurY;
  138383. private _dofMerge;
  138384. /**
  138385. * @hidden Internal post processes in depth of field effect
  138386. */
  138387. _effects: Array<PostProcess>;
  138388. /**
  138389. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  138390. */
  138391. set focalLength(value: number);
  138392. get focalLength(): number;
  138393. /**
  138394. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  138395. */
  138396. set fStop(value: number);
  138397. get fStop(): number;
  138398. /**
  138399. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  138400. */
  138401. set focusDistance(value: number);
  138402. get focusDistance(): number;
  138403. /**
  138404. * 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.
  138405. */
  138406. set lensSize(value: number);
  138407. get lensSize(): number;
  138408. /**
  138409. * Creates a new instance DepthOfFieldEffect
  138410. * @param scene The scene the effect belongs to.
  138411. * @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.
  138412. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  138413. * @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)
  138414. */
  138415. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  138416. /**
  138417. * Get the current class name of the current effet
  138418. * @returns "DepthOfFieldEffect"
  138419. */
  138420. getClassName(): string;
  138421. /**
  138422. * 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.
  138423. */
  138424. set depthTexture(value: RenderTargetTexture);
  138425. /**
  138426. * Disposes each of the internal effects for a given camera.
  138427. * @param camera The camera to dispose the effect on.
  138428. */
  138429. disposeEffects(camera: Camera): void;
  138430. /**
  138431. * @hidden Internal
  138432. */
  138433. _updateEffects(): void;
  138434. /**
  138435. * Internal
  138436. * @returns if all the contained post processes are ready.
  138437. * @hidden
  138438. */
  138439. _isReady(): boolean;
  138440. }
  138441. }
  138442. declare module BABYLON {
  138443. /** @hidden */
  138444. export var displayPassPixelShader: {
  138445. name: string;
  138446. shader: string;
  138447. };
  138448. }
  138449. declare module BABYLON {
  138450. /**
  138451. * DisplayPassPostProcess which produces an output the same as it's input
  138452. */
  138453. export class DisplayPassPostProcess extends PostProcess {
  138454. /**
  138455. * Creates the DisplayPassPostProcess
  138456. * @param name The name of the effect.
  138457. * @param options The required width/height ratio to downsize to before computing the render pass.
  138458. * @param camera The camera to apply the render pass to.
  138459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138460. * @param engine The engine which the post process will be applied. (default: current engine)
  138461. * @param reusable If the post process can be reused on the same frame. (default: false)
  138462. */
  138463. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138464. }
  138465. }
  138466. declare module BABYLON {
  138467. /** @hidden */
  138468. export var filterPixelShader: {
  138469. name: string;
  138470. shader: string;
  138471. };
  138472. }
  138473. declare module BABYLON {
  138474. /**
  138475. * Applies a kernel filter to the image
  138476. */
  138477. export class FilterPostProcess extends PostProcess {
  138478. /** The matrix to be applied to the image */
  138479. kernelMatrix: Matrix;
  138480. /**
  138481. *
  138482. * @param name The name of the effect.
  138483. * @param kernelMatrix The matrix to be applied to the image
  138484. * @param options The required width/height ratio to downsize to before computing the render pass.
  138485. * @param camera The camera to apply the render pass to.
  138486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138487. * @param engine The engine which the post process will be applied. (default: current engine)
  138488. * @param reusable If the post process can be reused on the same frame. (default: false)
  138489. */
  138490. constructor(name: string,
  138491. /** The matrix to be applied to the image */
  138492. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138493. }
  138494. }
  138495. declare module BABYLON {
  138496. /** @hidden */
  138497. export var fxaaPixelShader: {
  138498. name: string;
  138499. shader: string;
  138500. };
  138501. }
  138502. declare module BABYLON {
  138503. /** @hidden */
  138504. export var fxaaVertexShader: {
  138505. name: string;
  138506. shader: string;
  138507. };
  138508. }
  138509. declare module BABYLON {
  138510. /**
  138511. * Fxaa post process
  138512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  138513. */
  138514. export class FxaaPostProcess extends PostProcess {
  138515. /** @hidden */
  138516. texelWidth: number;
  138517. /** @hidden */
  138518. texelHeight: number;
  138519. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138520. private _getDefines;
  138521. }
  138522. }
  138523. declare module BABYLON {
  138524. /** @hidden */
  138525. export var grainPixelShader: {
  138526. name: string;
  138527. shader: string;
  138528. };
  138529. }
  138530. declare module BABYLON {
  138531. /**
  138532. * The GrainPostProcess adds noise to the image at mid luminance levels
  138533. */
  138534. export class GrainPostProcess extends PostProcess {
  138535. /**
  138536. * The intensity of the grain added (default: 30)
  138537. */
  138538. intensity: number;
  138539. /**
  138540. * If the grain should be randomized on every frame
  138541. */
  138542. animated: boolean;
  138543. /**
  138544. * Creates a new instance of @see GrainPostProcess
  138545. * @param name The name of the effect.
  138546. * @param options The required width/height ratio to downsize to before computing the render pass.
  138547. * @param camera The camera to apply the render pass to.
  138548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138549. * @param engine The engine which the post process will be applied. (default: current engine)
  138550. * @param reusable If the post process can be reused on the same frame. (default: false)
  138551. * @param textureType Type of textures used when performing the post process. (default: 0)
  138552. * @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)
  138553. */
  138554. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138555. }
  138556. }
  138557. declare module BABYLON {
  138558. /** @hidden */
  138559. export var highlightsPixelShader: {
  138560. name: string;
  138561. shader: string;
  138562. };
  138563. }
  138564. declare module BABYLON {
  138565. /**
  138566. * Extracts highlights from the image
  138567. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138568. */
  138569. export class HighlightsPostProcess extends PostProcess {
  138570. /**
  138571. * Extracts highlights from the image
  138572. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138573. * @param name The name of the effect.
  138574. * @param options The required width/height ratio to downsize to before computing the render pass.
  138575. * @param camera The camera to apply the render pass to.
  138576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138577. * @param engine The engine which the post process will be applied. (default: current engine)
  138578. * @param reusable If the post process can be reused on the same frame. (default: false)
  138579. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  138580. */
  138581. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138582. }
  138583. }
  138584. declare module BABYLON {
  138585. /** @hidden */
  138586. export var mrtFragmentDeclaration: {
  138587. name: string;
  138588. shader: string;
  138589. };
  138590. }
  138591. declare module BABYLON {
  138592. /** @hidden */
  138593. export var geometryPixelShader: {
  138594. name: string;
  138595. shader: string;
  138596. };
  138597. }
  138598. declare module BABYLON {
  138599. /** @hidden */
  138600. export var geometryVertexShader: {
  138601. name: string;
  138602. shader: string;
  138603. };
  138604. }
  138605. declare module BABYLON {
  138606. /** @hidden */
  138607. interface ISavedTransformationMatrix {
  138608. world: Matrix;
  138609. viewProjection: Matrix;
  138610. }
  138611. /**
  138612. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  138613. */
  138614. export class GeometryBufferRenderer {
  138615. /**
  138616. * Constant used to retrieve the position texture index in the G-Buffer textures array
  138617. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  138618. */
  138619. static readonly POSITION_TEXTURE_TYPE: number;
  138620. /**
  138621. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  138622. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  138623. */
  138624. static readonly VELOCITY_TEXTURE_TYPE: number;
  138625. /**
  138626. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  138627. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  138628. */
  138629. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  138630. /**
  138631. * Dictionary used to store the previous transformation matrices of each rendered mesh
  138632. * in order to compute objects velocities when enableVelocity is set to "true"
  138633. * @hidden
  138634. */
  138635. _previousTransformationMatrices: {
  138636. [index: number]: ISavedTransformationMatrix;
  138637. };
  138638. /**
  138639. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  138640. * in order to compute objects velocities when enableVelocity is set to "true"
  138641. * @hidden
  138642. */
  138643. _previousBonesTransformationMatrices: {
  138644. [index: number]: Float32Array;
  138645. };
  138646. /**
  138647. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  138648. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  138649. */
  138650. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  138651. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  138652. renderTransparentMeshes: boolean;
  138653. private _scene;
  138654. private _multiRenderTarget;
  138655. private _ratio;
  138656. private _enablePosition;
  138657. private _enableVelocity;
  138658. private _enableReflectivity;
  138659. private _positionIndex;
  138660. private _velocityIndex;
  138661. private _reflectivityIndex;
  138662. protected _effect: Effect;
  138663. protected _cachedDefines: string;
  138664. /**
  138665. * Set the render list (meshes to be rendered) used in the G buffer.
  138666. */
  138667. set renderList(meshes: Mesh[]);
  138668. /**
  138669. * Gets wether or not G buffer are supported by the running hardware.
  138670. * This requires draw buffer supports
  138671. */
  138672. get isSupported(): boolean;
  138673. /**
  138674. * Returns the index of the given texture type in the G-Buffer textures array
  138675. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138676. * @returns the index of the given texture type in the G-Buffer textures array
  138677. */
  138678. getTextureIndex(textureType: number): number;
  138679. /**
  138680. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138681. */
  138682. get enablePosition(): boolean;
  138683. /**
  138684. * Sets whether or not objects positions are enabled for the G buffer.
  138685. */
  138686. set enablePosition(enable: boolean);
  138687. /**
  138688. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138689. */
  138690. get enableVelocity(): boolean;
  138691. /**
  138692. * Sets wether or not objects velocities are enabled for the G buffer.
  138693. */
  138694. set enableVelocity(enable: boolean);
  138695. /**
  138696. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138697. */
  138698. get enableReflectivity(): boolean;
  138699. /**
  138700. * Sets wether or not objects roughness are enabled for the G buffer.
  138701. */
  138702. set enableReflectivity(enable: boolean);
  138703. /**
  138704. * Gets the scene associated with the buffer.
  138705. */
  138706. get scene(): Scene;
  138707. /**
  138708. * Gets the ratio used by the buffer during its creation.
  138709. * How big is the buffer related to the main canvas.
  138710. */
  138711. get ratio(): number;
  138712. /** @hidden */
  138713. static _SceneComponentInitialization: (scene: Scene) => void;
  138714. /**
  138715. * Creates a new G Buffer for the scene
  138716. * @param scene The scene the buffer belongs to
  138717. * @param ratio How big is the buffer related to the main canvas.
  138718. */
  138719. constructor(scene: Scene, ratio?: number);
  138720. /**
  138721. * Checks wether everything is ready to render a submesh to the G buffer.
  138722. * @param subMesh the submesh to check readiness for
  138723. * @param useInstances is the mesh drawn using instance or not
  138724. * @returns true if ready otherwise false
  138725. */
  138726. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138727. /**
  138728. * Gets the current underlying G Buffer.
  138729. * @returns the buffer
  138730. */
  138731. getGBuffer(): MultiRenderTarget;
  138732. /**
  138733. * Gets the number of samples used to render the buffer (anti aliasing).
  138734. */
  138735. get samples(): number;
  138736. /**
  138737. * Sets the number of samples used to render the buffer (anti aliasing).
  138738. */
  138739. set samples(value: number);
  138740. /**
  138741. * Disposes the renderer and frees up associated resources.
  138742. */
  138743. dispose(): void;
  138744. protected _createRenderTargets(): void;
  138745. private _copyBonesTransformationMatrices;
  138746. }
  138747. }
  138748. declare module BABYLON {
  138749. interface Scene {
  138750. /** @hidden (Backing field) */
  138751. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138752. /**
  138753. * Gets or Sets the current geometry buffer associated to the scene.
  138754. */
  138755. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138756. /**
  138757. * Enables a GeometryBufferRender and associates it with the scene
  138758. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138759. * @returns the GeometryBufferRenderer
  138760. */
  138761. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138762. /**
  138763. * Disables the GeometryBufferRender associated with the scene
  138764. */
  138765. disableGeometryBufferRenderer(): void;
  138766. }
  138767. /**
  138768. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138769. * in several rendering techniques.
  138770. */
  138771. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138772. /**
  138773. * The component name helpful to identify the component in the list of scene components.
  138774. */
  138775. readonly name: string;
  138776. /**
  138777. * The scene the component belongs to.
  138778. */
  138779. scene: Scene;
  138780. /**
  138781. * Creates a new instance of the component for the given scene
  138782. * @param scene Defines the scene to register the component in
  138783. */
  138784. constructor(scene: Scene);
  138785. /**
  138786. * Registers the component in a given scene
  138787. */
  138788. register(): void;
  138789. /**
  138790. * Rebuilds the elements related to this component in case of
  138791. * context lost for instance.
  138792. */
  138793. rebuild(): void;
  138794. /**
  138795. * Disposes the component and the associated ressources
  138796. */
  138797. dispose(): void;
  138798. private _gatherRenderTargets;
  138799. }
  138800. }
  138801. declare module BABYLON {
  138802. /** @hidden */
  138803. export var motionBlurPixelShader: {
  138804. name: string;
  138805. shader: string;
  138806. };
  138807. }
  138808. declare module BABYLON {
  138809. /**
  138810. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138811. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138812. * As an example, all you have to do is to create the post-process:
  138813. * var mb = new BABYLON.MotionBlurPostProcess(
  138814. * 'mb', // The name of the effect.
  138815. * scene, // The scene containing the objects to blur according to their velocity.
  138816. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138817. * camera // The camera to apply the render pass to.
  138818. * );
  138819. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138820. */
  138821. export class MotionBlurPostProcess extends PostProcess {
  138822. /**
  138823. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138824. */
  138825. motionStrength: number;
  138826. /**
  138827. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138828. */
  138829. get motionBlurSamples(): number;
  138830. /**
  138831. * Sets the number of iterations to be used for motion blur quality
  138832. */
  138833. set motionBlurSamples(samples: number);
  138834. private _motionBlurSamples;
  138835. private _geometryBufferRenderer;
  138836. /**
  138837. * Creates a new instance MotionBlurPostProcess
  138838. * @param name The name of the effect.
  138839. * @param scene The scene containing the objects to blur according to their velocity.
  138840. * @param options The required width/height ratio to downsize to before computing the render pass.
  138841. * @param camera The camera to apply the render pass to.
  138842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138843. * @param engine The engine which the post process will be applied. (default: current engine)
  138844. * @param reusable If the post process can be reused on the same frame. (default: false)
  138845. * @param textureType Type of textures used when performing the post process. (default: 0)
  138846. * @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)
  138847. */
  138848. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138849. /**
  138850. * Excludes the given skinned mesh from computing bones velocities.
  138851. * 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.
  138852. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138853. */
  138854. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138855. /**
  138856. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138857. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138858. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138859. */
  138860. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138861. /**
  138862. * Disposes the post process.
  138863. * @param camera The camera to dispose the post process on.
  138864. */
  138865. dispose(camera?: Camera): void;
  138866. }
  138867. }
  138868. declare module BABYLON {
  138869. /** @hidden */
  138870. export var refractionPixelShader: {
  138871. name: string;
  138872. shader: string;
  138873. };
  138874. }
  138875. declare module BABYLON {
  138876. /**
  138877. * Post process which applies a refractin texture
  138878. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138879. */
  138880. export class RefractionPostProcess extends PostProcess {
  138881. /** the base color of the refraction (used to taint the rendering) */
  138882. color: Color3;
  138883. /** simulated refraction depth */
  138884. depth: number;
  138885. /** the coefficient of the base color (0 to remove base color tainting) */
  138886. colorLevel: number;
  138887. private _refTexture;
  138888. private _ownRefractionTexture;
  138889. /**
  138890. * Gets or sets the refraction texture
  138891. * Please note that you are responsible for disposing the texture if you set it manually
  138892. */
  138893. get refractionTexture(): Texture;
  138894. set refractionTexture(value: Texture);
  138895. /**
  138896. * Initializes the RefractionPostProcess
  138897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138898. * @param name The name of the effect.
  138899. * @param refractionTextureUrl Url of the refraction texture to use
  138900. * @param color the base color of the refraction (used to taint the rendering)
  138901. * @param depth simulated refraction depth
  138902. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138903. * @param camera The camera to apply the render pass to.
  138904. * @param options The required width/height ratio to downsize to before computing the render pass.
  138905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138906. * @param engine The engine which the post process will be applied. (default: current engine)
  138907. * @param reusable If the post process can be reused on the same frame. (default: false)
  138908. */
  138909. constructor(name: string, refractionTextureUrl: string,
  138910. /** the base color of the refraction (used to taint the rendering) */
  138911. color: Color3,
  138912. /** simulated refraction depth */
  138913. depth: number,
  138914. /** the coefficient of the base color (0 to remove base color tainting) */
  138915. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138916. /**
  138917. * Disposes of the post process
  138918. * @param camera Camera to dispose post process on
  138919. */
  138920. dispose(camera: Camera): void;
  138921. }
  138922. }
  138923. declare module BABYLON {
  138924. /** @hidden */
  138925. export var sharpenPixelShader: {
  138926. name: string;
  138927. shader: string;
  138928. };
  138929. }
  138930. declare module BABYLON {
  138931. /**
  138932. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138933. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138934. */
  138935. export class SharpenPostProcess extends PostProcess {
  138936. /**
  138937. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138938. */
  138939. colorAmount: number;
  138940. /**
  138941. * How much sharpness should be applied (default: 0.3)
  138942. */
  138943. edgeAmount: number;
  138944. /**
  138945. * Creates a new instance ConvolutionPostProcess
  138946. * @param name The name of the effect.
  138947. * @param options The required width/height ratio to downsize to before computing the render pass.
  138948. * @param camera The camera to apply the render pass to.
  138949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138950. * @param engine The engine which the post process will be applied. (default: current engine)
  138951. * @param reusable If the post process can be reused on the same frame. (default: false)
  138952. * @param textureType Type of textures used when performing the post process. (default: 0)
  138953. * @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)
  138954. */
  138955. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138956. }
  138957. }
  138958. declare module BABYLON {
  138959. /**
  138960. * PostProcessRenderPipeline
  138961. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138962. */
  138963. export class PostProcessRenderPipeline {
  138964. private engine;
  138965. private _renderEffects;
  138966. private _renderEffectsForIsolatedPass;
  138967. /**
  138968. * List of inspectable custom properties (used by the Inspector)
  138969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138970. */
  138971. inspectableCustomProperties: IInspectable[];
  138972. /**
  138973. * @hidden
  138974. */
  138975. protected _cameras: Camera[];
  138976. /** @hidden */
  138977. _name: string;
  138978. /**
  138979. * Gets pipeline name
  138980. */
  138981. get name(): string;
  138982. /** Gets the list of attached cameras */
  138983. get cameras(): Camera[];
  138984. /**
  138985. * Initializes a PostProcessRenderPipeline
  138986. * @param engine engine to add the pipeline to
  138987. * @param name name of the pipeline
  138988. */
  138989. constructor(engine: Engine, name: string);
  138990. /**
  138991. * Gets the class name
  138992. * @returns "PostProcessRenderPipeline"
  138993. */
  138994. getClassName(): string;
  138995. /**
  138996. * If all the render effects in the pipeline are supported
  138997. */
  138998. get isSupported(): boolean;
  138999. /**
  139000. * Adds an effect to the pipeline
  139001. * @param renderEffect the effect to add
  139002. */
  139003. addEffect(renderEffect: PostProcessRenderEffect): void;
  139004. /** @hidden */
  139005. _rebuild(): void;
  139006. /** @hidden */
  139007. _enableEffect(renderEffectName: string, cameras: Camera): void;
  139008. /** @hidden */
  139009. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  139010. /** @hidden */
  139011. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  139012. /** @hidden */
  139013. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  139014. /** @hidden */
  139015. _attachCameras(cameras: Camera, unique: boolean): void;
  139016. /** @hidden */
  139017. _attachCameras(cameras: Camera[], unique: boolean): void;
  139018. /** @hidden */
  139019. _detachCameras(cameras: Camera): void;
  139020. /** @hidden */
  139021. _detachCameras(cameras: Nullable<Camera[]>): void;
  139022. /** @hidden */
  139023. _update(): void;
  139024. /** @hidden */
  139025. _reset(): void;
  139026. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  139027. /**
  139028. * Disposes of the pipeline
  139029. */
  139030. dispose(): void;
  139031. }
  139032. }
  139033. declare module BABYLON {
  139034. /**
  139035. * PostProcessRenderPipelineManager class
  139036. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139037. */
  139038. export class PostProcessRenderPipelineManager {
  139039. private _renderPipelines;
  139040. /**
  139041. * Initializes a PostProcessRenderPipelineManager
  139042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139043. */
  139044. constructor();
  139045. /**
  139046. * Gets the list of supported render pipelines
  139047. */
  139048. get supportedPipelines(): PostProcessRenderPipeline[];
  139049. /**
  139050. * Adds a pipeline to the manager
  139051. * @param renderPipeline The pipeline to add
  139052. */
  139053. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  139054. /**
  139055. * Attaches a camera to the pipeline
  139056. * @param renderPipelineName The name of the pipeline to attach to
  139057. * @param cameras the camera to attach
  139058. * @param unique if the camera can be attached multiple times to the pipeline
  139059. */
  139060. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  139061. /**
  139062. * Detaches a camera from the pipeline
  139063. * @param renderPipelineName The name of the pipeline to detach from
  139064. * @param cameras the camera to detach
  139065. */
  139066. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  139067. /**
  139068. * Enables an effect by name on a pipeline
  139069. * @param renderPipelineName the name of the pipeline to enable the effect in
  139070. * @param renderEffectName the name of the effect to enable
  139071. * @param cameras the cameras that the effect should be enabled on
  139072. */
  139073. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  139074. /**
  139075. * Disables an effect by name on a pipeline
  139076. * @param renderPipelineName the name of the pipeline to disable the effect in
  139077. * @param renderEffectName the name of the effect to disable
  139078. * @param cameras the cameras that the effect should be disabled on
  139079. */
  139080. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  139081. /**
  139082. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  139083. */
  139084. update(): void;
  139085. /** @hidden */
  139086. _rebuild(): void;
  139087. /**
  139088. * Disposes of the manager and pipelines
  139089. */
  139090. dispose(): void;
  139091. }
  139092. }
  139093. declare module BABYLON {
  139094. interface Scene {
  139095. /** @hidden (Backing field) */
  139096. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  139097. /**
  139098. * Gets the postprocess render pipeline manager
  139099. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139100. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  139101. */
  139102. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  139103. }
  139104. /**
  139105. * Defines the Render Pipeline scene component responsible to rendering pipelines
  139106. */
  139107. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  139108. /**
  139109. * The component name helpfull to identify the component in the list of scene components.
  139110. */
  139111. readonly name: string;
  139112. /**
  139113. * The scene the component belongs to.
  139114. */
  139115. scene: Scene;
  139116. /**
  139117. * Creates a new instance of the component for the given scene
  139118. * @param scene Defines the scene to register the component in
  139119. */
  139120. constructor(scene: Scene);
  139121. /**
  139122. * Registers the component in a given scene
  139123. */
  139124. register(): void;
  139125. /**
  139126. * Rebuilds the elements related to this component in case of
  139127. * context lost for instance.
  139128. */
  139129. rebuild(): void;
  139130. /**
  139131. * Disposes the component and the associated ressources
  139132. */
  139133. dispose(): void;
  139134. private _gatherRenderTargets;
  139135. }
  139136. }
  139137. declare module BABYLON {
  139138. /**
  139139. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  139140. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  139141. */
  139142. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139143. private _scene;
  139144. private _camerasToBeAttached;
  139145. /**
  139146. * ID of the sharpen post process,
  139147. */
  139148. private readonly SharpenPostProcessId;
  139149. /**
  139150. * @ignore
  139151. * ID of the image processing post process;
  139152. */
  139153. readonly ImageProcessingPostProcessId: string;
  139154. /**
  139155. * @ignore
  139156. * ID of the Fast Approximate Anti-Aliasing post process;
  139157. */
  139158. readonly FxaaPostProcessId: string;
  139159. /**
  139160. * ID of the chromatic aberration post process,
  139161. */
  139162. private readonly ChromaticAberrationPostProcessId;
  139163. /**
  139164. * ID of the grain post process
  139165. */
  139166. private readonly GrainPostProcessId;
  139167. /**
  139168. * Sharpen post process which will apply a sharpen convolution to enhance edges
  139169. */
  139170. sharpen: SharpenPostProcess;
  139171. private _sharpenEffect;
  139172. private bloom;
  139173. /**
  139174. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  139175. */
  139176. depthOfField: DepthOfFieldEffect;
  139177. /**
  139178. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139179. */
  139180. fxaa: FxaaPostProcess;
  139181. /**
  139182. * Image post processing pass used to perform operations such as tone mapping or color grading.
  139183. */
  139184. imageProcessing: ImageProcessingPostProcess;
  139185. /**
  139186. * Chromatic aberration post process which will shift rgb colors in the image
  139187. */
  139188. chromaticAberration: ChromaticAberrationPostProcess;
  139189. private _chromaticAberrationEffect;
  139190. /**
  139191. * Grain post process which add noise to the image
  139192. */
  139193. grain: GrainPostProcess;
  139194. private _grainEffect;
  139195. /**
  139196. * Glow post process which adds a glow to emissive areas of the image
  139197. */
  139198. private _glowLayer;
  139199. /**
  139200. * Animations which can be used to tweak settings over a period of time
  139201. */
  139202. animations: Animation[];
  139203. private _imageProcessingConfigurationObserver;
  139204. private _sharpenEnabled;
  139205. private _bloomEnabled;
  139206. private _depthOfFieldEnabled;
  139207. private _depthOfFieldBlurLevel;
  139208. private _fxaaEnabled;
  139209. private _imageProcessingEnabled;
  139210. private _defaultPipelineTextureType;
  139211. private _bloomScale;
  139212. private _chromaticAberrationEnabled;
  139213. private _grainEnabled;
  139214. private _buildAllowed;
  139215. /**
  139216. * Gets active scene
  139217. */
  139218. get scene(): Scene;
  139219. /**
  139220. * Enable or disable the sharpen process from the pipeline
  139221. */
  139222. set sharpenEnabled(enabled: boolean);
  139223. get sharpenEnabled(): boolean;
  139224. private _resizeObserver;
  139225. private _hardwareScaleLevel;
  139226. private _bloomKernel;
  139227. /**
  139228. * Specifies the size of the bloom blur kernel, relative to the final output size
  139229. */
  139230. get bloomKernel(): number;
  139231. set bloomKernel(value: number);
  139232. /**
  139233. * Specifies the weight of the bloom in the final rendering
  139234. */
  139235. private _bloomWeight;
  139236. /**
  139237. * Specifies the luma threshold for the area that will be blurred by the bloom
  139238. */
  139239. private _bloomThreshold;
  139240. private _hdr;
  139241. /**
  139242. * The strength of the bloom.
  139243. */
  139244. set bloomWeight(value: number);
  139245. get bloomWeight(): number;
  139246. /**
  139247. * The strength of the bloom.
  139248. */
  139249. set bloomThreshold(value: number);
  139250. get bloomThreshold(): number;
  139251. /**
  139252. * The scale of the bloom, lower value will provide better performance.
  139253. */
  139254. set bloomScale(value: number);
  139255. get bloomScale(): number;
  139256. /**
  139257. * Enable or disable the bloom from the pipeline
  139258. */
  139259. set bloomEnabled(enabled: boolean);
  139260. get bloomEnabled(): boolean;
  139261. private _rebuildBloom;
  139262. /**
  139263. * If the depth of field is enabled.
  139264. */
  139265. get depthOfFieldEnabled(): boolean;
  139266. set depthOfFieldEnabled(enabled: boolean);
  139267. /**
  139268. * Blur level of the depth of field effect. (Higher blur will effect performance)
  139269. */
  139270. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  139271. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  139272. /**
  139273. * If the anti aliasing is enabled.
  139274. */
  139275. set fxaaEnabled(enabled: boolean);
  139276. get fxaaEnabled(): boolean;
  139277. private _samples;
  139278. /**
  139279. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139280. */
  139281. set samples(sampleCount: number);
  139282. get samples(): number;
  139283. /**
  139284. * If image processing is enabled.
  139285. */
  139286. set imageProcessingEnabled(enabled: boolean);
  139287. get imageProcessingEnabled(): boolean;
  139288. /**
  139289. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  139290. */
  139291. set glowLayerEnabled(enabled: boolean);
  139292. get glowLayerEnabled(): boolean;
  139293. /**
  139294. * Gets the glow layer (or null if not defined)
  139295. */
  139296. get glowLayer(): Nullable<GlowLayer>;
  139297. /**
  139298. * Enable or disable the chromaticAberration process from the pipeline
  139299. */
  139300. set chromaticAberrationEnabled(enabled: boolean);
  139301. get chromaticAberrationEnabled(): boolean;
  139302. /**
  139303. * Enable or disable the grain process from the pipeline
  139304. */
  139305. set grainEnabled(enabled: boolean);
  139306. get grainEnabled(): boolean;
  139307. /**
  139308. * @constructor
  139309. * @param name - The rendering pipeline name (default: "")
  139310. * @param hdr - If high dynamic range textures should be used (default: true)
  139311. * @param scene - The scene linked to this pipeline (default: the last created scene)
  139312. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  139313. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  139314. */
  139315. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  139316. /**
  139317. * Get the class name
  139318. * @returns "DefaultRenderingPipeline"
  139319. */
  139320. getClassName(): string;
  139321. /**
  139322. * Force the compilation of the entire pipeline.
  139323. */
  139324. prepare(): void;
  139325. private _hasCleared;
  139326. private _prevPostProcess;
  139327. private _prevPrevPostProcess;
  139328. private _setAutoClearAndTextureSharing;
  139329. private _depthOfFieldSceneObserver;
  139330. private _buildPipeline;
  139331. private _disposePostProcesses;
  139332. /**
  139333. * Adds a camera to the pipeline
  139334. * @param camera the camera to be added
  139335. */
  139336. addCamera(camera: Camera): void;
  139337. /**
  139338. * Removes a camera from the pipeline
  139339. * @param camera the camera to remove
  139340. */
  139341. removeCamera(camera: Camera): void;
  139342. /**
  139343. * Dispose of the pipeline and stop all post processes
  139344. */
  139345. dispose(): void;
  139346. /**
  139347. * Serialize the rendering pipeline (Used when exporting)
  139348. * @returns the serialized object
  139349. */
  139350. serialize(): any;
  139351. /**
  139352. * Parse the serialized pipeline
  139353. * @param source Source pipeline.
  139354. * @param scene The scene to load the pipeline to.
  139355. * @param rootUrl The URL of the serialized pipeline.
  139356. * @returns An instantiated pipeline from the serialized object.
  139357. */
  139358. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  139359. }
  139360. }
  139361. declare module BABYLON {
  139362. /** @hidden */
  139363. export var lensHighlightsPixelShader: {
  139364. name: string;
  139365. shader: string;
  139366. };
  139367. }
  139368. declare module BABYLON {
  139369. /** @hidden */
  139370. export var depthOfFieldPixelShader: {
  139371. name: string;
  139372. shader: string;
  139373. };
  139374. }
  139375. declare module BABYLON {
  139376. /**
  139377. * BABYLON.JS Chromatic Aberration GLSL Shader
  139378. * Author: Olivier Guyot
  139379. * Separates very slightly R, G and B colors on the edges of the screen
  139380. * Inspired by Francois Tarlier & Martins Upitis
  139381. */
  139382. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  139383. /**
  139384. * @ignore
  139385. * The chromatic aberration PostProcess id in the pipeline
  139386. */
  139387. LensChromaticAberrationEffect: string;
  139388. /**
  139389. * @ignore
  139390. * The highlights enhancing PostProcess id in the pipeline
  139391. */
  139392. HighlightsEnhancingEffect: string;
  139393. /**
  139394. * @ignore
  139395. * The depth-of-field PostProcess id in the pipeline
  139396. */
  139397. LensDepthOfFieldEffect: string;
  139398. private _scene;
  139399. private _depthTexture;
  139400. private _grainTexture;
  139401. private _chromaticAberrationPostProcess;
  139402. private _highlightsPostProcess;
  139403. private _depthOfFieldPostProcess;
  139404. private _edgeBlur;
  139405. private _grainAmount;
  139406. private _chromaticAberration;
  139407. private _distortion;
  139408. private _highlightsGain;
  139409. private _highlightsThreshold;
  139410. private _dofDistance;
  139411. private _dofAperture;
  139412. private _dofDarken;
  139413. private _dofPentagon;
  139414. private _blurNoise;
  139415. /**
  139416. * @constructor
  139417. *
  139418. * Effect parameters are as follow:
  139419. * {
  139420. * chromatic_aberration: number; // from 0 to x (1 for realism)
  139421. * edge_blur: number; // from 0 to x (1 for realism)
  139422. * distortion: number; // from 0 to x (1 for realism)
  139423. * grain_amount: number; // from 0 to 1
  139424. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  139425. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  139426. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  139427. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  139428. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  139429. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  139430. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  139431. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  139432. * }
  139433. * Note: if an effect parameter is unset, effect is disabled
  139434. *
  139435. * @param name The rendering pipeline name
  139436. * @param parameters - An object containing all parameters (see above)
  139437. * @param scene The scene linked to this pipeline
  139438. * @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)
  139439. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139440. */
  139441. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  139442. /**
  139443. * Get the class name
  139444. * @returns "LensRenderingPipeline"
  139445. */
  139446. getClassName(): string;
  139447. /**
  139448. * Gets associated scene
  139449. */
  139450. get scene(): Scene;
  139451. /**
  139452. * Gets or sets the edge blur
  139453. */
  139454. get edgeBlur(): number;
  139455. set edgeBlur(value: number);
  139456. /**
  139457. * Gets or sets the grain amount
  139458. */
  139459. get grainAmount(): number;
  139460. set grainAmount(value: number);
  139461. /**
  139462. * Gets or sets the chromatic aberration amount
  139463. */
  139464. get chromaticAberration(): number;
  139465. set chromaticAberration(value: number);
  139466. /**
  139467. * Gets or sets the depth of field aperture
  139468. */
  139469. get dofAperture(): number;
  139470. set dofAperture(value: number);
  139471. /**
  139472. * Gets or sets the edge distortion
  139473. */
  139474. get edgeDistortion(): number;
  139475. set edgeDistortion(value: number);
  139476. /**
  139477. * Gets or sets the depth of field distortion
  139478. */
  139479. get dofDistortion(): number;
  139480. set dofDistortion(value: number);
  139481. /**
  139482. * Gets or sets the darken out of focus amount
  139483. */
  139484. get darkenOutOfFocus(): number;
  139485. set darkenOutOfFocus(value: number);
  139486. /**
  139487. * Gets or sets a boolean indicating if blur noise is enabled
  139488. */
  139489. get blurNoise(): boolean;
  139490. set blurNoise(value: boolean);
  139491. /**
  139492. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  139493. */
  139494. get pentagonBokeh(): boolean;
  139495. set pentagonBokeh(value: boolean);
  139496. /**
  139497. * Gets or sets the highlight grain amount
  139498. */
  139499. get highlightsGain(): number;
  139500. set highlightsGain(value: number);
  139501. /**
  139502. * Gets or sets the highlight threshold
  139503. */
  139504. get highlightsThreshold(): number;
  139505. set highlightsThreshold(value: number);
  139506. /**
  139507. * Sets the amount of blur at the edges
  139508. * @param amount blur amount
  139509. */
  139510. setEdgeBlur(amount: number): void;
  139511. /**
  139512. * Sets edge blur to 0
  139513. */
  139514. disableEdgeBlur(): void;
  139515. /**
  139516. * Sets the amout of grain
  139517. * @param amount Amount of grain
  139518. */
  139519. setGrainAmount(amount: number): void;
  139520. /**
  139521. * Set grain amount to 0
  139522. */
  139523. disableGrain(): void;
  139524. /**
  139525. * Sets the chromatic aberration amount
  139526. * @param amount amount of chromatic aberration
  139527. */
  139528. setChromaticAberration(amount: number): void;
  139529. /**
  139530. * Sets chromatic aberration amount to 0
  139531. */
  139532. disableChromaticAberration(): void;
  139533. /**
  139534. * Sets the EdgeDistortion amount
  139535. * @param amount amount of EdgeDistortion
  139536. */
  139537. setEdgeDistortion(amount: number): void;
  139538. /**
  139539. * Sets edge distortion to 0
  139540. */
  139541. disableEdgeDistortion(): void;
  139542. /**
  139543. * Sets the FocusDistance amount
  139544. * @param amount amount of FocusDistance
  139545. */
  139546. setFocusDistance(amount: number): void;
  139547. /**
  139548. * Disables depth of field
  139549. */
  139550. disableDepthOfField(): void;
  139551. /**
  139552. * Sets the Aperture amount
  139553. * @param amount amount of Aperture
  139554. */
  139555. setAperture(amount: number): void;
  139556. /**
  139557. * Sets the DarkenOutOfFocus amount
  139558. * @param amount amount of DarkenOutOfFocus
  139559. */
  139560. setDarkenOutOfFocus(amount: number): void;
  139561. private _pentagonBokehIsEnabled;
  139562. /**
  139563. * Creates a pentagon bokeh effect
  139564. */
  139565. enablePentagonBokeh(): void;
  139566. /**
  139567. * Disables the pentagon bokeh effect
  139568. */
  139569. disablePentagonBokeh(): void;
  139570. /**
  139571. * Enables noise blur
  139572. */
  139573. enableNoiseBlur(): void;
  139574. /**
  139575. * Disables noise blur
  139576. */
  139577. disableNoiseBlur(): void;
  139578. /**
  139579. * Sets the HighlightsGain amount
  139580. * @param amount amount of HighlightsGain
  139581. */
  139582. setHighlightsGain(amount: number): void;
  139583. /**
  139584. * Sets the HighlightsThreshold amount
  139585. * @param amount amount of HighlightsThreshold
  139586. */
  139587. setHighlightsThreshold(amount: number): void;
  139588. /**
  139589. * Disables highlights
  139590. */
  139591. disableHighlights(): void;
  139592. /**
  139593. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  139594. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  139595. */
  139596. dispose(disableDepthRender?: boolean): void;
  139597. private _createChromaticAberrationPostProcess;
  139598. private _createHighlightsPostProcess;
  139599. private _createDepthOfFieldPostProcess;
  139600. private _createGrainTexture;
  139601. }
  139602. }
  139603. declare module BABYLON {
  139604. /** @hidden */
  139605. export var ssao2PixelShader: {
  139606. name: string;
  139607. shader: string;
  139608. };
  139609. }
  139610. declare module BABYLON {
  139611. /** @hidden */
  139612. export var ssaoCombinePixelShader: {
  139613. name: string;
  139614. shader: string;
  139615. };
  139616. }
  139617. declare module BABYLON {
  139618. /**
  139619. * Render pipeline to produce ssao effect
  139620. */
  139621. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  139622. /**
  139623. * @ignore
  139624. * The PassPostProcess id in the pipeline that contains the original scene color
  139625. */
  139626. SSAOOriginalSceneColorEffect: string;
  139627. /**
  139628. * @ignore
  139629. * The SSAO PostProcess id in the pipeline
  139630. */
  139631. SSAORenderEffect: string;
  139632. /**
  139633. * @ignore
  139634. * The horizontal blur PostProcess id in the pipeline
  139635. */
  139636. SSAOBlurHRenderEffect: string;
  139637. /**
  139638. * @ignore
  139639. * The vertical blur PostProcess id in the pipeline
  139640. */
  139641. SSAOBlurVRenderEffect: string;
  139642. /**
  139643. * @ignore
  139644. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139645. */
  139646. SSAOCombineRenderEffect: string;
  139647. /**
  139648. * The output strength of the SSAO post-process. Default value is 1.0.
  139649. */
  139650. totalStrength: number;
  139651. /**
  139652. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  139653. */
  139654. maxZ: number;
  139655. /**
  139656. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  139657. */
  139658. minZAspect: number;
  139659. private _samples;
  139660. /**
  139661. * Number of samples used for the SSAO calculations. Default value is 8
  139662. */
  139663. set samples(n: number);
  139664. get samples(): number;
  139665. private _textureSamples;
  139666. /**
  139667. * Number of samples to use for antialiasing
  139668. */
  139669. set textureSamples(n: number);
  139670. get textureSamples(): number;
  139671. /**
  139672. * Ratio object used for SSAO ratio and blur ratio
  139673. */
  139674. private _ratio;
  139675. /**
  139676. * Dynamically generated sphere sampler.
  139677. */
  139678. private _sampleSphere;
  139679. /**
  139680. * Blur filter offsets
  139681. */
  139682. private _samplerOffsets;
  139683. private _expensiveBlur;
  139684. /**
  139685. * If bilateral blur should be used
  139686. */
  139687. set expensiveBlur(b: boolean);
  139688. get expensiveBlur(): boolean;
  139689. /**
  139690. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139691. */
  139692. radius: number;
  139693. /**
  139694. * The base color of the SSAO post-process
  139695. * The final result is "base + ssao" between [0, 1]
  139696. */
  139697. base: number;
  139698. /**
  139699. * Support test.
  139700. */
  139701. static get IsSupported(): boolean;
  139702. private _scene;
  139703. private _depthTexture;
  139704. private _normalTexture;
  139705. private _randomTexture;
  139706. private _originalColorPostProcess;
  139707. private _ssaoPostProcess;
  139708. private _blurHPostProcess;
  139709. private _blurVPostProcess;
  139710. private _ssaoCombinePostProcess;
  139711. /**
  139712. * Gets active scene
  139713. */
  139714. get scene(): Scene;
  139715. /**
  139716. * @constructor
  139717. * @param name The rendering pipeline name
  139718. * @param scene The scene linked to this pipeline
  139719. * @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 }
  139720. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139721. */
  139722. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139723. /**
  139724. * Get the class name
  139725. * @returns "SSAO2RenderingPipeline"
  139726. */
  139727. getClassName(): string;
  139728. /**
  139729. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139730. */
  139731. dispose(disableGeometryBufferRenderer?: boolean): void;
  139732. private _createBlurPostProcess;
  139733. /** @hidden */
  139734. _rebuild(): void;
  139735. private _bits;
  139736. private _radicalInverse_VdC;
  139737. private _hammersley;
  139738. private _hemisphereSample_uniform;
  139739. private _generateHemisphere;
  139740. private _createSSAOPostProcess;
  139741. private _createSSAOCombinePostProcess;
  139742. private _createRandomTexture;
  139743. /**
  139744. * Serialize the rendering pipeline (Used when exporting)
  139745. * @returns the serialized object
  139746. */
  139747. serialize(): any;
  139748. /**
  139749. * Parse the serialized pipeline
  139750. * @param source Source pipeline.
  139751. * @param scene The scene to load the pipeline to.
  139752. * @param rootUrl The URL of the serialized pipeline.
  139753. * @returns An instantiated pipeline from the serialized object.
  139754. */
  139755. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139756. }
  139757. }
  139758. declare module BABYLON {
  139759. /** @hidden */
  139760. export var ssaoPixelShader: {
  139761. name: string;
  139762. shader: string;
  139763. };
  139764. }
  139765. declare module BABYLON {
  139766. /**
  139767. * Render pipeline to produce ssao effect
  139768. */
  139769. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139770. /**
  139771. * @ignore
  139772. * The PassPostProcess id in the pipeline that contains the original scene color
  139773. */
  139774. SSAOOriginalSceneColorEffect: string;
  139775. /**
  139776. * @ignore
  139777. * The SSAO PostProcess id in the pipeline
  139778. */
  139779. SSAORenderEffect: string;
  139780. /**
  139781. * @ignore
  139782. * The horizontal blur PostProcess id in the pipeline
  139783. */
  139784. SSAOBlurHRenderEffect: string;
  139785. /**
  139786. * @ignore
  139787. * The vertical blur PostProcess id in the pipeline
  139788. */
  139789. SSAOBlurVRenderEffect: string;
  139790. /**
  139791. * @ignore
  139792. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139793. */
  139794. SSAOCombineRenderEffect: string;
  139795. /**
  139796. * The output strength of the SSAO post-process. Default value is 1.0.
  139797. */
  139798. totalStrength: number;
  139799. /**
  139800. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139801. */
  139802. radius: number;
  139803. /**
  139804. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139805. * Must not be equal to fallOff and superior to fallOff.
  139806. * Default value is 0.0075
  139807. */
  139808. area: number;
  139809. /**
  139810. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139811. * Must not be equal to area and inferior to area.
  139812. * Default value is 0.000001
  139813. */
  139814. fallOff: number;
  139815. /**
  139816. * The base color of the SSAO post-process
  139817. * The final result is "base + ssao" between [0, 1]
  139818. */
  139819. base: number;
  139820. private _scene;
  139821. private _depthTexture;
  139822. private _randomTexture;
  139823. private _originalColorPostProcess;
  139824. private _ssaoPostProcess;
  139825. private _blurHPostProcess;
  139826. private _blurVPostProcess;
  139827. private _ssaoCombinePostProcess;
  139828. private _firstUpdate;
  139829. /**
  139830. * Gets active scene
  139831. */
  139832. get scene(): Scene;
  139833. /**
  139834. * @constructor
  139835. * @param name - The rendering pipeline name
  139836. * @param scene - The scene linked to this pipeline
  139837. * @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 }
  139838. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139839. */
  139840. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139841. /**
  139842. * Get the class name
  139843. * @returns "SSAORenderingPipeline"
  139844. */
  139845. getClassName(): string;
  139846. /**
  139847. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139848. */
  139849. dispose(disableDepthRender?: boolean): void;
  139850. private _createBlurPostProcess;
  139851. /** @hidden */
  139852. _rebuild(): void;
  139853. private _createSSAOPostProcess;
  139854. private _createSSAOCombinePostProcess;
  139855. private _createRandomTexture;
  139856. }
  139857. }
  139858. declare module BABYLON {
  139859. /** @hidden */
  139860. export var screenSpaceReflectionPixelShader: {
  139861. name: string;
  139862. shader: string;
  139863. };
  139864. }
  139865. declare module BABYLON {
  139866. /**
  139867. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139868. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139869. */
  139870. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139871. /**
  139872. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139873. */
  139874. threshold: number;
  139875. /**
  139876. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139877. */
  139878. strength: number;
  139879. /**
  139880. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139881. */
  139882. reflectionSpecularFalloffExponent: number;
  139883. /**
  139884. * 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]
  139885. */
  139886. step: number;
  139887. /**
  139888. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139889. */
  139890. roughnessFactor: number;
  139891. private _geometryBufferRenderer;
  139892. private _enableSmoothReflections;
  139893. private _reflectionSamples;
  139894. private _smoothSteps;
  139895. /**
  139896. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139897. * @param name The name of the effect.
  139898. * @param scene The scene containing the objects to calculate reflections.
  139899. * @param options The required width/height ratio to downsize to before computing the render pass.
  139900. * @param camera The camera to apply the render pass to.
  139901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139902. * @param engine The engine which the post process will be applied. (default: current engine)
  139903. * @param reusable If the post process can be reused on the same frame. (default: false)
  139904. * @param textureType Type of textures used when performing the post process. (default: 0)
  139905. * @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)
  139906. */
  139907. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139908. /**
  139909. * Gets wether or not smoothing reflections is enabled.
  139910. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139911. */
  139912. get enableSmoothReflections(): boolean;
  139913. /**
  139914. * Sets wether or not smoothing reflections is enabled.
  139915. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139916. */
  139917. set enableSmoothReflections(enabled: boolean);
  139918. /**
  139919. * Gets the number of samples taken while computing reflections. More samples count is high,
  139920. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139921. */
  139922. get reflectionSamples(): number;
  139923. /**
  139924. * Sets the number of samples taken while computing reflections. More samples count is high,
  139925. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139926. */
  139927. set reflectionSamples(samples: number);
  139928. /**
  139929. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139930. * more the post-process will require GPU power and can generate a drop in FPS.
  139931. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139932. */
  139933. get smoothSteps(): number;
  139934. set smoothSteps(steps: number);
  139935. private _updateEffectDefines;
  139936. }
  139937. }
  139938. declare module BABYLON {
  139939. /** @hidden */
  139940. export var standardPixelShader: {
  139941. name: string;
  139942. shader: string;
  139943. };
  139944. }
  139945. declare module BABYLON {
  139946. /**
  139947. * Standard rendering pipeline
  139948. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139949. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139950. */
  139951. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139952. /**
  139953. * Public members
  139954. */
  139955. /**
  139956. * Post-process which contains the original scene color before the pipeline applies all the effects
  139957. */
  139958. originalPostProcess: Nullable<PostProcess>;
  139959. /**
  139960. * Post-process used to down scale an image x4
  139961. */
  139962. downSampleX4PostProcess: Nullable<PostProcess>;
  139963. /**
  139964. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139965. */
  139966. brightPassPostProcess: Nullable<PostProcess>;
  139967. /**
  139968. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139969. */
  139970. blurHPostProcesses: PostProcess[];
  139971. /**
  139972. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139973. */
  139974. blurVPostProcesses: PostProcess[];
  139975. /**
  139976. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139977. */
  139978. textureAdderPostProcess: Nullable<PostProcess>;
  139979. /**
  139980. * Post-process used to create volumetric lighting effect
  139981. */
  139982. volumetricLightPostProcess: Nullable<PostProcess>;
  139983. /**
  139984. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139985. */
  139986. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139987. /**
  139988. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139989. */
  139990. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139991. /**
  139992. * Post-process used to merge the volumetric light effect and the real scene color
  139993. */
  139994. volumetricLightMergePostProces: Nullable<PostProcess>;
  139995. /**
  139996. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139997. */
  139998. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139999. /**
  140000. * Base post-process used to calculate the average luminance of the final image for HDR
  140001. */
  140002. luminancePostProcess: Nullable<PostProcess>;
  140003. /**
  140004. * Post-processes used to create down sample post-processes in order to get
  140005. * the average luminance of the final image for HDR
  140006. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  140007. */
  140008. luminanceDownSamplePostProcesses: PostProcess[];
  140009. /**
  140010. * Post-process used to create a HDR effect (light adaptation)
  140011. */
  140012. hdrPostProcess: Nullable<PostProcess>;
  140013. /**
  140014. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  140015. */
  140016. textureAdderFinalPostProcess: Nullable<PostProcess>;
  140017. /**
  140018. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  140019. */
  140020. lensFlareFinalPostProcess: Nullable<PostProcess>;
  140021. /**
  140022. * Post-process used to merge the final HDR post-process and the real scene color
  140023. */
  140024. hdrFinalPostProcess: Nullable<PostProcess>;
  140025. /**
  140026. * Post-process used to create a lens flare effect
  140027. */
  140028. lensFlarePostProcess: Nullable<PostProcess>;
  140029. /**
  140030. * Post-process that merges the result of the lens flare post-process and the real scene color
  140031. */
  140032. lensFlareComposePostProcess: Nullable<PostProcess>;
  140033. /**
  140034. * Post-process used to create a motion blur effect
  140035. */
  140036. motionBlurPostProcess: Nullable<PostProcess>;
  140037. /**
  140038. * Post-process used to create a depth of field effect
  140039. */
  140040. depthOfFieldPostProcess: Nullable<PostProcess>;
  140041. /**
  140042. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140043. */
  140044. fxaaPostProcess: Nullable<FxaaPostProcess>;
  140045. /**
  140046. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  140047. */
  140048. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  140049. /**
  140050. * Represents the brightness threshold in order to configure the illuminated surfaces
  140051. */
  140052. brightThreshold: number;
  140053. /**
  140054. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  140055. */
  140056. blurWidth: number;
  140057. /**
  140058. * Sets if the blur for highlighted surfaces must be only horizontal
  140059. */
  140060. horizontalBlur: boolean;
  140061. /**
  140062. * Gets the overall exposure used by the pipeline
  140063. */
  140064. get exposure(): number;
  140065. /**
  140066. * Sets the overall exposure used by the pipeline
  140067. */
  140068. set exposure(value: number);
  140069. /**
  140070. * Texture used typically to simulate "dirty" on camera lens
  140071. */
  140072. lensTexture: Nullable<Texture>;
  140073. /**
  140074. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  140075. */
  140076. volumetricLightCoefficient: number;
  140077. /**
  140078. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  140079. */
  140080. volumetricLightPower: number;
  140081. /**
  140082. * Used the set the blur intensity to smooth the volumetric lights
  140083. */
  140084. volumetricLightBlurScale: number;
  140085. /**
  140086. * Light (spot or directional) used to generate the volumetric lights rays
  140087. * The source light must have a shadow generate so the pipeline can get its
  140088. * depth map
  140089. */
  140090. sourceLight: Nullable<SpotLight | DirectionalLight>;
  140091. /**
  140092. * For eye adaptation, represents the minimum luminance the eye can see
  140093. */
  140094. hdrMinimumLuminance: number;
  140095. /**
  140096. * For eye adaptation, represents the decrease luminance speed
  140097. */
  140098. hdrDecreaseRate: number;
  140099. /**
  140100. * For eye adaptation, represents the increase luminance speed
  140101. */
  140102. hdrIncreaseRate: number;
  140103. /**
  140104. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  140105. */
  140106. get hdrAutoExposure(): boolean;
  140107. /**
  140108. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  140109. */
  140110. set hdrAutoExposure(value: boolean);
  140111. /**
  140112. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  140113. */
  140114. lensColorTexture: Nullable<Texture>;
  140115. /**
  140116. * The overall strengh for the lens flare effect
  140117. */
  140118. lensFlareStrength: number;
  140119. /**
  140120. * Dispersion coefficient for lens flare ghosts
  140121. */
  140122. lensFlareGhostDispersal: number;
  140123. /**
  140124. * Main lens flare halo width
  140125. */
  140126. lensFlareHaloWidth: number;
  140127. /**
  140128. * Based on the lens distortion effect, defines how much the lens flare result
  140129. * is distorted
  140130. */
  140131. lensFlareDistortionStrength: number;
  140132. /**
  140133. * Configures the blur intensity used for for lens flare (halo)
  140134. */
  140135. lensFlareBlurWidth: number;
  140136. /**
  140137. * Lens star texture must be used to simulate rays on the flares and is available
  140138. * in the documentation
  140139. */
  140140. lensStarTexture: Nullable<Texture>;
  140141. /**
  140142. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  140143. * flare effect by taking account of the dirt texture
  140144. */
  140145. lensFlareDirtTexture: Nullable<Texture>;
  140146. /**
  140147. * Represents the focal length for the depth of field effect
  140148. */
  140149. depthOfFieldDistance: number;
  140150. /**
  140151. * Represents the blur intensity for the blurred part of the depth of field effect
  140152. */
  140153. depthOfFieldBlurWidth: number;
  140154. /**
  140155. * Gets how much the image is blurred by the movement while using the motion blur post-process
  140156. */
  140157. get motionStrength(): number;
  140158. /**
  140159. * Sets how much the image is blurred by the movement while using the motion blur post-process
  140160. */
  140161. set motionStrength(strength: number);
  140162. /**
  140163. * Gets wether or not the motion blur post-process is object based or screen based.
  140164. */
  140165. get objectBasedMotionBlur(): boolean;
  140166. /**
  140167. * Sets wether or not the motion blur post-process should be object based or screen based
  140168. */
  140169. set objectBasedMotionBlur(value: boolean);
  140170. /**
  140171. * List of animations for the pipeline (IAnimatable implementation)
  140172. */
  140173. animations: Animation[];
  140174. /**
  140175. * Private members
  140176. */
  140177. private _scene;
  140178. private _currentDepthOfFieldSource;
  140179. private _basePostProcess;
  140180. private _fixedExposure;
  140181. private _currentExposure;
  140182. private _hdrAutoExposure;
  140183. private _hdrCurrentLuminance;
  140184. private _motionStrength;
  140185. private _isObjectBasedMotionBlur;
  140186. private _floatTextureType;
  140187. private _camerasToBeAttached;
  140188. private _ratio;
  140189. private _bloomEnabled;
  140190. private _depthOfFieldEnabled;
  140191. private _vlsEnabled;
  140192. private _lensFlareEnabled;
  140193. private _hdrEnabled;
  140194. private _motionBlurEnabled;
  140195. private _fxaaEnabled;
  140196. private _screenSpaceReflectionsEnabled;
  140197. private _motionBlurSamples;
  140198. private _volumetricLightStepsCount;
  140199. private _samples;
  140200. /**
  140201. * @ignore
  140202. * Specifies if the bloom pipeline is enabled
  140203. */
  140204. get BloomEnabled(): boolean;
  140205. set BloomEnabled(enabled: boolean);
  140206. /**
  140207. * @ignore
  140208. * Specifies if the depth of field pipeline is enabed
  140209. */
  140210. get DepthOfFieldEnabled(): boolean;
  140211. set DepthOfFieldEnabled(enabled: boolean);
  140212. /**
  140213. * @ignore
  140214. * Specifies if the lens flare pipeline is enabed
  140215. */
  140216. get LensFlareEnabled(): boolean;
  140217. set LensFlareEnabled(enabled: boolean);
  140218. /**
  140219. * @ignore
  140220. * Specifies if the HDR pipeline is enabled
  140221. */
  140222. get HDREnabled(): boolean;
  140223. set HDREnabled(enabled: boolean);
  140224. /**
  140225. * @ignore
  140226. * Specifies if the volumetric lights scattering effect is enabled
  140227. */
  140228. get VLSEnabled(): boolean;
  140229. set VLSEnabled(enabled: boolean);
  140230. /**
  140231. * @ignore
  140232. * Specifies if the motion blur effect is enabled
  140233. */
  140234. get MotionBlurEnabled(): boolean;
  140235. set MotionBlurEnabled(enabled: boolean);
  140236. /**
  140237. * Specifies if anti-aliasing is enabled
  140238. */
  140239. get fxaaEnabled(): boolean;
  140240. set fxaaEnabled(enabled: boolean);
  140241. /**
  140242. * Specifies if screen space reflections are enabled.
  140243. */
  140244. get screenSpaceReflectionsEnabled(): boolean;
  140245. set screenSpaceReflectionsEnabled(enabled: boolean);
  140246. /**
  140247. * Specifies the number of steps used to calculate the volumetric lights
  140248. * Typically in interval [50, 200]
  140249. */
  140250. get volumetricLightStepsCount(): number;
  140251. set volumetricLightStepsCount(count: number);
  140252. /**
  140253. * Specifies the number of samples used for the motion blur effect
  140254. * Typically in interval [16, 64]
  140255. */
  140256. get motionBlurSamples(): number;
  140257. set motionBlurSamples(samples: number);
  140258. /**
  140259. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140260. */
  140261. get samples(): number;
  140262. set samples(sampleCount: number);
  140263. /**
  140264. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140265. * @constructor
  140266. * @param name The rendering pipeline name
  140267. * @param scene The scene linked to this pipeline
  140268. * @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)
  140269. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  140270. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140271. */
  140272. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  140273. private _buildPipeline;
  140274. private _createDownSampleX4PostProcess;
  140275. private _createBrightPassPostProcess;
  140276. private _createBlurPostProcesses;
  140277. private _createTextureAdderPostProcess;
  140278. private _createVolumetricLightPostProcess;
  140279. private _createLuminancePostProcesses;
  140280. private _createHdrPostProcess;
  140281. private _createLensFlarePostProcess;
  140282. private _createDepthOfFieldPostProcess;
  140283. private _createMotionBlurPostProcess;
  140284. private _getDepthTexture;
  140285. private _disposePostProcesses;
  140286. /**
  140287. * Dispose of the pipeline and stop all post processes
  140288. */
  140289. dispose(): void;
  140290. /**
  140291. * Serialize the rendering pipeline (Used when exporting)
  140292. * @returns the serialized object
  140293. */
  140294. serialize(): any;
  140295. /**
  140296. * Parse the serialized pipeline
  140297. * @param source Source pipeline.
  140298. * @param scene The scene to load the pipeline to.
  140299. * @param rootUrl The URL of the serialized pipeline.
  140300. * @returns An instantiated pipeline from the serialized object.
  140301. */
  140302. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  140303. /**
  140304. * Luminance steps
  140305. */
  140306. static LuminanceSteps: number;
  140307. }
  140308. }
  140309. declare module BABYLON {
  140310. /** @hidden */
  140311. export var tonemapPixelShader: {
  140312. name: string;
  140313. shader: string;
  140314. };
  140315. }
  140316. declare module BABYLON {
  140317. /** Defines operator used for tonemapping */
  140318. export enum TonemappingOperator {
  140319. /** Hable */
  140320. Hable = 0,
  140321. /** Reinhard */
  140322. Reinhard = 1,
  140323. /** HejiDawson */
  140324. HejiDawson = 2,
  140325. /** Photographic */
  140326. Photographic = 3
  140327. }
  140328. /**
  140329. * Defines a post process to apply tone mapping
  140330. */
  140331. export class TonemapPostProcess extends PostProcess {
  140332. private _operator;
  140333. /** Defines the required exposure adjustement */
  140334. exposureAdjustment: number;
  140335. /**
  140336. * Creates a new TonemapPostProcess
  140337. * @param name defines the name of the postprocess
  140338. * @param _operator defines the operator to use
  140339. * @param exposureAdjustment defines the required exposure adjustement
  140340. * @param camera defines the camera to use (can be null)
  140341. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  140342. * @param engine defines the hosting engine (can be ignore if camera is set)
  140343. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140344. */
  140345. constructor(name: string, _operator: TonemappingOperator,
  140346. /** Defines the required exposure adjustement */
  140347. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  140348. }
  140349. }
  140350. declare module BABYLON {
  140351. /** @hidden */
  140352. export var volumetricLightScatteringPixelShader: {
  140353. name: string;
  140354. shader: string;
  140355. };
  140356. }
  140357. declare module BABYLON {
  140358. /** @hidden */
  140359. export var volumetricLightScatteringPassVertexShader: {
  140360. name: string;
  140361. shader: string;
  140362. };
  140363. }
  140364. declare module BABYLON {
  140365. /** @hidden */
  140366. export var volumetricLightScatteringPassPixelShader: {
  140367. name: string;
  140368. shader: string;
  140369. };
  140370. }
  140371. declare module BABYLON {
  140372. /**
  140373. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  140374. */
  140375. export class VolumetricLightScatteringPostProcess extends PostProcess {
  140376. private _volumetricLightScatteringPass;
  140377. private _volumetricLightScatteringRTT;
  140378. private _viewPort;
  140379. private _screenCoordinates;
  140380. private _cachedDefines;
  140381. /**
  140382. * If not undefined, the mesh position is computed from the attached node position
  140383. */
  140384. attachedNode: {
  140385. position: Vector3;
  140386. };
  140387. /**
  140388. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  140389. */
  140390. customMeshPosition: Vector3;
  140391. /**
  140392. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  140393. */
  140394. useCustomMeshPosition: boolean;
  140395. /**
  140396. * If the post-process should inverse the light scattering direction
  140397. */
  140398. invert: boolean;
  140399. /**
  140400. * The internal mesh used by the post-process
  140401. */
  140402. mesh: Mesh;
  140403. /**
  140404. * @hidden
  140405. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  140406. */
  140407. get useDiffuseColor(): boolean;
  140408. set useDiffuseColor(useDiffuseColor: boolean);
  140409. /**
  140410. * Array containing the excluded meshes not rendered in the internal pass
  140411. */
  140412. excludedMeshes: AbstractMesh[];
  140413. /**
  140414. * Controls the overall intensity of the post-process
  140415. */
  140416. exposure: number;
  140417. /**
  140418. * Dissipates each sample's contribution in range [0, 1]
  140419. */
  140420. decay: number;
  140421. /**
  140422. * Controls the overall intensity of each sample
  140423. */
  140424. weight: number;
  140425. /**
  140426. * Controls the density of each sample
  140427. */
  140428. density: number;
  140429. /**
  140430. * @constructor
  140431. * @param name The post-process name
  140432. * @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)
  140433. * @param camera The camera that the post-process will be attached to
  140434. * @param mesh The mesh used to create the light scattering
  140435. * @param samples The post-process quality, default 100
  140436. * @param samplingModeThe post-process filtering mode
  140437. * @param engine The babylon engine
  140438. * @param reusable If the post-process is reusable
  140439. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  140440. */
  140441. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  140442. /**
  140443. * Returns the string "VolumetricLightScatteringPostProcess"
  140444. * @returns "VolumetricLightScatteringPostProcess"
  140445. */
  140446. getClassName(): string;
  140447. private _isReady;
  140448. /**
  140449. * Sets the new light position for light scattering effect
  140450. * @param position The new custom light position
  140451. */
  140452. setCustomMeshPosition(position: Vector3): void;
  140453. /**
  140454. * Returns the light position for light scattering effect
  140455. * @return Vector3 The custom light position
  140456. */
  140457. getCustomMeshPosition(): Vector3;
  140458. /**
  140459. * Disposes the internal assets and detaches the post-process from the camera
  140460. */
  140461. dispose(camera: Camera): void;
  140462. /**
  140463. * Returns the render target texture used by the post-process
  140464. * @return the render target texture used by the post-process
  140465. */
  140466. getPass(): RenderTargetTexture;
  140467. private _meshExcluded;
  140468. private _createPass;
  140469. private _updateMeshScreenCoordinates;
  140470. /**
  140471. * Creates a default mesh for the Volumeric Light Scattering post-process
  140472. * @param name The mesh name
  140473. * @param scene The scene where to create the mesh
  140474. * @return the default mesh
  140475. */
  140476. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  140477. }
  140478. }
  140479. declare module BABYLON {
  140480. interface Scene {
  140481. /** @hidden (Backing field) */
  140482. _boundingBoxRenderer: BoundingBoxRenderer;
  140483. /** @hidden (Backing field) */
  140484. _forceShowBoundingBoxes: boolean;
  140485. /**
  140486. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  140487. */
  140488. forceShowBoundingBoxes: boolean;
  140489. /**
  140490. * Gets the bounding box renderer associated with the scene
  140491. * @returns a BoundingBoxRenderer
  140492. */
  140493. getBoundingBoxRenderer(): BoundingBoxRenderer;
  140494. }
  140495. interface AbstractMesh {
  140496. /** @hidden (Backing field) */
  140497. _showBoundingBox: boolean;
  140498. /**
  140499. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  140500. */
  140501. showBoundingBox: boolean;
  140502. }
  140503. /**
  140504. * Component responsible of rendering the bounding box of the meshes in a scene.
  140505. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  140506. */
  140507. export class BoundingBoxRenderer implements ISceneComponent {
  140508. /**
  140509. * The component name helpfull to identify the component in the list of scene components.
  140510. */
  140511. readonly name: string;
  140512. /**
  140513. * The scene the component belongs to.
  140514. */
  140515. scene: Scene;
  140516. /**
  140517. * Color of the bounding box lines placed in front of an object
  140518. */
  140519. frontColor: Color3;
  140520. /**
  140521. * Color of the bounding box lines placed behind an object
  140522. */
  140523. backColor: Color3;
  140524. /**
  140525. * Defines if the renderer should show the back lines or not
  140526. */
  140527. showBackLines: boolean;
  140528. /**
  140529. * @hidden
  140530. */
  140531. renderList: SmartArray<BoundingBox>;
  140532. private _colorShader;
  140533. private _vertexBuffers;
  140534. private _indexBuffer;
  140535. private _fillIndexBuffer;
  140536. private _fillIndexData;
  140537. /**
  140538. * Instantiates a new bounding box renderer in a scene.
  140539. * @param scene the scene the renderer renders in
  140540. */
  140541. constructor(scene: Scene);
  140542. /**
  140543. * Registers the component in a given scene
  140544. */
  140545. register(): void;
  140546. private _evaluateSubMesh;
  140547. private _activeMesh;
  140548. private _prepareRessources;
  140549. private _createIndexBuffer;
  140550. /**
  140551. * Rebuilds the elements related to this component in case of
  140552. * context lost for instance.
  140553. */
  140554. rebuild(): void;
  140555. /**
  140556. * @hidden
  140557. */
  140558. reset(): void;
  140559. /**
  140560. * Render the bounding boxes of a specific rendering group
  140561. * @param renderingGroupId defines the rendering group to render
  140562. */
  140563. render(renderingGroupId: number): void;
  140564. /**
  140565. * In case of occlusion queries, we can render the occlusion bounding box through this method
  140566. * @param mesh Define the mesh to render the occlusion bounding box for
  140567. */
  140568. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  140569. /**
  140570. * Dispose and release the resources attached to this renderer.
  140571. */
  140572. dispose(): void;
  140573. }
  140574. }
  140575. declare module BABYLON {
  140576. interface Scene {
  140577. /** @hidden (Backing field) */
  140578. _depthRenderer: {
  140579. [id: string]: DepthRenderer;
  140580. };
  140581. /**
  140582. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  140583. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  140584. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140585. * @returns the created depth renderer
  140586. */
  140587. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  140588. /**
  140589. * Disables a depth renderer for a given camera
  140590. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  140591. */
  140592. disableDepthRenderer(camera?: Nullable<Camera>): void;
  140593. }
  140594. /**
  140595. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  140596. * in several rendering techniques.
  140597. */
  140598. export class DepthRendererSceneComponent implements ISceneComponent {
  140599. /**
  140600. * The component name helpfull to identify the component in the list of scene components.
  140601. */
  140602. readonly name: string;
  140603. /**
  140604. * The scene the component belongs to.
  140605. */
  140606. scene: Scene;
  140607. /**
  140608. * Creates a new instance of the component for the given scene
  140609. * @param scene Defines the scene to register the component in
  140610. */
  140611. constructor(scene: Scene);
  140612. /**
  140613. * Registers the component in a given scene
  140614. */
  140615. register(): void;
  140616. /**
  140617. * Rebuilds the elements related to this component in case of
  140618. * context lost for instance.
  140619. */
  140620. rebuild(): void;
  140621. /**
  140622. * Disposes the component and the associated ressources
  140623. */
  140624. dispose(): void;
  140625. private _gatherRenderTargets;
  140626. private _gatherActiveCameraRenderTargets;
  140627. }
  140628. }
  140629. declare module BABYLON {
  140630. /** @hidden */
  140631. export var outlinePixelShader: {
  140632. name: string;
  140633. shader: string;
  140634. };
  140635. }
  140636. declare module BABYLON {
  140637. /** @hidden */
  140638. export var outlineVertexShader: {
  140639. name: string;
  140640. shader: string;
  140641. };
  140642. }
  140643. declare module BABYLON {
  140644. interface Scene {
  140645. /** @hidden */
  140646. _outlineRenderer: OutlineRenderer;
  140647. /**
  140648. * Gets the outline renderer associated with the scene
  140649. * @returns a OutlineRenderer
  140650. */
  140651. getOutlineRenderer(): OutlineRenderer;
  140652. }
  140653. interface AbstractMesh {
  140654. /** @hidden (Backing field) */
  140655. _renderOutline: boolean;
  140656. /**
  140657. * Gets or sets a boolean indicating if the outline must be rendered as well
  140658. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  140659. */
  140660. renderOutline: boolean;
  140661. /** @hidden (Backing field) */
  140662. _renderOverlay: boolean;
  140663. /**
  140664. * Gets or sets a boolean indicating if the overlay must be rendered as well
  140665. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  140666. */
  140667. renderOverlay: boolean;
  140668. }
  140669. /**
  140670. * This class is responsible to draw bothe outline/overlay of meshes.
  140671. * It should not be used directly but through the available method on mesh.
  140672. */
  140673. export class OutlineRenderer implements ISceneComponent {
  140674. /**
  140675. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140676. */
  140677. private static _StencilReference;
  140678. /**
  140679. * The name of the component. Each component must have a unique name.
  140680. */
  140681. name: string;
  140682. /**
  140683. * The scene the component belongs to.
  140684. */
  140685. scene: Scene;
  140686. /**
  140687. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140688. */
  140689. zOffset: number;
  140690. private _engine;
  140691. private _effect;
  140692. private _cachedDefines;
  140693. private _savedDepthWrite;
  140694. /**
  140695. * Instantiates a new outline renderer. (There could be only one per scene).
  140696. * @param scene Defines the scene it belongs to
  140697. */
  140698. constructor(scene: Scene);
  140699. /**
  140700. * Register the component to one instance of a scene.
  140701. */
  140702. register(): void;
  140703. /**
  140704. * Rebuilds the elements related to this component in case of
  140705. * context lost for instance.
  140706. */
  140707. rebuild(): void;
  140708. /**
  140709. * Disposes the component and the associated ressources.
  140710. */
  140711. dispose(): void;
  140712. /**
  140713. * Renders the outline in the canvas.
  140714. * @param subMesh Defines the sumesh to render
  140715. * @param batch Defines the batch of meshes in case of instances
  140716. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140717. */
  140718. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140719. /**
  140720. * Returns whether or not the outline renderer is ready for a given submesh.
  140721. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140722. * @param subMesh Defines the submesh to check readyness for
  140723. * @param useInstances Defines wheter wee are trying to render instances or not
  140724. * @returns true if ready otherwise false
  140725. */
  140726. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140727. private _beforeRenderingMesh;
  140728. private _afterRenderingMesh;
  140729. }
  140730. }
  140731. declare module BABYLON {
  140732. /**
  140733. * Defines the basic options interface of a Sprite Frame Source Size.
  140734. */
  140735. export interface ISpriteJSONSpriteSourceSize {
  140736. /**
  140737. * number of the original width of the Frame
  140738. */
  140739. w: number;
  140740. /**
  140741. * number of the original height of the Frame
  140742. */
  140743. h: number;
  140744. }
  140745. /**
  140746. * Defines the basic options interface of a Sprite Frame Data.
  140747. */
  140748. export interface ISpriteJSONSpriteFrameData {
  140749. /**
  140750. * number of the x offset of the Frame
  140751. */
  140752. x: number;
  140753. /**
  140754. * number of the y offset of the Frame
  140755. */
  140756. y: number;
  140757. /**
  140758. * number of the width of the Frame
  140759. */
  140760. w: number;
  140761. /**
  140762. * number of the height of the Frame
  140763. */
  140764. h: number;
  140765. }
  140766. /**
  140767. * Defines the basic options interface of a JSON Sprite.
  140768. */
  140769. export interface ISpriteJSONSprite {
  140770. /**
  140771. * string name of the Frame
  140772. */
  140773. filename: string;
  140774. /**
  140775. * ISpriteJSONSpriteFrame basic object of the frame data
  140776. */
  140777. frame: ISpriteJSONSpriteFrameData;
  140778. /**
  140779. * boolean to flag is the frame was rotated.
  140780. */
  140781. rotated: boolean;
  140782. /**
  140783. * boolean to flag is the frame was trimmed.
  140784. */
  140785. trimmed: boolean;
  140786. /**
  140787. * ISpriteJSONSpriteFrame basic object of the source data
  140788. */
  140789. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140790. /**
  140791. * ISpriteJSONSpriteFrame basic object of the source data
  140792. */
  140793. sourceSize: ISpriteJSONSpriteSourceSize;
  140794. }
  140795. /**
  140796. * Defines the basic options interface of a JSON atlas.
  140797. */
  140798. export interface ISpriteJSONAtlas {
  140799. /**
  140800. * Array of objects that contain the frame data.
  140801. */
  140802. frames: Array<ISpriteJSONSprite>;
  140803. /**
  140804. * object basic object containing the sprite meta data.
  140805. */
  140806. meta?: object;
  140807. }
  140808. }
  140809. declare module BABYLON {
  140810. /** @hidden */
  140811. export var spriteMapPixelShader: {
  140812. name: string;
  140813. shader: string;
  140814. };
  140815. }
  140816. declare module BABYLON {
  140817. /** @hidden */
  140818. export var spriteMapVertexShader: {
  140819. name: string;
  140820. shader: string;
  140821. };
  140822. }
  140823. declare module BABYLON {
  140824. /**
  140825. * Defines the basic options interface of a SpriteMap
  140826. */
  140827. export interface ISpriteMapOptions {
  140828. /**
  140829. * Vector2 of the number of cells in the grid.
  140830. */
  140831. stageSize?: Vector2;
  140832. /**
  140833. * Vector2 of the size of the output plane in World Units.
  140834. */
  140835. outputSize?: Vector2;
  140836. /**
  140837. * Vector3 of the position of the output plane in World Units.
  140838. */
  140839. outputPosition?: Vector3;
  140840. /**
  140841. * Vector3 of the rotation of the output plane.
  140842. */
  140843. outputRotation?: Vector3;
  140844. /**
  140845. * number of layers that the system will reserve in resources.
  140846. */
  140847. layerCount?: number;
  140848. /**
  140849. * number of max animation frames a single cell will reserve in resources.
  140850. */
  140851. maxAnimationFrames?: number;
  140852. /**
  140853. * number cell index of the base tile when the system compiles.
  140854. */
  140855. baseTile?: number;
  140856. /**
  140857. * boolean flip the sprite after its been repositioned by the framing data.
  140858. */
  140859. flipU?: boolean;
  140860. /**
  140861. * Vector3 scalar of the global RGB values of the SpriteMap.
  140862. */
  140863. colorMultiply?: Vector3;
  140864. }
  140865. /**
  140866. * Defines the IDisposable interface in order to be cleanable from resources.
  140867. */
  140868. export interface ISpriteMap extends IDisposable {
  140869. /**
  140870. * String name of the SpriteMap.
  140871. */
  140872. name: string;
  140873. /**
  140874. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140875. */
  140876. atlasJSON: ISpriteJSONAtlas;
  140877. /**
  140878. * Texture of the SpriteMap.
  140879. */
  140880. spriteSheet: Texture;
  140881. /**
  140882. * The parameters to initialize the SpriteMap with.
  140883. */
  140884. options: ISpriteMapOptions;
  140885. }
  140886. /**
  140887. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140888. */
  140889. export class SpriteMap implements ISpriteMap {
  140890. /** The Name of the spriteMap */
  140891. name: string;
  140892. /** The JSON file with the frame and meta data */
  140893. atlasJSON: ISpriteJSONAtlas;
  140894. /** The systems Sprite Sheet Texture */
  140895. spriteSheet: Texture;
  140896. /** Arguments passed with the Constructor */
  140897. options: ISpriteMapOptions;
  140898. /** Public Sprite Storage array, parsed from atlasJSON */
  140899. sprites: Array<ISpriteJSONSprite>;
  140900. /** Returns the Number of Sprites in the System */
  140901. get spriteCount(): number;
  140902. /** Returns the Position of Output Plane*/
  140903. get position(): Vector3;
  140904. /** Returns the Position of Output Plane*/
  140905. set position(v: Vector3);
  140906. /** Returns the Rotation of Output Plane*/
  140907. get rotation(): Vector3;
  140908. /** Returns the Rotation of Output Plane*/
  140909. set rotation(v: Vector3);
  140910. /** Sets the AnimationMap*/
  140911. get animationMap(): RawTexture;
  140912. /** Sets the AnimationMap*/
  140913. set animationMap(v: RawTexture);
  140914. /** Scene that the SpriteMap was created in */
  140915. private _scene;
  140916. /** Texture Buffer of Float32 that holds tile frame data*/
  140917. private _frameMap;
  140918. /** Texture Buffers of Float32 that holds tileMap data*/
  140919. private _tileMaps;
  140920. /** Texture Buffer of Float32 that holds Animation Data*/
  140921. private _animationMap;
  140922. /** Custom ShaderMaterial Central to the System*/
  140923. private _material;
  140924. /** Custom ShaderMaterial Central to the System*/
  140925. private _output;
  140926. /** Systems Time Ticker*/
  140927. private _time;
  140928. /**
  140929. * Creates a new SpriteMap
  140930. * @param name defines the SpriteMaps Name
  140931. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140932. * @param spriteSheet is the Texture that the Sprites are on.
  140933. * @param options a basic deployment configuration
  140934. * @param scene The Scene that the map is deployed on
  140935. */
  140936. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140937. /**
  140938. * Returns tileID location
  140939. * @returns Vector2 the cell position ID
  140940. */
  140941. getTileID(): Vector2;
  140942. /**
  140943. * Gets the UV location of the mouse over the SpriteMap.
  140944. * @returns Vector2 the UV position of the mouse interaction
  140945. */
  140946. getMousePosition(): Vector2;
  140947. /**
  140948. * Creates the "frame" texture Buffer
  140949. * -------------------------------------
  140950. * Structure of frames
  140951. * "filename": "Falling-Water-2.png",
  140952. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140953. * "rotated": true,
  140954. * "trimmed": true,
  140955. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140956. * "sourceSize": {"w":32,"h":32}
  140957. * @returns RawTexture of the frameMap
  140958. */
  140959. private _createFrameBuffer;
  140960. /**
  140961. * Creates the tileMap texture Buffer
  140962. * @param buffer normally and array of numbers, or a false to generate from scratch
  140963. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140964. * @returns RawTexture of the tileMap
  140965. */
  140966. private _createTileBuffer;
  140967. /**
  140968. * Modifies the data of the tileMaps
  140969. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140970. * @param pos is the iVector2 Coordinates of the Tile
  140971. * @param tile The SpriteIndex of the new Tile
  140972. */
  140973. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140974. /**
  140975. * Creates the animationMap texture Buffer
  140976. * @param buffer normally and array of numbers, or a false to generate from scratch
  140977. * @returns RawTexture of the animationMap
  140978. */
  140979. private _createTileAnimationBuffer;
  140980. /**
  140981. * Modifies the data of the animationMap
  140982. * @param cellID is the Index of the Sprite
  140983. * @param _frame is the target Animation frame
  140984. * @param toCell is the Target Index of the next frame of the animation
  140985. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140986. * @param speed is a global scalar of the time variable on the map.
  140987. */
  140988. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140989. /**
  140990. * Exports the .tilemaps file
  140991. */
  140992. saveTileMaps(): void;
  140993. /**
  140994. * Imports the .tilemaps file
  140995. * @param url of the .tilemaps file
  140996. */
  140997. loadTileMaps(url: string): void;
  140998. /**
  140999. * Release associated resources
  141000. */
  141001. dispose(): void;
  141002. }
  141003. }
  141004. declare module BABYLON {
  141005. /**
  141006. * Class used to manage multiple sprites of different sizes on the same spritesheet
  141007. * @see http://doc.babylonjs.com/babylon101/sprites
  141008. */
  141009. export class SpritePackedManager extends SpriteManager {
  141010. /** defines the packed manager's name */
  141011. name: string;
  141012. /**
  141013. * Creates a new sprite manager from a packed sprite sheet
  141014. * @param name defines the manager's name
  141015. * @param imgUrl defines the sprite sheet url
  141016. * @param capacity defines the maximum allowed number of sprites
  141017. * @param scene defines the hosting scene
  141018. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  141019. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  141020. * @param samplingMode defines the smapling mode to use with spritesheet
  141021. * @param fromPacked set to true; do not alter
  141022. */
  141023. constructor(
  141024. /** defines the packed manager's name */
  141025. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  141026. }
  141027. }
  141028. declare module BABYLON {
  141029. /**
  141030. * Defines the list of states available for a task inside a AssetsManager
  141031. */
  141032. export enum AssetTaskState {
  141033. /**
  141034. * Initialization
  141035. */
  141036. INIT = 0,
  141037. /**
  141038. * Running
  141039. */
  141040. RUNNING = 1,
  141041. /**
  141042. * Done
  141043. */
  141044. DONE = 2,
  141045. /**
  141046. * Error
  141047. */
  141048. ERROR = 3
  141049. }
  141050. /**
  141051. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  141052. */
  141053. export abstract class AbstractAssetTask {
  141054. /**
  141055. * Task name
  141056. */ name: string;
  141057. /**
  141058. * Callback called when the task is successful
  141059. */
  141060. onSuccess: (task: any) => void;
  141061. /**
  141062. * Callback called when the task is not successful
  141063. */
  141064. onError: (task: any, message?: string, exception?: any) => void;
  141065. /**
  141066. * Creates a new AssetsManager
  141067. * @param name defines the name of the task
  141068. */
  141069. constructor(
  141070. /**
  141071. * Task name
  141072. */ name: string);
  141073. private _isCompleted;
  141074. private _taskState;
  141075. private _errorObject;
  141076. /**
  141077. * Get if the task is completed
  141078. */
  141079. get isCompleted(): boolean;
  141080. /**
  141081. * Gets the current state of the task
  141082. */
  141083. get taskState(): AssetTaskState;
  141084. /**
  141085. * Gets the current error object (if task is in error)
  141086. */
  141087. get errorObject(): {
  141088. message?: string;
  141089. exception?: any;
  141090. };
  141091. /**
  141092. * Internal only
  141093. * @hidden
  141094. */
  141095. _setErrorObject(message?: string, exception?: any): void;
  141096. /**
  141097. * Execute the current task
  141098. * @param scene defines the scene where you want your assets to be loaded
  141099. * @param onSuccess is a callback called when the task is successfully executed
  141100. * @param onError is a callback called if an error occurs
  141101. */
  141102. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141103. /**
  141104. * Execute the current task
  141105. * @param scene defines the scene where you want your assets to be loaded
  141106. * @param onSuccess is a callback called when the task is successfully executed
  141107. * @param onError is a callback called if an error occurs
  141108. */
  141109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141110. /**
  141111. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  141112. * This can be used with failed tasks that have the reason for failure fixed.
  141113. */
  141114. reset(): void;
  141115. private onErrorCallback;
  141116. private onDoneCallback;
  141117. }
  141118. /**
  141119. * Define the interface used by progress events raised during assets loading
  141120. */
  141121. export interface IAssetsProgressEvent {
  141122. /**
  141123. * Defines the number of remaining tasks to process
  141124. */
  141125. remainingCount: number;
  141126. /**
  141127. * Defines the total number of tasks
  141128. */
  141129. totalCount: number;
  141130. /**
  141131. * Defines the task that was just processed
  141132. */
  141133. task: AbstractAssetTask;
  141134. }
  141135. /**
  141136. * Class used to share progress information about assets loading
  141137. */
  141138. export class AssetsProgressEvent implements IAssetsProgressEvent {
  141139. /**
  141140. * Defines the number of remaining tasks to process
  141141. */
  141142. remainingCount: number;
  141143. /**
  141144. * Defines the total number of tasks
  141145. */
  141146. totalCount: number;
  141147. /**
  141148. * Defines the task that was just processed
  141149. */
  141150. task: AbstractAssetTask;
  141151. /**
  141152. * Creates a AssetsProgressEvent
  141153. * @param remainingCount defines the number of remaining tasks to process
  141154. * @param totalCount defines the total number of tasks
  141155. * @param task defines the task that was just processed
  141156. */
  141157. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  141158. }
  141159. /**
  141160. * Define a task used by AssetsManager to load meshes
  141161. */
  141162. export class MeshAssetTask extends AbstractAssetTask {
  141163. /**
  141164. * Defines the name of the task
  141165. */
  141166. name: string;
  141167. /**
  141168. * Defines the list of mesh's names you want to load
  141169. */
  141170. meshesNames: any;
  141171. /**
  141172. * Defines the root url to use as a base to load your meshes and associated resources
  141173. */
  141174. rootUrl: string;
  141175. /**
  141176. * Defines the filename of the scene to load from
  141177. */
  141178. sceneFilename: string;
  141179. /**
  141180. * Gets the list of loaded meshes
  141181. */
  141182. loadedMeshes: Array<AbstractMesh>;
  141183. /**
  141184. * Gets the list of loaded particle systems
  141185. */
  141186. loadedParticleSystems: Array<IParticleSystem>;
  141187. /**
  141188. * Gets the list of loaded skeletons
  141189. */
  141190. loadedSkeletons: Array<Skeleton>;
  141191. /**
  141192. * Gets the list of loaded animation groups
  141193. */
  141194. loadedAnimationGroups: Array<AnimationGroup>;
  141195. /**
  141196. * Callback called when the task is successful
  141197. */
  141198. onSuccess: (task: MeshAssetTask) => void;
  141199. /**
  141200. * Callback called when the task is successful
  141201. */
  141202. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  141203. /**
  141204. * Creates a new MeshAssetTask
  141205. * @param name defines the name of the task
  141206. * @param meshesNames defines the list of mesh's names you want to load
  141207. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  141208. * @param sceneFilename defines the filename of the scene to load from
  141209. */
  141210. constructor(
  141211. /**
  141212. * Defines the name of the task
  141213. */
  141214. name: string,
  141215. /**
  141216. * Defines the list of mesh's names you want to load
  141217. */
  141218. meshesNames: any,
  141219. /**
  141220. * Defines the root url to use as a base to load your meshes and associated resources
  141221. */
  141222. rootUrl: string,
  141223. /**
  141224. * Defines the filename of the scene to load from
  141225. */
  141226. sceneFilename: string);
  141227. /**
  141228. * Execute the current task
  141229. * @param scene defines the scene where you want your assets to be loaded
  141230. * @param onSuccess is a callback called when the task is successfully executed
  141231. * @param onError is a callback called if an error occurs
  141232. */
  141233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141234. }
  141235. /**
  141236. * Define a task used by AssetsManager to load text content
  141237. */
  141238. export class TextFileAssetTask extends AbstractAssetTask {
  141239. /**
  141240. * Defines the name of the task
  141241. */
  141242. name: string;
  141243. /**
  141244. * Defines the location of the file to load
  141245. */
  141246. url: string;
  141247. /**
  141248. * Gets the loaded text string
  141249. */
  141250. text: string;
  141251. /**
  141252. * Callback called when the task is successful
  141253. */
  141254. onSuccess: (task: TextFileAssetTask) => void;
  141255. /**
  141256. * Callback called when the task is successful
  141257. */
  141258. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  141259. /**
  141260. * Creates a new TextFileAssetTask object
  141261. * @param name defines the name of the task
  141262. * @param url defines the location of the file to load
  141263. */
  141264. constructor(
  141265. /**
  141266. * Defines the name of the task
  141267. */
  141268. name: string,
  141269. /**
  141270. * Defines the location of the file to load
  141271. */
  141272. url: string);
  141273. /**
  141274. * Execute the current task
  141275. * @param scene defines the scene where you want your assets to be loaded
  141276. * @param onSuccess is a callback called when the task is successfully executed
  141277. * @param onError is a callback called if an error occurs
  141278. */
  141279. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141280. }
  141281. /**
  141282. * Define a task used by AssetsManager to load binary data
  141283. */
  141284. export class BinaryFileAssetTask extends AbstractAssetTask {
  141285. /**
  141286. * Defines the name of the task
  141287. */
  141288. name: string;
  141289. /**
  141290. * Defines the location of the file to load
  141291. */
  141292. url: string;
  141293. /**
  141294. * Gets the lodaded data (as an array buffer)
  141295. */
  141296. data: ArrayBuffer;
  141297. /**
  141298. * Callback called when the task is successful
  141299. */
  141300. onSuccess: (task: BinaryFileAssetTask) => void;
  141301. /**
  141302. * Callback called when the task is successful
  141303. */
  141304. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  141305. /**
  141306. * Creates a new BinaryFileAssetTask object
  141307. * @param name defines the name of the new task
  141308. * @param url defines the location of the file to load
  141309. */
  141310. constructor(
  141311. /**
  141312. * Defines the name of the task
  141313. */
  141314. name: string,
  141315. /**
  141316. * Defines the location of the file to load
  141317. */
  141318. url: string);
  141319. /**
  141320. * Execute the current task
  141321. * @param scene defines the scene where you want your assets to be loaded
  141322. * @param onSuccess is a callback called when the task is successfully executed
  141323. * @param onError is a callback called if an error occurs
  141324. */
  141325. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141326. }
  141327. /**
  141328. * Define a task used by AssetsManager to load images
  141329. */
  141330. export class ImageAssetTask extends AbstractAssetTask {
  141331. /**
  141332. * Defines the name of the task
  141333. */
  141334. name: string;
  141335. /**
  141336. * Defines the location of the image to load
  141337. */
  141338. url: string;
  141339. /**
  141340. * Gets the loaded images
  141341. */
  141342. image: HTMLImageElement;
  141343. /**
  141344. * Callback called when the task is successful
  141345. */
  141346. onSuccess: (task: ImageAssetTask) => void;
  141347. /**
  141348. * Callback called when the task is successful
  141349. */
  141350. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  141351. /**
  141352. * Creates a new ImageAssetTask
  141353. * @param name defines the name of the task
  141354. * @param url defines the location of the image to load
  141355. */
  141356. constructor(
  141357. /**
  141358. * Defines the name of the task
  141359. */
  141360. name: string,
  141361. /**
  141362. * Defines the location of the image to load
  141363. */
  141364. url: string);
  141365. /**
  141366. * Execute the current task
  141367. * @param scene defines the scene where you want your assets to be loaded
  141368. * @param onSuccess is a callback called when the task is successfully executed
  141369. * @param onError is a callback called if an error occurs
  141370. */
  141371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141372. }
  141373. /**
  141374. * Defines the interface used by texture loading tasks
  141375. */
  141376. export interface ITextureAssetTask<TEX extends BaseTexture> {
  141377. /**
  141378. * Gets the loaded texture
  141379. */
  141380. texture: TEX;
  141381. }
  141382. /**
  141383. * Define a task used by AssetsManager to load 2D textures
  141384. */
  141385. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  141386. /**
  141387. * Defines the name of the task
  141388. */
  141389. name: string;
  141390. /**
  141391. * Defines the location of the file to load
  141392. */
  141393. url: string;
  141394. /**
  141395. * Defines if mipmap should not be generated (default is false)
  141396. */
  141397. noMipmap?: boolean | undefined;
  141398. /**
  141399. * Defines if texture must be inverted on Y axis (default is false)
  141400. */
  141401. invertY?: boolean | undefined;
  141402. /**
  141403. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141404. */
  141405. samplingMode: number;
  141406. /**
  141407. * Gets the loaded texture
  141408. */
  141409. texture: Texture;
  141410. /**
  141411. * Callback called when the task is successful
  141412. */
  141413. onSuccess: (task: TextureAssetTask) => void;
  141414. /**
  141415. * Callback called when the task is successful
  141416. */
  141417. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  141418. /**
  141419. * Creates a new TextureAssetTask object
  141420. * @param name defines the name of the task
  141421. * @param url defines the location of the file to load
  141422. * @param noMipmap defines if mipmap should not be generated (default is false)
  141423. * @param invertY defines if texture must be inverted on Y axis (default is false)
  141424. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141425. */
  141426. constructor(
  141427. /**
  141428. * Defines the name of the task
  141429. */
  141430. name: string,
  141431. /**
  141432. * Defines the location of the file to load
  141433. */
  141434. url: string,
  141435. /**
  141436. * Defines if mipmap should not be generated (default is false)
  141437. */
  141438. noMipmap?: boolean | undefined,
  141439. /**
  141440. * Defines if texture must be inverted on Y axis (default is false)
  141441. */
  141442. invertY?: boolean | undefined,
  141443. /**
  141444. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141445. */
  141446. samplingMode?: number);
  141447. /**
  141448. * Execute the current task
  141449. * @param scene defines the scene where you want your assets to be loaded
  141450. * @param onSuccess is a callback called when the task is successfully executed
  141451. * @param onError is a callback called if an error occurs
  141452. */
  141453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141454. }
  141455. /**
  141456. * Define a task used by AssetsManager to load cube textures
  141457. */
  141458. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  141459. /**
  141460. * Defines the name of the task
  141461. */
  141462. name: string;
  141463. /**
  141464. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141465. */
  141466. url: string;
  141467. /**
  141468. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141469. */
  141470. extensions?: string[] | undefined;
  141471. /**
  141472. * Defines if mipmaps should not be generated (default is false)
  141473. */
  141474. noMipmap?: boolean | undefined;
  141475. /**
  141476. * Defines the explicit list of files (undefined by default)
  141477. */
  141478. files?: string[] | undefined;
  141479. /**
  141480. * Gets the loaded texture
  141481. */
  141482. texture: CubeTexture;
  141483. /**
  141484. * Callback called when the task is successful
  141485. */
  141486. onSuccess: (task: CubeTextureAssetTask) => void;
  141487. /**
  141488. * Callback called when the task is successful
  141489. */
  141490. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  141491. /**
  141492. * Creates a new CubeTextureAssetTask
  141493. * @param name defines the name of the task
  141494. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141495. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141496. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141497. * @param files defines the explicit list of files (undefined by default)
  141498. */
  141499. constructor(
  141500. /**
  141501. * Defines the name of the task
  141502. */
  141503. name: string,
  141504. /**
  141505. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141506. */
  141507. url: string,
  141508. /**
  141509. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141510. */
  141511. extensions?: string[] | undefined,
  141512. /**
  141513. * Defines if mipmaps should not be generated (default is false)
  141514. */
  141515. noMipmap?: boolean | undefined,
  141516. /**
  141517. * Defines the explicit list of files (undefined by default)
  141518. */
  141519. files?: string[] | undefined);
  141520. /**
  141521. * Execute the current task
  141522. * @param scene defines the scene where you want your assets to be loaded
  141523. * @param onSuccess is a callback called when the task is successfully executed
  141524. * @param onError is a callback called if an error occurs
  141525. */
  141526. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141527. }
  141528. /**
  141529. * Define a task used by AssetsManager to load HDR cube textures
  141530. */
  141531. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  141532. /**
  141533. * Defines the name of the task
  141534. */
  141535. name: string;
  141536. /**
  141537. * Defines the location of the file to load
  141538. */
  141539. url: string;
  141540. /**
  141541. * Defines the desired size (the more it increases the longer the generation will be)
  141542. */
  141543. size: number;
  141544. /**
  141545. * Defines if mipmaps should not be generated (default is false)
  141546. */
  141547. noMipmap: boolean;
  141548. /**
  141549. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141550. */
  141551. generateHarmonics: boolean;
  141552. /**
  141553. * 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)
  141554. */
  141555. gammaSpace: boolean;
  141556. /**
  141557. * Internal Use Only
  141558. */
  141559. reserved: boolean;
  141560. /**
  141561. * Gets the loaded texture
  141562. */
  141563. texture: HDRCubeTexture;
  141564. /**
  141565. * Callback called when the task is successful
  141566. */
  141567. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  141568. /**
  141569. * Callback called when the task is successful
  141570. */
  141571. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  141572. /**
  141573. * Creates a new HDRCubeTextureAssetTask object
  141574. * @param name defines the name of the task
  141575. * @param url defines the location of the file to load
  141576. * @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.
  141577. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141578. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141579. * @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)
  141580. * @param reserved Internal use only
  141581. */
  141582. constructor(
  141583. /**
  141584. * Defines the name of the task
  141585. */
  141586. name: string,
  141587. /**
  141588. * Defines the location of the file to load
  141589. */
  141590. url: string,
  141591. /**
  141592. * Defines the desired size (the more it increases the longer the generation will be)
  141593. */
  141594. size: number,
  141595. /**
  141596. * Defines if mipmaps should not be generated (default is false)
  141597. */
  141598. noMipmap?: boolean,
  141599. /**
  141600. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141601. */
  141602. generateHarmonics?: boolean,
  141603. /**
  141604. * 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)
  141605. */
  141606. gammaSpace?: boolean,
  141607. /**
  141608. * Internal Use Only
  141609. */
  141610. reserved?: boolean);
  141611. /**
  141612. * Execute the current task
  141613. * @param scene defines the scene where you want your assets to be loaded
  141614. * @param onSuccess is a callback called when the task is successfully executed
  141615. * @param onError is a callback called if an error occurs
  141616. */
  141617. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141618. }
  141619. /**
  141620. * Define a task used by AssetsManager to load Equirectangular cube textures
  141621. */
  141622. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  141623. /**
  141624. * Defines the name of the task
  141625. */
  141626. name: string;
  141627. /**
  141628. * Defines the location of the file to load
  141629. */
  141630. url: string;
  141631. /**
  141632. * Defines the desired size (the more it increases the longer the generation will be)
  141633. */
  141634. size: number;
  141635. /**
  141636. * Defines if mipmaps should not be generated (default is false)
  141637. */
  141638. noMipmap: boolean;
  141639. /**
  141640. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141641. * but the standard material would require them in Gamma space) (default is true)
  141642. */
  141643. gammaSpace: boolean;
  141644. /**
  141645. * Gets the loaded texture
  141646. */
  141647. texture: EquiRectangularCubeTexture;
  141648. /**
  141649. * Callback called when the task is successful
  141650. */
  141651. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  141652. /**
  141653. * Callback called when the task is successful
  141654. */
  141655. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  141656. /**
  141657. * Creates a new EquiRectangularCubeTextureAssetTask object
  141658. * @param name defines the name of the task
  141659. * @param url defines the location of the file to load
  141660. * @param size defines the desired size (the more it increases the longer the generation will be)
  141661. * If the size is omitted this implies you are using a preprocessed cubemap.
  141662. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141663. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  141664. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  141665. * (default is true)
  141666. */
  141667. constructor(
  141668. /**
  141669. * Defines the name of the task
  141670. */
  141671. name: string,
  141672. /**
  141673. * Defines the location of the file to load
  141674. */
  141675. url: string,
  141676. /**
  141677. * Defines the desired size (the more it increases the longer the generation will be)
  141678. */
  141679. size: number,
  141680. /**
  141681. * Defines if mipmaps should not be generated (default is false)
  141682. */
  141683. noMipmap?: boolean,
  141684. /**
  141685. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141686. * but the standard material would require them in Gamma space) (default is true)
  141687. */
  141688. gammaSpace?: boolean);
  141689. /**
  141690. * Execute the current task
  141691. * @param scene defines the scene where you want your assets to be loaded
  141692. * @param onSuccess is a callback called when the task is successfully executed
  141693. * @param onError is a callback called if an error occurs
  141694. */
  141695. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141696. }
  141697. /**
  141698. * This class can be used to easily import assets into a scene
  141699. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141700. */
  141701. export class AssetsManager {
  141702. private _scene;
  141703. private _isLoading;
  141704. protected _tasks: AbstractAssetTask[];
  141705. protected _waitingTasksCount: number;
  141706. protected _totalTasksCount: number;
  141707. /**
  141708. * Callback called when all tasks are processed
  141709. */
  141710. onFinish: (tasks: AbstractAssetTask[]) => void;
  141711. /**
  141712. * Callback called when a task is successful
  141713. */
  141714. onTaskSuccess: (task: AbstractAssetTask) => void;
  141715. /**
  141716. * Callback called when a task had an error
  141717. */
  141718. onTaskError: (task: AbstractAssetTask) => void;
  141719. /**
  141720. * Callback called when a task is done (whatever the result is)
  141721. */
  141722. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141723. /**
  141724. * Observable called when all tasks are processed
  141725. */
  141726. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141727. /**
  141728. * Observable called when a task had an error
  141729. */
  141730. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141731. /**
  141732. * Observable called when all tasks were executed
  141733. */
  141734. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141735. /**
  141736. * Observable called when a task is done (whatever the result is)
  141737. */
  141738. onProgressObservable: Observable<IAssetsProgressEvent>;
  141739. /**
  141740. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141742. */
  141743. useDefaultLoadingScreen: boolean;
  141744. /**
  141745. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141746. * when all assets have been downloaded.
  141747. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141748. */
  141749. autoHideLoadingUI: boolean;
  141750. /**
  141751. * Creates a new AssetsManager
  141752. * @param scene defines the scene to work on
  141753. */
  141754. constructor(scene: Scene);
  141755. /**
  141756. * Add a MeshAssetTask to the list of active tasks
  141757. * @param taskName defines the name of the new task
  141758. * @param meshesNames defines the name of meshes to load
  141759. * @param rootUrl defines the root url to use to locate files
  141760. * @param sceneFilename defines the filename of the scene file
  141761. * @returns a new MeshAssetTask object
  141762. */
  141763. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141764. /**
  141765. * Add a TextFileAssetTask to the list of active tasks
  141766. * @param taskName defines the name of the new task
  141767. * @param url defines the url of the file to load
  141768. * @returns a new TextFileAssetTask object
  141769. */
  141770. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141771. /**
  141772. * Add a BinaryFileAssetTask to the list of active tasks
  141773. * @param taskName defines the name of the new task
  141774. * @param url defines the url of the file to load
  141775. * @returns a new BinaryFileAssetTask object
  141776. */
  141777. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141778. /**
  141779. * Add a ImageAssetTask to the list of active tasks
  141780. * @param taskName defines the name of the new task
  141781. * @param url defines the url of the file to load
  141782. * @returns a new ImageAssetTask object
  141783. */
  141784. addImageTask(taskName: string, url: string): ImageAssetTask;
  141785. /**
  141786. * Add a TextureAssetTask to the list of active tasks
  141787. * @param taskName defines the name of the new task
  141788. * @param url defines the url of the file to load
  141789. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141790. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141791. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141792. * @returns a new TextureAssetTask object
  141793. */
  141794. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141795. /**
  141796. * Add a CubeTextureAssetTask to the list of active tasks
  141797. * @param taskName defines the name of the new task
  141798. * @param url defines the url of the file to load
  141799. * @param extensions defines the extension to use to load the cube map (can be null)
  141800. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141801. * @param files defines the list of files to load (can be null)
  141802. * @returns a new CubeTextureAssetTask object
  141803. */
  141804. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141805. /**
  141806. *
  141807. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141808. * @param taskName defines the name of the new task
  141809. * @param url defines the url of the file to load
  141810. * @param size defines the size you want for the cubemap (can be null)
  141811. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141812. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141813. * @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)
  141814. * @param reserved Internal use only
  141815. * @returns a new HDRCubeTextureAssetTask object
  141816. */
  141817. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141818. /**
  141819. *
  141820. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141821. * @param taskName defines the name of the new task
  141822. * @param url defines the url of the file to load
  141823. * @param size defines the size you want for the cubemap (can be null)
  141824. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141825. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141826. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141827. * @returns a new EquiRectangularCubeTextureAssetTask object
  141828. */
  141829. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141830. /**
  141831. * Remove a task from the assets manager.
  141832. * @param task the task to remove
  141833. */
  141834. removeTask(task: AbstractAssetTask): void;
  141835. private _decreaseWaitingTasksCount;
  141836. private _runTask;
  141837. /**
  141838. * Reset the AssetsManager and remove all tasks
  141839. * @return the current instance of the AssetsManager
  141840. */
  141841. reset(): AssetsManager;
  141842. /**
  141843. * Start the loading process
  141844. * @return the current instance of the AssetsManager
  141845. */
  141846. load(): AssetsManager;
  141847. /**
  141848. * Start the loading process as an async operation
  141849. * @return a promise returning the list of failed tasks
  141850. */
  141851. loadAsync(): Promise<void>;
  141852. }
  141853. }
  141854. declare module BABYLON {
  141855. /**
  141856. * Wrapper class for promise with external resolve and reject.
  141857. */
  141858. export class Deferred<T> {
  141859. /**
  141860. * The promise associated with this deferred object.
  141861. */
  141862. readonly promise: Promise<T>;
  141863. private _resolve;
  141864. private _reject;
  141865. /**
  141866. * The resolve method of the promise associated with this deferred object.
  141867. */
  141868. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141869. /**
  141870. * The reject method of the promise associated with this deferred object.
  141871. */
  141872. get reject(): (reason?: any) => void;
  141873. /**
  141874. * Constructor for this deferred object.
  141875. */
  141876. constructor();
  141877. }
  141878. }
  141879. declare module BABYLON {
  141880. /**
  141881. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141882. */
  141883. export class MeshExploder {
  141884. private _centerMesh;
  141885. private _meshes;
  141886. private _meshesOrigins;
  141887. private _toCenterVectors;
  141888. private _scaledDirection;
  141889. private _newPosition;
  141890. private _centerPosition;
  141891. /**
  141892. * Explodes meshes from a center mesh.
  141893. * @param meshes The meshes to explode.
  141894. * @param centerMesh The mesh to be center of explosion.
  141895. */
  141896. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141897. private _setCenterMesh;
  141898. /**
  141899. * Get class name
  141900. * @returns "MeshExploder"
  141901. */
  141902. getClassName(): string;
  141903. /**
  141904. * "Exploded meshes"
  141905. * @returns Array of meshes with the centerMesh at index 0.
  141906. */
  141907. getMeshes(): Array<Mesh>;
  141908. /**
  141909. * Explodes meshes giving a specific direction
  141910. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141911. */
  141912. explode(direction?: number): void;
  141913. }
  141914. }
  141915. declare module BABYLON {
  141916. /**
  141917. * Class used to help managing file picking and drag'n'drop
  141918. */
  141919. export class FilesInput {
  141920. /**
  141921. * List of files ready to be loaded
  141922. */
  141923. static get FilesToLoad(): {
  141924. [key: string]: File;
  141925. };
  141926. /**
  141927. * Callback called when a file is processed
  141928. */
  141929. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141930. private _engine;
  141931. private _currentScene;
  141932. private _sceneLoadedCallback;
  141933. private _progressCallback;
  141934. private _additionalRenderLoopLogicCallback;
  141935. private _textureLoadingCallback;
  141936. private _startingProcessingFilesCallback;
  141937. private _onReloadCallback;
  141938. private _errorCallback;
  141939. private _elementToMonitor;
  141940. private _sceneFileToLoad;
  141941. private _filesToLoad;
  141942. /**
  141943. * Creates a new FilesInput
  141944. * @param engine defines the rendering engine
  141945. * @param scene defines the hosting scene
  141946. * @param sceneLoadedCallback callback called when scene is loaded
  141947. * @param progressCallback callback called to track progress
  141948. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141949. * @param textureLoadingCallback callback called when a texture is loading
  141950. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141951. * @param onReloadCallback callback called when a reload is requested
  141952. * @param errorCallback callback call if an error occurs
  141953. */
  141954. 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);
  141955. private _dragEnterHandler;
  141956. private _dragOverHandler;
  141957. private _dropHandler;
  141958. /**
  141959. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141960. * @param elementToMonitor defines the DOM element to track
  141961. */
  141962. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141963. /**
  141964. * Release all associated resources
  141965. */
  141966. dispose(): void;
  141967. private renderFunction;
  141968. private drag;
  141969. private drop;
  141970. private _traverseFolder;
  141971. private _processFiles;
  141972. /**
  141973. * Load files from a drop event
  141974. * @param event defines the drop event to use as source
  141975. */
  141976. loadFiles(event: any): void;
  141977. private _processReload;
  141978. /**
  141979. * Reload the current scene from the loaded files
  141980. */
  141981. reload(): void;
  141982. }
  141983. }
  141984. declare module BABYLON {
  141985. /**
  141986. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141988. */
  141989. export class SceneOptimization {
  141990. /**
  141991. * Defines the priority of this optimization (0 by default which means first in the list)
  141992. */
  141993. priority: number;
  141994. /**
  141995. * Gets a string describing the action executed by the current optimization
  141996. * @returns description string
  141997. */
  141998. getDescription(): string;
  141999. /**
  142000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142001. * @param scene defines the current scene where to apply this optimization
  142002. * @param optimizer defines the current optimizer
  142003. * @returns true if everything that can be done was applied
  142004. */
  142005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142006. /**
  142007. * Creates the SceneOptimization object
  142008. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142009. * @param desc defines the description associated with the optimization
  142010. */
  142011. constructor(
  142012. /**
  142013. * Defines the priority of this optimization (0 by default which means first in the list)
  142014. */
  142015. priority?: number);
  142016. }
  142017. /**
  142018. * Defines an optimization used to reduce the size of render target textures
  142019. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142020. */
  142021. export class TextureOptimization extends SceneOptimization {
  142022. /**
  142023. * Defines the priority of this optimization (0 by default which means first in the list)
  142024. */
  142025. priority: number;
  142026. /**
  142027. * 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
  142028. */
  142029. maximumSize: number;
  142030. /**
  142031. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  142032. */
  142033. step: number;
  142034. /**
  142035. * Gets a string describing the action executed by the current optimization
  142036. * @returns description string
  142037. */
  142038. getDescription(): string;
  142039. /**
  142040. * Creates the TextureOptimization object
  142041. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142042. * @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
  142043. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  142044. */
  142045. constructor(
  142046. /**
  142047. * Defines the priority of this optimization (0 by default which means first in the list)
  142048. */
  142049. priority?: number,
  142050. /**
  142051. * 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
  142052. */
  142053. maximumSize?: number,
  142054. /**
  142055. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  142056. */
  142057. step?: number);
  142058. /**
  142059. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142060. * @param scene defines the current scene where to apply this optimization
  142061. * @param optimizer defines the current optimizer
  142062. * @returns true if everything that can be done was applied
  142063. */
  142064. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142065. }
  142066. /**
  142067. * Defines an optimization used to increase or decrease the rendering resolution
  142068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142069. */
  142070. export class HardwareScalingOptimization extends SceneOptimization {
  142071. /**
  142072. * Defines the priority of this optimization (0 by default which means first in the list)
  142073. */
  142074. priority: number;
  142075. /**
  142076. * Defines the maximum scale to use (2 by default)
  142077. */
  142078. maximumScale: number;
  142079. /**
  142080. * Defines the step to use between two passes (0.5 by default)
  142081. */
  142082. step: number;
  142083. private _currentScale;
  142084. private _directionOffset;
  142085. /**
  142086. * Gets a string describing the action executed by the current optimization
  142087. * @return description string
  142088. */
  142089. getDescription(): string;
  142090. /**
  142091. * Creates the HardwareScalingOptimization object
  142092. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142093. * @param maximumScale defines the maximum scale to use (2 by default)
  142094. * @param step defines the step to use between two passes (0.5 by default)
  142095. */
  142096. constructor(
  142097. /**
  142098. * Defines the priority of this optimization (0 by default which means first in the list)
  142099. */
  142100. priority?: number,
  142101. /**
  142102. * Defines the maximum scale to use (2 by default)
  142103. */
  142104. maximumScale?: number,
  142105. /**
  142106. * Defines the step to use between two passes (0.5 by default)
  142107. */
  142108. step?: number);
  142109. /**
  142110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142111. * @param scene defines the current scene where to apply this optimization
  142112. * @param optimizer defines the current optimizer
  142113. * @returns true if everything that can be done was applied
  142114. */
  142115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142116. }
  142117. /**
  142118. * Defines an optimization used to remove shadows
  142119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142120. */
  142121. export class ShadowsOptimization extends SceneOptimization {
  142122. /**
  142123. * Gets a string describing the action executed by the current optimization
  142124. * @return description string
  142125. */
  142126. getDescription(): string;
  142127. /**
  142128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142129. * @param scene defines the current scene where to apply this optimization
  142130. * @param optimizer defines the current optimizer
  142131. * @returns true if everything that can be done was applied
  142132. */
  142133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142134. }
  142135. /**
  142136. * Defines an optimization used to turn post-processes off
  142137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142138. */
  142139. export class PostProcessesOptimization extends SceneOptimization {
  142140. /**
  142141. * Gets a string describing the action executed by the current optimization
  142142. * @return description string
  142143. */
  142144. getDescription(): string;
  142145. /**
  142146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142147. * @param scene defines the current scene where to apply this optimization
  142148. * @param optimizer defines the current optimizer
  142149. * @returns true if everything that can be done was applied
  142150. */
  142151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142152. }
  142153. /**
  142154. * Defines an optimization used to turn lens flares off
  142155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142156. */
  142157. export class LensFlaresOptimization extends SceneOptimization {
  142158. /**
  142159. * Gets a string describing the action executed by the current optimization
  142160. * @return description string
  142161. */
  142162. getDescription(): string;
  142163. /**
  142164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142165. * @param scene defines the current scene where to apply this optimization
  142166. * @param optimizer defines the current optimizer
  142167. * @returns true if everything that can be done was applied
  142168. */
  142169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142170. }
  142171. /**
  142172. * Defines an optimization based on user defined callback.
  142173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142174. */
  142175. export class CustomOptimization extends SceneOptimization {
  142176. /**
  142177. * Callback called to apply the custom optimization.
  142178. */
  142179. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  142180. /**
  142181. * Callback called to get custom description
  142182. */
  142183. onGetDescription: () => string;
  142184. /**
  142185. * Gets a string describing the action executed by the current optimization
  142186. * @returns description string
  142187. */
  142188. getDescription(): string;
  142189. /**
  142190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142191. * @param scene defines the current scene where to apply this optimization
  142192. * @param optimizer defines the current optimizer
  142193. * @returns true if everything that can be done was applied
  142194. */
  142195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142196. }
  142197. /**
  142198. * Defines an optimization used to turn particles off
  142199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142200. */
  142201. export class ParticlesOptimization extends SceneOptimization {
  142202. /**
  142203. * Gets a string describing the action executed by the current optimization
  142204. * @return description string
  142205. */
  142206. getDescription(): string;
  142207. /**
  142208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142209. * @param scene defines the current scene where to apply this optimization
  142210. * @param optimizer defines the current optimizer
  142211. * @returns true if everything that can be done was applied
  142212. */
  142213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142214. }
  142215. /**
  142216. * Defines an optimization used to turn render targets off
  142217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142218. */
  142219. export class RenderTargetsOptimization extends SceneOptimization {
  142220. /**
  142221. * Gets a string describing the action executed by the current optimization
  142222. * @return description string
  142223. */
  142224. getDescription(): string;
  142225. /**
  142226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142227. * @param scene defines the current scene where to apply this optimization
  142228. * @param optimizer defines the current optimizer
  142229. * @returns true if everything that can be done was applied
  142230. */
  142231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142232. }
  142233. /**
  142234. * Defines an optimization used to merge meshes with compatible materials
  142235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142236. */
  142237. export class MergeMeshesOptimization extends SceneOptimization {
  142238. private static _UpdateSelectionTree;
  142239. /**
  142240. * Gets or sets a boolean which defines if optimization octree has to be updated
  142241. */
  142242. static get UpdateSelectionTree(): boolean;
  142243. /**
  142244. * Gets or sets a boolean which defines if optimization octree has to be updated
  142245. */
  142246. static set UpdateSelectionTree(value: boolean);
  142247. /**
  142248. * Gets a string describing the action executed by the current optimization
  142249. * @return description string
  142250. */
  142251. getDescription(): string;
  142252. private _canBeMerged;
  142253. /**
  142254. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142255. * @param scene defines the current scene where to apply this optimization
  142256. * @param optimizer defines the current optimizer
  142257. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  142258. * @returns true if everything that can be done was applied
  142259. */
  142260. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  142261. }
  142262. /**
  142263. * Defines a list of options used by SceneOptimizer
  142264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142265. */
  142266. export class SceneOptimizerOptions {
  142267. /**
  142268. * Defines the target frame rate to reach (60 by default)
  142269. */
  142270. targetFrameRate: number;
  142271. /**
  142272. * Defines the interval between two checkes (2000ms by default)
  142273. */
  142274. trackerDuration: number;
  142275. /**
  142276. * Gets the list of optimizations to apply
  142277. */
  142278. optimizations: SceneOptimization[];
  142279. /**
  142280. * Creates a new list of options used by SceneOptimizer
  142281. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  142282. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  142283. */
  142284. constructor(
  142285. /**
  142286. * Defines the target frame rate to reach (60 by default)
  142287. */
  142288. targetFrameRate?: number,
  142289. /**
  142290. * Defines the interval between two checkes (2000ms by default)
  142291. */
  142292. trackerDuration?: number);
  142293. /**
  142294. * Add a new optimization
  142295. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  142296. * @returns the current SceneOptimizerOptions
  142297. */
  142298. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  142299. /**
  142300. * Add a new custom optimization
  142301. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  142302. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  142303. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142304. * @returns the current SceneOptimizerOptions
  142305. */
  142306. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  142307. /**
  142308. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  142309. * @param targetFrameRate defines the target frame rate (60 by default)
  142310. * @returns a SceneOptimizerOptions object
  142311. */
  142312. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142313. /**
  142314. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  142315. * @param targetFrameRate defines the target frame rate (60 by default)
  142316. * @returns a SceneOptimizerOptions object
  142317. */
  142318. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142319. /**
  142320. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  142321. * @param targetFrameRate defines the target frame rate (60 by default)
  142322. * @returns a SceneOptimizerOptions object
  142323. */
  142324. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142325. }
  142326. /**
  142327. * Class used to run optimizations in order to reach a target frame rate
  142328. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142329. */
  142330. export class SceneOptimizer implements IDisposable {
  142331. private _isRunning;
  142332. private _options;
  142333. private _scene;
  142334. private _currentPriorityLevel;
  142335. private _targetFrameRate;
  142336. private _trackerDuration;
  142337. private _currentFrameRate;
  142338. private _sceneDisposeObserver;
  142339. private _improvementMode;
  142340. /**
  142341. * Defines an observable called when the optimizer reaches the target frame rate
  142342. */
  142343. onSuccessObservable: Observable<SceneOptimizer>;
  142344. /**
  142345. * Defines an observable called when the optimizer enables an optimization
  142346. */
  142347. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  142348. /**
  142349. * Defines an observable called when the optimizer is not able to reach the target frame rate
  142350. */
  142351. onFailureObservable: Observable<SceneOptimizer>;
  142352. /**
  142353. * Gets a boolean indicating if the optimizer is in improvement mode
  142354. */
  142355. get isInImprovementMode(): boolean;
  142356. /**
  142357. * Gets the current priority level (0 at start)
  142358. */
  142359. get currentPriorityLevel(): number;
  142360. /**
  142361. * Gets the current frame rate checked by the SceneOptimizer
  142362. */
  142363. get currentFrameRate(): number;
  142364. /**
  142365. * Gets or sets the current target frame rate (60 by default)
  142366. */
  142367. get targetFrameRate(): number;
  142368. /**
  142369. * Gets or sets the current target frame rate (60 by default)
  142370. */
  142371. set targetFrameRate(value: number);
  142372. /**
  142373. * Gets or sets the current interval between two checks (every 2000ms by default)
  142374. */
  142375. get trackerDuration(): number;
  142376. /**
  142377. * Gets or sets the current interval between two checks (every 2000ms by default)
  142378. */
  142379. set trackerDuration(value: number);
  142380. /**
  142381. * Gets the list of active optimizations
  142382. */
  142383. get optimizations(): SceneOptimization[];
  142384. /**
  142385. * Creates a new SceneOptimizer
  142386. * @param scene defines the scene to work on
  142387. * @param options defines the options to use with the SceneOptimizer
  142388. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  142389. * @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)
  142390. */
  142391. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  142392. /**
  142393. * Stops the current optimizer
  142394. */
  142395. stop(): void;
  142396. /**
  142397. * Reset the optimizer to initial step (current priority level = 0)
  142398. */
  142399. reset(): void;
  142400. /**
  142401. * Start the optimizer. By default it will try to reach a specific framerate
  142402. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  142403. */
  142404. start(): void;
  142405. private _checkCurrentState;
  142406. /**
  142407. * Release all resources
  142408. */
  142409. dispose(): void;
  142410. /**
  142411. * Helper function to create a SceneOptimizer with one single line of code
  142412. * @param scene defines the scene to work on
  142413. * @param options defines the options to use with the SceneOptimizer
  142414. * @param onSuccess defines a callback to call on success
  142415. * @param onFailure defines a callback to call on failure
  142416. * @returns the new SceneOptimizer object
  142417. */
  142418. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  142419. }
  142420. }
  142421. declare module BABYLON {
  142422. /**
  142423. * Class used to serialize a scene into a string
  142424. */
  142425. export class SceneSerializer {
  142426. /**
  142427. * Clear cache used by a previous serialization
  142428. */
  142429. static ClearCache(): void;
  142430. /**
  142431. * Serialize a scene into a JSON compatible object
  142432. * @param scene defines the scene to serialize
  142433. * @returns a JSON compatible object
  142434. */
  142435. static Serialize(scene: Scene): any;
  142436. /**
  142437. * Serialize a mesh into a JSON compatible object
  142438. * @param toSerialize defines the mesh to serialize
  142439. * @param withParents defines if parents must be serialized as well
  142440. * @param withChildren defines if children must be serialized as well
  142441. * @returns a JSON compatible object
  142442. */
  142443. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  142444. }
  142445. }
  142446. declare module BABYLON {
  142447. /**
  142448. * Class used to host texture specific utilities
  142449. */
  142450. export class TextureTools {
  142451. /**
  142452. * Uses the GPU to create a copy texture rescaled at a given size
  142453. * @param texture Texture to copy from
  142454. * @param width defines the desired width
  142455. * @param height defines the desired height
  142456. * @param useBilinearMode defines if bilinear mode has to be used
  142457. * @return the generated texture
  142458. */
  142459. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  142460. }
  142461. }
  142462. declare module BABYLON {
  142463. /**
  142464. * This represents the different options available for the video capture.
  142465. */
  142466. export interface VideoRecorderOptions {
  142467. /** Defines the mime type of the video. */
  142468. mimeType: string;
  142469. /** Defines the FPS the video should be recorded at. */
  142470. fps: number;
  142471. /** Defines the chunk size for the recording data. */
  142472. recordChunckSize: number;
  142473. /** The audio tracks to attach to the recording. */
  142474. audioTracks?: MediaStreamTrack[];
  142475. }
  142476. /**
  142477. * This can help with recording videos from BabylonJS.
  142478. * This is based on the available WebRTC functionalities of the browser.
  142479. *
  142480. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  142481. */
  142482. export class VideoRecorder {
  142483. private static readonly _defaultOptions;
  142484. /**
  142485. * Returns whether or not the VideoRecorder is available in your browser.
  142486. * @param engine Defines the Babylon Engine.
  142487. * @returns true if supported otherwise false.
  142488. */
  142489. static IsSupported(engine: Engine): boolean;
  142490. private readonly _options;
  142491. private _canvas;
  142492. private _mediaRecorder;
  142493. private _recordedChunks;
  142494. private _fileName;
  142495. private _resolve;
  142496. private _reject;
  142497. /**
  142498. * True when a recording is already in progress.
  142499. */
  142500. get isRecording(): boolean;
  142501. /**
  142502. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  142503. * @param engine Defines the BabylonJS Engine you wish to record.
  142504. * @param options Defines options that can be used to customize the capture.
  142505. */
  142506. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  142507. /**
  142508. * Stops the current recording before the default capture timeout passed in the startRecording function.
  142509. */
  142510. stopRecording(): void;
  142511. /**
  142512. * Starts recording the canvas for a max duration specified in parameters.
  142513. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  142514. * If null no automatic download will start and you can rely on the promise to get the data back.
  142515. * @param maxDuration Defines the maximum recording time in seconds.
  142516. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  142517. * @return A promise callback at the end of the recording with the video data in Blob.
  142518. */
  142519. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  142520. /**
  142521. * Releases internal resources used during the recording.
  142522. */
  142523. dispose(): void;
  142524. private _handleDataAvailable;
  142525. private _handleError;
  142526. private _handleStop;
  142527. }
  142528. }
  142529. declare module BABYLON {
  142530. /**
  142531. * Class containing a set of static utilities functions for screenshots
  142532. */
  142533. export class ScreenshotTools {
  142534. /**
  142535. * Captures a screenshot of the current rendering
  142536. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142537. * @param engine defines the rendering engine
  142538. * @param camera defines the source camera
  142539. * @param size This parameter can be set to a single number or to an object with the
  142540. * following (optional) properties: precision, width, height. If a single number is passed,
  142541. * it will be used for both width and height. If an object is passed, the screenshot size
  142542. * will be derived from the parameters. The precision property is a multiplier allowing
  142543. * rendering at a higher or lower resolution
  142544. * @param successCallback defines the callback receives a single parameter which contains the
  142545. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142546. * src parameter of an <img> to display it
  142547. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142548. * Check your browser for supported MIME types
  142549. */
  142550. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  142551. /**
  142552. * Captures a screenshot of the current rendering
  142553. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142554. * @param engine defines the rendering engine
  142555. * @param camera defines the source camera
  142556. * @param size This parameter can be set to a single number or to an object with the
  142557. * following (optional) properties: precision, width, height. If a single number is passed,
  142558. * it will be used for both width and height. If an object is passed, the screenshot size
  142559. * will be derived from the parameters. The precision property is a multiplier allowing
  142560. * rendering at a higher or lower resolution
  142561. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142562. * Check your browser for supported MIME types
  142563. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142564. * to the src parameter of an <img> to display it
  142565. */
  142566. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  142567. /**
  142568. * Generates an image screenshot from the specified camera.
  142569. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142570. * @param engine The engine to use for rendering
  142571. * @param camera The camera to use for rendering
  142572. * @param size This parameter can be set to a single number or to an object with the
  142573. * following (optional) properties: precision, width, height. If a single number is passed,
  142574. * it will be used for both width and height. If an object is passed, the screenshot size
  142575. * will be derived from the parameters. The precision property is a multiplier allowing
  142576. * rendering at a higher or lower resolution
  142577. * @param successCallback The callback receives a single parameter which contains the
  142578. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142579. * src parameter of an <img> to display it
  142580. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142581. * Check your browser for supported MIME types
  142582. * @param samples Texture samples (default: 1)
  142583. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142584. * @param fileName A name for for the downloaded file.
  142585. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142586. */
  142587. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  142588. /**
  142589. * Generates an image screenshot from the specified camera.
  142590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142591. * @param engine The engine to use for rendering
  142592. * @param camera The camera to use for rendering
  142593. * @param size This parameter can be set to a single number or to an object with the
  142594. * following (optional) properties: precision, width, height. If a single number is passed,
  142595. * it will be used for both width and height. If an object is passed, the screenshot size
  142596. * will be derived from the parameters. The precision property is a multiplier allowing
  142597. * rendering at a higher or lower resolution
  142598. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142599. * Check your browser for supported MIME types
  142600. * @param samples Texture samples (default: 1)
  142601. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142602. * @param fileName A name for for the downloaded file.
  142603. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142604. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142605. * to the src parameter of an <img> to display it
  142606. */
  142607. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  142608. /**
  142609. * Gets height and width for screenshot size
  142610. * @private
  142611. */
  142612. private static _getScreenshotSize;
  142613. }
  142614. }
  142615. declare module BABYLON {
  142616. /**
  142617. * Interface for a data buffer
  142618. */
  142619. export interface IDataBuffer {
  142620. /**
  142621. * Reads bytes from the data buffer.
  142622. * @param byteOffset The byte offset to read
  142623. * @param byteLength The byte length to read
  142624. * @returns A promise that resolves when the bytes are read
  142625. */
  142626. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  142627. /**
  142628. * The byte length of the buffer.
  142629. */
  142630. readonly byteLength: number;
  142631. }
  142632. /**
  142633. * Utility class for reading from a data buffer
  142634. */
  142635. export class DataReader {
  142636. /**
  142637. * The data buffer associated with this data reader.
  142638. */
  142639. readonly buffer: IDataBuffer;
  142640. /**
  142641. * The current byte offset from the beginning of the data buffer.
  142642. */
  142643. byteOffset: number;
  142644. private _dataView;
  142645. private _dataByteOffset;
  142646. /**
  142647. * Constructor
  142648. * @param buffer The buffer to read
  142649. */
  142650. constructor(buffer: IDataBuffer);
  142651. /**
  142652. * Loads the given byte length.
  142653. * @param byteLength The byte length to load
  142654. * @returns A promise that resolves when the load is complete
  142655. */
  142656. loadAsync(byteLength: number): Promise<void>;
  142657. /**
  142658. * Read a unsigned 32-bit integer from the currently loaded data range.
  142659. * @returns The 32-bit integer read
  142660. */
  142661. readUint32(): number;
  142662. /**
  142663. * Read a byte array from the currently loaded data range.
  142664. * @param byteLength The byte length to read
  142665. * @returns The byte array read
  142666. */
  142667. readUint8Array(byteLength: number): Uint8Array;
  142668. /**
  142669. * Read a string from the currently loaded data range.
  142670. * @param byteLength The byte length to read
  142671. * @returns The string read
  142672. */
  142673. readString(byteLength: number): string;
  142674. /**
  142675. * Skips the given byte length the currently loaded data range.
  142676. * @param byteLength The byte length to skip
  142677. */
  142678. skipBytes(byteLength: number): void;
  142679. }
  142680. }
  142681. declare module BABYLON {
  142682. /**
  142683. * Class for storing data to local storage if available or in-memory storage otherwise
  142684. */
  142685. export class DataStorage {
  142686. private static _Storage;
  142687. private static _GetStorage;
  142688. /**
  142689. * Reads a string from the data storage
  142690. * @param key The key to read
  142691. * @param defaultValue The value if the key doesn't exist
  142692. * @returns The string value
  142693. */
  142694. static ReadString(key: string, defaultValue: string): string;
  142695. /**
  142696. * Writes a string to the data storage
  142697. * @param key The key to write
  142698. * @param value The value to write
  142699. */
  142700. static WriteString(key: string, value: string): void;
  142701. /**
  142702. * Reads a boolean from the data storage
  142703. * @param key The key to read
  142704. * @param defaultValue The value if the key doesn't exist
  142705. * @returns The boolean value
  142706. */
  142707. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  142708. /**
  142709. * Writes a boolean to the data storage
  142710. * @param key The key to write
  142711. * @param value The value to write
  142712. */
  142713. static WriteBoolean(key: string, value: boolean): void;
  142714. /**
  142715. * Reads a number from the data storage
  142716. * @param key The key to read
  142717. * @param defaultValue The value if the key doesn't exist
  142718. * @returns The number value
  142719. */
  142720. static ReadNumber(key: string, defaultValue: number): number;
  142721. /**
  142722. * Writes a number to the data storage
  142723. * @param key The key to write
  142724. * @param value The value to write
  142725. */
  142726. static WriteNumber(key: string, value: number): void;
  142727. }
  142728. }
  142729. declare module BABYLON {
  142730. /**
  142731. * Options used for hit testing
  142732. */
  142733. export interface IWebXRHitTestOptions {
  142734. /**
  142735. * Only test when user interacted with the scene. Default - hit test every frame
  142736. */
  142737. testOnPointerDownOnly?: boolean;
  142738. /**
  142739. * The node to use to transform the local results to world coordinates
  142740. */
  142741. worldParentNode?: TransformNode;
  142742. }
  142743. /**
  142744. * Interface defining the babylon result of raycasting/hit-test
  142745. */
  142746. export interface IWebXRHitResult {
  142747. /**
  142748. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142749. */
  142750. transformationMatrix: Matrix;
  142751. /**
  142752. * The native hit test result
  142753. */
  142754. xrHitResult: XRHitResult;
  142755. }
  142756. /**
  142757. * The currently-working hit-test module.
  142758. * Hit test (or Ray-casting) is used to interact with the real world.
  142759. * For further information read here - https://github.com/immersive-web/hit-test
  142760. */
  142761. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142762. /**
  142763. * options to use when constructing this feature
  142764. */
  142765. readonly options: IWebXRHitTestOptions;
  142766. private _direction;
  142767. private _mat;
  142768. private _onSelectEnabled;
  142769. private _origin;
  142770. /**
  142771. * The module's name
  142772. */
  142773. static readonly Name: string;
  142774. /**
  142775. * The (Babylon) version of this module.
  142776. * This is an integer representing the implementation version.
  142777. * This number does not correspond to the WebXR specs version
  142778. */
  142779. static readonly Version: number;
  142780. /**
  142781. * Populated with the last native XR Hit Results
  142782. */
  142783. lastNativeXRHitResults: XRHitResult[];
  142784. /**
  142785. * Triggered when new babylon (transformed) hit test results are available
  142786. */
  142787. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142788. /**
  142789. * Creates a new instance of the (legacy version) hit test feature
  142790. * @param _xrSessionManager an instance of WebXRSessionManager
  142791. * @param options options to use when constructing this feature
  142792. */
  142793. constructor(_xrSessionManager: WebXRSessionManager,
  142794. /**
  142795. * options to use when constructing this feature
  142796. */
  142797. options?: IWebXRHitTestOptions);
  142798. /**
  142799. * execute a hit test with an XR Ray
  142800. *
  142801. * @param xrSession a native xrSession that will execute this hit test
  142802. * @param xrRay the ray (position and direction) to use for ray-casting
  142803. * @param referenceSpace native XR reference space to use for the hit-test
  142804. * @param filter filter function that will filter the results
  142805. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142806. */
  142807. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142808. /**
  142809. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142810. * @param event the (select) event to use to select with
  142811. * @param referenceSpace the reference space to use for this hit test
  142812. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142813. */
  142814. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142815. /**
  142816. * attach this feature
  142817. * Will usually be called by the features manager
  142818. *
  142819. * @returns true if successful.
  142820. */
  142821. attach(): boolean;
  142822. /**
  142823. * detach this feature.
  142824. * Will usually be called by the features manager
  142825. *
  142826. * @returns true if successful.
  142827. */
  142828. detach(): boolean;
  142829. /**
  142830. * Dispose this feature and all of the resources attached
  142831. */
  142832. dispose(): void;
  142833. protected _onXRFrame(frame: XRFrame): void;
  142834. private _onHitTestResults;
  142835. private _onSelect;
  142836. }
  142837. }
  142838. declare module BABYLON {
  142839. /**
  142840. * Options used in the plane detector module
  142841. */
  142842. export interface IWebXRPlaneDetectorOptions {
  142843. /**
  142844. * The node to use to transform the local results to world coordinates
  142845. */
  142846. worldParentNode?: TransformNode;
  142847. }
  142848. /**
  142849. * A babylon interface for a WebXR plane.
  142850. * A Plane is actually a polygon, built from N points in space
  142851. *
  142852. * Supported in chrome 79, not supported in canary 81 ATM
  142853. */
  142854. export interface IWebXRPlane {
  142855. /**
  142856. * a babylon-assigned ID for this polygon
  142857. */
  142858. id: number;
  142859. /**
  142860. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142861. */
  142862. polygonDefinition: Array<Vector3>;
  142863. /**
  142864. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142865. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142866. */
  142867. transformationMatrix: Matrix;
  142868. /**
  142869. * the native xr-plane object
  142870. */
  142871. xrPlane: XRPlane;
  142872. }
  142873. /**
  142874. * The plane detector is used to detect planes in the real world when in AR
  142875. * For more information see https://github.com/immersive-web/real-world-geometry/
  142876. */
  142877. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142878. private _options;
  142879. private _detectedPlanes;
  142880. private _enabled;
  142881. private _lastFrameDetected;
  142882. /**
  142883. * The module's name
  142884. */
  142885. static readonly Name: string;
  142886. /**
  142887. * The (Babylon) version of this module.
  142888. * This is an integer representing the implementation version.
  142889. * This number does not correspond to the WebXR specs version
  142890. */
  142891. static readonly Version: number;
  142892. /**
  142893. * Observers registered here will be executed when a new plane was added to the session
  142894. */
  142895. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142896. /**
  142897. * Observers registered here will be executed when a plane is no longer detected in the session
  142898. */
  142899. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142900. /**
  142901. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142902. * This can execute N times every frame
  142903. */
  142904. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142905. /**
  142906. * construct a new Plane Detector
  142907. * @param _xrSessionManager an instance of xr Session manager
  142908. * @param _options configuration to use when constructing this feature
  142909. */
  142910. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142911. /**
  142912. * Dispose this feature and all of the resources attached
  142913. */
  142914. dispose(): void;
  142915. protected _onXRFrame(frame: XRFrame): void;
  142916. private _init;
  142917. private _updatePlaneWithXRPlane;
  142918. /**
  142919. * avoiding using Array.find for global support.
  142920. * @param xrPlane the plane to find in the array
  142921. */
  142922. private findIndexInPlaneArray;
  142923. }
  142924. }
  142925. declare module BABYLON {
  142926. /**
  142927. * Configuration options of the anchor system
  142928. */
  142929. export interface IWebXRAnchorSystemOptions {
  142930. /**
  142931. * Should a new anchor be added every time a select event is triggered
  142932. */
  142933. addAnchorOnSelect?: boolean;
  142934. /**
  142935. * should the anchor system use plane detection.
  142936. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142937. */
  142938. usePlaneDetection?: boolean;
  142939. /**
  142940. * a node that will be used to convert local to world coordinates
  142941. */
  142942. worldParentNode?: TransformNode;
  142943. }
  142944. /**
  142945. * A babylon container for an XR Anchor
  142946. */
  142947. export interface IWebXRAnchor {
  142948. /**
  142949. * A babylon-assigned ID for this anchor
  142950. */
  142951. id: number;
  142952. /**
  142953. * Transformation matrix to apply to an object attached to this anchor
  142954. */
  142955. transformationMatrix: Matrix;
  142956. /**
  142957. * The native anchor object
  142958. */
  142959. xrAnchor: XRAnchor;
  142960. }
  142961. /**
  142962. * An implementation of the anchor system of WebXR.
  142963. * Note that the current documented implementation is not available in any browser. Future implementations
  142964. * will use the frame to create an anchor and not the session or a detected plane
  142965. * For further information see https://github.com/immersive-web/anchors/
  142966. */
  142967. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142968. private _options;
  142969. private _enabled;
  142970. private _hitTestModule;
  142971. private _lastFrameDetected;
  142972. private _onSelect;
  142973. private _planeDetector;
  142974. private _trackedAnchors;
  142975. /**
  142976. * The module's name
  142977. */
  142978. static readonly Name: string;
  142979. /**
  142980. * The (Babylon) version of this module.
  142981. * This is an integer representing the implementation version.
  142982. * This number does not correspond to the WebXR specs version
  142983. */
  142984. static readonly Version: number;
  142985. /**
  142986. * Observers registered here will be executed when a new anchor was added to the session
  142987. */
  142988. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142989. /**
  142990. * Observers registered here will be executed when an anchor was removed from the session
  142991. */
  142992. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142993. /**
  142994. * Observers registered here will be executed when an existing anchor updates
  142995. * This can execute N times every frame
  142996. */
  142997. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142998. /**
  142999. * constructs a new anchor system
  143000. * @param _xrSessionManager an instance of WebXRSessionManager
  143001. * @param _options configuration object for this feature
  143002. */
  143003. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  143004. /**
  143005. * Add anchor at a specific XR point.
  143006. *
  143007. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  143008. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  143009. * @returns a promise the fulfills when the anchor was created
  143010. */
  143011. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  143012. /**
  143013. * attach this feature
  143014. * Will usually be called by the features manager
  143015. *
  143016. * @returns true if successful.
  143017. */
  143018. attach(): boolean;
  143019. /**
  143020. * detach this feature.
  143021. * Will usually be called by the features manager
  143022. *
  143023. * @returns true if successful.
  143024. */
  143025. detach(): boolean;
  143026. /**
  143027. * Dispose this feature and all of the resources attached
  143028. */
  143029. dispose(): void;
  143030. /**
  143031. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  143032. * @param hitTestModule the hit-test module to use.
  143033. */
  143034. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  143035. /**
  143036. * set the plane detector to use in order to create anchors from frames
  143037. * @param planeDetector the plane-detector module to use
  143038. * @param enable enable plane-anchors. default is true
  143039. */
  143040. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  143041. protected _onXRFrame(frame: XRFrame): void;
  143042. /**
  143043. * avoiding using Array.find for global support.
  143044. * @param xrAnchor the plane to find in the array
  143045. */
  143046. private _findIndexInAnchorArray;
  143047. private _updateAnchorWithXRFrame;
  143048. }
  143049. }
  143050. declare module BABYLON {
  143051. /**
  143052. * Options interface for the background remover plugin
  143053. */
  143054. export interface IWebXRBackgroundRemoverOptions {
  143055. /**
  143056. * Further background meshes to disable when entering AR
  143057. */
  143058. backgroundMeshes?: AbstractMesh[];
  143059. /**
  143060. * flags to configure the removal of the environment helper.
  143061. * If not set, the entire background will be removed. If set, flags should be set as well.
  143062. */
  143063. environmentHelperRemovalFlags?: {
  143064. /**
  143065. * Should the skybox be removed (default false)
  143066. */
  143067. skyBox?: boolean;
  143068. /**
  143069. * Should the ground be removed (default false)
  143070. */
  143071. ground?: boolean;
  143072. };
  143073. /**
  143074. * don't disable the environment helper
  143075. */
  143076. ignoreEnvironmentHelper?: boolean;
  143077. }
  143078. /**
  143079. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  143080. */
  143081. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  143082. /**
  143083. * read-only options to be used in this module
  143084. */
  143085. readonly options: IWebXRBackgroundRemoverOptions;
  143086. /**
  143087. * The module's name
  143088. */
  143089. static readonly Name: string;
  143090. /**
  143091. * The (Babylon) version of this module.
  143092. * This is an integer representing the implementation version.
  143093. * This number does not correspond to the WebXR specs version
  143094. */
  143095. static readonly Version: number;
  143096. /**
  143097. * registered observers will be triggered when the background state changes
  143098. */
  143099. onBackgroundStateChangedObservable: Observable<boolean>;
  143100. /**
  143101. * constructs a new background remover module
  143102. * @param _xrSessionManager the session manager for this module
  143103. * @param options read-only options to be used in this module
  143104. */
  143105. constructor(_xrSessionManager: WebXRSessionManager,
  143106. /**
  143107. * read-only options to be used in this module
  143108. */
  143109. options?: IWebXRBackgroundRemoverOptions);
  143110. /**
  143111. * attach this feature
  143112. * Will usually be called by the features manager
  143113. *
  143114. * @returns true if successful.
  143115. */
  143116. attach(): boolean;
  143117. /**
  143118. * detach this feature.
  143119. * Will usually be called by the features manager
  143120. *
  143121. * @returns true if successful.
  143122. */
  143123. detach(): boolean;
  143124. /**
  143125. * Dispose this feature and all of the resources attached
  143126. */
  143127. dispose(): void;
  143128. protected _onXRFrame(_xrFrame: XRFrame): void;
  143129. private _setBackgroundState;
  143130. }
  143131. }
  143132. declare module BABYLON {
  143133. /**
  143134. * Options for the controller physics feature
  143135. */
  143136. export class IWebXRControllerPhysicsOptions {
  143137. /**
  143138. * Should the headset get its own impostor
  143139. */
  143140. enableHeadsetImpostor?: boolean;
  143141. /**
  143142. * Optional parameters for the headset impostor
  143143. */
  143144. headsetImpostorParams?: {
  143145. /**
  143146. * The type of impostor to create. Default is sphere
  143147. */
  143148. impostorType: number;
  143149. /**
  143150. * the size of the impostor. Defaults to 10cm
  143151. */
  143152. impostorSize?: number | {
  143153. width: number;
  143154. height: number;
  143155. depth: number;
  143156. };
  143157. /**
  143158. * Friction definitions
  143159. */
  143160. friction?: number;
  143161. /**
  143162. * Restitution
  143163. */
  143164. restitution?: number;
  143165. };
  143166. /**
  143167. * The physics properties of the future impostors
  143168. */
  143169. physicsProperties?: {
  143170. /**
  143171. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  143172. * Note that this requires a physics engine that supports mesh impostors!
  143173. */
  143174. useControllerMesh?: boolean;
  143175. /**
  143176. * The type of impostor to create. Default is sphere
  143177. */
  143178. impostorType?: number;
  143179. /**
  143180. * the size of the impostor. Defaults to 10cm
  143181. */
  143182. impostorSize?: number | {
  143183. width: number;
  143184. height: number;
  143185. depth: number;
  143186. };
  143187. /**
  143188. * Friction definitions
  143189. */
  143190. friction?: number;
  143191. /**
  143192. * Restitution
  143193. */
  143194. restitution?: number;
  143195. };
  143196. /**
  143197. * the xr input to use with this pointer selection
  143198. */
  143199. xrInput: WebXRInput;
  143200. }
  143201. /**
  143202. * Add physics impostor to your webxr controllers,
  143203. * including naive calculation of their linear and angular velocity
  143204. */
  143205. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  143206. private readonly _options;
  143207. private _attachController;
  143208. private _controllers;
  143209. private _debugMode;
  143210. private _delta;
  143211. private _headsetImpostor?;
  143212. private _headsetMesh?;
  143213. private _lastTimestamp;
  143214. private _tmpQuaternion;
  143215. private _tmpVector;
  143216. /**
  143217. * The module's name
  143218. */
  143219. static readonly Name: string;
  143220. /**
  143221. * The (Babylon) version of this module.
  143222. * This is an integer representing the implementation version.
  143223. * This number does not correspond to the webxr specs version
  143224. */
  143225. static readonly Version: number;
  143226. /**
  143227. * Construct a new Controller Physics Feature
  143228. * @param _xrSessionManager the corresponding xr session manager
  143229. * @param _options options to create this feature with
  143230. */
  143231. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  143232. /**
  143233. * @hidden
  143234. * enable debugging - will show console outputs and the impostor mesh
  143235. */
  143236. _enablePhysicsDebug(): void;
  143237. /**
  143238. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  143239. * @param xrController the controller to add
  143240. */
  143241. addController(xrController: WebXRInputSource): void;
  143242. /**
  143243. * attach this feature
  143244. * Will usually be called by the features manager
  143245. *
  143246. * @returns true if successful.
  143247. */
  143248. attach(): boolean;
  143249. /**
  143250. * detach this feature.
  143251. * Will usually be called by the features manager
  143252. *
  143253. * @returns true if successful.
  143254. */
  143255. detach(): boolean;
  143256. /**
  143257. * Get the headset impostor, if enabled
  143258. * @returns the impostor
  143259. */
  143260. getHeadsetImpostor(): PhysicsImpostor | undefined;
  143261. /**
  143262. * Get the physics impostor of a specific controller.
  143263. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  143264. * @param controller the controller or the controller id of which to get the impostor
  143265. * @returns the impostor or null
  143266. */
  143267. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  143268. /**
  143269. * Update the physics properties provided in the constructor
  143270. * @param newProperties the new properties object
  143271. */
  143272. setPhysicsProperties(newProperties: {
  143273. impostorType?: number;
  143274. impostorSize?: number | {
  143275. width: number;
  143276. height: number;
  143277. depth: number;
  143278. };
  143279. friction?: number;
  143280. restitution?: number;
  143281. }): void;
  143282. protected _onXRFrame(_xrFrame: any): void;
  143283. private _detachController;
  143284. }
  143285. }
  143286. declare module BABYLON {
  143287. /**
  143288. * The motion controller class for all microsoft mixed reality controllers
  143289. */
  143290. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  143291. protected readonly _mapping: {
  143292. defaultButton: {
  143293. "valueNodeName": string;
  143294. "unpressedNodeName": string;
  143295. "pressedNodeName": string;
  143296. };
  143297. defaultAxis: {
  143298. "valueNodeName": string;
  143299. "minNodeName": string;
  143300. "maxNodeName": string;
  143301. };
  143302. buttons: {
  143303. "xr-standard-trigger": {
  143304. "rootNodeName": string;
  143305. "componentProperty": string;
  143306. "states": string[];
  143307. };
  143308. "xr-standard-squeeze": {
  143309. "rootNodeName": string;
  143310. "componentProperty": string;
  143311. "states": string[];
  143312. };
  143313. "xr-standard-touchpad": {
  143314. "rootNodeName": string;
  143315. "labelAnchorNodeName": string;
  143316. "touchPointNodeName": string;
  143317. };
  143318. "xr-standard-thumbstick": {
  143319. "rootNodeName": string;
  143320. "componentProperty": string;
  143321. "states": string[];
  143322. };
  143323. };
  143324. axes: {
  143325. "xr-standard-touchpad": {
  143326. "x-axis": {
  143327. "rootNodeName": string;
  143328. };
  143329. "y-axis": {
  143330. "rootNodeName": string;
  143331. };
  143332. };
  143333. "xr-standard-thumbstick": {
  143334. "x-axis": {
  143335. "rootNodeName": string;
  143336. };
  143337. "y-axis": {
  143338. "rootNodeName": string;
  143339. };
  143340. };
  143341. };
  143342. };
  143343. /**
  143344. * The base url used to load the left and right controller models
  143345. */
  143346. static MODEL_BASE_URL: string;
  143347. /**
  143348. * The name of the left controller model file
  143349. */
  143350. static MODEL_LEFT_FILENAME: string;
  143351. /**
  143352. * The name of the right controller model file
  143353. */
  143354. static MODEL_RIGHT_FILENAME: string;
  143355. profileId: string;
  143356. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  143357. protected _getFilenameAndPath(): {
  143358. filename: string;
  143359. path: string;
  143360. };
  143361. protected _getModelLoadingConstraints(): boolean;
  143362. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143363. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143364. protected _updateModel(): void;
  143365. }
  143366. }
  143367. declare module BABYLON {
  143368. /**
  143369. * The motion controller class for oculus touch (quest, rift).
  143370. * This class supports legacy mapping as well the standard xr mapping
  143371. */
  143372. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  143373. private _forceLegacyControllers;
  143374. private _modelRootNode;
  143375. /**
  143376. * The base url used to load the left and right controller models
  143377. */
  143378. static MODEL_BASE_URL: string;
  143379. /**
  143380. * The name of the left controller model file
  143381. */
  143382. static MODEL_LEFT_FILENAME: string;
  143383. /**
  143384. * The name of the right controller model file
  143385. */
  143386. static MODEL_RIGHT_FILENAME: string;
  143387. /**
  143388. * Base Url for the Quest controller model.
  143389. */
  143390. static QUEST_MODEL_BASE_URL: string;
  143391. profileId: string;
  143392. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  143393. protected _getFilenameAndPath(): {
  143394. filename: string;
  143395. path: string;
  143396. };
  143397. protected _getModelLoadingConstraints(): boolean;
  143398. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143399. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143400. protected _updateModel(): void;
  143401. /**
  143402. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  143403. * between the touch and touch 2.
  143404. */
  143405. private _isQuest;
  143406. }
  143407. }
  143408. declare module BABYLON {
  143409. /**
  143410. * The motion controller class for the standard HTC-Vive controllers
  143411. */
  143412. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  143413. private _modelRootNode;
  143414. /**
  143415. * The base url used to load the left and right controller models
  143416. */
  143417. static MODEL_BASE_URL: string;
  143418. /**
  143419. * File name for the controller model.
  143420. */
  143421. static MODEL_FILENAME: string;
  143422. profileId: string;
  143423. /**
  143424. * Create a new Vive motion controller object
  143425. * @param scene the scene to use to create this controller
  143426. * @param gamepadObject the corresponding gamepad object
  143427. * @param handness the handness of the controller
  143428. */
  143429. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  143430. protected _getFilenameAndPath(): {
  143431. filename: string;
  143432. path: string;
  143433. };
  143434. protected _getModelLoadingConstraints(): boolean;
  143435. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143436. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143437. protected _updateModel(): void;
  143438. }
  143439. }
  143440. declare module BABYLON {
  143441. /**
  143442. * A cursor which tracks a point on a path
  143443. */
  143444. export class PathCursor {
  143445. private path;
  143446. /**
  143447. * Stores path cursor callbacks for when an onchange event is triggered
  143448. */
  143449. private _onchange;
  143450. /**
  143451. * The value of the path cursor
  143452. */
  143453. value: number;
  143454. /**
  143455. * The animation array of the path cursor
  143456. */
  143457. animations: Animation[];
  143458. /**
  143459. * Initializes the path cursor
  143460. * @param path The path to track
  143461. */
  143462. constructor(path: Path2);
  143463. /**
  143464. * Gets the cursor point on the path
  143465. * @returns A point on the path cursor at the cursor location
  143466. */
  143467. getPoint(): Vector3;
  143468. /**
  143469. * Moves the cursor ahead by the step amount
  143470. * @param step The amount to move the cursor forward
  143471. * @returns This path cursor
  143472. */
  143473. moveAhead(step?: number): PathCursor;
  143474. /**
  143475. * Moves the cursor behind by the step amount
  143476. * @param step The amount to move the cursor back
  143477. * @returns This path cursor
  143478. */
  143479. moveBack(step?: number): PathCursor;
  143480. /**
  143481. * Moves the cursor by the step amount
  143482. * If the step amount is greater than one, an exception is thrown
  143483. * @param step The amount to move the cursor
  143484. * @returns This path cursor
  143485. */
  143486. move(step: number): PathCursor;
  143487. /**
  143488. * Ensures that the value is limited between zero and one
  143489. * @returns This path cursor
  143490. */
  143491. private ensureLimits;
  143492. /**
  143493. * Runs onchange callbacks on change (used by the animation engine)
  143494. * @returns This path cursor
  143495. */
  143496. private raiseOnChange;
  143497. /**
  143498. * Executes a function on change
  143499. * @param f A path cursor onchange callback
  143500. * @returns This path cursor
  143501. */
  143502. onchange(f: (cursor: PathCursor) => void): PathCursor;
  143503. }
  143504. }
  143505. declare module BABYLON {
  143506. /** @hidden */
  143507. export var blurPixelShader: {
  143508. name: string;
  143509. shader: string;
  143510. };
  143511. }
  143512. declare module BABYLON {
  143513. /** @hidden */
  143514. export var pointCloudVertexDeclaration: {
  143515. name: string;
  143516. shader: string;
  143517. };
  143518. }
  143519. // Mixins
  143520. interface Window {
  143521. mozIndexedDB: IDBFactory;
  143522. webkitIndexedDB: IDBFactory;
  143523. msIndexedDB: IDBFactory;
  143524. webkitURL: typeof URL;
  143525. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  143526. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  143527. WebGLRenderingContext: WebGLRenderingContext;
  143528. MSGesture: MSGesture;
  143529. CANNON: any;
  143530. AudioContext: AudioContext;
  143531. webkitAudioContext: AudioContext;
  143532. PointerEvent: any;
  143533. Math: Math;
  143534. Uint8Array: Uint8ArrayConstructor;
  143535. Float32Array: Float32ArrayConstructor;
  143536. mozURL: typeof URL;
  143537. msURL: typeof URL;
  143538. VRFrameData: any; // WebVR, from specs 1.1
  143539. DracoDecoderModule: any;
  143540. setImmediate(handler: (...args: any[]) => void): number;
  143541. }
  143542. interface HTMLCanvasElement {
  143543. requestPointerLock(): void;
  143544. msRequestPointerLock?(): void;
  143545. mozRequestPointerLock?(): void;
  143546. webkitRequestPointerLock?(): void;
  143547. /** Track wether a record is in progress */
  143548. isRecording: boolean;
  143549. /** Capture Stream method defined by some browsers */
  143550. captureStream(fps?: number): MediaStream;
  143551. }
  143552. interface CanvasRenderingContext2D {
  143553. msImageSmoothingEnabled: boolean;
  143554. }
  143555. interface MouseEvent {
  143556. mozMovementX: number;
  143557. mozMovementY: number;
  143558. webkitMovementX: number;
  143559. webkitMovementY: number;
  143560. msMovementX: number;
  143561. msMovementY: number;
  143562. }
  143563. interface Navigator {
  143564. mozGetVRDevices: (any: any) => any;
  143565. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143566. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143567. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143568. webkitGetGamepads(): Gamepad[];
  143569. msGetGamepads(): Gamepad[];
  143570. webkitGamepads(): Gamepad[];
  143571. }
  143572. interface HTMLVideoElement {
  143573. mozSrcObject: any;
  143574. }
  143575. interface Math {
  143576. fround(x: number): number;
  143577. imul(a: number, b: number): number;
  143578. }
  143579. interface WebGLRenderingContext {
  143580. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  143581. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  143582. vertexAttribDivisor(index: number, divisor: number): void;
  143583. createVertexArray(): any;
  143584. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  143585. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  143586. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  143587. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  143588. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  143589. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  143590. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  143591. // Queries
  143592. createQuery(): WebGLQuery;
  143593. deleteQuery(query: WebGLQuery): void;
  143594. beginQuery(target: number, query: WebGLQuery): void;
  143595. endQuery(target: number): void;
  143596. getQueryParameter(query: WebGLQuery, pname: number): any;
  143597. getQuery(target: number, pname: number): any;
  143598. MAX_SAMPLES: number;
  143599. RGBA8: number;
  143600. READ_FRAMEBUFFER: number;
  143601. DRAW_FRAMEBUFFER: number;
  143602. UNIFORM_BUFFER: number;
  143603. HALF_FLOAT_OES: number;
  143604. RGBA16F: number;
  143605. RGBA32F: number;
  143606. R32F: number;
  143607. RG32F: number;
  143608. RGB32F: number;
  143609. R16F: number;
  143610. RG16F: number;
  143611. RGB16F: number;
  143612. RED: number;
  143613. RG: number;
  143614. R8: number;
  143615. RG8: number;
  143616. UNSIGNED_INT_24_8: number;
  143617. DEPTH24_STENCIL8: number;
  143618. MIN: number;
  143619. MAX: number;
  143620. /* Multiple Render Targets */
  143621. drawBuffers(buffers: number[]): void;
  143622. readBuffer(src: number): void;
  143623. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  143624. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  143625. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  143626. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  143627. // Occlusion Query
  143628. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  143629. ANY_SAMPLES_PASSED: number;
  143630. QUERY_RESULT_AVAILABLE: number;
  143631. QUERY_RESULT: number;
  143632. }
  143633. interface WebGLProgram {
  143634. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  143635. }
  143636. interface EXT_disjoint_timer_query {
  143637. QUERY_COUNTER_BITS_EXT: number;
  143638. TIME_ELAPSED_EXT: number;
  143639. TIMESTAMP_EXT: number;
  143640. GPU_DISJOINT_EXT: number;
  143641. QUERY_RESULT_EXT: number;
  143642. QUERY_RESULT_AVAILABLE_EXT: number;
  143643. queryCounterEXT(query: WebGLQuery, target: number): void;
  143644. createQueryEXT(): WebGLQuery;
  143645. beginQueryEXT(target: number, query: WebGLQuery): void;
  143646. endQueryEXT(target: number): void;
  143647. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  143648. deleteQueryEXT(query: WebGLQuery): void;
  143649. }
  143650. interface WebGLUniformLocation {
  143651. _currentState: any;
  143652. }
  143653. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  143654. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  143655. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  143656. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143657. interface WebGLRenderingContext {
  143658. readonly RASTERIZER_DISCARD: number;
  143659. readonly DEPTH_COMPONENT24: number;
  143660. readonly TEXTURE_3D: number;
  143661. readonly TEXTURE_2D_ARRAY: number;
  143662. readonly TEXTURE_COMPARE_FUNC: number;
  143663. readonly TEXTURE_COMPARE_MODE: number;
  143664. readonly COMPARE_REF_TO_TEXTURE: number;
  143665. readonly TEXTURE_WRAP_R: number;
  143666. readonly HALF_FLOAT: number;
  143667. readonly RGB8: number;
  143668. readonly RED_INTEGER: number;
  143669. readonly RG_INTEGER: number;
  143670. readonly RGB_INTEGER: number;
  143671. readonly RGBA_INTEGER: number;
  143672. readonly R8_SNORM: number;
  143673. readonly RG8_SNORM: number;
  143674. readonly RGB8_SNORM: number;
  143675. readonly RGBA8_SNORM: number;
  143676. readonly R8I: number;
  143677. readonly RG8I: number;
  143678. readonly RGB8I: number;
  143679. readonly RGBA8I: number;
  143680. readonly R8UI: number;
  143681. readonly RG8UI: number;
  143682. readonly RGB8UI: number;
  143683. readonly RGBA8UI: number;
  143684. readonly R16I: number;
  143685. readonly RG16I: number;
  143686. readonly RGB16I: number;
  143687. readonly RGBA16I: number;
  143688. readonly R16UI: number;
  143689. readonly RG16UI: number;
  143690. readonly RGB16UI: number;
  143691. readonly RGBA16UI: number;
  143692. readonly R32I: number;
  143693. readonly RG32I: number;
  143694. readonly RGB32I: number;
  143695. readonly RGBA32I: number;
  143696. readonly R32UI: number;
  143697. readonly RG32UI: number;
  143698. readonly RGB32UI: number;
  143699. readonly RGBA32UI: number;
  143700. readonly RGB10_A2UI: number;
  143701. readonly R11F_G11F_B10F: number;
  143702. readonly RGB9_E5: number;
  143703. readonly RGB10_A2: number;
  143704. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  143705. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  143706. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  143707. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  143708. readonly DEPTH_COMPONENT32F: number;
  143709. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  143710. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  143711. 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;
  143712. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  143713. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  143714. readonly TRANSFORM_FEEDBACK: number;
  143715. readonly INTERLEAVED_ATTRIBS: number;
  143716. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  143717. createTransformFeedback(): WebGLTransformFeedback;
  143718. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143719. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143720. beginTransformFeedback(primitiveMode: number): void;
  143721. endTransformFeedback(): void;
  143722. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143723. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143724. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143725. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143726. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143727. }
  143728. interface ImageBitmap {
  143729. readonly width: number;
  143730. readonly height: number;
  143731. close(): void;
  143732. }
  143733. interface WebGLQuery extends WebGLObject {
  143734. }
  143735. declare var WebGLQuery: {
  143736. prototype: WebGLQuery;
  143737. new(): WebGLQuery;
  143738. };
  143739. interface WebGLSampler extends WebGLObject {
  143740. }
  143741. declare var WebGLSampler: {
  143742. prototype: WebGLSampler;
  143743. new(): WebGLSampler;
  143744. };
  143745. interface WebGLSync extends WebGLObject {
  143746. }
  143747. declare var WebGLSync: {
  143748. prototype: WebGLSync;
  143749. new(): WebGLSync;
  143750. };
  143751. interface WebGLTransformFeedback extends WebGLObject {
  143752. }
  143753. declare var WebGLTransformFeedback: {
  143754. prototype: WebGLTransformFeedback;
  143755. new(): WebGLTransformFeedback;
  143756. };
  143757. interface WebGLVertexArrayObject extends WebGLObject {
  143758. }
  143759. declare var WebGLVertexArrayObject: {
  143760. prototype: WebGLVertexArrayObject;
  143761. new(): WebGLVertexArrayObject;
  143762. };
  143763. // Type definitions for WebVR API
  143764. // Project: https://w3c.github.io/webvr/
  143765. // Definitions by: six a <https://github.com/lostfictions>
  143766. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143767. interface VRDisplay extends EventTarget {
  143768. /**
  143769. * Dictionary of capabilities describing the VRDisplay.
  143770. */
  143771. readonly capabilities: VRDisplayCapabilities;
  143772. /**
  143773. * z-depth defining the far plane of the eye view frustum
  143774. * enables mapping of values in the render target depth
  143775. * attachment to scene coordinates. Initially set to 10000.0.
  143776. */
  143777. depthFar: number;
  143778. /**
  143779. * z-depth defining the near plane of the eye view frustum
  143780. * enables mapping of values in the render target depth
  143781. * attachment to scene coordinates. Initially set to 0.01.
  143782. */
  143783. depthNear: number;
  143784. /**
  143785. * An identifier for this distinct VRDisplay. Used as an
  143786. * association point in the Gamepad API.
  143787. */
  143788. readonly displayId: number;
  143789. /**
  143790. * A display name, a user-readable name identifying it.
  143791. */
  143792. readonly displayName: string;
  143793. readonly isConnected: boolean;
  143794. readonly isPresenting: boolean;
  143795. /**
  143796. * If this VRDisplay supports room-scale experiences, the optional
  143797. * stage attribute contains details on the room-scale parameters.
  143798. */
  143799. readonly stageParameters: VRStageParameters | null;
  143800. /**
  143801. * Passing the value returned by `requestAnimationFrame` to
  143802. * `cancelAnimationFrame` will unregister the callback.
  143803. * @param handle Define the hanle of the request to cancel
  143804. */
  143805. cancelAnimationFrame(handle: number): void;
  143806. /**
  143807. * Stops presenting to the VRDisplay.
  143808. * @returns a promise to know when it stopped
  143809. */
  143810. exitPresent(): Promise<void>;
  143811. /**
  143812. * Return the current VREyeParameters for the given eye.
  143813. * @param whichEye Define the eye we want the parameter for
  143814. * @returns the eye parameters
  143815. */
  143816. getEyeParameters(whichEye: string): VREyeParameters;
  143817. /**
  143818. * Populates the passed VRFrameData with the information required to render
  143819. * the current frame.
  143820. * @param frameData Define the data structure to populate
  143821. * @returns true if ok otherwise false
  143822. */
  143823. getFrameData(frameData: VRFrameData): boolean;
  143824. /**
  143825. * Get the layers currently being presented.
  143826. * @returns the list of VR layers
  143827. */
  143828. getLayers(): VRLayer[];
  143829. /**
  143830. * Return a VRPose containing the future predicted pose of the VRDisplay
  143831. * when the current frame will be presented. The value returned will not
  143832. * change until JavaScript has returned control to the browser.
  143833. *
  143834. * The VRPose will contain the position, orientation, velocity,
  143835. * and acceleration of each of these properties.
  143836. * @returns the pose object
  143837. */
  143838. getPose(): VRPose;
  143839. /**
  143840. * Return the current instantaneous pose of the VRDisplay, with no
  143841. * prediction applied.
  143842. * @returns the current instantaneous pose
  143843. */
  143844. getImmediatePose(): VRPose;
  143845. /**
  143846. * The callback passed to `requestAnimationFrame` will be called
  143847. * any time a new frame should be rendered. When the VRDisplay is
  143848. * presenting the callback will be called at the native refresh
  143849. * rate of the HMD. When not presenting this function acts
  143850. * identically to how window.requestAnimationFrame acts. Content should
  143851. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143852. * asynchronously from other displays and at differing refresh rates.
  143853. * @param callback Define the eaction to run next frame
  143854. * @returns the request handle it
  143855. */
  143856. requestAnimationFrame(callback: FrameRequestCallback): number;
  143857. /**
  143858. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143859. * Repeat calls while already presenting will update the VRLayers being displayed.
  143860. * @param layers Define the list of layer to present
  143861. * @returns a promise to know when the request has been fulfilled
  143862. */
  143863. requestPresent(layers: VRLayer[]): Promise<void>;
  143864. /**
  143865. * Reset the pose for this display, treating its current position and
  143866. * orientation as the "origin/zero" values. VRPose.position,
  143867. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143868. * updated when calling resetPose(). This should be called in only
  143869. * sitting-space experiences.
  143870. */
  143871. resetPose(): void;
  143872. /**
  143873. * The VRLayer provided to the VRDisplay will be captured and presented
  143874. * in the HMD. Calling this function has the same effect on the source
  143875. * canvas as any other operation that uses its source image, and canvases
  143876. * created without preserveDrawingBuffer set to true will be cleared.
  143877. * @param pose Define the pose to submit
  143878. */
  143879. submitFrame(pose?: VRPose): void;
  143880. }
  143881. declare var VRDisplay: {
  143882. prototype: VRDisplay;
  143883. new(): VRDisplay;
  143884. };
  143885. interface VRLayer {
  143886. leftBounds?: number[] | Float32Array | null;
  143887. rightBounds?: number[] | Float32Array | null;
  143888. source?: HTMLCanvasElement | null;
  143889. }
  143890. interface VRDisplayCapabilities {
  143891. readonly canPresent: boolean;
  143892. readonly hasExternalDisplay: boolean;
  143893. readonly hasOrientation: boolean;
  143894. readonly hasPosition: boolean;
  143895. readonly maxLayers: number;
  143896. }
  143897. interface VREyeParameters {
  143898. /** @deprecated */
  143899. readonly fieldOfView: VRFieldOfView;
  143900. readonly offset: Float32Array;
  143901. readonly renderHeight: number;
  143902. readonly renderWidth: number;
  143903. }
  143904. interface VRFieldOfView {
  143905. readonly downDegrees: number;
  143906. readonly leftDegrees: number;
  143907. readonly rightDegrees: number;
  143908. readonly upDegrees: number;
  143909. }
  143910. interface VRFrameData {
  143911. readonly leftProjectionMatrix: Float32Array;
  143912. readonly leftViewMatrix: Float32Array;
  143913. readonly pose: VRPose;
  143914. readonly rightProjectionMatrix: Float32Array;
  143915. readonly rightViewMatrix: Float32Array;
  143916. readonly timestamp: number;
  143917. }
  143918. interface VRPose {
  143919. readonly angularAcceleration: Float32Array | null;
  143920. readonly angularVelocity: Float32Array | null;
  143921. readonly linearAcceleration: Float32Array | null;
  143922. readonly linearVelocity: Float32Array | null;
  143923. readonly orientation: Float32Array | null;
  143924. readonly position: Float32Array | null;
  143925. readonly timestamp: number;
  143926. }
  143927. interface VRStageParameters {
  143928. sittingToStandingTransform?: Float32Array;
  143929. sizeX?: number;
  143930. sizeY?: number;
  143931. }
  143932. interface Navigator {
  143933. getVRDisplays(): Promise<VRDisplay[]>;
  143934. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143935. }
  143936. interface Window {
  143937. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143938. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143939. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143940. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143941. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143942. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143943. }
  143944. interface Gamepad {
  143945. readonly displayId: number;
  143946. }
  143947. type XRSessionMode =
  143948. | "inline"
  143949. | "immersive-vr"
  143950. | "immersive-ar";
  143951. type XRReferenceSpaceType =
  143952. | "viewer"
  143953. | "local"
  143954. | "local-floor"
  143955. | "bounded-floor"
  143956. | "unbounded";
  143957. type XREnvironmentBlendMode =
  143958. | "opaque"
  143959. | "additive"
  143960. | "alpha-blend";
  143961. type XRVisibilityState =
  143962. | "visible"
  143963. | "visible-blurred"
  143964. | "hidden";
  143965. type XRHandedness =
  143966. | "none"
  143967. | "left"
  143968. | "right";
  143969. type XRTargetRayMode =
  143970. | "gaze"
  143971. | "tracked-pointer"
  143972. | "screen";
  143973. type XREye =
  143974. | "none"
  143975. | "left"
  143976. | "right";
  143977. interface XRSpace extends EventTarget {
  143978. }
  143979. interface XRRenderState {
  143980. depthNear?: number;
  143981. depthFar?: number;
  143982. inlineVerticalFieldOfView?: number;
  143983. baseLayer?: XRWebGLLayer;
  143984. }
  143985. interface XRInputSource {
  143986. handedness: XRHandedness;
  143987. targetRayMode: XRTargetRayMode;
  143988. targetRaySpace: XRSpace;
  143989. gripSpace: XRSpace | undefined;
  143990. gamepad: Gamepad | undefined;
  143991. profiles: Array<string>;
  143992. }
  143993. interface XRSessionInit {
  143994. optionalFeatures?: XRReferenceSpaceType[];
  143995. requiredFeatures?: XRReferenceSpaceType[];
  143996. }
  143997. interface XRSession extends XRAnchorCreator {
  143998. addEventListener: Function;
  143999. removeEventListener: Function;
  144000. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  144001. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  144002. requestAnimationFrame: Function;
  144003. end(): Promise<void>;
  144004. renderState: XRRenderState;
  144005. inputSources: Array<XRInputSource>;
  144006. // AR hit test
  144007. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  144008. updateWorldTrackingState(options: {
  144009. planeDetectionState?: { enabled: boolean; }
  144010. }): void;
  144011. }
  144012. interface XRReferenceSpace extends XRSpace {
  144013. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  144014. onreset: any;
  144015. }
  144016. type XRPlaneSet = Set<XRPlane>;
  144017. type XRAnchorSet = Set<XRAnchor>;
  144018. interface XRFrame {
  144019. session: XRSession;
  144020. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  144021. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  144022. // Anchors
  144023. trackedAnchors?: XRAnchorSet;
  144024. // Planes
  144025. worldInformation: {
  144026. detectedPlanes?: XRPlaneSet;
  144027. };
  144028. }
  144029. interface XRViewerPose extends XRPose {
  144030. views: Array<XRView>;
  144031. }
  144032. interface XRPose {
  144033. transform: XRRigidTransform;
  144034. emulatedPosition: boolean;
  144035. }
  144036. interface XRWebGLLayerOptions {
  144037. antialias?: boolean;
  144038. depth?: boolean;
  144039. stencil?: boolean;
  144040. alpha?: boolean;
  144041. multiview?: boolean;
  144042. framebufferScaleFactor?: number;
  144043. }
  144044. declare var XRWebGLLayer: {
  144045. prototype: XRWebGLLayer;
  144046. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  144047. };
  144048. interface XRWebGLLayer {
  144049. framebuffer: WebGLFramebuffer;
  144050. framebufferWidth: number;
  144051. framebufferHeight: number;
  144052. getViewport: Function;
  144053. }
  144054. declare class XRRigidTransform {
  144055. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  144056. position: DOMPointReadOnly;
  144057. orientation: DOMPointReadOnly;
  144058. matrix: Float32Array;
  144059. inverse: XRRigidTransform;
  144060. }
  144061. interface XRView {
  144062. eye: XREye;
  144063. projectionMatrix: Float32Array;
  144064. transform: XRRigidTransform;
  144065. }
  144066. interface XRInputSourceChangeEvent {
  144067. session: XRSession;
  144068. removed: Array<XRInputSource>;
  144069. added: Array<XRInputSource>;
  144070. }
  144071. interface XRInputSourceEvent extends Event {
  144072. readonly frame: XRFrame;
  144073. readonly inputSource: XRInputSource;
  144074. }
  144075. // Experimental(er) features
  144076. declare class XRRay {
  144077. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  144078. origin: DOMPointReadOnly;
  144079. direction: DOMPointReadOnly;
  144080. matrix: Float32Array;
  144081. }
  144082. interface XRHitResult {
  144083. hitMatrix: Float32Array;
  144084. }
  144085. interface XRAnchor {
  144086. // remove?
  144087. id?: string;
  144088. anchorSpace: XRSpace;
  144089. lastChangedTime: number;
  144090. detach(): void;
  144091. }
  144092. interface XRPlane extends XRAnchorCreator {
  144093. orientation: "Horizontal" | "Vertical";
  144094. planeSpace: XRSpace;
  144095. polygon: Array<DOMPointReadOnly>;
  144096. lastChangedTime: number;
  144097. }
  144098. interface XRAnchorCreator {
  144099. // AR Anchors
  144100. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  144101. }